obj-m += compat.o
-#compat-objs :=
-
-obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o
-obj-$(CONFIG_COMPAT_NET_SCH_CODEL) += sch_codel.o
-obj-$(CONFIG_COMPAT_NET_SCH_FQ_CODEL) += sch_fq_codel.o
compat-y += main.o
# Compat kernel compatibility code
-compat-$(CONFIG_COMPAT_KERNEL_2_6_18) += compat-2.6.18.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_19) += compat-2.6.19.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_21) += compat-2.6.21.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_22) += compat-2.6.22.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_23) += compat-2.6.23.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_24) += compat-2.6.24.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_25) += \
- compat-2.6.25.o \
- pm_qos_params.o
-
-compat-$(CONFIG_COMPAT_KERNEL_2_6_26) += compat-2.6.26.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_27) += compat-2.6.27.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_28) += compat-2.6.28.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_29) += compat-2.6.29.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_32) += compat-2.6.32.o
-
-compat-$(CONFIG_COMPAT_KERNEL_2_6_33) += compat-2.6.33.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_34) += compat-2.6.34.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_35) += compat-2.6.35.o
-
-ifeq ($(CONFIG_COMPAT_IS_KTHREAD),)
-compat-$(CONFIG_COMPAT_KERNEL_2_6_35) += kthread.o
-endif
-
-compat-$(CONFIG_COMPAT_KERNEL_2_6_36) += compat-2.6.36.o
-
-compat-$(CONFIG_COMPAT_KFIFO) += kfifo.o
-
-compat-$(CONFIG_COMPAT_KERNEL_2_6_37) += compat-2.6.37.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_38) += compat-2.6.38.o
-compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \
- compat-2.6.39.o \
- kstrtox.o
-compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o
-compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o
-compat-$(CONFIG_COMPAT_KERNEL_3_3) += \
- compat-3.3.o
-compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o
-compat-$(CONFIG_COMPAT_KERNEL_3_5) += compat-3.5.o
-compat-$(CONFIG_COMPAT_KERNEL_3_6) += compat-3.6.o
-compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o
-compat-$(CONFIG_COMPAT_KERNEL_3_9) += compat-3.9.o
compat-$(CONFIG_COMPAT_KERNEL_3_11) += compat-3.11.o
compat-$(CONFIG_COMPAT_KERNEL_3_12) += compat-3.12.o
compat-$(CONFIG_COMPAT_KERNEL_3_13) += compat-3.13.o
compat-$(CONFIG_COMPAT_KERNEL_3_18) += compat-3.18.o
compat-$(CONFIG_COMPAT_KERNEL_4_0) += compat-4.0.o
compat-$(CONFIG_COMPAT_KERNEL_4_1) += compat-4.1.o
-
-compat-$(CONFIG_COMPAT_CORDIC) += cordic.o
-compat-$(CONFIG_COMPAT_CRC8) += crc8.o
-
-ifndef CONFIG_64BIT
-ifndef CONFIG_GENERIC_ATOMIC64
- compat-y += compat_atomic.o
-endif
-endif
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.18.
- */
-
-#include <net/compat.h>
-
-/* 2.6.18 compat code goes here */
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.19.
- */
-
-#include <net/compat.h>
-
-/* 2.6.19 compat code goes here */
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.21.
- */
-
-#include <net/compat.h>
-
-/* 2.6.21 compat code goes here */
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.22.
- */
-
-#include <net/compat.h>
-
-/* 2.6.22 compat code goes here */
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.23.
- */
-
-#include <net/compat.h>
-
-/* On net/core/dev.c as of 2.6.24 */
-#define __dev_addr_delete LINUX_BACKPORT(__dev_addr_delete)
-int __dev_addr_delete(struct dev_addr_list **list, int *count,
- void *addr, int alen, int glbl)
-{
- struct dev_addr_list *da;
-
- for (; (da = *list) != NULL; list = &da->next) {
- if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 &&
- alen == da->da_addrlen) {
- if (glbl) {
- int old_glbl = da->da_gusers;
- da->da_gusers = 0;
- if (old_glbl == 0)
- break;
- }
- if (--da->da_users)
- return 0;
-
- *list = da->next;
- kfree(da);
- (*count)--;
- return 0;
- }
- }
- return -ENOENT;
-}
-EXPORT_SYMBOL_GPL(__dev_addr_delete);
-
-/* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but
- * might as well add it */
-#define __dev_addr_add LINUX_BACKPORT(__dev_addr_add)
-int __dev_addr_add(struct dev_addr_list **list, int *count,
- void *addr, int alen, int glbl)
-{
- struct dev_addr_list *da;
-
- for (da = *list; da != NULL; da = da->next) {
- if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 &&
- da->da_addrlen == alen) {
- if (glbl) {
- int old_glbl = da->da_gusers;
- da->da_gusers = 1;
- if (old_glbl)
- return 0;
- }
- da->da_users++;
- return 0;
- }
- }
-
- da = kmalloc(sizeof(*da), GFP_ATOMIC);
- if (da == NULL)
- return -ENOMEM;
- memcpy(da->da_addr, addr, alen);
- da->da_addrlen = alen;
- da->da_users = 1;
- da->da_gusers = glbl ? 1 : 0;
- da->next = *list;
- *list = da;
- (*count)++;
- return 0;
-}
-EXPORT_SYMBOL_GPL(__dev_addr_add);
-
-
-/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version.
- * Since da->da_synced is not part of 2.6.22 we need to take longer route when
- * syncing */
-
-/**
- * dev_mc_sync - Synchronize device's multicast list to another device
- * @to: destination device
- * @from: source device
- *
- * Add newly added addresses to the destination device and release
- * addresses that have no users left. The source device must be
- * locked by netif_tx_lock_bh.
- *
- * This function is intended to be called from the dev->set_multicast_list
- * function of layered software devices.
- */
-int dev_mc_sync(struct net_device *to, struct net_device *from)
-{
- struct dev_addr_list *da, *next, *da_to;
- int err = 0;
-
- netif_tx_lock_bh(to);
- da = from->mc_list;
- while (da != NULL) {
- int synced = 0;
- next = da->next;
- da_to = to->mc_list;
- /* 2.6.22 does not have da->da_synced so lets take the long route */
- while (da_to != NULL) {
- if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 &&
- da->da_addrlen == da_to->da_addrlen)
- synced = 1;
- break;
- }
- if (!synced) {
- err = __dev_addr_add(&to->mc_list, &to->mc_count,
- da->da_addr, da->da_addrlen, 0);
- if (err < 0)
- break;
- da->da_users++;
- } else if (da->da_users == 1) {
- __dev_addr_delete(&to->mc_list, &to->mc_count,
- da->da_addr, da->da_addrlen, 0);
- __dev_addr_delete(&from->mc_list, &from->mc_count,
- da->da_addr, da->da_addrlen, 0);
- }
- da = next;
- }
- if (!err)
- __dev_set_rx_mode(to);
- netif_tx_unlock_bh(to);
-
- return err;
-}
-EXPORT_SYMBOL_GPL(dev_mc_sync);
-
-
-/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version.
- * Since da->da_synced is not part of 2.6.22 we need to take longer route when
- * unsyncing */
-
-/**
- * dev_mc_unsync - Remove synchronized addresses from the destination
- * device
- * @to: destination device
- * @from: source device
- *
- * Remove all addresses that were added to the destination device by
- * dev_mc_sync(). This function is intended to be called from the
- * dev->stop function of layered software devices.
- */
-void dev_mc_unsync(struct net_device *to, struct net_device *from)
-{
- struct dev_addr_list *da, *next, *da_to;
-
- netif_tx_lock_bh(from);
- netif_tx_lock_bh(to);
-
- da = from->mc_list;
- while (da != NULL) {
- bool synced = false;
- next = da->next;
- da_to = to->mc_list;
- /* 2.6.22 does not have da->da_synced so lets take the long route */
- while (da_to != NULL) {
- if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 &&
- da->da_addrlen == da_to->da_addrlen)
- synced = true;
- break;
- }
- if (!synced) {
- da = next;
- continue;
- }
- __dev_addr_delete(&to->mc_list, &to->mc_count,
- da->da_addr, da->da_addrlen, 0);
- __dev_addr_delete(&from->mc_list, &from->mc_count,
- da->da_addr, da->da_addrlen, 0);
- da = next;
- }
- __dev_set_rx_mode(to);
-
- netif_tx_unlock_bh(to);
- netif_tx_unlock_bh(from);
-}
-EXPORT_SYMBOL_GPL(dev_mc_unsync);
-
-/* Added as of 2.6.23 on net/core/dev.c. Slightly modifed, no dev->set_rx_mode on
- * 2.6.22 so ignore that. */
-
-/*
- * Upload unicast and multicast address lists to device and
- * configure RX filtering. When the device doesn't support unicast
- * filtering it is put in promiscous mode while unicast addresses
- * are present.
- */
-void __dev_set_rx_mode(struct net_device *dev)
-{
- /* dev_open will call this function so the list will stay sane. */
- if (!(dev->flags&IFF_UP))
- return;
-
- if (!netif_device_present(dev))
- return;
-
-/* This needs to be ported to 2.6.22 framework */
-#if 0
- /* Unicast addresses changes may only happen under the rtnl,
- * therefore calling __dev_set_promiscuity here is safe.
- */
- if (dev->uc_count > 0 && !dev->uc_promisc) {
- __dev_set_promiscuity(dev, 1);
- dev->uc_promisc = 1;
- } else if (dev->uc_count == 0 && dev->uc_promisc) {
- __dev_set_promiscuity(dev, -1);
- dev->uc_promisc = 0;
- }
-#endif
-
- if (dev->set_multicast_list)
- dev->set_multicast_list(dev);
-}
-
-/**
- * pci_try_set_mwi - enables memory-write-invalidate PCI transaction
- * @dev: the PCI device for which MWI is enabled
- *
- * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND.
- * Callers are not required to check the return value.
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-int pci_try_set_mwi(struct pci_dev *dev)
-{
- int rc = 0;
-#ifdef HAVE_PCI_SET_MWI
- rc = pci_set_mwi(dev);
-#endif
- return rc;
-}
-EXPORT_SYMBOL_GPL(pci_try_set_mwi);
-#endif
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.24.
- */
-
-#include <net/compat.h>
-#include <net/arp.h>
-
-/*
- * We simply won't use it though, just declare it for our wrappers and
- * for usage with tons of code that makes mention to it.
- */
-struct net init_net;
-EXPORT_SYMBOL_GPL(init_net);
-
-/* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h
- * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
-
-/**
- * eth_header_cache_update - update cache entry
- * @hh: destination cache entry
- * @dev: network device
- * @haddr: new hardware address
- *
- * Called by Address Resolution module to notify changes in address.
- */
-void eth_header_cache_update(struct hh_cache *hh,
- struct net_device *dev,
- unsigned char *haddr)
-{
- memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
- haddr, ETH_ALEN);
-}
-EXPORT_SYMBOL_GPL(eth_header_cache_update);
-
-/* 2.6.22 and 2.6.23 have eth_header_cache defined as extern in include/linux/etherdevice.h
- * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
-
-/**
- * eth_header_cache - fill cache entry from neighbour
- * @neigh: source neighbour
- * @hh: destination cache entry
- * Create an Ethernet header template from the neighbour.
- */
-int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
-{
- __be16 type = hh->hh_type;
- struct ethhdr *eth;
- const struct net_device *dev = neigh->dev;
-
- eth = (struct ethhdr *)
- (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth))));
-
- if (type == htons(ETH_P_802_3))
- return -1;
-
- eth->h_proto = type;
- memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
- memcpy(eth->h_dest, neigh->ha, ETH_ALEN);
- hh->hh_len = ETH_HLEN;
- return 0;
-}
-EXPORT_SYMBOL_GPL(eth_header_cache);
-
-/* 2.6.22 and 2.6.23 have eth_header() defined as extern in include/linux/etherdevice.h
- * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
-
-/**
- * eth_header - create the Ethernet header
- * @skb: buffer to alter
- * @dev: source device
- * @type: Ethernet type field
- * @daddr: destination address (NULL leave destination address)
- * @saddr: source address (NULL use device source address)
- * @len: packet length (<= skb->len)
- *
- *
- * Set the protocol type. For a packet of type ETH_P_802_3 we put the length
- * in here instead. It is up to the 802.2 layer to carry protocol information.
- */
-int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
- void *daddr, void *saddr, unsigned len)
-{
- struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
-
- if (type != ETH_P_802_3)
- eth->h_proto = htons(type);
- else
- eth->h_proto = htons(len);
-
- /*
- * Set the source hardware address.
- */
-
- if (!saddr)
- saddr = dev->dev_addr;
- memcpy(eth->h_source, saddr, dev->addr_len);
-
- if (daddr) {
- memcpy(eth->h_dest, daddr, dev->addr_len);
- return ETH_HLEN;
- }
-
- /*
- * Anyway, the loopback-device should never use this function...
- */
-
- if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
- memset(eth->h_dest, 0, dev->addr_len);
- return ETH_HLEN;
- }
-
- return -ETH_HLEN;
-}
-
-EXPORT_SYMBOL_GPL(eth_header);
-
-/* 2.6.22 and 2.6.23 have eth_rebuild_header defined as extern in include/linux/etherdevice.h
- * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */
-
-/**
- * eth_rebuild_header- rebuild the Ethernet MAC header.
- * @skb: socket buffer to update
- *
- * This is called after an ARP or IPV6 ndisc it's resolution on this
- * sk_buff. We now let protocol (ARP) fill in the other fields.
- *
- * This routine CANNOT use cached dst->neigh!
- * Really, it is used only when dst->neigh is wrong.
- */
-int eth_rebuild_header(struct sk_buff *skb)
-{
- struct ethhdr *eth = (struct ethhdr *)skb->data;
- struct net_device *dev = skb->dev;
-
- switch (eth->h_proto) {
-#ifdef CONFIG_INET
- case __constant_htons(ETH_P_IP):
- return arp_find(eth->h_dest, skb);
-#endif
- default:
- printk(KERN_DEBUG
- "%s: unable to resolve type %X addresses.\n",
- dev->name, (int)eth->h_proto);
-
- memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
- break;
- }
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(eth_rebuild_header);
-
+++ /dev/null
-/*
- * Copyright 2007-2012 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.25.
- */
-
-#include <linux/miscdevice.h>
-#include <linux/pci.h>
-
-/*
- * To backport b718989d correctly pcibios_enable_device()
- * is required but we don't have access to it on modules
- * as its an architecture specific routine that is not
- * exported and as such only core kernel code has access
- * to it. We implement a sloppy work around for backporting
- * this.
- */
-int pci_enable_device_mem(struct pci_dev *dev)
-{
- int bars = pci_select_bars(dev, IORESOURCE_MEM);
-
- return pci_enable_device_bars(dev, bars);
-}
-EXPORT_SYMBOL_GPL(pci_enable_device_mem);
-
-/**
- * The following things are out of ./lib/vsprintf.c
- * The new iwlwifi driver is using them.
- */
-
-/**
- * strict_strtoul - convert a string to an unsigned long strictly
- * @cp: The string to be converted
- * @base: The number base to use
- * @res: The converted result value
- *
- * strict_strtoul converts a string to an unsigned long only if the
- * string is really an unsigned long string, any string containing
- * any invalid char at the tail will be rejected and -EINVAL is returned,
- * only a newline char at the tail is acceptible because people generally
- * change a module parameter in the following way:
- *
- * echo 1024 > /sys/module/e1000/parameters/copybreak
- *
- * echo will append a newline to the tail.
- *
- * It returns 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
- *
- * simple_strtoul just ignores the successive invalid characters and
- * return the converted value of prefix part of the string.
- */
-int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
-
-/**
- * strict_strtol - convert a string to a long strictly
- * @cp: The string to be converted
- * @base: The number base to use
- * @res: The converted result value
- *
- * strict_strtol is similiar to strict_strtoul, but it allows the first
- * character of a string is '-'.
- *
- * It returns 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
- */
-int strict_strtol(const char *cp, unsigned int base, long *res);
-
-#define define_strict_strtoux(type, valtype) \
-int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\
-{ \
- char *tail; \
- valtype val; \
- size_t len; \
- \
- *res = 0; \
- len = strlen(cp); \
- if (len == 0) \
- return -EINVAL; \
- \
- val = simple_strtou##type(cp, &tail, base); \
- if ((*tail == '\0') || \
- ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\
- *res = val; \
- return 0; \
- } \
- \
- return -EINVAL; \
-} \
-
-#define define_strict_strtox(type, valtype) \
-int strict_strto##type(const char *cp, unsigned int base, valtype *res) \
-{ \
- int ret; \
- if (*cp == '-') { \
- ret = strict_strtou##type(cp+1, base, res); \
- if (!ret) \
- *res = -(*res); \
- } else \
- ret = strict_strtou##type(cp, base, res); \
- \
- return ret; \
-} \
-
-define_strict_strtoux(l, unsigned long)
-define_strict_strtox(l, long)
-
-EXPORT_SYMBOL_GPL(strict_strtoul);
-EXPORT_SYMBOL_GPL(strict_strtol);
-
+++ /dev/null
-/*
- * Copyright 2007-2010 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.26.
- *
- * Copyright holders from ported work:
- *
- * Copyright (c) 2002-2003 Patrick Mochel <mochel@osdl.org>
- * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com>
- * Copyright (c) 2006-2007 Novell Inc.
- */
-
-#include <net/compat.h>
-
-/* 2.6.24 does not have the struct kobject with a name */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-
-/**
- * kobject_set_name_vargs - Set the name of an kobject
- * @kobj: struct kobject to set the name of
- * @fmt: format string used to build the name
- * @vargs: vargs to format the string.
- */
-static
-int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
- va_list vargs)
-{
- const char *old_name = kobj->name;
- char *s;
-
- if (kobj->name && !fmt)
- return 0;
-
- kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
- if (!kobj->name)
- return -ENOMEM;
-
- /* ewww... some of these buggers have '/' in the name ... */
- while ((s = strchr(kobj->name, '/')))
- s[0] = '!';
-
- kfree(old_name);
- return 0;
-}
-#else
-static
-int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
- va_list vargs)
-{
- struct device *dev;
- unsigned int len;
- va_list aq;
-
- dev = container_of(kobj, struct device, kobj);
-
- va_copy(aq, vargs);
- len = vsnprintf(NULL, 0, fmt, aq);
- va_end(aq);
-
- len = len < BUS_ID_SIZE ? (len + 1) : BUS_ID_SIZE;
-
- vsnprintf(dev->bus_id, len, fmt, vargs);
- return 0;
-}
-#endif
-
-/**
- * dev_set_name - set a device name
- * @dev: device
- * @fmt: format string for the device's name
- */
-int dev_set_name(struct device *dev, const char *fmt, ...)
-{
- va_list vargs;
- int err;
-
- va_start(vargs, fmt);
- err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
- va_end(vargs);
- return err;
-}
-EXPORT_SYMBOL_GPL(dev_set_name);
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.27
- */
-
-#include <linux/compat.h>
-#include <linux/pci.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
-#include <linux/mmc/sdio.h>
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
-#endif
-
-/* rfkill notification chain */
-#define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill
- switch has changed */
-
-/*
- * e5899e1b7d73e67de758a32174a859cc2586c0b9 made pci_pme_capable() external,
- * it was defined internally, some drivers want access to this information.
- *
- * Unfortunately the old kernels do not have ->pm_cap or ->pme_support so
- * we have to call the PCI routines directly.
- */
-
-/**
- * pci_pme_capable - check the capability of PCI device to generate PME#
- * @dev: PCI device to handle.
- * @state: PCI state from which device will issue PME#.
- *
- * This is the backport code for older kernels for compat-wireless, we read stuff
- * from the initialization stuff from pci_pm_init().
- */
-bool pci_pme_capable(struct pci_dev *dev, pci_power_t state)
-{
- int pm;
- u16 pmc = 0;
- u16 pme_support; /* as from the pci dev */
- /* find PCI PM capability in list */
- pm = pci_find_capability(dev, PCI_CAP_ID_PM);
- if (!pm)
- return false;
-
- if ((pmc & PCI_PM_CAP_VER_MASK) > 3) {
- dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n",
- pmc & PCI_PM_CAP_VER_MASK);
- return false;
- }
-
- pmc &= PCI_PM_CAP_PME_MASK;
-
- if (!pmc)
- return false;
-
- pme_support = pmc >> PCI_PM_CAP_PME_SHIFT;
-
- /* Check device's ability to generate PME# */
-
- return !!(pme_support & (1 << state));
-}
-EXPORT_SYMBOL_GPL(pci_pme_capable);
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
-/**
- * mmc_align_data_size - pads a transfer size to a more optimal value
- * @card: the MMC card associated with the data transfer
- * @sz: original transfer size
- *
- * Pads the original data size with a number of extra bytes in
- * order to avoid controller bugs and/or performance hits
- * (e.g. some controllers revert to PIO for certain sizes).
- *
- * Returns the improved size, which might be unmodified.
- *
- * Note that this function is only relevant when issuing a
- * single scatter gather entry.
- */
-unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz)
-{
- /*
- * FIXME: We don't have a system for the controller to tell
- * the core about its problems yet, so for now we just 32-bit
- * align the size.
- */
- sz = ((sz + 3) / 4) * 4;
-
- return sz;
-}
-EXPORT_SYMBOL_GPL(mmc_align_data_size);
-
-/*
- * Calculate the maximum byte mode transfer size
- */
-static inline unsigned int sdio_max_byte_size(struct sdio_func *func)
-{
- unsigned int mval = (unsigned int) min(func->card->host->max_seg_size,
- func->card->host->max_blk_size);
- mval = min(mval, func->max_blksize);
- return min(mval, 512u); /* maximum size for byte mode */
-}
-
-/**
- * sdio_align_size - pads a transfer size to a more optimal value
- * @func: SDIO function
- * @sz: original transfer size
- *
- * Pads the original data size with a number of extra bytes in
- * order to avoid controller bugs and/or performance hits
- * (e.g. some controllers revert to PIO for certain sizes).
- *
- * If possible, it will also adjust the size so that it can be
- * handled in just a single request.
- *
- * Returns the improved size, which might be unmodified.
- */
-unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
-{
- unsigned int orig_sz;
- unsigned int blk_sz, byte_sz;
- unsigned chunk_sz;
-
- orig_sz = sz;
-
- /*
- * Do a first check with the controller, in case it
- * wants to increase the size up to a point where it
- * might need more than one block.
- */
- sz = mmc_align_data_size(func->card, sz);
-
- /*
- * If we can still do this with just a byte transfer, then
- * we're done.
- */
- if (sz <= sdio_max_byte_size(func))
- return sz;
-
- if (func->card->cccr.multi_block) {
- /*
- * Check if the transfer is already block aligned
- */
- if ((sz % func->cur_blksize) == 0)
- return sz;
-
- /*
- * Realign it so that it can be done with one request,
- * and recheck if the controller still likes it.
- */
- blk_sz = ((sz + func->cur_blksize - 1) /
- func->cur_blksize) * func->cur_blksize;
- blk_sz = mmc_align_data_size(func->card, blk_sz);
-
- /*
- * This value is only good if it is still just
- * one request.
- */
- if ((blk_sz % func->cur_blksize) == 0)
- return blk_sz;
-
- /*
- * We failed to do one request, but at least try to
- * pad the remainder properly.
- */
- byte_sz = mmc_align_data_size(func->card,
- sz % func->cur_blksize);
- if (byte_sz <= sdio_max_byte_size(func)) {
- blk_sz = sz / func->cur_blksize;
- return blk_sz * func->cur_blksize + byte_sz;
- }
- } else {
- /*
- * We need multiple requests, so first check that the
- * controller can handle the chunk size;
- */
- chunk_sz = mmc_align_data_size(func->card,
- sdio_max_byte_size(func));
- if (chunk_sz == sdio_max_byte_size(func)) {
- /*
- * Fix up the size of the remainder (if any)
- */
- byte_sz = orig_sz % chunk_sz;
- if (byte_sz) {
- byte_sz = mmc_align_data_size(func->card,
- byte_sz);
- }
-
- return (orig_sz / chunk_sz) * chunk_sz + byte_sz;
- }
- }
-
- /*
- * The controller is simply incapable of transferring the size
- * we want in decent manner, so just return the original size.
- */
- return orig_sz;
-}
-EXPORT_SYMBOL_GPL(sdio_align_size);
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
-
-#ifdef CONFIG_DEBUG_FS
-/*
- * Backport of debugfs_remove_recursive() without using the internals globals
- * which are used by the kernel's version with:
- * simple_release_fs(&debugfs_mount, &debugfs_mount_count);
- */
-void debugfs_remove_recursive(struct dentry *dentry)
-{
- struct dentry *last = NULL;
-
- /* Sanity checks */
- if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
- return;
-
- while (dentry != last) {
- struct dentry *child = dentry;
-
- /* Find a child without children */
- while (!list_empty(&child->d_subdirs))
- child = list_entry(child->d_subdirs.next,
- struct dentry,
- d_u.d_child);
-
- /* Bail out if we already tried to remove that entry */
- if (child == last)
- return;
-
- last = child;
- debugfs_remove(child);
- }
-}
-EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
-#endif /* CONFIG_DEBUG_FS */
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.28.
- */
-
-#include <linux/compat.h>
-#include <linux/tty.h>
-#include <asm/poll.h>
-
-/* 2.6.28 compat code goes here */
-
-void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
-{
- /*
- * Make sure the BAR is actually a memory resource, not an IO resource
- */
- if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
- WARN_ON(1);
- return NULL;
- }
- return ioremap_nocache(pci_resource_start(pdev, bar),
- pci_resource_len(pdev, bar));
-}
-EXPORT_SYMBOL_GPL(pci_ioremap_bar);
-
-static unsigned long round_jiffies_common(unsigned long j, int cpu,
- bool force_up)
-{
- int rem;
- unsigned long original = j;
-
- /*
- * We don't want all cpus firing their timers at once hitting the
- * same lock or cachelines, so we skew each extra cpu with an extra
- * 3 jiffies. This 3 jiffies came originally from the mm/ code which
- * already did this.
- * The skew is done by adding 3*cpunr, then round, then subtract this
- * extra offset again.
- */
- j += cpu * 3;
-
- rem = j % HZ;
-
- /*
- * If the target jiffie is just after a whole second (which can happen
- * due to delays of the timer irq, long irq off times etc etc) then
- * we should round down to the whole second, not up. Use 1/4th second
- * as cutoff for this rounding as an extreme upper bound for this.
- * But never round down if @force_up is set.
- */
- if (rem < HZ/4 && !force_up) /* round down */
- j = j - rem;
- else /* round up */
- j = j - rem + HZ;
-
- /* now that we have rounded, subtract the extra skew again */
- j -= cpu * 3;
-
- if (j <= jiffies) /* rounding ate our timeout entirely; */
- return original;
- return j;
-}
-
-/**
- * round_jiffies_up - function to round jiffies up to a full second
- * @j: the time in (absolute) jiffies that should be rounded
- *
- * This is the same as round_jiffies() except that it will never
- * round down. This is useful for timeouts for which the exact time
- * of firing does not matter too much, as long as they don't fire too
- * early.
- */
-unsigned long round_jiffies_up(unsigned long j)
-{
- return round_jiffies_common(j, raw_smp_processor_id(), true);
-}
-EXPORT_SYMBOL_GPL(round_jiffies_up);
-
-void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
- int size)
-{
- skb_fill_page_desc(skb, i, page, off, size);
- skb->len += size;
- skb->data_len += size;
- skb->truesize += size;
-}
-EXPORT_SYMBOL_GPL(v2_6_28_skb_add_rx_frag);
-
-void tty_write_unlock(struct tty_struct *tty)
-{
- mutex_unlock(&tty->atomic_write_lock);
- wake_up_interruptible_poll(&tty->write_wait, POLLOUT);
-}
-
-int tty_write_lock(struct tty_struct *tty, int ndelay)
-{
- if (!mutex_trylock(&tty->atomic_write_lock)) {
- if (ndelay)
- return -EAGAIN;
- if (mutex_lock_interruptible(&tty->atomic_write_lock))
- return -ERESTARTSYS;
- }
- return 0;
-}
-
-/**
- * send_prio_char - send priority character
- *
- * Send a high priority character to the tty even if stopped
- *
- * Locking: none for xchar method, write ordering for write method.
- */
-
-static int send_prio_char(struct tty_struct *tty, char ch)
-{
- int was_stopped = tty->stopped;
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
- if (tty->ops->send_xchar) {
- tty->ops->send_xchar(tty, ch);
-#else
- if (tty->driver->send_xchar) {
- tty->driver->send_xchar(tty, ch);
-#endif
- return 0;
- }
-
- if (tty_write_lock(tty, 0) < 0)
- return -ERESTARTSYS;
-
- if (was_stopped)
- start_tty(tty);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
- tty->ops->write(tty, &ch, 1);
-#else
- tty->driver->write(tty, &ch, 1);
-#endif
- if (was_stopped)
- stop_tty(tty);
- tty_write_unlock(tty);
- return 0;
-}
-
-int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
- unsigned long flags;
-#endif
- int retval;
-
- switch (cmd) {
- case TCXONC:
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- switch (arg) {
- case TCOOFF:
- if (!tty->flow_stopped) {
- tty->flow_stopped = 1;
- stop_tty(tty);
- }
- break;
- case TCOON:
- if (tty->flow_stopped) {
- tty->flow_stopped = 0;
- start_tty(tty);
- }
- break;
- case TCIOFF:
- if (STOP_CHAR(tty) != __DISABLED_CHAR)
- return send_prio_char(tty, STOP_CHAR(tty));
- break;
- case TCION:
- if (START_CHAR(tty) != __DISABLED_CHAR)
- return send_prio_char(tty, START_CHAR(tty));
- break;
- default:
- return -EINVAL;
- }
- return 0;
- case TCFLSH:
- return tty_perform_flush(tty, arg);
- case TIOCPKT:
- {
- int pktmode;
-
- if (tty->driver->type != TTY_DRIVER_TYPE_PTY ||
- tty->driver->subtype != PTY_TYPE_MASTER)
- return -ENOTTY;
- if (get_user(pktmode, (int __user *) arg))
- return -EFAULT;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
- spin_lock_irqsave(&tty->ctrl_lock, flags);
-#endif
- if (pktmode) {
- if (!tty->packet) {
- tty->packet = 1;
- tty->link->ctrl_status = 0;
- }
- } else
- tty->packet = 0;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
- spin_unlock_irqrestore(&tty->ctrl_lock, flags);
-#endif
- return 0;
- }
- default:
- /* Try the mode commands */
- return tty_mode_ioctl(tty, file, cmd, arg);
- }
-}
-EXPORT_SYMBOL_GPL(n_tty_ioctl_helper);
-
-/**
- * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold
- * @dev: PCI device to prepare
- * @enable: True to enable wake-up event generation; false to disable
- *
- * Many drivers want the device to wake up the system from D3_hot or D3_cold
- * and this function allows them to set that up cleanly - pci_enable_wake()
- * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI
- * ordering constraints.
- *
- * This function only returns error code if the device is not capable of
- * generating PME# from both D3_hot and D3_cold, and the platform is unable to
- * enable wake-up power for it.
- */
-int pci_wake_from_d3(struct pci_dev *dev, bool enable)
-{
- return pci_pme_capable(dev, PCI_D3cold) ?
- pci_enable_wake(dev, PCI_D3cold, enable) :
- pci_enable_wake(dev, PCI_D3hot, enable);
-}
-EXPORT_SYMBOL_GPL(pci_wake_from_d3);
-
+++ /dev/null
-/*
- * Copyright 2007-2010 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.29.
- */
-
-#include <linux/compat.h>
-#include <linux/usb.h>
-#include <linux/etherdevice.h>
-
-/*
- * If you don't see your net_device_ops implemented on
- * netdev_attach_ops() then you are shit out of luck and
- * you must do the nasty ifdef magic, unless you figure
- * out a way to squeze your hacks into this routine :)
- */
-void netdev_attach_ops(struct net_device *dev,
- const struct net_device_ops *ops)
-{
- dev->open = ops->ndo_open;
- dev->init = ops->ndo_init;
- dev->stop = ops->ndo_stop;
- dev->hard_start_xmit = ops->ndo_start_xmit;
- dev->change_rx_flags = ops->ndo_change_rx_flags;
- dev->set_multicast_list = ops->ndo_set_multicast_list;
- dev->validate_addr = ops->ndo_validate_addr;
- dev->do_ioctl = ops->ndo_do_ioctl;
- dev->set_config = ops->ndo_set_config;
- dev->change_mtu = ops->ndo_change_mtu;
- dev->set_mac_address = ops->ndo_set_mac_address;
- dev->tx_timeout = ops->ndo_tx_timeout;
- if (ops->ndo_get_stats)
- dev->get_stats = ops->ndo_get_stats;
- dev->vlan_rx_register = ops->ndo_vlan_rx_register;
- dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid;
- dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = ops->ndo_poll_controller;
-#endif
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
- dev->select_queue = ops->ndo_select_queue;
-#endif
-}
-EXPORT_SYMBOL_GPL(netdev_attach_ops);
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
-#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
-/**
- * usb_unpoison_anchored_urbs - let an anchor be used successfully again
- * @anchor: anchor the requests are bound to
- *
- * Reverses the effect of usb_poison_anchored_urbs
- * the anchor can be used normally after it returns
- */
-void usb_unpoison_anchored_urbs(struct usb_anchor *anchor)
-{
- unsigned long flags;
- struct urb *lazarus;
-
- spin_lock_irqsave(&anchor->lock, flags);
- list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) {
- usb_unpoison_urb(lazarus);
- }
- //anchor->poisoned = 0; /* XXX: cannot backport */
- spin_unlock_irqrestore(&anchor->lock, flags);
-}
-EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs);
-#endif /* CONFIG_USB */
-#endif
-
-/**
- * eth_mac_addr - set new Ethernet hardware address
- * @dev: network device
- * @p: socket address
- * Change hardware address of device.
- *
- * This doesn't change hardware matching, so needs to be overridden
- * for most real devices.
- */
-int eth_mac_addr(struct net_device *dev, void *p)
-{
- struct sockaddr *addr = p;
-
- if (netif_running(dev))
- return -EBUSY;
- if (!is_valid_ether_addr(addr->sa_data))
- return -EADDRNOTAVAIL;
- memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
- return 0;
-}
-EXPORT_SYMBOL_GPL(eth_mac_addr);
-
-/**
- * eth_change_mtu - set new MTU size
- * @dev: network device
- * @new_mtu: new Maximum Transfer Unit
- *
- * Allow changing MTU size. Needs to be overridden for devices
- * supporting jumbo frames.
- */
-int eth_change_mtu(struct net_device *dev, int new_mtu)
-{
- if (new_mtu < 68 || new_mtu > ETH_DATA_LEN)
- return -EINVAL;
- dev->mtu = new_mtu;
- return 0;
-}
-EXPORT_SYMBOL_GPL(eth_change_mtu);
-
-int eth_validate_addr(struct net_device *dev)
-{
- if (!is_valid_ether_addr(dev->dev_addr))
- return -EADDRNOTAVAIL;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(eth_validate_addr);
-/* Source: net/ethernet/eth.c */
-
-#define NETREG_DUMMY 5
-/**
- * init_dummy_netdev - init a dummy network device for NAPI
- * @dev: device to init
- *
- * This takes a network device structure and initialize the minimum
- * amount of fields so it can be used to schedule NAPI polls without
- * registering a full blown interface. This is to be used by drivers
- * that need to tie several hardware interfaces to a single NAPI
- * poll scheduler due to HW limitations.
- */
-int init_dummy_netdev(struct net_device *dev)
-{
- /* Clear everything. Note we don't initialize spinlocks
- * are they aren't supposed to be taken by any of the
- * NAPI code and this dummy netdev is supposed to be
- * only ever used for NAPI polls
- */
- memset(dev, 0, sizeof(struct net_device));
-
- /* make sure we BUG if trying to hit standard
- * register/unregister code path
- */
- dev->reg_state = NETREG_DUMMY;
-
- /* initialize the ref count */
- atomic_set(&dev->refcnt, 1);
-
-#ifdef CONFIG_NETPOLL
- /* NAPI wants this */
- INIT_LIST_HEAD(&dev->napi_list);
-#endif
-
- /* a dummy interface is started by default */
- set_bit(__LINK_STATE_PRESENT, &dev->state);
- set_bit(__LINK_STATE_START, &dev->state);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(init_dummy_netdev);
-/* Source: net/core/dev.c */
-
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.32.
- */
-
-#include <linux/compat.h>
-#include <linux/netdevice.h>
-
-int __dev_addr_add(struct dev_addr_list **list, int *count,
- void *addr, int alen, int glbl)
-{
- struct dev_addr_list *da;
-
- for (da = *list; da != NULL; da = da->next) {
- if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 &&
- da->da_addrlen == alen) {
- if (glbl) {
- int old_glbl = da->da_gusers;
- da->da_gusers = 1;
- if (old_glbl)
- return 0;
- }
- da->da_users++;
- return 0;
- }
- }
-
- da = kzalloc(sizeof(*da), GFP_ATOMIC);
- if (da == NULL)
- return -ENOMEM;
- memcpy(da->da_addr, addr, alen);
- da->da_addrlen = alen;
- da->da_users = 1;
- da->da_gusers = glbl ? 1 : 0;
- da->next = *list;
- *list = da;
- (*count)++;
- return 0;
-}
-
-int __dev_addr_delete(struct dev_addr_list **list, int *count,
- void *addr, int alen, int glbl)
-{
- struct dev_addr_list *da;
-
- for (; (da = *list) != NULL; list = &da->next) {
- if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 &&
- alen == da->da_addrlen) {
- if (glbl) {
- int old_glbl = da->da_gusers;
- da->da_gusers = 0;
- if (old_glbl == 0)
- break;
- }
- if (--da->da_users)
- return 0;
-
- *list = da->next;
- kfree(da);
- (*count)--;
- return 0;
- }
- }
- return -ENOENT;
-}
-
-int __dev_addr_sync(struct dev_addr_list **to, int *to_count,
- struct dev_addr_list **from, int *from_count)
-{
- struct dev_addr_list *da, *next;
- int err = 0;
-
- da = *from;
- while (da != NULL) {
- next = da->next;
- if (!da->da_synced) {
- err = __dev_addr_add(to, to_count,
- da->da_addr, da->da_addrlen, 0);
- if (err < 0)
- break;
- da->da_synced = 1;
- da->da_users++;
- } else if (da->da_users == 1) {
- __dev_addr_delete(to, to_count,
- da->da_addr, da->da_addrlen, 0);
- __dev_addr_delete(from, from_count,
- da->da_addr, da->da_addrlen, 0);
- }
- da = next;
- }
- return err;
-}
-EXPORT_SYMBOL_GPL(__dev_addr_sync);
-
-void __dev_addr_unsync(struct dev_addr_list **to, int *to_count,
- struct dev_addr_list **from, int *from_count)
-{
- struct dev_addr_list *da, *next;
-
- da = *from;
- while (da != NULL) {
- next = da->next;
- if (da->da_synced) {
- __dev_addr_delete(to, to_count,
- da->da_addr, da->da_addrlen, 0);
- da->da_synced = 0;
- __dev_addr_delete(from, from_count,
- da->da_addr, da->da_addrlen, 0);
- }
- da = next;
- }
-}
-EXPORT_SYMBOL_GPL(__dev_addr_unsync);
-
-/*
- * Nonzero if YEAR is a leap year (every 4 years,
- * except every 100th isn't, and every 400th is).
- */
-static int __isleap(long year)
-{
- return (year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0);
-}
-
-/* do a mathdiv for long type */
-static long math_div(long a, long b)
-{
- return a / b - (a % b < 0);
-}
-
-/* How many leap years between y1 and y2, y1 must less or equal to y2 */
-static long leaps_between(long y1, long y2)
-{
- long leaps1 = math_div(y1 - 1, 4) - math_div(y1 - 1, 100)
- + math_div(y1 - 1, 400);
- long leaps2 = math_div(y2 - 1, 4) - math_div(y2 - 1, 100)
- + math_div(y2 - 1, 400);
- return leaps2 - leaps1;
-}
-
-/* How many days come before each month (0-12). */
-static const unsigned short __mon_yday[2][13] = {
- /* Normal years. */
- {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
- /* Leap years. */
- {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
-};
-
-#define SECS_PER_HOUR (60 * 60)
-#define SECS_PER_DAY (SECS_PER_HOUR * 24)
-
-/**
- * time_to_tm - converts the calendar time to local broken-down time
- *
- * @totalsecs the number of seconds elapsed since 00:00:00 on January 1, 1970,
- * Coordinated Universal Time (UTC).
- * @offset offset seconds adding to totalsecs.
- * @result pointer to struct tm variable to receive broken-down time
- */
-void time_to_tm(time_t totalsecs, int offset, struct tm *result)
-{
- long days, rem, y;
- const unsigned short *ip;
-
- days = totalsecs / SECS_PER_DAY;
- rem = totalsecs % SECS_PER_DAY;
- rem += offset;
- while (rem < 0) {
- rem += SECS_PER_DAY;
- --days;
- }
- while (rem >= SECS_PER_DAY) {
- rem -= SECS_PER_DAY;
- ++days;
- }
-
- result->tm_hour = rem / SECS_PER_HOUR;
- rem %= SECS_PER_HOUR;
- result->tm_min = rem / 60;
- result->tm_sec = rem % 60;
-
- /* January 1, 1970 was a Thursday. */
- result->tm_wday = (4 + days) % 7;
- if (result->tm_wday < 0)
- result->tm_wday += 7;
-
- y = 1970;
-
- while (days < 0 || days >= (__isleap(y) ? 366 : 365)) {
- /* Guess a corrected year, assuming 365 days per year. */
- long yg = y + math_div(days, 365);
-
- /* Adjust DAYS and Y to match the guessed year. */
- days -= (yg - y) * 365 + leaps_between(y, yg);
- y = yg;
- }
-
- result->tm_year = y - 1900;
-
- result->tm_yday = days;
-
- ip = __mon_yday[__isleap(y)];
- for (y = 11; days < ip[y]; y--)
- continue;
- days -= ip[y];
-
- result->tm_mon = y;
- result->tm_mday = days + 1;
-}
-EXPORT_SYMBOL_GPL(time_to_tm);
-/* source: kernel/time/timeconv.c*/
-
+++ /dev/null
-/*
- * Copyright 2009 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.33.
- */
-
-#include <linux/compat.h>
-#include <linux/autoconf.h>
-#include <linux/string.h>
-#include <linux/ctype.h>
-
-#ifndef BITMAP_FIRST_WORD_MASK
-#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
-#endif /* BITMAP_FIRST_WORD_MASK */
-
-#ifndef CONFIG_COMPAT_IS_BITMAP
-
-void bitmap_set(unsigned long *map, int start, int nr)
-{
- unsigned long *p = map + BIT_WORD(start);
- const int size = start + nr;
- int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
- unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
-
- while (nr - bits_to_set >= 0) {
- *p |= mask_to_set;
- nr -= bits_to_set;
- bits_to_set = BITS_PER_LONG;
- mask_to_set = ~0UL;
- p++;
- }
- if (nr) {
- mask_to_set &= BITMAP_LAST_WORD_MASK(size);
- *p |= mask_to_set;
- }
-}
-EXPORT_SYMBOL(bitmap_set);
-
-void bitmap_clear(unsigned long *map, int start, int nr)
-{
- unsigned long *p = map + BIT_WORD(start);
- const int size = start + nr;
- int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
- unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
-
- while (nr - bits_to_clear >= 0) {
- *p &= ~mask_to_clear;
- nr -= bits_to_clear;
- bits_to_clear = BITS_PER_LONG;
- mask_to_clear = ~0UL;
- p++;
- }
- if (nr) {
- mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
- *p &= ~mask_to_clear;
- }
-}
-EXPORT_SYMBOL(bitmap_clear);
-
-/*
- * bitmap_find_next_zero_area - find a contiguous aligned zero area
- * @map: The address to base the search on
- * @size: The bitmap size in bits
- * @start: The bitnumber to start searching at
- * @nr: The number of zeroed bits we're looking for
- * @align_mask: Alignment mask for zero area
- *
- * The @align_mask should be one less than a power of 2; the effect is that
- * the bit offset of all zero areas this function finds is multiples of that
- * power of 2. A @align_mask of 0 means no alignment is required.
- */
-unsigned long bitmap_find_next_zero_area(unsigned long *map,
- unsigned long size,
- unsigned long start,
- unsigned int nr,
- unsigned long align_mask)
-{
- unsigned long index, end, i;
-again:
- index = find_next_zero_bit(map, size, start);
-
- /* Align allocation */
- index = __ALIGN_MASK(index, align_mask);
-
- end = index + nr;
- if (end > size)
- return end;
- i = find_next_bit(map, end, index);
- if (i < end) {
- start = i + 1;
- goto again;
- }
- return index;
-}
-EXPORT_SYMBOL(bitmap_find_next_zero_area);
-#endif /* CONFIG_COMPAT_IS_BITMAP */
-
-/**
- * skip_spaces - Removes leading whitespace from @str.
- * @str: The string to be stripped.
- *
- * Returns a pointer to the first non-whitespace character in @str.
- */
-char *skip_spaces(const char *str)
-{
- while (isspace(*str))
- ++str;
- return (char *)str;
-}
-EXPORT_SYMBOL(skip_spaces);
-
-/**
- * strim - Removes leading and trailing whitespace from @s.
- * @s: The string to be stripped.
- *
- * Note that the first trailing whitespace is replaced with a %NUL-terminator
- * in the given string @s. Returns a pointer to the first non-whitespace
- * character in @s.
- */
-char *strim(char *s)
-{
- size_t size;
- char *end;
-
- size = strlen(s);
- if (!size)
- return s;
-
- end = s + size - 1;
- while (end >= s && isspace(*end))
- end--;
- *(end + 1) = '\0';
-
- return skip_spaces(s);
-}
-EXPORT_SYMBOL(strim);
-
+++ /dev/null
-/*
- * Copyright 2012 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.34.
- */
-
-#include <linux/pci.h>
-#include <linux/export.h>
-
-int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt)
-{
- int i;
-
- for (i = off; i < len; ) {
- u8 val = buf[i];
-
- if (val & PCI_VPD_LRDT) {
- /* Don't return success of the tag isn't complete */
- if (i + PCI_VPD_LRDT_TAG_SIZE > len)
- break;
-
- if (val == rdt)
- return i;
-
- i += PCI_VPD_LRDT_TAG_SIZE +
- pci_vpd_lrdt_size(&buf[i]);
- } else {
- u8 tag = val & ~PCI_VPD_SRDT_LEN_MASK;
-
- if (tag == rdt)
- return i;
-
- if (tag == PCI_VPD_SRDT_END)
- break;
-
- i += PCI_VPD_SRDT_TAG_SIZE +
- pci_vpd_srdt_size(&buf[i]);
- }
- }
-
- return -ENOENT;
-}
-EXPORT_SYMBOL_GPL(pci_vpd_find_tag);
-
-int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
- unsigned int len, const char *kw)
-{
- int i;
-
- for (i = off; i + PCI_VPD_INFO_FLD_HDR_SIZE <= off + len;) {
- if (buf[i + 0] == kw[0] &&
- buf[i + 1] == kw[1])
- return i;
-
- i += PCI_VPD_INFO_FLD_HDR_SIZE +
- pci_vpd_info_field_size(&buf[i]);
- }
-
- return -ENOENT;
-}
-EXPORT_SYMBOL_GPL(pci_vpd_find_info_keyword);
+++ /dev/null
-/*
- * Copyright 2010 Kshitij Kulshreshtha <kkhere.geo@gmail.com>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.35.
- */
-
-#include <linux/compat.h>
-#include <linux/ctype.h>
-
-/**
- * hex_to_bin - convert a hex digit to its real value
- * @ch: ascii character represents hex digit
- *
- * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad
- * input.
- */
-int hex_to_bin(char ch)
-{
- if ((ch >= '0') && (ch <= '9'))
- return ch - '0';
- ch = tolower(ch);
- if ((ch >= 'a') && (ch <= 'f'))
- return ch - 'a' + 10;
- return -1;
-}
-EXPORT_SYMBOL_GPL(hex_to_bin);
-
-/**
- * noop_llseek - No Operation Performed llseek implementation
- * @file: file structure to seek on
- * @offset: file offset to seek to
- * @origin: type of seek
- *
- * This is an implementation of ->llseek useable for the rare special case when
- * userspace expects the seek to succeed but the (device) file is actually not
- * able to perform the seek. In this case you use noop_llseek() instead of
- * falling back to the default implementation of ->llseek.
- */
-loff_t noop_llseek(struct file *file, loff_t offset, int origin)
-{
- return file->f_pos;
-}
-EXPORT_SYMBOL_GPL(noop_llseek);
+++ /dev/null
-/*
- * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.36.
- */
-
-#include <linux/compat.h>
-
-struct workqueue_struct *system_wq __read_mostly;
-struct workqueue_struct *system_long_wq __read_mostly;
-struct workqueue_struct *system_nrt_wq __read_mostly;
-EXPORT_SYMBOL_GPL(system_wq);
-EXPORT_SYMBOL_GPL(system_long_wq);
-EXPORT_SYMBOL_GPL(system_nrt_wq);
-
-int schedule_work(struct work_struct *work)
-{
- return queue_work(system_wq, work);
-}
-EXPORT_SYMBOL_GPL(schedule_work);
-
-int schedule_work_on(int cpu, struct work_struct *work)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
- return queue_work_on(cpu, system_wq, work);
-#else
- return queue_work(system_wq, work);
-#endif
-}
-EXPORT_SYMBOL_GPL(schedule_work_on);
-
-int schedule_delayed_work(struct delayed_work *dwork,
- unsigned long delay)
-{
- return queue_delayed_work(system_wq, dwork, delay);
-}
-EXPORT_SYMBOL_GPL(schedule_delayed_work);
-
-int schedule_delayed_work_on(int cpu,
- struct delayed_work *dwork,
- unsigned long delay)
-{
- return queue_delayed_work_on(cpu, system_wq, dwork, delay);
-}
-EXPORT_SYMBOL_GPL(schedule_delayed_work_on);
-
-void flush_scheduled_work(void)
-{
- flush_workqueue(system_wq);
-}
-EXPORT_SYMBOL_GPL(flush_scheduled_work);
-
-/**
- * work_busy - test whether a work is currently pending or running
- * @work: the work to be tested
- *
- * Test whether @work is currently pending or running. There is no
- * synchronization around this function and the test result is
- * unreliable and only useful as advisory hints or for debugging.
- * Especially for reentrant wqs, the pending state might hide the
- * running state.
- *
- * RETURNS:
- * OR'd bitmask of WORK_BUSY_* bits.
- */
-unsigned int work_busy(struct work_struct *work)
-{
- unsigned int ret = 0;
-
- if (work_pending(work))
- ret |= WORK_BUSY_PENDING;
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(work_busy);
-
-int backport_system_workqueue_create()
-{
- system_wq = alloc_workqueue("events", 0, 0);
- if (!system_wq)
- return -ENOMEM;
-
- system_long_wq = alloc_workqueue("events_long", 0, 0);
- if (!system_long_wq)
- goto err1;
-
- system_nrt_wq = create_singlethread_workqueue("events_nrt");
- if (!system_nrt_wq)
- goto err2;
-
- return 0;
-
-err2:
- destroy_workqueue(system_long_wq);
-err1:
- destroy_workqueue(system_wq);
- return -ENOMEM;
-}
-
-void backport_system_workqueue_destroy()
-{
- destroy_workqueue(system_nrt_wq);
- destroy_workqueue(system_wq);
- destroy_workqueue(system_long_wq);
-}
+++ /dev/null
-/*
- * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.37.
- */
-
-#include <linux/compat.h>
-#include <linux/netdevice.h>
-#include <net/sock.h>
-#include <linux/nsproxy.h>
-#include <linux/vmalloc.h>
-#include <linux/sunrpc/xprt.h>
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
-static const void *net_current_ns(void)
-{
- return current->nsproxy->net_ns;
-}
-
-static const void *net_initial_ns(void)
-{
- return &init_net;
-}
-
-static const void *net_netlink_ns(struct sock *sk)
-{
- return sock_net(sk);
-}
-
-struct kobj_ns_type_operations net_ns_type_operations = {
- .type = KOBJ_NS_TYPE_NET,
- .current_ns = net_current_ns,
- .netlink_ns = net_netlink_ns,
- .initial_ns = net_initial_ns,
-};
-EXPORT_SYMBOL_GPL(net_ns_type_operations);
-
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)*/
-
-#undef genl_info
-#undef genl_unregister_family
-
-static LIST_HEAD(compat_nl_fam);
-
-static struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family)
-{
- struct genl_ops *ops;
-
- list_for_each_entry(ops, &family->family.ops_list, ops.ops_list)
- if (ops->cmd == cmd)
- return ops;
-
- return NULL;
-}
-
-
-static int nl_doit_wrapper(struct sk_buff *skb, struct genl_info *info)
-{
- struct compat_genl_info compat_info;
- struct genl_family *family;
- struct genl_ops *ops;
- int err;
-
- list_for_each_entry(family, &compat_nl_fam, list) {
- if (family->id == info->nlhdr->nlmsg_type)
- goto found;
- }
- return -ENOENT;
-
-found:
- ops = genl_get_cmd(info->genlhdr->cmd, family);
- if (!ops)
- return -ENOENT;
-
- memset(&compat_info.user_ptr, 0, sizeof(compat_info.user_ptr));
- compat_info.info = info;
-#define __copy(_field) compat_info._field = info->_field
- __copy(snd_seq);
- __copy(snd_pid);
- __copy(genlhdr);
- __copy(attrs);
-#undef __copy
- if (family->pre_doit) {
- err = family->pre_doit(ops, skb, &compat_info);
- if (err)
- return err;
- }
-
- err = ops->doit(skb, &compat_info);
-
- if (family->post_doit)
- family->post_doit(ops, skb, &compat_info);
-
- return err;
-}
-
-int compat_genl_register_family_with_ops(struct genl_family *family,
- struct genl_ops *ops, size_t n_ops)
-{
- int i, ret;
-
-#define __copy(_field) family->family._field = family->_field
- __copy(id);
- __copy(hdrsize);
- __copy(version);
- __copy(maxattr);
- strncpy(family->family.name, family->name, sizeof(family->family.name));
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
- __copy(netnsok);
-#endif
-#undef __copy
-
- ret = genl_register_family(&family->family);
- if (ret < 0)
- return ret;
-
- family->attrbuf = family->family.attrbuf;
- family->id = family->family.id;
-
- for (i = 0; i < n_ops; i++) {
-#define __copy(_field) ops[i].ops._field = ops[i]._field
- __copy(cmd);
- __copy(flags);
- __copy(policy);
- __copy(dumpit);
- __copy(done);
-#undef __copy
- if (ops[i].doit)
- ops[i].ops.doit = nl_doit_wrapper;
- ret = genl_register_ops(&family->family, &ops[i].ops);
- if (ret < 0)
- goto error_ops;
- }
- list_add(&family->list, &compat_nl_fam);
-
- return ret;
-
-error_ops:
- compat_genl_unregister_family(family);
- return ret;
-}
-EXPORT_SYMBOL_GPL(compat_genl_register_family_with_ops);
-
-int compat_genl_unregister_family(struct genl_family *family)
-{
- int err;
- err = genl_unregister_family(&family->family);
- list_del(&family->list);
- return err;
-}
-EXPORT_SYMBOL_GPL(compat_genl_unregister_family);
-
-#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
-
-#undef led_brightness_set
-#undef led_classdev_unregister
-
-static DEFINE_SPINLOCK(led_lock);
-static LIST_HEAD(led_timers);
-
-struct led_timer {
- struct list_head list;
- struct led_classdev *cdev;
- struct timer_list blink_timer;
- unsigned long blink_delay_on;
- unsigned long blink_delay_off;
- int blink_brightness;
-};
-
-static void led_brightness_set(struct led_classdev *led_cdev,
- enum led_brightness brightness)
-{
- led_cdev->brightness = brightness;
- led_cdev->brightness_set(led_cdev, brightness);
-}
-
-static struct led_timer *led_get_timer(struct led_classdev *led_cdev)
-{
- struct led_timer *p;
- unsigned long flags;
-
- spin_lock_irqsave(&led_lock, flags);
- list_for_each_entry(p, &led_timers, list) {
- if (p->cdev == led_cdev)
- goto found;
- }
- p = NULL;
-found:
- spin_unlock_irqrestore(&led_lock, flags);
- return p;
-}
-
-static void led_stop_software_blink(struct led_timer *led)
-{
- del_timer_sync(&led->blink_timer);
- led->blink_delay_on = 0;
- led->blink_delay_off = 0;
-}
-
-static void led_timer_function(unsigned long data)
-{
- struct led_timer *led = (struct led_timer *)data;
- unsigned long brightness;
- unsigned long delay;
-
- if (!led->blink_delay_on || !led->blink_delay_off) {
- led->cdev->brightness_set(led->cdev, LED_OFF);
- return;
- }
-
- brightness = led->cdev->brightness;
- if (!brightness) {
- /* Time to switch the LED on. */
- brightness = led->blink_brightness;
- delay = led->blink_delay_on;
- } else {
- /* Store the current brightness value to be able
- * to restore it when the delay_off period is over.
- */
- led->blink_brightness = brightness;
- brightness = LED_OFF;
- delay = led->blink_delay_off;
- }
-
- led_brightness_set(led->cdev, brightness);
- mod_timer(&led->blink_timer, jiffies + msecs_to_jiffies(delay));
-}
-
-static struct led_timer *led_new_timer(struct led_classdev *led_cdev)
-{
- struct led_timer *led;
- unsigned long flags;
-
- led = kzalloc(sizeof(struct led_timer), GFP_ATOMIC);
- if (!led)
- return NULL;
-
- led->cdev = led_cdev;
- init_timer(&led->blink_timer);
- led->blink_timer.function = led_timer_function;
- led->blink_timer.data = (unsigned long) led;
-
- spin_lock_irqsave(&led_lock, flags);
- list_add(&led->list, &led_timers);
- spin_unlock_irqrestore(&led_lock, flags);
-
- return led;
-}
-
-void led_blink_set(struct led_classdev *led_cdev,
- unsigned long *delay_on,
- unsigned long *delay_off)
-{
- struct led_timer *led;
- int current_brightness;
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
- if (led_cdev->blink_set &&
- !led_cdev->blink_set(led_cdev, delay_on, delay_off))
- return;
-#endif
-
- led = led_get_timer(led_cdev);
- if (!led) {
- led = led_new_timer(led_cdev);
- if (!led)
- return;
- }
-
- /* blink with 1 Hz as default if nothing specified */
- if (!*delay_on && !*delay_off)
- *delay_on = *delay_off = 500;
-
- if (led->blink_delay_on == *delay_on &&
- led->blink_delay_off == *delay_off)
- return;
-
- current_brightness = led_cdev->brightness;
- if (current_brightness)
- led->blink_brightness = current_brightness;
- if (!led->blink_brightness)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
- led->blink_brightness = led_cdev->max_brightness;
-#else
- led->blink_brightness = LED_FULL;
-#endif
-
- led_stop_software_blink(led);
- led->blink_delay_on = *delay_on;
- led->blink_delay_off = *delay_off;
-
- /* never on - don't blink */
- if (!*delay_on)
- return;
-
- /* never off - just set to brightness */
- if (!*delay_off) {
- led_brightness_set(led_cdev, led->blink_brightness);
- return;
- }
-
- mod_timer(&led->blink_timer, jiffies + 1);
-}
-EXPORT_SYMBOL_GPL(led_blink_set);
-
-void compat_led_brightness_set(struct led_classdev *led_cdev,
- enum led_brightness brightness)
-{
- struct led_timer *led = led_get_timer(led_cdev);
-
- if (led)
- led_stop_software_blink(led);
-
- return led_cdev->brightness_set(led_cdev, brightness);
-}
-EXPORT_SYMBOL_GPL(compat_led_brightness_set);
-
-void compat_led_classdev_unregister(struct led_classdev *led_cdev)
-{
- struct led_timer *led = led_get_timer(led_cdev);
- unsigned long flags;
-
- if (led) {
- del_timer_sync(&led->blink_timer);
- spin_lock_irqsave(&led_lock, flags);
- list_del(&led->list);
- spin_unlock_irqrestore(&led_lock, flags);
- kfree(led);
- }
-
- led_classdev_unregister(led_cdev);
-}
-EXPORT_SYMBOL_GPL(compat_led_classdev_unregister);
-
-/**
- * vzalloc - allocate virtually contiguous memory with zero fill
- * @size: allocation size
- * Allocate enough pages to cover @size from the page level
- * allocator and map them into contiguous kernel virtual space.
- * The memory allocated is set to zero.
- *
- * For tight control over page level allocator and protection flags
- * use __vmalloc() instead.
- */
-void *vzalloc(unsigned long size)
-{
- void *buf;
- buf = vmalloc(size);
- if (buf)
- memset(buf, 0, size);
- return buf;
-}
-EXPORT_SYMBOL_GPL(vzalloc);
-
-/**
- * vzalloc_node - allocate memory on a specific node with zero fill
- * @size: allocation size
- * @node: numa node
- *
- * Allocate enough pages to cover @size from the page level
- * allocator and map them into contiguous kernel virtual space.
- * The memory allocated is set to zero.
- *
- * For tight control over page level allocator and protection flags
- * use __vmalloc() instead.
- */
-void *vzalloc_node(unsigned long size, int node)
-{
- return vzalloc(size);
-}
-EXPORT_SYMBOL(vzalloc_node);
-
-#endif
-
-#ifndef CONFIG_COMPAT_XPRTRDMA_NEEDED
-struct rpc_xprt *xprt_alloc(int size, int max_req)
-{
- struct rpc_xprt *xprt;
-
- xprt = kzalloc(size, GFP_KERNEL);
- if (xprt == NULL)
- goto out;
-
- xprt->max_reqs = max_req;
- xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL);
- if (xprt->slot == NULL)
- goto out_free;
-
- return xprt;
-
-out_free:
- kfree(xprt);
-out:
- return NULL;
-}
-EXPORT_SYMBOL_GPL(xprt_alloc);
-
-void xprt_free(struct rpc_xprt *xprt)
-{
- kfree(xprt->slot);
- kfree(xprt);
-}
-EXPORT_SYMBOL_GPL(xprt_free);
-#endif
+++ /dev/null
-/*
- * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.38.
- */
-
-#if !defined(RHEL_MINOR) || (RHEL_MINOR < 3)
-#include <linux/compat.h>
-#include <linux/module.h>
-#include <linux/bug.h>
-
-/**
- * ewma_init() - Initialize EWMA parameters
- * @avg: Average structure
- * @factor: Factor to use for the scaled up internal value. The maximum value
- * of averages can be ULONG_MAX/(factor*weight).
- * @weight: Exponential weight, or decay rate. This defines how fast the
- * influence of older values decreases. Has to be bigger than 1.
- *
- * Initialize the EWMA parameters for a given struct ewma @avg.
- */
-void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight)
-{
- WARN_ON(weight <= 1 || factor == 0);
- avg->internal = 0;
- avg->weight = weight;
- avg->factor = factor;
-}
-EXPORT_SYMBOL_GPL(ewma_init);
-
-/**
- * ewma_add() - Exponentially weighted moving average (EWMA)
- * @avg: Average structure
- * @val: Current value
- *
- * Add a sample to the average.
- */
-struct ewma *ewma_add(struct ewma *avg, unsigned long val)
-{
- avg->internal = avg->internal ?
- (((avg->internal * (avg->weight - 1)) +
- (val * avg->factor)) / avg->weight) :
- (val * avg->factor);
- return avg;
-}
-EXPORT_SYMBOL_GPL(ewma_add);
-
-#endif
+++ /dev/null
-/*
- * Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 2.6.39.
- */
-
-#include <linux/compat.h>
-#include <linux/tty.h>
-#include <linux/sched.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
-/*
- * Termios Helper Methods
- */
-static void unset_locked_termios(struct ktermios *termios,
- struct ktermios *old,
- struct ktermios *locked)
-{
- int i;
-
-#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z)))
-
- if (!locked) {
- printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n");
- return;
- }
-
- NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag);
- NOSET_MASK(termios->c_oflag, old->c_oflag, locked->c_oflag);
- NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag);
- NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag);
- termios->c_line = locked->c_line ? old->c_line : termios->c_line;
- for (i = 0; i < NCCS; i++)
- termios->c_cc[i] = locked->c_cc[i] ?
- old->c_cc[i] : termios->c_cc[i];
- /* FIXME: What should we do for i/ospeed */
-}
-
-/**
- * tty_set_termios - update termios values
- * @tty: tty to update
- * @new_termios: desired new value
- *
- * Perform updates to the termios values set on this terminal. There
- * is a bit of layering violation here with n_tty in terms of the
- * internal knowledge of this function.
- *
- * Locking: termios_mutex
- */
-int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)
-{
- struct ktermios old_termios;
- struct tty_ldisc *ld;
- unsigned long flags;
-
- /*
- * Perform the actual termios internal changes under lock.
- */
-
-
- /* FIXME: we need to decide on some locking/ordering semantics
- for the set_termios notification eventually */
- mutex_lock(&tty->termios_mutex);
- old_termios = *tty->termios;
- *tty->termios = *new_termios;
- unset_locked_termios(tty->termios, &old_termios, tty->termios_locked);
-
- /* See if packet mode change of state. */
- if (tty->link && tty->link->packet) {
- int extproc = (old_termios.c_lflag & EXTPROC) |
- (tty->termios->c_lflag & EXTPROC);
- int old_flow = ((old_termios.c_iflag & IXON) &&
- (old_termios.c_cc[VSTOP] == '\023') &&
- (old_termios.c_cc[VSTART] == '\021'));
- int new_flow = (I_IXON(tty) &&
- STOP_CHAR(tty) == '\023' &&
- START_CHAR(tty) == '\021');
- if ((old_flow != new_flow) || extproc) {
- spin_lock_irqsave(&tty->ctrl_lock, flags);
- if (old_flow != new_flow) {
- tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
- if (new_flow)
- tty->ctrl_status |= TIOCPKT_DOSTOP;
- else
- tty->ctrl_status |= TIOCPKT_NOSTOP;
- }
- if (extproc)
- tty->ctrl_status |= TIOCPKT_IOCTL;
- spin_unlock_irqrestore(&tty->ctrl_lock, flags);
- wake_up_interruptible(&tty->link->read_wait);
- }
- }
-
- if (tty->ops->set_termios)
- (*tty->ops->set_termios)(tty, &old_termios);
- else
- tty_termios_copy_hw(tty->termios, &old_termios);
-
- ld = tty_ldisc_ref(tty);
- if (ld != NULL) {
- if (ld->ops->set_termios)
- (ld->ops->set_termios)(tty, &old_termios);
- tty_ldisc_deref(ld);
- }
- mutex_unlock(&tty->termios_mutex);
- return 0;
-}
-EXPORT_SYMBOL_GPL(tty_set_termios);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
-
+++ /dev/null
-/*
- * Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de>
- * Copyright 2011 Alexey Dobriyan <adobriyan@gmail.com>
- *
- * 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.
- *
- * Compatibility file for Linux wireless for kernels 3.0.
- */
-
-#include <linux/compat.h>
-#include <linux/if_ether.h>
-
-int mac_pton(const char *s, u8 *mac)
-{
- int i;
-
- /* XX:XX:XX:XX:XX:XX */
- if (strlen(s) < 3 * ETH_ALEN - 1)
- return 0;
-
- /* Don't dirty result unless string is valid MAC. */
- for (i = 0; i < ETH_ALEN; i++) {
- if (!strchr("0123456789abcdefABCDEF", s[i * 3]))
- return 0;
- if (!strchr("0123456789abcdefABCDEF", s[i * 3 + 1]))
- return 0;
- if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
- return 0;
- }
- for (i = 0; i < ETH_ALEN; i++) {
- mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
- }
- return 1;
-}
-EXPORT_SYMBOL_GPL(mac_pton);
-
-#ifndef CONFIG_COMPAT_IS_KSTRTOX
-#define kstrto_from_user(f, g, type) \
-int f(const char __user *s, size_t count, unsigned int base, type *res) \
-{ \
- /* sign, base 2 representation, newline, terminator */ \
- char buf[1 + sizeof(type) * 8 + 1 + 1]; \
- \
- count = min(count, sizeof(buf) - 1); \
- if (copy_from_user(buf, s, count)) \
- return -EFAULT; \
- buf[count] = '\0'; \
- return g(buf, base, res); \
-} \
-EXPORT_SYMBOL_GPL(f)
-
-kstrto_from_user(kstrtoull_from_user, kstrtoull, unsigned long long);
-kstrto_from_user(kstrtoll_from_user, kstrtoll, long long);
-kstrto_from_user(kstrtoul_from_user, kstrtoul, unsigned long);
-kstrto_from_user(kstrtol_from_user, kstrtol, long);
-kstrto_from_user(kstrtouint_from_user, kstrtouint, unsigned int);
-kstrto_from_user(kstrtoint_from_user, kstrtoint, int);
-kstrto_from_user(kstrtou16_from_user, kstrtou16, u16);
-kstrto_from_user(kstrtos16_from_user, kstrtos16, s16);
-kstrto_from_user(kstrtou8_from_user, kstrtou8, u8);
-kstrto_from_user(kstrtos8_from_user, kstrtos8, s8);
-#endif
+++ /dev/null
-#include <linux/spinlock.h>
-#include <linux/module.h>
-
-#if !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && (defined(CONFIG_UML) || defined(CONFIG_X86))) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64))
-
-static DEFINE_SPINLOCK(lock);
-
-long long atomic64_read(const atomic64_t *v)
-{
- unsigned long flags;
- long long val;
-
- spin_lock_irqsave(&lock, flags);
- val = v->counter;
- spin_unlock_irqrestore(&lock, flags);
- return val;
-}
-EXPORT_SYMBOL_GPL(atomic64_read);
-
-long long atomic64_add_return(long long a, atomic64_t *v)
-{
- unsigned long flags;
- long long val;
-
- spin_lock_irqsave(&lock, flags);
- val = v->counter += a;
- spin_unlock_irqrestore(&lock, flags);
- return val;
-}
-EXPORT_SYMBOL_GPL(atomic64_add_return);
-
-#endif
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#include <linux/module.h>
-#include <linux/cordic.h>
-
-#define CORDIC_ANGLE_GEN 39797
-#define CORDIC_PRECISION_SHIFT 16
-#define CORDIC_NUM_ITER (CORDIC_PRECISION_SHIFT + 2)
-
-#define FIXED(X) ((s32)((X) << CORDIC_PRECISION_SHIFT))
-#define FLOAT(X) (((X) >= 0) \
- ? ((((X) >> (CORDIC_PRECISION_SHIFT - 1)) + 1) >> 1) \
- : -((((-(X)) >> (CORDIC_PRECISION_SHIFT - 1)) + 1) >> 1))
-
-static const s32 arctan_table[] = {
- 2949120,
- 1740967,
- 919879,
- 466945,
- 234379,
- 117304,
- 58666,
- 29335,
- 14668,
- 7334,
- 3667,
- 1833,
- 917,
- 458,
- 229,
- 115,
- 57,
- 29
-};
-
-/*
- * cordic_calc_iq() - calculates the i/q coordinate for given angle
- *
- * theta: angle in degrees for which i/q coordinate is to be calculated
- * coord: function output parameter holding the i/q coordinate
- */
-struct cordic_iq cordic_calc_iq(s32 theta)
-{
- struct cordic_iq coord;
- s32 angle, valtmp;
- unsigned iter;
- int signx = 1;
- int signtheta;
-
- coord.i = CORDIC_ANGLE_GEN;
- coord.q = 0;
- angle = 0;
-
- theta = FIXED(theta);
- signtheta = (theta < 0) ? -1 : 1;
- theta = ((theta + FIXED(180) * signtheta) % FIXED(360)) -
- FIXED(180) * signtheta;
-
- if (FLOAT(theta) > 90) {
- theta -= FIXED(180);
- signx = -1;
- } else if (FLOAT(theta) < -90) {
- theta += FIXED(180);
- signx = -1;
- }
-
- for (iter = 0; iter < CORDIC_NUM_ITER; iter++) {
- if (theta > angle) {
- valtmp = coord.i - (coord.q >> iter);
- coord.q += (coord.i >> iter);
- angle += arctan_table[iter];
- } else {
- valtmp = coord.i + (coord.q >> iter);
- coord.q -= (coord.i >> iter);
- angle -= arctan_table[iter];
- }
- coord.i = valtmp;
- }
-
- coord.i *= signx;
- coord.q *= signx;
- return coord;
-}
-EXPORT_SYMBOL_GPL(cordic_calc_iq);
-
-MODULE_DESCRIPTION("Cordic functions");
-MODULE_AUTHOR("Broadcom Corporation");
-MODULE_LICENSE("Dual BSD/GPL");
+++ /dev/null
-/*
- * Copyright (c) 2011 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#undef pr_fmt
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/module.h>
-#include <linux/crc8.h>
-#include <linux/printk.h>
-
-/*
- * crc8_populate_msb - fill crc table for given polynomial in reverse bit order.
- *
- * table: table to be filled.
- * polynomial: polynomial for which table is to be filled.
- */
-void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial)
-{
- int i, j;
- const u8 msbit = 0x80;
- u8 t = msbit;
-
- table[0] = 0;
-
- for (i = 1; i < CRC8_TABLE_SIZE; i *= 2) {
- t = (t << 1) ^ (t & msbit ? polynomial : 0);
- for (j = 0; j < i; j++)
- table[i+j] = table[j] ^ t;
- }
-}
-EXPORT_SYMBOL_GPL(crc8_populate_msb);
-
-/*
- * crc8_populate_lsb - fill crc table for given polynomial in regular bit order.
- *
- * table: table to be filled.
- * polynomial: polynomial for which table is to be filled.
- */
-void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial)
-{
- int i, j;
- u8 t = 1;
-
- table[0] = 0;
-
- for (i = (CRC8_TABLE_SIZE >> 1); i; i >>= 1) {
- t = (t >> 1) ^ (t & 1 ? polynomial : 0);
- for (j = 0; j < CRC8_TABLE_SIZE; j += 2*i)
- table[i+j] = table[j] ^ t;
- }
-}
-EXPORT_SYMBOL_GPL(crc8_populate_lsb);
-
-/*
- * crc8 - calculate a crc8 over the given input data.
- *
- * table: crc table used for calculation.
- * pdata: pointer to data buffer.
- * nbytes: number of bytes in data buffer.
- * crc: previous returned crc8 value.
- */
-u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc)
-{
- /* loop over the buffer data */
- while (nbytes-- > 0)
- crc = table[(crc ^ *pdata++) & 0xff];
-
- return crc;
-}
-EXPORT_SYMBOL_GPL(crc8);
-
-MODULE_DESCRIPTION("CRC8 (by Williams, Ross N.) function");
-MODULE_AUTHOR("Broadcom Corporation");
-MODULE_LICENSE("Dual BSD/GPL");
+++ /dev/null
-#include <linux/skbuff.h>
-#include <linux/export.h>
-#include <linux/ip.h>
-#include <linux/ipv6.h>
-#include <linux/if_vlan.h>
-#include <net/ip.h>
-#include <linux/if_tunnel.h>
-#include <linux/if_pppox.h>
-#include <linux/ppp_defs.h>
-#include <net/flow_keys.h>
-
-/* copy saddr & daddr, possibly using 64bit load/store
- * Equivalent to : flow->src = iph->saddr;
- * flow->dst = iph->daddr;
- */
-static void iph_to_flow_copy_addrs(struct flow_keys *flow, const struct iphdr *iph)
-{
- BUILD_BUG_ON(offsetof(typeof(*flow), dst) !=
- offsetof(typeof(*flow), src) + sizeof(flow->src));
- memcpy(&flow->src, &iph->saddr, sizeof(flow->src) + sizeof(flow->dst));
-}
-
-bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
-{
- int poff, nhoff = skb_network_offset(skb);
- u8 ip_proto;
- __be16 proto = skb->protocol;
-
- memset(flow, 0, sizeof(*flow));
-
-again:
- switch (proto) {
- case __constant_htons(ETH_P_IP): {
- const struct iphdr *iph;
- struct iphdr _iph;
-ip:
- iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
- if (!iph)
- return false;
-
- if (ip_is_fragment(iph))
- ip_proto = 0;
- else
- ip_proto = iph->protocol;
- iph_to_flow_copy_addrs(flow, iph);
- nhoff += iph->ihl * 4;
- break;
- }
- case __constant_htons(ETH_P_IPV6): {
- const struct ipv6hdr *iph;
- struct ipv6hdr _iph;
-ipv6:
- iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
- if (!iph)
- return false;
-
- ip_proto = iph->nexthdr;
- flow->src = iph->saddr.s6_addr32[3];
- flow->dst = iph->daddr.s6_addr32[3];
- nhoff += sizeof(struct ipv6hdr);
- break;
- }
- case __constant_htons(ETH_P_8021Q): {
- const struct vlan_hdr *vlan;
- struct vlan_hdr _vlan;
-
- vlan = skb_header_pointer(skb, nhoff, sizeof(_vlan), &_vlan);
- if (!vlan)
- return false;
-
- proto = vlan->h_vlan_encapsulated_proto;
- nhoff += sizeof(*vlan);
- goto again;
- }
- case __constant_htons(ETH_P_PPP_SES): {
- struct {
- struct pppoe_hdr hdr;
- __be16 proto;
- } *hdr, _hdr;
- hdr = skb_header_pointer(skb, nhoff, sizeof(_hdr), &_hdr);
- if (!hdr)
- return false;
- proto = hdr->proto;
- nhoff += PPPOE_SES_HLEN;
- switch (proto) {
- case __constant_htons(PPP_IP):
- goto ip;
- case __constant_htons(PPP_IPV6):
- goto ipv6;
- default:
- return false;
- }
- }
- default:
- return false;
- }
-
- switch (ip_proto) {
- case IPPROTO_GRE: {
- struct gre_hdr {
- __be16 flags;
- __be16 proto;
- } *hdr, _hdr;
-
- hdr = skb_header_pointer(skb, nhoff, sizeof(_hdr), &_hdr);
- if (!hdr)
- return false;
- /*
- * Only look inside GRE if version zero and no
- * routing
- */
- if (!(hdr->flags & (GRE_VERSION|GRE_ROUTING))) {
- proto = hdr->proto;
- nhoff += 4;
- if (hdr->flags & GRE_CSUM)
- nhoff += 4;
- if (hdr->flags & GRE_KEY)
- nhoff += 4;
- if (hdr->flags & GRE_SEQ)
- nhoff += 4;
- goto again;
- }
- break;
- }
- case IPPROTO_IPIP:
- goto again;
- default:
- break;
- }
-
- flow->ip_proto = ip_proto;
- poff = proto_ports_offset(ip_proto);
- if (poff >= 0) {
- __be32 *ports, _ports;
-
- nhoff += poff;
- ports = skb_header_pointer(skb, nhoff, sizeof(_ports), &_ports);
- if (ports)
- flow->ports = *ports;
- }
-
- return true;
-}
-EXPORT_SYMBOL_GPL(skb_flow_dissect);
+++ /dev/null
-/*
- * A generic kernel FIFO implementation
- *
- * Copyright (C) 2009/2010 Stefani Seibold <stefani@seibold.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/err.h>
-#include <linux/log2.h>
-#include <linux/uaccess.h>
-#include <linux/kfifo.h>
-
-/*
- * internal helper to calculate the unused elements in a fifo
- */
-static inline unsigned int kfifo_unused(struct __kfifo *fifo)
-{
- return (fifo->mask + 1) - (fifo->in - fifo->out);
-}
-
-int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
- size_t esize, gfp_t gfp_mask)
-{
- /*
- * round down to the next power of 2, since our 'let the indices
- * wrap' technique works only in this case.
- */
- if (!is_power_of_2(size))
- size = rounddown_pow_of_two(size);
-
- fifo->in = 0;
- fifo->out = 0;
- fifo->esize = esize;
-
- if (size < 2) {
- fifo->data = NULL;
- fifo->mask = 0;
- return -EINVAL;
- }
-
- fifo->data = kmalloc(size * esize, gfp_mask);
-
- if (!fifo->data) {
- fifo->mask = 0;
- return -ENOMEM;
- }
- fifo->mask = size - 1;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(__kfifo_alloc);
-
-void __kfifo_free(struct __kfifo *fifo)
-{
- kfree(fifo->data);
- fifo->in = 0;
- fifo->out = 0;
- fifo->esize = 0;
- fifo->data = NULL;
- fifo->mask = 0;
-}
-EXPORT_SYMBOL_GPL(__kfifo_free);
-
-int __kfifo_init(struct __kfifo *fifo, void *buffer,
- unsigned int size, size_t esize)
-{
- size /= esize;
-
- if (!is_power_of_2(size))
- size = rounddown_pow_of_two(size);
-
- fifo->in = 0;
- fifo->out = 0;
- fifo->esize = esize;
- fifo->data = buffer;
-
- if (size < 2) {
- fifo->mask = 0;
- return -EINVAL;
- }
- fifo->mask = size - 1;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(__kfifo_init);
-
-static void kfifo_copy_in(struct __kfifo *fifo, const void *src,
- unsigned int len, unsigned int off)
-{
- unsigned int size = fifo->mask + 1;
- unsigned int esize = fifo->esize;
- unsigned int l;
-
- off &= fifo->mask;
- if (esize != 1) {
- off *= esize;
- size *= esize;
- len *= esize;
- }
- l = min(len, size - off);
-
- memcpy(fifo->data + off, src, l);
- memcpy(fifo->data, src + l, len - l);
- /*
- * make sure that the data in the fifo is up to date before
- * incrementing the fifo->in index counter
- */
- smp_wmb();
-}
-
-unsigned int __kfifo_in(struct __kfifo *fifo,
- const void *buf, unsigned int len)
-{
- unsigned int l;
-
- l = kfifo_unused(fifo);
- if (len > l)
- len = l;
-
- kfifo_copy_in(fifo, buf, len, fifo->in);
- fifo->in += len;
- return len;
-}
-EXPORT_SYMBOL_GPL(__kfifo_in);
-
-static void kfifo_copy_out(struct __kfifo *fifo, void *dst,
- unsigned int len, unsigned int off)
-{
- unsigned int size = fifo->mask + 1;
- unsigned int esize = fifo->esize;
- unsigned int l;
-
- off &= fifo->mask;
- if (esize != 1) {
- off *= esize;
- size *= esize;
- len *= esize;
- }
- l = min(len, size - off);
-
- memcpy(dst, fifo->data + off, l);
- memcpy(dst + l, fifo->data, len - l);
- /*
- * make sure that the data is copied before
- * incrementing the fifo->out index counter
- */
- smp_wmb();
-}
-
-unsigned int __kfifo_out_peek(struct __kfifo *fifo,
- void *buf, unsigned int len)
-{
- unsigned int l;
-
- l = fifo->in - fifo->out;
- if (len > l)
- len = l;
-
- kfifo_copy_out(fifo, buf, len, fifo->out);
- return len;
-}
-EXPORT_SYMBOL_GPL(__kfifo_out_peek);
-
-unsigned int __kfifo_out(struct __kfifo *fifo,
- void *buf, unsigned int len)
-{
- len = __kfifo_out_peek(fifo, buf, len);
- fifo->out += len;
- return len;
-}
-EXPORT_SYMBOL_GPL(__kfifo_out);
-
-static unsigned long kfifo_copy_from_user(struct __kfifo *fifo,
- const void __user *from, unsigned int len, unsigned int off,
- unsigned int *copied)
-{
- unsigned int size = fifo->mask + 1;
- unsigned int esize = fifo->esize;
- unsigned int l;
- unsigned long ret;
-
- off &= fifo->mask;
- if (esize != 1) {
- off *= esize;
- size *= esize;
- len *= esize;
- }
- l = min(len, size - off);
-
- ret = copy_from_user(fifo->data + off, from, l);
- if (unlikely(ret))
- ret = DIV_ROUND_UP(ret + len - l, esize);
- else {
- ret = copy_from_user(fifo->data, from + l, len - l);
- if (unlikely(ret))
- ret = DIV_ROUND_UP(ret, esize);
- }
- /*
- * make sure that the data in the fifo is up to date before
- * incrementing the fifo->in index counter
- */
- smp_wmb();
- *copied = len - ret;
- /* return the number of elements which are not copied */
- return ret;
-}
-
-int __kfifo_from_user(struct __kfifo *fifo, const void __user *from,
- unsigned long len, unsigned int *copied)
-{
- unsigned int l;
- unsigned long ret;
- unsigned int esize = fifo->esize;
- int err;
-
- if (esize != 1)
- len /= esize;
-
- l = kfifo_unused(fifo);
- if (len > l)
- len = l;
-
- ret = kfifo_copy_from_user(fifo, from, len, fifo->in, copied);
- if (unlikely(ret)) {
- len -= ret;
- err = -EFAULT;
- } else
- err = 0;
- fifo->in += len;
- return err;
-}
-EXPORT_SYMBOL_GPL(__kfifo_from_user);
-
-static unsigned long kfifo_copy_to_user(struct __kfifo *fifo, void __user *to,
- unsigned int len, unsigned int off, unsigned int *copied)
-{
- unsigned int l;
- unsigned long ret;
- unsigned int size = fifo->mask + 1;
- unsigned int esize = fifo->esize;
-
- off &= fifo->mask;
- if (esize != 1) {
- off *= esize;
- size *= esize;
- len *= esize;
- }
- l = min(len, size - off);
-
- ret = copy_to_user(to, fifo->data + off, l);
- if (unlikely(ret))
- ret = DIV_ROUND_UP(ret + len - l, esize);
- else {
- ret = copy_to_user(to + l, fifo->data, len - l);
- if (unlikely(ret))
- ret = DIV_ROUND_UP(ret, esize);
- }
- /*
- * make sure that the data is copied before
- * incrementing the fifo->out index counter
- */
- smp_wmb();
- *copied = len - ret;
- /* return the number of elements which are not copied */
- return ret;
-}
-
-int __kfifo_to_user(struct __kfifo *fifo, void __user *to,
- unsigned long len, unsigned int *copied)
-{
- unsigned int l;
- unsigned long ret;
- unsigned int esize = fifo->esize;
- int err;
-
- if (esize != 1)
- len /= esize;
-
- l = fifo->in - fifo->out;
- if (len > l)
- len = l;
- ret = kfifo_copy_to_user(fifo, to, len, fifo->out, copied);
- if (unlikely(ret)) {
- len -= ret;
- err = -EFAULT;
- } else
- err = 0;
- fifo->out += len;
- return err;
-}
-EXPORT_SYMBOL_GPL(__kfifo_to_user);
-
-static int setup_sgl_buf(struct scatterlist *sgl, void *buf,
- int nents, unsigned int len)
-{
- int n;
- unsigned int l;
- unsigned int off;
- struct page *page;
-
- if (!nents)
- return 0;
-
- if (!len)
- return 0;
-
- n = 0;
- page = virt_to_page(buf);
- off = offset_in_page(buf);
- l = 0;
-
- while (len >= l + PAGE_SIZE - off) {
- struct page *npage;
-
- l += PAGE_SIZE;
- buf += PAGE_SIZE;
- npage = virt_to_page(buf);
- if (page_to_phys(page) != page_to_phys(npage) - l) {
- sg_set_page(sgl, page, l - off, off);
- sgl = sg_next(sgl);
- if (++n == nents || sgl == NULL)
- return n;
- page = npage;
- len -= l - off;
- l = off = 0;
- }
- }
- sg_set_page(sgl, page, len, off);
- return n + 1;
-}
-
-static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl,
- int nents, unsigned int len, unsigned int off)
-{
- unsigned int size = fifo->mask + 1;
- unsigned int esize = fifo->esize;
- unsigned int l;
- unsigned int n;
-
- off &= fifo->mask;
- if (esize != 1) {
- off *= esize;
- size *= esize;
- len *= esize;
- }
- l = min(len, size - off);
-
- n = setup_sgl_buf(sgl, fifo->data + off, nents, l);
- n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l);
-
- return n;
-}
-
-unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len)
-{
- unsigned int l;
-
- l = kfifo_unused(fifo);
- if (len > l)
- len = l;
-
- return setup_sgl(fifo, sgl, nents, len, fifo->in);
-}
-EXPORT_SYMBOL_GPL(__kfifo_dma_in_prepare);
-
-unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len)
-{
- unsigned int l;
-
- l = fifo->in - fifo->out;
- if (len > l)
- len = l;
-
- return setup_sgl(fifo, sgl, nents, len, fifo->out);
-}
-EXPORT_SYMBOL_GPL(__kfifo_dma_out_prepare);
-
-unsigned int __kfifo_max_r(unsigned int len, size_t recsize)
-{
- unsigned int max = (1 << (recsize << 3)) - 1;
-
- if (len > max)
- return max;
- return len;
-}
-
-#define __KFIFO_PEEK(data, out, mask) \
- ((data)[(out) & (mask)])
-/*
- * __kfifo_peek_n internal helper function for determinate the length of
- * the next record in the fifo
- */
-static unsigned int __kfifo_peek_n(struct __kfifo *fifo, size_t recsize)
-{
- unsigned int l;
- unsigned int mask = fifo->mask;
- unsigned char *data = fifo->data;
-
- l = __KFIFO_PEEK(data, fifo->out, mask);
-
- if (--recsize)
- l |= __KFIFO_PEEK(data, fifo->out + 1, mask) << 8;
-
- return l;
-}
-
-#define __KFIFO_POKE(data, in, mask, val) \
- ( \
- (data)[(in) & (mask)] = (unsigned char)(val) \
- )
-
-/*
- * __kfifo_poke_n internal helper function for storeing the length of
- * the record into the fifo
- */
-static void __kfifo_poke_n(struct __kfifo *fifo, unsigned int n, size_t recsize)
-{
- unsigned int mask = fifo->mask;
- unsigned char *data = fifo->data;
-
- __KFIFO_POKE(data, fifo->in, mask, n);
-
- if (recsize > 1)
- __KFIFO_POKE(data, fifo->in + 1, mask, n >> 8);
-}
-
-unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize)
-{
- return __kfifo_peek_n(fifo, recsize);
-}
-EXPORT_SYMBOL_GPL(__kfifo_len_r);
-
-unsigned int __kfifo_in_r(struct __kfifo *fifo, const void *buf,
- unsigned int len, size_t recsize)
-{
- if (len + recsize > kfifo_unused(fifo))
- return 0;
-
- __kfifo_poke_n(fifo, len, recsize);
-
- kfifo_copy_in(fifo, buf, len, fifo->in + recsize);
- fifo->in += len + recsize;
- return len;
-}
-EXPORT_SYMBOL_GPL(__kfifo_in_r);
-
-static unsigned int kfifo_out_copy_r(struct __kfifo *fifo,
- void *buf, unsigned int len, size_t recsize, unsigned int *n)
-{
- *n = __kfifo_peek_n(fifo, recsize);
-
- if (len > *n)
- len = *n;
-
- kfifo_copy_out(fifo, buf, len, fifo->out + recsize);
- return len;
-}
-
-unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, void *buf,
- unsigned int len, size_t recsize)
-{
- unsigned int n;
-
- if (fifo->in == fifo->out)
- return 0;
-
- return kfifo_out_copy_r(fifo, buf, len, recsize, &n);
-}
-EXPORT_SYMBOL_GPL(__kfifo_out_peek_r);
-
-unsigned int __kfifo_out_r(struct __kfifo *fifo, void *buf,
- unsigned int len, size_t recsize)
-{
- unsigned int n;
-
- if (fifo->in == fifo->out)
- return 0;
-
- len = kfifo_out_copy_r(fifo, buf, len, recsize, &n);
- fifo->out += n + recsize;
- return len;
-}
-EXPORT_SYMBOL_GPL(__kfifo_out_r);
-
-void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize)
-{
- unsigned int n;
-
- n = __kfifo_peek_n(fifo, recsize);
- fifo->out += n + recsize;
-}
-EXPORT_SYMBOL_GPL(__kfifo_skip_r);
-
-int __kfifo_from_user_r(struct __kfifo *fifo, const void __user *from,
- unsigned long len, unsigned int *copied, size_t recsize)
-{
- unsigned long ret;
-
- len = __kfifo_max_r(len, recsize);
-
- if (len + recsize > kfifo_unused(fifo)) {
- *copied = 0;
- return 0;
- }
-
- __kfifo_poke_n(fifo, len, recsize);
-
- ret = kfifo_copy_from_user(fifo, from, len, fifo->in + recsize, copied);
- if (unlikely(ret)) {
- *copied = 0;
- return -EFAULT;
- }
- fifo->in += len + recsize;
- return 0;
-}
-EXPORT_SYMBOL_GPL(__kfifo_from_user_r);
-
-int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to,
- unsigned long len, unsigned int *copied, size_t recsize)
-{
- unsigned long ret;
- unsigned int n;
-
- if (fifo->in == fifo->out) {
- *copied = 0;
- return 0;
- }
-
- n = __kfifo_peek_n(fifo, recsize);
- if (len > n)
- len = n;
-
- ret = kfifo_copy_to_user(fifo, to, len, fifo->out + recsize, copied);
- if (unlikely(ret)) {
- *copied = 0;
- return -EFAULT;
- }
- fifo->out += n + recsize;
- return 0;
-}
-EXPORT_SYMBOL_GPL(__kfifo_to_user_r);
-
-unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
-{
- if (!nents)
- return -EINVAL;
-
- len = __kfifo_max_r(len, recsize);
-
- if (len + recsize > kfifo_unused(fifo))
- return 0;
-
- return setup_sgl(fifo, sgl, nents, len, fifo->in + recsize);
-}
-EXPORT_SYMBOL_GPL(__kfifo_dma_in_prepare_r);
-
-void __kfifo_dma_in_finish_r(struct __kfifo *fifo,
- unsigned int len, size_t recsize)
-{
- len = __kfifo_max_r(len, recsize);
- __kfifo_poke_n(fifo, len, recsize);
- fifo->in += len + recsize;
-}
-EXPORT_SYMBOL_GPL(__kfifo_dma_in_finish_r);
-
-unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
-{
- if (!nents)
- return -EINVAL;
-
- len = __kfifo_max_r(len, recsize);
-
- if (len + recsize > fifo->in - fifo->out)
- return 0;
-
- return setup_sgl(fifo, sgl, nents, len, fifo->out + recsize);
-}
-EXPORT_SYMBOL_GPL(__kfifo_dma_out_prepare_r);
-
-void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize)
-{
- unsigned int len;
-
- len = __kfifo_peek_n(fifo, recsize);
- fifo->out += len + recsize;
-}
-EXPORT_SYMBOL_GPL(__kfifo_dma_out_finish_r);
+++ /dev/null
-/*
- * Convert integer string representation to an integer.
- * If an integer doesn't fit into specified type, -E is returned.
- *
- * Integer starts with optional sign.
- * kstrtou*() functions do not accept sign "-".
- *
- * Radix 0 means autodetection: leading "0x" implies radix 16,
- * leading "0" implies radix 8, otherwise radix is 10.
- * Autodetection hints work after optional sign, but not before.
- *
- * If -E is returned, result is not touched.
- */
-#include <linux/kernel.h>
-
-#ifndef CONFIG_COMPAT_IS_KSTRTOX
-/*
- * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the
- * version included in compat-wireless. We use strict_strtol to check if
- * kstrto* is already available.
- */
-#ifndef strict_strtoll
-
-#include <linux/ctype.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/math64.h>
-#include <linux/module.h>
-#include <linux/types.h>
-
-static inline char _tolower(const char c)
-{
- return c | 0x20;
-}
-
-static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
-{
- unsigned long long acc;
- int ok;
-
- if (base == 0) {
- if (s[0] == '0') {
- if (_tolower(s[1]) == 'x' && isxdigit(s[2]))
- base = 16;
- else
- base = 8;
- } else
- base = 10;
- }
- if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
- s += 2;
-
- acc = 0;
- ok = 0;
- while (*s) {
- unsigned int val;
-
- if ('0' <= *s && *s <= '9')
- val = *s - '0';
- else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f')
- val = _tolower(*s) - 'a' + 10;
- else if (*s == '\n') {
- if (*(s + 1) == '\0')
- break;
- else
- return -EINVAL;
- } else
- return -EINVAL;
-
- if (val >= base)
- return -EINVAL;
- if (acc > div_u64(ULLONG_MAX - val, base))
- return -ERANGE;
- acc = acc * base + val;
- ok = 1;
-
- s++;
- }
- if (!ok)
- return -EINVAL;
- *res = acc;
- return 0;
-}
-
-int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
-{
- if (s[0] == '+')
- s++;
- return _kstrtoull(s, base, res);
-}
-EXPORT_SYMBOL_GPL(kstrtoull);
-
-int kstrtoll(const char *s, unsigned int base, long long *res)
-{
- unsigned long long tmp;
- int rv;
-
- if (s[0] == '-') {
- rv = _kstrtoull(s + 1, base, &tmp);
- if (rv < 0)
- return rv;
- if ((long long)(-tmp) >= 0)
- return -ERANGE;
- *res = -tmp;
- } else {
- rv = kstrtoull(s, base, &tmp);
- if (rv < 0)
- return rv;
- if ((long long)tmp < 0)
- return -ERANGE;
- *res = tmp;
- }
- return 0;
-}
-EXPORT_SYMBOL_GPL(kstrtoll);
-
-/* Internal, do not use. */
-int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
-{
- unsigned long long tmp;
- int rv;
-
- rv = kstrtoull(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (unsigned long long)(unsigned long)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(_kstrtoul);
-
-/* Internal, do not use. */
-int _kstrtol(const char *s, unsigned int base, long *res)
-{
- long long tmp;
- int rv;
-
- rv = kstrtoll(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (long long)(long)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(_kstrtol);
-
-int kstrtouint(const char *s, unsigned int base, unsigned int *res)
-{
- unsigned long long tmp;
- int rv;
-
- rv = kstrtoull(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (unsigned long long)(unsigned int)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(kstrtouint);
-
-int kstrtoint(const char *s, unsigned int base, int *res)
-{
- long long tmp;
- int rv;
-
- rv = kstrtoll(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (long long)(int)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(kstrtoint);
-
-int kstrtou16(const char *s, unsigned int base, u16 *res)
-{
- unsigned long long tmp;
- int rv;
-
- rv = kstrtoull(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (unsigned long long)(u16)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(kstrtou16);
-
-int kstrtos16(const char *s, unsigned int base, s16 *res)
-{
- long long tmp;
- int rv;
-
- rv = kstrtoll(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (long long)(s16)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(kstrtos16);
-
-int kstrtou8(const char *s, unsigned int base, u8 *res)
-{
- unsigned long long tmp;
- int rv;
-
- rv = kstrtoull(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (unsigned long long)(u8)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(kstrtou8);
-
-int kstrtos8(const char *s, unsigned int base, s8 *res)
-{
- long long tmp;
- int rv;
-
- rv = kstrtoll(s, base, &tmp);
- if (rv < 0)
- return rv;
- if (tmp != (long long)(s8)tmp)
- return -ERANGE;
- *res = tmp;
- return 0;
-}
-EXPORT_SYMBOL_GPL(kstrtos8);
-#endif /* #ifndef strict_strtol */
-#endif /* #ifndef CONFIG_COMPAT_IS_KSTRTOX */
+++ /dev/null
-/* Kernel thread helper functions.
- * Copyright (C) 2004 IBM Corporation, Rusty Russell.
- *
- * Creation is done via kthreadd, so that we get a clean environment
- * even if we're invoked from userspace (think modprobe, hotplug cpu,
- * etc.).
- */
-#include <linux/sched.h>
-#include <linux/kthread.h>
-#include <linux/completion.h>
-#include <linux/err.h>
-#include <linux/cpuset.h>
-#include <linux/unistd.h>
-#include <linux/file.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/freezer.h>
-#include <trace/events/sched.h>
-
-void __init_kthread_worker(struct kthread_worker *worker,
- const char *name,
- struct lock_class_key *key)
-{
- spin_lock_init(&worker->lock);
- lockdep_set_class_and_name(&worker->lock, key, name);
- INIT_LIST_HEAD(&worker->work_list);
- worker->task = NULL;
-}
-EXPORT_SYMBOL_GPL(__init_kthread_worker);
-
-/**
- * kthread_worker_fn - kthread function to process kthread_worker
- * @worker_ptr: pointer to initialized kthread_worker
- *
- * This function can be used as @threadfn to kthread_create() or
- * kthread_run() with @worker_ptr argument pointing to an initialized
- * kthread_worker. The started kthread will process work_list until
- * the it is stopped with kthread_stop(). A kthread can also call
- * this function directly after extra initialization.
- *
- * Different kthreads can be used for the same kthread_worker as long
- * as there's only one kthread attached to it at any given time. A
- * kthread_worker without an attached kthread simply collects queued
- * kthread_works.
- */
-int kthread_worker_fn(void *worker_ptr)
-{
- struct kthread_worker *worker = worker_ptr;
- struct kthread_work *work;
-
- WARN_ON(worker->task);
- worker->task = current;
-repeat:
- set_current_state(TASK_INTERRUPTIBLE); /* mb paired w/ kthread_stop */
-
- if (kthread_should_stop()) {
- __set_current_state(TASK_RUNNING);
- spin_lock_irq(&worker->lock);
- worker->task = NULL;
- spin_unlock_irq(&worker->lock);
- return 0;
- }
-
- work = NULL;
- spin_lock_irq(&worker->lock);
- if (!list_empty(&worker->work_list)) {
- work = list_first_entry(&worker->work_list,
- struct kthread_work, node);
- list_del_init(&work->node);
- }
- spin_unlock_irq(&worker->lock);
-
- if (work) {
- __set_current_state(TASK_RUNNING);
- work->func(work);
- smp_wmb(); /* wmb worker-b0 paired with flush-b1 */
- work->done_seq = work->queue_seq;
- smp_mb(); /* mb worker-b1 paired with flush-b0 */
- if (atomic_read(&work->flushing))
- wake_up_all(&work->done);
- } else if (!freezing(current))
- schedule();
-
- try_to_freeze();
- goto repeat;
-}
-EXPORT_SYMBOL_GPL(kthread_worker_fn);
-
-/**
- * queue_kthread_work - queue a kthread_work
- * @worker: target kthread_worker
- * @work: kthread_work to queue
- *
- * Queue @work to work processor @task for async execution. @task
- * must have been created with kthread_worker_create(). Returns %true
- * if @work was successfully queued, %false if it was already pending.
- */
-bool queue_kthread_work(struct kthread_worker *worker,
- struct kthread_work *work)
-{
- bool ret = false;
- unsigned long flags;
-
- spin_lock_irqsave(&worker->lock, flags);
- if (list_empty(&work->node)) {
- list_add_tail(&work->node, &worker->work_list);
- work->queue_seq++;
- if (likely(worker->task))
- wake_up_process(worker->task);
- ret = true;
- }
- spin_unlock_irqrestore(&worker->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL_GPL(queue_kthread_work);
-
-/**
- * flush_kthread_work - flush a kthread_work
- * @work: work to flush
- *
- * If @work is queued or executing, wait for it to finish execution.
- */
-void flush_kthread_work(struct kthread_work *work)
-{
- int seq = work->queue_seq;
-
- atomic_inc(&work->flushing);
-
- /*
- * mb flush-b0 paired with worker-b1, to make sure either
- * worker sees the above increment or we see done_seq update.
- */
- smp_mb__after_atomic_inc();
-
- /* A - B <= 0 tests whether B is in front of A regardless of overflow */
- wait_event(work->done, seq - work->done_seq <= 0);
- atomic_dec(&work->flushing);
-
- /*
- * rmb flush-b1 paired with worker-b0, to make sure our caller
- * sees every change made by work->func().
- */
- smp_mb__after_atomic_dec();
-}
-EXPORT_SYMBOL_GPL(flush_kthread_work);
-
-struct kthread_flush_work {
- struct kthread_work work;
- struct completion done;
-};
-
-static void kthread_flush_work_fn(struct kthread_work *work)
-{
- struct kthread_flush_work *fwork =
- container_of(work, struct kthread_flush_work, work);
- complete(&fwork->done);
-}
-
-/**
- * flush_kthread_worker - flush all current works on a kthread_worker
- * @worker: worker to flush
- *
- * Wait until all currently executing or pending works on @worker are
- * finished.
- */
-void flush_kthread_worker(struct kthread_worker *worker)
-{
- struct kthread_flush_work fwork = {
- KTHREAD_WORK_INIT(fwork.work, kthread_flush_work_fn),
- COMPLETION_INITIALIZER_ONSTACK(fwork.done),
- };
-
- queue_kthread_work(worker, &fwork.work);
- wait_for_completion(&fwork.done);
-}
-EXPORT_SYMBOL_GPL(flush_kthread_worker);
static int __init backport_init(void)
{
- int err;
-
- err = backport_system_workqueue_create();
- if (err) {
- pr_warn("backport_system_workqueue_create() failed\n");
- return err;
- }
-
printk(KERN_INFO
COMPAT_PROJECT " backport release: "
COMPAT_VERSION
static void __exit backport_exit(void)
{
- backport_system_workqueue_destroy();
-
return;
}
module_exit(backport_exit);
+++ /dev/null
-#include <net/compat.h>
-
-/* This is the backport of pm-qos params for kernels <= 2.6.25 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
-
-/*
- * This module exposes the interface to kernel space for specifying
- * QoS dependencies. It provides infrastructure for registration of:
- *
- * Dependents on a QoS value : register requirements
- * Watchers of QoS value : get notified when target QoS value changes
- *
- * This QoS design is best effort based. Dependents register their QoS needs.
- * Watchers register to keep track of the current QoS needs of the system.
- *
- * There are 3 basic classes of QoS parameter: latency, timeout, throughput
- * each have defined units:
- * latency: usec
- * timeout: usec <-- currently not used.
- * throughput: kbs (kilo byte / sec)
- *
- * There are lists of pm_qos_objects each one wrapping requirements, notifiers
- *
- * User mode requirements on a QOS parameter register themselves to the
- * subsystem by opening the device node /dev/... and writing there request to
- * the node. As long as the process holds a file handle open to the node the
- * client continues to be accounted for. Upon file release the usermode
- * requirement is removed and a new qos target is computed. This way when the
- * requirement that the application has is cleaned up when closes the file
- * pointer or exits the pm_qos_object will get an opportunity to clean up.
- *
- * Mark Gross <mgross@linux.intel.com>
- */
-
-#include <linux/pm_qos_params.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/time.h>
-#include <linux/fs.h>
-#include <linux/device.h>
-#include <linux/miscdevice.h>
-#include <linux/string.h>
-#include <linux/platform_device.h>
-#include <linux/init.h>
-
-#include <linux/uaccess.h>
-
-/*
- * locking rule: all changes to requirements or notifiers lists
- * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock
- * held, taken with _irqsave. One lock to rule them all
- */
-struct requirement_list {
- struct list_head list;
- union {
- s32 value;
- s32 usec;
- s32 kbps;
- };
- char *name;
-};
-
-static s32 max_compare(s32 v1, s32 v2);
-static s32 min_compare(s32 v1, s32 v2);
-
-struct pm_qos_object {
- struct requirement_list requirements;
- struct blocking_notifier_head *notifiers;
- struct miscdevice pm_qos_power_miscdev;
- char *name;
- s32 default_value;
- atomic_t target_value;
- s32 (*comparitor)(s32, s32);
-};
-
-static struct pm_qos_object null_pm_qos;
-static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier);
-static struct pm_qos_object cpu_dma_pm_qos = {
- .requirements = {LIST_HEAD_INIT(cpu_dma_pm_qos.requirements.list)},
- .notifiers = &cpu_dma_lat_notifier,
- .name = "cpu_dma_latency",
- .default_value = 2000 * USEC_PER_SEC,
- .target_value = ATOMIC_INIT(2000 * USEC_PER_SEC),
- .comparitor = min_compare
-};
-
-static BLOCKING_NOTIFIER_HEAD(network_lat_notifier);
-static struct pm_qos_object network_lat_pm_qos = {
- .requirements = {LIST_HEAD_INIT(network_lat_pm_qos.requirements.list)},
- .notifiers = &network_lat_notifier,
- .name = "network_latency",
- .default_value = 2000 * USEC_PER_SEC,
- .target_value = ATOMIC_INIT(2000 * USEC_PER_SEC),
- .comparitor = min_compare
-};
-
-
-static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier);
-static struct pm_qos_object network_throughput_pm_qos = {
- .requirements =
- {LIST_HEAD_INIT(network_throughput_pm_qos.requirements.list)},
- .notifiers = &network_throughput_notifier,
- .name = "network_throughput",
- .default_value = 0,
- .target_value = ATOMIC_INIT(0),
- .comparitor = max_compare
-};
-
-static BLOCKING_NOTIFIER_HEAD(system_bus_freq_notifier);
-static struct pm_qos_object system_bus_freq_pm_qos = {
- .requirements =
- {LIST_HEAD_INIT(system_bus_freq_pm_qos.requirements.list)},
- .notifiers = &system_bus_freq_notifier,
- .name = "system_bus_freq",
- .default_value = 0,
- .target_value = ATOMIC_INIT(0),
- .comparitor = max_compare
-};
-
-
-static struct pm_qos_object *pm_qos_array[PM_QOS_NUM_CLASSES] = {
- [PM_QOS_RESERVED] = &null_pm_qos,
- [PM_QOS_CPU_DMA_LATENCY] = &cpu_dma_pm_qos,
- [PM_QOS_NETWORK_LATENCY] = &network_lat_pm_qos,
- [PM_QOS_NETWORK_THROUGHPUT] = &network_throughput_pm_qos,
- [PM_QOS_SYSTEM_BUS_FREQ] = &system_bus_freq_pm_qos,
-};
-
-static DEFINE_SPINLOCK(pm_qos_lock);
-
-static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *f_pos);
-static int pm_qos_power_open(struct inode *inode, struct file *filp);
-static int pm_qos_power_release(struct inode *inode, struct file *filp);
-
-static const struct file_operations pm_qos_power_fops = {
- .write = pm_qos_power_write,
- .open = pm_qos_power_open,
- .release = pm_qos_power_release,
-};
-
-/* static helper functions */
-static s32 max_compare(s32 v1, s32 v2)
-{
- return max(v1, v2);
-}
-
-static s32 min_compare(s32 v1, s32 v2)
-{
- return min(v1, v2);
-}
-
-
-static void update_target(int target)
-{
- s32 extreme_value;
- struct requirement_list *node;
- unsigned long flags;
- int call_notifier = 0;
-
- spin_lock_irqsave(&pm_qos_lock, flags);
- extreme_value = pm_qos_array[target]->default_value;
- list_for_each_entry(node,
- &pm_qos_array[target]->requirements.list, list) {
- extreme_value = pm_qos_array[target]->comparitor(
- extreme_value, node->value);
- }
- if (atomic_read(&pm_qos_array[target]->target_value) != extreme_value) {
- call_notifier = 1;
- atomic_set(&pm_qos_array[target]->target_value, extreme_value);
- pr_debug(KERN_ERR "new target for qos %d is %d\n", target,
- atomic_read(&pm_qos_array[target]->target_value));
- }
- spin_unlock_irqrestore(&pm_qos_lock, flags);
-
- if (call_notifier)
- blocking_notifier_call_chain(pm_qos_array[target]->notifiers,
- (unsigned long) extreme_value, NULL);
-}
-
-static int register_pm_qos_misc(struct pm_qos_object *qos)
-{
- qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR;
- qos->pm_qos_power_miscdev.name = qos->name;
- qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops;
-
- return misc_register(&qos->pm_qos_power_miscdev);
-}
-
-static int find_pm_qos_object_by_minor(int minor)
-{
- int pm_qos_class;
-
- for (pm_qos_class = 0;
- pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) {
- if (minor ==
- pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor)
- return pm_qos_class;
- }
- return -1;
-}
-
-/**
- * pm_qos_requirement - returns current system wide qos expectation
- * @pm_qos_class: identification of which qos value is requested
- *
- * This function returns the current target value in an atomic manner.
- */
-int pm_qos_requirement(int pm_qos_class)
-{
- return atomic_read(&pm_qos_array[pm_qos_class]->target_value);
-}
-EXPORT_SYMBOL_GPL(pm_qos_requirement);
-
-/**
- * pm_qos_add_requirement - inserts new qos request into the list
- * @pm_qos_class: identifies which list of qos request to us
- * @name: identifies the request
- * @value: defines the qos request
- *
- * This function inserts a new entry in the pm_qos_class list of requested qos
- * performance characteristics. It recomputes the aggregate QoS expectations
- * for the pm_qos_class of parameters.
- */
-int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value)
-{
- struct requirement_list *dep;
- unsigned long flags;
-
- dep = kzalloc(sizeof(struct requirement_list), GFP_KERNEL);
- if (dep) {
- if (value == PM_QOS_DEFAULT_VALUE)
- dep->value = pm_qos_array[pm_qos_class]->default_value;
- else
- dep->value = value;
- dep->name = kstrdup(name, GFP_KERNEL);
- if (!dep->name)
- goto cleanup;
-
- spin_lock_irqsave(&pm_qos_lock, flags);
- list_add(&dep->list,
- &pm_qos_array[pm_qos_class]->requirements.list);
- spin_unlock_irqrestore(&pm_qos_lock, flags);
- update_target(pm_qos_class);
-
- return 0;
- }
-
-cleanup:
- kfree(dep);
- return -ENOMEM;
-}
-EXPORT_SYMBOL_GPL(pm_qos_add_requirement);
-
-/**
- * pm_qos_update_requirement - modifies an existing qos request
- * @pm_qos_class: identifies which list of qos request to us
- * @name: identifies the request
- * @value: defines the qos request
- *
- * Updates an existing qos requirement for the pm_qos_class of parameters along
- * with updating the target pm_qos_class value.
- *
- * If the named request isn't in the list then no change is made.
- */
-int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value)
-{
- unsigned long flags;
- struct requirement_list *node;
- int pending_update = 0;
-
- spin_lock_irqsave(&pm_qos_lock, flags);
- list_for_each_entry(node,
- &pm_qos_array[pm_qos_class]->requirements.list, list) {
- if (strcmp(node->name, name) == 0) {
- if (new_value == PM_QOS_DEFAULT_VALUE)
- node->value =
- pm_qos_array[pm_qos_class]->default_value;
- else
- node->value = new_value;
- pending_update = 1;
- break;
- }
- }
- spin_unlock_irqrestore(&pm_qos_lock, flags);
- if (pending_update)
- update_target(pm_qos_class);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(pm_qos_update_requirement);
-
-/**
- * pm_qos_remove_requirement - modifies an existing qos request
- * @pm_qos_class: identifies which list of qos request to us
- * @name: identifies the request
- *
- * Will remove named qos request from pm_qos_class list of parameters and
- * recompute the current target value for the pm_qos_class.
- */
-void pm_qos_remove_requirement(int pm_qos_class, char *name)
-{
- unsigned long flags;
- struct requirement_list *node;
- int pending_update = 0;
-
- spin_lock_irqsave(&pm_qos_lock, flags);
- list_for_each_entry(node,
- &pm_qos_array[pm_qos_class]->requirements.list, list) {
- if (strcmp(node->name, name) == 0) {
- kfree(node->name);
- list_del(&node->list);
- kfree(node);
- pending_update = 1;
- break;
- }
- }
- spin_unlock_irqrestore(&pm_qos_lock, flags);
- if (pending_update)
- update_target(pm_qos_class);
-}
-EXPORT_SYMBOL_GPL(pm_qos_remove_requirement);
-
-/**
- * pm_qos_add_notifier - sets notification entry for changes to target value
- * @pm_qos_class: identifies which qos target changes should be notified.
- * @notifier: notifier block managed by caller.
- *
- * will register the notifier into a notification chain that gets called
- * upon changes to the pm_qos_class target value.
- */
-int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier)
-{
- int retval;
-
- retval = blocking_notifier_chain_register(
- pm_qos_array[pm_qos_class]->notifiers, notifier);
-
- return retval;
-}
-EXPORT_SYMBOL_GPL(pm_qos_add_notifier);
-
-/**
- * pm_qos_remove_notifier - deletes notification entry from chain.
- * @pm_qos_class: identifies which qos target changes are notified.
- * @notifier: notifier block to be removed.
- *
- * will remove the notifier from the notification chain that gets called
- * upon changes to the pm_qos_class target value.
- */
-int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)
-{
- int retval;
-
- retval = blocking_notifier_chain_unregister(
- pm_qos_array[pm_qos_class]->notifiers, notifier);
-
- return retval;
-}
-EXPORT_SYMBOL_GPL(pm_qos_remove_notifier);
-
-#define PID_NAME_LEN 32
-
-static int pm_qos_power_open(struct inode *inode, struct file *filp)
-{
- int ret;
- long pm_qos_class;
- char name[PID_NAME_LEN];
-
- pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
- if (pm_qos_class >= 0) {
- filp->private_data = (void *)pm_qos_class;
- snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
- ret = pm_qos_add_requirement(pm_qos_class, name,
- PM_QOS_DEFAULT_VALUE);
- if (ret >= 0)
- return 0;
- }
- return -EPERM;
-}
-
-static int pm_qos_power_release(struct inode *inode, struct file *filp)
-{
- int pm_qos_class;
- char name[PID_NAME_LEN];
-
- pm_qos_class = (long)filp->private_data;
- snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
- pm_qos_remove_requirement(pm_qos_class, name);
-
- return 0;
-}
-
-static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *f_pos)
-{
- s32 value;
- int pm_qos_class;
- char name[PID_NAME_LEN];
-
- pm_qos_class = (long)filp->private_data;
- if (count != sizeof(s32))
- return -EINVAL;
- if (copy_from_user(&value, buf, sizeof(s32)))
- return -EFAULT;
- snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
- pm_qos_update_requirement(pm_qos_class, name, value);
-
- return sizeof(s32);
-}
-
-
-/*
- * This initializes pm-qos for older kernels.
- */
-int backport_pm_qos_power_init(void)
-{
- int ret = 0;
-
- ret = register_pm_qos_misc(&cpu_dma_pm_qos);
- if (ret < 0) {
- printk(KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n");
- return ret;
- }
- ret = register_pm_qos_misc(&network_lat_pm_qos);
- if (ret < 0) {
- printk(KERN_ERR "pm_qos_param: network_latency setup failed\n");
- return ret;
- }
- ret = register_pm_qos_misc(&network_throughput_pm_qos);
- if (ret < 0) {
- printk(KERN_ERR
- "pm_qos_param: network_throughput setup failed\n");
- return ret;
- }
- ret = register_pm_qos_misc(&system_bus_freq_pm_qos);
- if (ret < 0)
- printk(KERN_ERR
- "pm_qos_param: system_bus_freq setup failed\n");
-
- return ret;
-}
-
-int backport_pm_qos_power_deinit(void)
-{
- int ret = 0;
-
- ret = misc_deregister(&cpu_dma_pm_qos.pm_qos_power_miscdev);
- if (ret < 0) {
- printk(KERN_ERR "pm_qos_param: cpu_dma_latency deinit failed\n");
- return ret;
- }
-
- ret = misc_deregister(&network_lat_pm_qos.pm_qos_power_miscdev);
- if (ret < 0) {
- printk(KERN_ERR "pm_qos_param: network_latency deinit failed\n");
- return ret;
- }
-
- ret = misc_deregister(&network_throughput_pm_qos.pm_qos_power_miscdev);
- if (ret < 0) {
- printk(KERN_ERR
- "pm_qos_param: network_throughput deinit failed\n");
- return ret;
- }
-
- ret = misc_deregister(&system_bus_freq_pm_qos.pm_qos_power_miscdev);
- if (ret < 0) {
- printk(KERN_ERR
- "pm_qos_param: system_bus_freq deinit failed\n");
- return ret;
- }
-
- return ret;
-}
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */
+++ /dev/null
-/*
- * Codel - The Controlled-Delay Active Queue Management algorithm
- *
- * Copyright (C) 2011-2012 Kathleen Nichols <nichols@pollere.com>
- * Copyright (C) 2011-2012 Van Jacobson <van@pollere.net>
- *
- * Implemented on linux by :
- * Copyright (C) 2012 Michael D. Taht <dave.taht@bufferbloat.net>
- * Copyright (C) 2012 Eric Dumazet <edumazet@google.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The names of the authors may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/skbuff.h>
-#include <linux/prefetch.h>
-#include <net/pkt_sched.h>
-#include <net/codel.h>
-
-
-#define DEFAULT_CODEL_LIMIT 1000
-
-struct codel_sched_data {
- struct codel_params params;
- struct codel_vars vars;
- struct codel_stats stats;
- u32 drop_overlimit;
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- u32 limit;
-#endif
-};
-
-/* This is the specific function called from codel_dequeue()
- * to dequeue a packet from queue. Note: backlog is handled in
- * codel, we dont need to reduce it here.
- */
-static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch)
-{
- struct sk_buff *skb = __skb_dequeue(&sch->q);
-
- prefetch(&skb->end); /* we'll need skb_shinfo() */
- return skb;
-}
-
-static struct sk_buff *codel_qdisc_dequeue(struct Qdisc *sch)
-{
- struct codel_sched_data *q = qdisc_priv(sch);
- struct sk_buff *skb;
-
- skb = codel_dequeue(sch, &q->params, &q->vars, &q->stats, dequeue);
-
- /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0,
- * or HTB crashes. Defer it for next round.
- */
- if (q->stats.drop_count && sch->q.qlen) {
- qdisc_tree_decrease_qlen(sch, q->stats.drop_count);
- q->stats.drop_count = 0;
- }
- if (skb)
- qdisc_bstats_update(sch, skb);
- return skb;
-}
-
-static int codel_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
-{
- struct codel_sched_data *q;
-
- q = qdisc_priv(sch);
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- if (likely(qdisc_qlen(sch) < q->limit)) {
-#else
- if (likely(qdisc_qlen(sch) < sch->limit)) {
-#endif
- codel_set_enqueue_time(skb);
- return qdisc_enqueue_tail(skb, sch);
- }
- q->drop_overlimit++;
- return qdisc_drop(skb, sch);
-}
-
-static const struct nla_policy codel_policy[TCA_CODEL_MAX + 1] = {
- [TCA_CODEL_TARGET] = { .type = NLA_U32 },
- [TCA_CODEL_LIMIT] = { .type = NLA_U32 },
- [TCA_CODEL_INTERVAL] = { .type = NLA_U32 },
- [TCA_CODEL_ECN] = { .type = NLA_U32 },
-};
-
-static int codel_change(struct Qdisc *sch, struct nlattr *opt)
-{
- struct codel_sched_data *q = qdisc_priv(sch);
- struct nlattr *tb[TCA_CODEL_MAX + 1];
- unsigned int qlen;
- int err;
-
- if (!opt)
- return -EINVAL;
-
- err = nla_parse_nested(tb, TCA_CODEL_MAX, opt, codel_policy);
- if (err < 0)
- return err;
-
- sch_tree_lock(sch);
-
- if (tb[TCA_CODEL_TARGET]) {
- u32 target = nla_get_u32(tb[TCA_CODEL_TARGET]);
-
- q->params.target = ((u64)target * NSEC_PER_USEC) >> CODEL_SHIFT;
- }
-
- if (tb[TCA_CODEL_INTERVAL]) {
- u32 interval = nla_get_u32(tb[TCA_CODEL_INTERVAL]);
-
- q->params.interval = ((u64)interval * NSEC_PER_USEC) >> CODEL_SHIFT;
- }
-
- if (tb[TCA_CODEL_LIMIT])
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- q->limit = nla_get_u32(tb[TCA_CODEL_LIMIT]);
-#else
- sch->limit = nla_get_u32(tb[TCA_CODEL_LIMIT]);
-#endif
-
- if (tb[TCA_CODEL_ECN])
- q->params.ecn = !!nla_get_u32(tb[TCA_CODEL_ECN]);
-
- qlen = sch->q.qlen;
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- while (sch->q.qlen > q->limit) {
-#else
- while (sch->q.qlen > sch->limit) {
-#endif
- struct sk_buff *skb = __skb_dequeue(&sch->q);
-
- sch->qstats.backlog -= qdisc_pkt_len(skb);
- qdisc_drop(skb, sch);
- }
- qdisc_tree_decrease_qlen(sch, qlen - sch->q.qlen);
-
- sch_tree_unlock(sch);
- return 0;
-}
-
-static int codel_init(struct Qdisc *sch, struct nlattr *opt)
-{
- struct codel_sched_data *q = qdisc_priv(sch);
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- q->limit = DEFAULT_CODEL_LIMIT;
-#else
- sch->limit = DEFAULT_CODEL_LIMIT;
-#endif
-
- codel_params_init(&q->params);
- codel_vars_init(&q->vars);
- codel_stats_init(&q->stats);
-
- if (opt) {
- int err = codel_change(sch, opt);
-
- if (err)
- return err;
- }
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- if (q->limit >= 1)
-#else
- if (sch->limit >= 1)
-#endif
- sch->flags |= TCQ_F_CAN_BYPASS;
- else
- sch->flags &= ~TCQ_F_CAN_BYPASS;
-
- return 0;
-}
-
-static int codel_dump(struct Qdisc *sch, struct sk_buff *skb)
-{
- struct codel_sched_data *q = qdisc_priv(sch);
- struct nlattr *opts;
-
- opts = nla_nest_start(skb, TCA_OPTIONS);
- if (opts == NULL)
- goto nla_put_failure;
-
- if (nla_put_u32(skb, TCA_CODEL_TARGET,
- codel_time_to_us(q->params.target)) ||
- nla_put_u32(skb, TCA_CODEL_LIMIT,
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- q->limit) ||
-#else
- sch->limit) ||
-#endif
- nla_put_u32(skb, TCA_CODEL_INTERVAL,
- codel_time_to_us(q->params.interval)) ||
- nla_put_u32(skb, TCA_CODEL_ECN,
- q->params.ecn))
- goto nla_put_failure;
-
- return nla_nest_end(skb, opts);
-
-nla_put_failure:
- nla_nest_cancel(skb, opts);
- return -1;
-}
-
-static int codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
-{
- const struct codel_sched_data *q = qdisc_priv(sch);
- struct tc_codel_xstats st = {
- .maxpacket = q->stats.maxpacket,
- .count = q->vars.count,
- .lastcount = q->vars.lastcount,
- .drop_overlimit = q->drop_overlimit,
- .ldelay = codel_time_to_us(q->vars.ldelay),
- .dropping = q->vars.dropping,
- .ecn_mark = q->stats.ecn_mark,
- };
-
- if (q->vars.dropping) {
- codel_tdiff_t delta = q->vars.drop_next - codel_get_time();
-
- if (delta >= 0)
- st.drop_next = codel_time_to_us(delta);
- else
- st.drop_next = -codel_time_to_us(-delta);
- }
-
- return gnet_stats_copy_app(d, &st, sizeof(st));
-}
-
-static void codel_reset(struct Qdisc *sch)
-{
- struct codel_sched_data *q = qdisc_priv(sch);
-
- qdisc_reset_queue(sch);
- codel_vars_init(&q->vars);
-}
-
-static struct Qdisc_ops codel_qdisc_ops __read_mostly = {
- .id = "codel",
- .priv_size = sizeof(struct codel_sched_data),
-
- .enqueue = codel_qdisc_enqueue,
- .dequeue = codel_qdisc_dequeue,
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
- .peek = qdisc_peek_dequeued,
-#endif
- .init = codel_init,
- .reset = codel_reset,
- .change = codel_change,
- .dump = codel_dump,
- .dump_stats = codel_dump_stats,
- .owner = THIS_MODULE,
-};
-
-static int __init codel_module_init(void)
-{
- return register_qdisc(&codel_qdisc_ops);
-}
-
-static void __exit codel_module_exit(void)
-{
- unregister_qdisc(&codel_qdisc_ops);
-}
-
-module_init(codel_module_init)
-module_exit(codel_module_exit)
-
-MODULE_DESCRIPTION("Controlled Delay queue discipline");
-MODULE_AUTHOR("Dave Taht");
-MODULE_AUTHOR("Eric Dumazet");
-MODULE_LICENSE("Dual BSD/GPL");
+++ /dev/null
-/*
- * Fair Queue CoDel discipline
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright (C) 2012 Eric Dumazet <edumazet@google.com>
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/jiffies.h>
-#include <linux/string.h>
-#include <linux/in.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/skbuff.h>
-#include <linux/jhash.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <net/netlink.h>
-#include <net/pkt_sched.h>
-#include <net/flow_keys.h>
-#include <net/codel.h>
-
-/* Fair Queue CoDel.
- *
- * Principles :
- * Packets are classified (internal classifier or external) on flows.
- * This is a Stochastic model (as we use a hash, several flows
- * might be hashed on same slot)
- * Each flow has a CoDel managed queue.
- * Flows are linked onto two (Round Robin) lists,
- * so that new flows have priority on old ones.
- *
- * For a given flow, packets are not reordered (CoDel uses a FIFO)
- * head drops only.
- * ECN capability is on by default.
- * Low memory footprint (64 bytes per flow)
- */
-
-struct fq_codel_flow {
- struct sk_buff *head;
- struct sk_buff *tail;
- struct list_head flowchain;
- int deficit;
- u32 dropped; /* number of drops (or ECN marks) on this flow */
- struct codel_vars cvars;
-}; /* please try to keep this structure <= 64 bytes */
-
-struct fq_codel_sched_data {
- struct tcf_proto *filter_list; /* optional external classifier */
- struct fq_codel_flow *flows; /* Flows table [flows_cnt] */
- u32 *backlogs; /* backlog table [flows_cnt] */
- u32 flows_cnt; /* number of flows */
- u32 perturbation; /* hash perturbation */
- u32 quantum; /* psched_mtu(qdisc_dev(sch)); */
- struct codel_params cparams;
- struct codel_stats cstats;
- u32 drop_overlimit;
- u32 new_flow_count;
-
- struct list_head new_flows; /* list of new flows */
- struct list_head old_flows; /* list of old flows */
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- u32 limit;
-#endif
-};
-
-static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q,
- const struct sk_buff *skb)
-{
- struct flow_keys keys;
- unsigned int hash;
-
- skb_flow_dissect(skb, &keys);
- hash = jhash_3words((__force u32)keys.dst,
- (__force u32)keys.src ^ keys.ip_proto,
- (__force u32)keys.ports, q->perturbation);
- return ((u64)hash * q->flows_cnt) >> 32;
-}
-
-static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch,
- int *qerr)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- struct tcf_result res;
- int result;
-
- if (TC_H_MAJ(skb->priority) == sch->handle &&
- TC_H_MIN(skb->priority) > 0 &&
- TC_H_MIN(skb->priority) <= q->flows_cnt)
- return TC_H_MIN(skb->priority);
-
- if (!q->filter_list)
- return fq_codel_hash(q, skb) + 1;
-
- *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
- result = tc_classify(skb, q->filter_list, &res);
- if (result >= 0) {
-#ifdef CONFIG_NET_CLS_ACT
- switch (result) {
- case TC_ACT_STOLEN:
- case TC_ACT_QUEUED:
- *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
- case TC_ACT_SHOT:
- return 0;
- }
-#endif
- if (TC_H_MIN(res.classid) <= q->flows_cnt)
- return TC_H_MIN(res.classid);
- }
- return 0;
-}
-
-/* helper functions : might be changed when/if skb use a standard list_head */
-
-/* remove one skb from head of slot queue */
-static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow)
-{
- struct sk_buff *skb = flow->head;
-
- flow->head = skb->next;
- skb->next = NULL;
- return skb;
-}
-
-/* add skb to flow queue (tail add) */
-static inline void flow_queue_add(struct fq_codel_flow *flow,
- struct sk_buff *skb)
-{
- if (flow->head == NULL)
- flow->head = skb;
- else
- flow->tail->next = skb;
- flow->tail = skb;
- skb->next = NULL;
-}
-
-static unsigned int fq_codel_drop(struct Qdisc *sch)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- struct sk_buff *skb;
- unsigned int maxbacklog = 0, idx = 0, i, len;
- struct fq_codel_flow *flow;
-
- /* Queue is full! Find the fat flow and drop packet from it.
- * This might sound expensive, but with 1024 flows, we scan
- * 4KB of memory, and we dont need to handle a complex tree
- * in fast path (packet queue/enqueue) with many cache misses.
- */
- for (i = 0; i < q->flows_cnt; i++) {
- if (q->backlogs[i] > maxbacklog) {
- maxbacklog = q->backlogs[i];
- idx = i;
- }
- }
- flow = &q->flows[idx];
- skb = dequeue_head(flow);
- len = qdisc_pkt_len(skb);
- q->backlogs[idx] -= len;
- kfree_skb(skb);
- sch->q.qlen--;
- sch->qstats.drops++;
- sch->qstats.backlog -= len;
- flow->dropped++;
- return idx;
-}
-
-static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- unsigned int idx;
- struct fq_codel_flow *flow;
- int uninitialized_var(ret);
-
- idx = fq_codel_classify(skb, sch, &ret);
- if (idx == 0) {
- if (ret & __NET_XMIT_BYPASS)
- sch->qstats.drops++;
- kfree_skb(skb);
- return ret;
- }
- idx--;
-
- codel_set_enqueue_time(skb);
- flow = &q->flows[idx];
- flow_queue_add(flow, skb);
- q->backlogs[idx] += qdisc_pkt_len(skb);
- sch->qstats.backlog += qdisc_pkt_len(skb);
-
- if (list_empty(&flow->flowchain)) {
- list_add_tail(&flow->flowchain, &q->new_flows);
- codel_vars_init(&flow->cvars);
- q->new_flow_count++;
- flow->deficit = q->quantum;
- flow->dropped = 0;
- }
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- if (++sch->q.qlen < q->limit)
-#else
- if (++sch->q.qlen < sch->limit)
-#endif
- return NET_XMIT_SUCCESS;
-
- q->drop_overlimit++;
- /* Return Congestion Notification only if we dropped a packet
- * from this flow.
- */
- if (fq_codel_drop(sch) == idx)
- return NET_XMIT_CN;
-
- /* As we dropped a packet, better let upper stack know this */
- qdisc_tree_decrease_qlen(sch, 1);
- return NET_XMIT_SUCCESS;
-}
-
-/* This is the specific function called from codel_dequeue()
- * to dequeue a packet from queue. Note: backlog is handled in
- * codel, we dont need to reduce it here.
- */
-static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- struct fq_codel_flow *flow;
- struct sk_buff *skb = NULL;
-
- flow = container_of(vars, struct fq_codel_flow, cvars);
- if (flow->head) {
- skb = dequeue_head(flow);
- q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb);
- sch->q.qlen--;
- }
- return skb;
-}
-
-static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- struct sk_buff *skb;
- struct fq_codel_flow *flow;
- struct list_head *head;
- u32 prev_drop_count, prev_ecn_mark;
-
-begin:
- head = &q->new_flows;
- if (list_empty(head)) {
- head = &q->old_flows;
- if (list_empty(head))
- return NULL;
- }
- flow = list_first_entry(head, struct fq_codel_flow, flowchain);
-
- if (flow->deficit <= 0) {
- flow->deficit += q->quantum;
- list_move_tail(&flow->flowchain, &q->old_flows);
- goto begin;
- }
-
- prev_drop_count = q->cstats.drop_count;
- prev_ecn_mark = q->cstats.ecn_mark;
-
- skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats,
- dequeue);
-
- flow->dropped += q->cstats.drop_count - prev_drop_count;
- flow->dropped += q->cstats.ecn_mark - prev_ecn_mark;
-
- if (!skb) {
- /* force a pass through old_flows to prevent starvation */
- if ((head == &q->new_flows) && !list_empty(&q->old_flows))
- list_move_tail(&flow->flowchain, &q->old_flows);
- else
- list_del_init(&flow->flowchain);
- goto begin;
- }
- qdisc_bstats_update(sch, skb);
- flow->deficit -= qdisc_pkt_len(skb);
- /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0,
- * or HTB crashes. Defer it for next round.
- */
- if (q->cstats.drop_count && sch->q.qlen) {
- qdisc_tree_decrease_qlen(sch, q->cstats.drop_count);
- q->cstats.drop_count = 0;
- }
- return skb;
-}
-
-static void fq_codel_reset(struct Qdisc *sch)
-{
- struct sk_buff *skb;
-
- while ((skb = fq_codel_dequeue(sch)) != NULL)
- kfree_skb(skb);
-}
-
-static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = {
- [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 },
- [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 },
- [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 },
- [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 },
- [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 },
- [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 },
-};
-
-static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- struct nlattr *tb[TCA_FQ_CODEL_MAX + 1];
- int err;
-
- if (!opt)
- return -EINVAL;
-
- err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy);
- if (err < 0)
- return err;
- if (tb[TCA_FQ_CODEL_FLOWS]) {
- if (q->flows)
- return -EINVAL;
- q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]);
- if (!q->flows_cnt ||
- q->flows_cnt > 65536)
- return -EINVAL;
- }
- sch_tree_lock(sch);
-
- if (tb[TCA_FQ_CODEL_TARGET]) {
- u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]);
-
- q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT;
- }
-
- if (tb[TCA_FQ_CODEL_INTERVAL]) {
- u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]);
-
- q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT;
- }
-
- if (tb[TCA_FQ_CODEL_LIMIT])
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]);
-#else
- sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]);
-#endif
-
- if (tb[TCA_FQ_CODEL_ECN])
- q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]);
-
- if (tb[TCA_FQ_CODEL_QUANTUM])
- q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM]));
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- while (sch->q.qlen > q->limit) {
-#else
- while (sch->q.qlen > sch->limit) {
-#endif
- struct sk_buff *skb = fq_codel_dequeue(sch);
-
- kfree_skb(skb);
- q->cstats.drop_count++;
- }
- qdisc_tree_decrease_qlen(sch, q->cstats.drop_count);
- q->cstats.drop_count = 0;
-
- sch_tree_unlock(sch);
- return 0;
-}
-
-static void *fq_codel_zalloc(size_t sz)
-{
- void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN);
-
- if (!ptr)
- ptr = vzalloc(sz);
- return ptr;
-}
-
-static void fq_codel_free(void *addr)
-{
- if (addr) {
- if (is_vmalloc_addr(addr))
- vfree(addr);
- else
- kfree(addr);
- }
-}
-
-static void fq_codel_destroy(struct Qdisc *sch)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
- tcf_destroy_chain(&q->filter_list);
-#else
- tcf_destroy_chain(q->filter_list);
-#endif
- fq_codel_free(q->backlogs);
- fq_codel_free(q->flows);
-}
-
-static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- int i;
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- q->limit = 10*1024;
-#else
- sch->limit = 10*1024;
-#endif
- q->flows_cnt = 1024;
- q->quantum = psched_mtu(qdisc_dev(sch));
- q->perturbation = net_random();
- INIT_LIST_HEAD(&q->new_flows);
- INIT_LIST_HEAD(&q->old_flows);
- codel_params_init(&q->cparams);
- codel_stats_init(&q->cstats);
- q->cparams.ecn = true;
-
- if (opt) {
- int err = fq_codel_change(sch, opt);
- if (err)
- return err;
- }
-
- if (!q->flows) {
- q->flows = fq_codel_zalloc(q->flows_cnt *
- sizeof(struct fq_codel_flow));
- if (!q->flows)
- return -ENOMEM;
- q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32));
- if (!q->backlogs) {
- fq_codel_free(q->flows);
- return -ENOMEM;
- }
- for (i = 0; i < q->flows_cnt; i++) {
- struct fq_codel_flow *flow = q->flows + i;
-
- INIT_LIST_HEAD(&flow->flowchain);
- }
- }
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- if (q->limit >= 1)
-#else
- if (sch->limit >= 1)
-#endif
- sch->flags |= TCQ_F_CAN_BYPASS;
- else
- sch->flags &= ~TCQ_F_CAN_BYPASS;
- return 0;
-}
-
-static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- struct nlattr *opts;
-
- opts = nla_nest_start(skb, TCA_OPTIONS);
- if (opts == NULL)
- goto nla_put_failure;
-
- if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET,
- codel_time_to_us(q->cparams.target)) ||
- nla_put_u32(skb, TCA_FQ_CODEL_LIMIT,
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39))
- q->limit) ||
-#else
- sch->limit) ||
-#endif
- nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL,
- codel_time_to_us(q->cparams.interval)) ||
- nla_put_u32(skb, TCA_FQ_CODEL_ECN,
- q->cparams.ecn) ||
- nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM,
- q->quantum) ||
- nla_put_u32(skb, TCA_FQ_CODEL_FLOWS,
- q->flows_cnt))
- goto nla_put_failure;
-
- nla_nest_end(skb, opts);
- return skb->len;
-
-nla_put_failure:
- return -1;
-}
-
-static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- struct tc_fq_codel_xstats st = {
- .type = TCA_FQ_CODEL_XSTATS_QDISC,
- };
- struct list_head *pos;
-
- st.qdisc_stats.maxpacket = q->cstats.maxpacket;
- st.qdisc_stats.drop_overlimit = q->drop_overlimit;
- st.qdisc_stats.ecn_mark = q->cstats.ecn_mark;
- st.qdisc_stats.new_flow_count = q->new_flow_count;
-
- list_for_each(pos, &q->new_flows)
- st.qdisc_stats.new_flows_len++;
-
- list_for_each(pos, &q->old_flows)
- st.qdisc_stats.old_flows_len++;
-
- return gnet_stats_copy_app(d, &st, sizeof(st));
-}
-
-static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg)
-{
- return NULL;
-}
-
-static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid)
-{
- return 0;
-}
-
-static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent,
- u32 classid)
-{
- /* we cannot bypass queue discipline anymore */
- sch->flags &= ~TCQ_F_CAN_BYPASS;
- return 0;
-}
-
-static void fq_codel_put(struct Qdisc *q, unsigned long cl)
-{
-}
-
-static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
-
- if (cl)
- return NULL;
- return &q->filter_list;
-}
-
-static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl,
- struct sk_buff *skb, struct tcmsg *tcm)
-{
- tcm->tcm_handle |= TC_H_MIN(cl);
- return 0;
-}
-
-static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl,
- struct gnet_dump *d)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- u32 idx = cl - 1;
- struct gnet_stats_queue qs = { 0 };
- struct tc_fq_codel_xstats xstats;
-
- if (idx < q->flows_cnt) {
- const struct fq_codel_flow *flow = &q->flows[idx];
- const struct sk_buff *skb = flow->head;
-
- memset(&xstats, 0, sizeof(xstats));
- xstats.type = TCA_FQ_CODEL_XSTATS_CLASS;
- xstats.class_stats.deficit = flow->deficit;
- xstats.class_stats.ldelay =
- codel_time_to_us(flow->cvars.ldelay);
- xstats.class_stats.count = flow->cvars.count;
- xstats.class_stats.lastcount = flow->cvars.lastcount;
- xstats.class_stats.dropping = flow->cvars.dropping;
- if (flow->cvars.dropping) {
- codel_tdiff_t delta = flow->cvars.drop_next -
- codel_get_time();
-
- xstats.class_stats.drop_next = (delta >= 0) ?
- codel_time_to_us(delta) :
- -codel_time_to_us(-delta);
- }
- while (skb) {
- qs.qlen++;
- skb = skb->next;
- }
- qs.backlog = q->backlogs[idx];
- qs.drops = flow->dropped;
- }
- if (gnet_stats_copy_queue(d, &qs) < 0)
- return -1;
- if (idx < q->flows_cnt)
- return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
- return 0;
-}
-
-static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg)
-{
- struct fq_codel_sched_data *q = qdisc_priv(sch);
- unsigned int i;
-
- if (arg->stop)
- return;
-
- for (i = 0; i < q->flows_cnt; i++) {
- if (list_empty(&q->flows[i].flowchain) ||
- arg->count < arg->skip) {
- arg->count++;
- continue;
- }
- if (arg->fn(sch, i + 1, arg) < 0) {
- arg->stop = 1;
- break;
- }
- arg->count++;
- }
-}
-
-static const struct Qdisc_class_ops fq_codel_class_ops = {
- .leaf = fq_codel_leaf,
- .get = fq_codel_get,
- .put = fq_codel_put,
- .tcf_chain = fq_codel_find_tcf,
- .bind_tcf = fq_codel_bind,
- .unbind_tcf = fq_codel_put,
- .dump = fq_codel_dump_class,
- .dump_stats = fq_codel_dump_class_stats,
- .walk = fq_codel_walk,
-};
-
-static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = {
- .cl_ops = &fq_codel_class_ops,
- .id = "fq_codel",
- .priv_size = sizeof(struct fq_codel_sched_data),
- .enqueue = fq_codel_enqueue,
- .dequeue = fq_codel_dequeue,
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
- .peek = qdisc_peek_dequeued,
-#endif
- .drop = fq_codel_drop,
- .init = fq_codel_init,
- .reset = fq_codel_reset,
- .destroy = fq_codel_destroy,
- .change = fq_codel_change,
- .dump = fq_codel_dump,
- .dump_stats = fq_codel_dump_stats,
- .owner = THIS_MODULE,
-};
-
-static int __init fq_codel_module_init(void)
-{
- return register_qdisc(&fq_codel_qdisc_ops);
-}
-
-static void __exit fq_codel_module_exit(void)
-{
- unregister_qdisc(&fq_codel_qdisc_ops);
-}
-
-module_init(fq_codel_module_init)
-module_exit(fq_codel_module_exit)
-MODULE_AUTHOR("Eric Dumazet");
-MODULE_LICENSE("GPL");
+++ /dev/null
-#!/bin/sh
-
-if [ -f /usr/bin/lsb_release ]; then
- LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
-else
- LSB_RED_ID="Unknown"
-fi
-
-case $LSB_RED_ID in
-"Ubuntu")
- mkdir -p /lib/udev/ /lib/udev/rules.d/
- cp udev/ubuntu/compat_firmware.sh /lib/udev/
- cp udev/ubuntu/50-compat_firmware.rules /lib/udev/rules.d/
- ;;
-*)
- mkdir -p /lib/udev/ /lib/udev/rules.d/
- cp udev/compat_firmware.sh /lib/udev/
- cp udev/50-compat_firmware.rules /lib/udev/rules.d/
- ;;
-esac
-
+++ /dev/null
-#!/bin/bash
-#
-# Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
-# Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de>
-# Copyright 2011 John W. Linville <linville@tuxdriver.com>
-#
-# Use this to parse a small .config equivalent looking file to generate
-# our own autoconf.h. This file has defines for each config option
-# just like the kernels include/linux/autoconf.h
-#
-# XXX: consider using scripts/kconfig/confdata.c instead.
-# On the downside this would require the user to have libc though.
-
-# This indicates which is the oldest kernel we support
-# Update this if you are adding support for older kernels.
-OLDEST_KERNEL_SUPPORTED="2.6.24"
-
-if [ $# -ne 1 ]; then
- echo "Usage $0 config-file"
- exit
-fi
-
-COMPAT_CONFIG="$1"
-
-if [ ! -f $COMPAT_CONFIG ]; then
- echo "File $1 is not a file"
- exit
-fi
-
-# Defines a CONFIG_ option if not defined yet, this helps respect
-# linux/autoconf.h
-function define_config {
- VAR=$1
- VALUE=$2
- case $VALUE in
- n) # Try to undefine it
- echo "#undef $VAR"
- ;;
- y)
- echo "#ifndef $VAR"
- echo "#define $VAR 1"
- echo "#endif /* $VAR */"
- ;;
- m)
- echo "#ifndef $VAR"
- echo "#define $VAR 1"
- echo "#endif /* $VAR */"
- ;;
- *) # Assume string
- # XXX: add better checks to make sure what was on
- # the right was indeed a string
- echo "#ifndef $VAR"
- echo "#define $VAR \"$VALUE\""
- echo "#endif /* $VAR */"
- ;;
- esac
-}
-
-function kernel_version_req {
- VERSION=$(echo $1 | sed -e 's/\./,/g')
- echo "#if (LINUX_VERSION_CODE < KERNEL_VERSION($VERSION))"
- echo "#error compat requirement: Linux >= $VERSION"
- echo "#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION($VERSION) */"
-}
-
-cat <<EOF
-#ifndef COMPAT_AUTOCONF_INCLUDED
-#define COMPAT_AUTOCONF_INCLUDED
-/*
- * Automatically generated C config: don't edit
- */
-EOF
-
-# Checks user is compiling against a kernel we support
-kernel_version_req $OLDEST_KERNEL_SUPPORTED
-
-# For each CONFIG_FOO=x option
-for i in $(egrep '^CONFIG_|^ifdef CONFIG_|^ifndef CONFIG_|^endif #CONFIG_|^else #CONFIG_' $COMPAT_CONFIG | sed 's/ /+/'); do
- case $i in
- 'ifdef+CONFIG_'* )
- echo "#$i" | sed -e 's/+/ /' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(3,\2,0))/' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,\2))/' -e 's/\(ifdef CONFIG_COMPAT_RHEL_\)\([0-9]*\)_\([0-9]*\)/if (defined(RHEL_MAJOR) \&\& RHEL_MAJOR == \2 \&\& RHEL_MINOR >= \3)/' -e 's/\(#ifdef \)\(CONFIG_[^:space:]*\)/#if defined(\2) || defined(\2_MODULE)/'
- continue
- ;;
- 'ifndef+CONFIG_'* )
- echo "#$i" | sed -e 's/+/ /' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,\2,0))/' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,\2))/' -e 's/\(ifndef CONFIG_COMPAT_RHEL_\)\([0-9]*\)_\([0-9]*\)/if (!defined(RHEL_MAJOR) || RHEL_MAJOR != \2 || RHEL_MINOR < \3)/' -e 's/\(#ifndef \)\(CONFIG_[^:space:]*\)/#if !defined(\2) \&\& !defined(\2_MODULE)/'
- continue
- ;;
- 'else+#CONFIG_'* | 'endif+#CONFIG_'* )
- echo "#$i */" |sed -e 's/+#/ \/* /g'
- continue
- ;;
- CONFIG_* )
- # Get the element on the left of the "="
- VAR=$(echo $i | cut -d"=" -f 1)
- # Get the element on the right of the "="
- VALUE=$(echo $i | cut -d"=" -f 2)
-
- # Any other module which can *definitely* be built as a module goes here
- define_config $VAR $VALUE
- continue
- ;;
- esac
-done
-
-echo "#endif /* COMPAT_AUTOCONF_INCLUDED */"
+++ /dev/null
-#!/bin/bash
-# Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
-# Copyright 2012 Hauke Mehrtens <hauke@hauke-m.de>
-#
-# This generates a bunch of CONFIG_COMPAT_KERNEL_2_6_22
-# CONFIG_COMPAT_KERNEL_3_0 .. etc for each kernel release you need an object
-# for.
-#
-# Note: this is part of the compat.git project, not compat-wireless.git,
-# send patches against compat.git.
-
-if [[ ! -f ${KLIB_BUILD}/Makefile ]]; then
- exit
-fi
-
-# Actual kernel version
-KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p')
-
-# 3.0 kernel stuff
-COMPAT_LATEST_VERSION="5"
-KERNEL_SUBLEVEL="-1"
-
-# Note that this script will export all variables explicitly,
-# trying to export all with a blanket "export" statement at
-# the top of the generated file causes the build to slow down
-# by an order of magnitude.
-
-if [[ ${KERNEL_VERSION} -eq "3" ]]; then
- KERNEL_SUBLEVEL=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^3\.\([0-9]\+\).*/\1/p')
-else
- COMPAT_26LATEST_VERSION="39"
- KERNEL_26SUBLEVEL=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p')
- let KERNEL_26SUBLEVEL=${KERNEL_26SUBLEVEL}+1
-
- for i in $(seq ${KERNEL_26SUBLEVEL} ${COMPAT_26LATEST_VERSION}); do
- eval CONFIG_COMPAT_KERNEL_2_6_${i}=y
- echo "export CONFIG_COMPAT_KERNEL_2_6_${i}=y"
- done
-fi
-
-let KERNEL_SUBLEVEL=${KERNEL_SUBLEVEL}+1
-for i in $(seq ${KERNEL_SUBLEVEL} ${COMPAT_LATEST_VERSION}); do
- eval CONFIG_COMPAT_KERNEL_3_${i}=y
- echo "export CONFIG_COMPAT_KERNEL_3_${i}=y"
-done
-
-# The purpose of these seem to be the inverse of the above other varibales.
-# The RHEL checks seem to annotate the existance of RHEL minor versions.
-RHEL_MAJOR=$(grep ^RHEL_MAJOR ${KLIB_BUILD}/Makefile | sed -n 's/.*= *\(.*\)/\1/p')
-if [[ ! -z ${RHEL_MAJOR} ]]; then
- RHEL_MINOR=$(grep ^RHEL_MINOR $(KLIB_BUILD)/Makefile | sed -n 's/.*= *\(.*\)/\1/p')
- for i in $(seq 0 ${RHEL_MINOR}); do
- eval CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y
- echo "export CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y"
- done
-fi
-
-if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} = "y" ]]; then
- echo "export CONFIG_COMPAT_FIRMWARE_CLASS=m"
-fi
-
-if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then
- echo "export CONFIG_COMPAT_KFIFO=y"
-fi
-
-if [[ ${CONFIG_COMPAT_KERNEL_3_5} = "y" ]]; then
- # We don't have 2.6.24 backport support yet for Codel / FQ CoDel
- # For those who want to try this is what is required that I can tell
- # so far:
- # * struct Qdisc_ops
- # - init and change callback ops use a different argument dataype
- # - you need to parse data received from userspace differently
- if [[ ${CONFIG_COMPAT_KERNEL_2_6_25} != "y" ]]; then
- echo "export CONFIG_COMPAT_NET_SCH_CODEL=m"
- echo "export CONFIG_COMPAT_NET_SCH_FQ_CODEL=m"
- fi
-fi
+++ /dev/null
-#!/bin/bash
-perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g'
AC_MSG_RESULT(no)
])
+ AC_MSG_CHECKING([if linux/sched/task.h exists])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/sched/task.h>
+ ],[
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_LINUX_SCHED_TASK_H, 1,
+ [linux/sched/task.h is exist])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
])
#
# COMPAT_CONFIG_HEADERS
+++ /dev/null
-#ifndef _COMPAT_CRYPTO_AES_H
-#define _COMPAT_CRYPTO_AES_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24))
-#include_next <crypto/aes.h>
-#else
-
-#define AES_MIN_KEY_SIZE 16
-#define AES_MAX_KEY_SIZE 32
-#define AES_KEYSIZE_128 16
-#define AES_KEYSIZE_192 24
-#define AES_KEYSIZE_256 32
-#define AES_BLOCK_SIZE 16
-#define AES_MAX_KEYLENGTH (15 * 16)
-#define AES_MAX_KEYLENGTH_U32 (AES_MAX_KEYLENGTH / sizeof(u32))
-
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)) */
-
-#endif
+++ /dev/null
-#ifndef _COMPAT_LINUX_ATOMIC_H
-#define _COMPAT_LINUX_ATOMIC_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36))
-#include_next <linux/atomic.h>
-#else
-
-#include <asm/atomic.h>
-
-/**
- * atomic_inc_not_zero_hint - increment if not null
- * @v: pointer of type atomic_t
- * @hint: probable value of the atomic before the increment
- *
- * This version of atomic_inc_not_zero() gives a hint of probable
- * value of the atomic. This helps processor to not read the memory
- * before doing the atomic read/modify/write cycle, lowering
- * number of bus transactions on some arches.
- *
- * Returns: 0 if increment was not done, 1 otherwise.
- */
-#ifndef atomic_inc_not_zero_hint
-static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
-{
- int val, c = hint;
-
- /* sanity test, should be removed by compiler if hint is a constant */
- if (!hint)
- return atomic_inc_not_zero(v);
-
- do {
- val = atomic_cmpxchg(v, c, c + 1);
- if (val == c)
- return 1;
- c = val;
- } while (c);
-
- return 0;
-}
-#endif
-
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) */
-
-#endif /* _COMPAT_LINUX_ATOMIC_H */
+++ /dev/null
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37))
-#include_next <linux/average.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) */
+++ /dev/null
-#ifndef COMPAT_BIT_OPS_H
-#define COMPAT_BIT_OPS_H
-
-#include_next <linux/bitops.h>
-
-/* Include the autogenerated header file */
-#include "../../compat/config.h"
-
-#ifndef BIT_ULL
-#define BIT_ULL(nr) (1ULL << (nr))
-#endif
-
-#endif /* COMPAT_BIT_OPS_H */
+++ /dev/null
-#ifndef LINUX_CLOCKSOURCE_H
-#define LINUX_CLOCKSOURCE_H
-
-#include <linux/version.h>
-#include "../../compat/config.h"
-
-#include_next <linux/clocksource.h>
-
-#ifndef HAVE_TIMECOUNTER_ADJTIME
-/**
-* timecounter_adjtime - Shifts the time of the clock.
-* @delta: Desired change in nanoseconds.
-*/
-static inline void timecounter_adjtime(struct timecounter *tc, s64 delta)
-{
- tc->nsec += delta;
-}
-#endif /* HAVE_TIMECOUNTER_H */
-
-#endif /* LINUX_CLOCKSOURCE_H */
+++ /dev/null
-#ifndef LINUX_26_14_COMPAT_H
-#define LINUX_26_14_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.14 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14))
-
-typedef unsigned int gfp_t;
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) */
-
-#endif /* LINUX_26_14_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_18_COMPAT_H
-#define LINUX_26_18_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.18 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
-
-#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) */
-
-#endif /* LINUX_26_18_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_19_COMPAT_H
-#define LINUX_26_19_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.19 */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
-
-#include <linux/slab.h>
-
-static inline int
-compat_kmem_cache_destroy(struct kmem_cache *cachep)
-{
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
- return kmem_cache_destroy(cachep);
-#else
- kmem_cache_destroy(cachep);
- return 0;
-#endif
-}
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) */
-
-#endif /* LINUX_26_19_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_20_COMPAT_H
-#define LINUX_26_20_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.20 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
-
-#include <linux/workqueue.h>
-
-typedef void (*work_func_t)(struct work_struct *work);
-typedef void (*compat_work_func_t)(void *work);
-static inline void (INIT_WORK)(struct work_struct *work, work_func_t func)
-{
- INIT_WORK(work, (compat_work_func_t)func, work);
-}
-#undef INIT_WORK
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) */
-
-#endif /* LINUX_26_20_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_21_COMPAT_H
-#define LINUX_26_21_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.21 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
-
-#include <linux/sysctl.h>
-
-#define register_sysctl_table(table) \
- ({ \
- register_sysctl_table((table), 0); \
- })
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) */
-
-#endif /* LINUX_26_21_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_22_COMPAT_H
-#define LINUX_26_22_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.21 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
-
-#include <linux/pci.h>
-#include <linux/skbuff.h>
-
-/* reuse ax25_ptr */
-#define ieee80211_ptr ax25_ptr
-
-#ifdef CONFIG_AX25
-#error Compat reuses the AX.25 pointer so that may not be enabled!
-#endif
-
-static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
-{
- return skb->mac.raw;
-}
-
-static inline void skb_set_mac_header(struct sk_buff *skb, int offset)
-{
- skb->mac.raw = skb->data + offset;
-}
-
-static inline void skb_reset_mac_header(struct sk_buff *skb)
-{
- skb->mac.raw = skb->data;
-}
-
-static inline void skb_reset_network_header(struct sk_buff *skb)
-{
- skb->nh.raw = skb->data;
-}
-
-static inline void skb_set_network_header(struct sk_buff *skb, int offset)
-{
- skb->nh.raw = skb->data + offset;
-}
-
-static inline void skb_set_transport_header(struct sk_buff *skb, int offset)
-{
- skb->h.raw = skb->data + offset;
-}
-
-static inline unsigned char *skb_transport_header(struct sk_buff *skb)
-{
- return skb->h.raw;
-}
-
-static inline unsigned char *skb_network_header(const struct sk_buff *skb)
-{
- return skb->nh.raw;
-}
-
-static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
-{
- return skb->tail;
-}
-
-static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
-{
- return (struct iphdr *)skb_network_header(skb);
-}
-
-static inline void skb_copy_from_linear_data(const struct sk_buff *skb,
- void *to,
- const unsigned int len)
-{
- memcpy(to, skb->data, len);
-}
-
-static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
- const int offset, void *to,
- const unsigned int len)
-{
- memcpy(to, skb->data + offset, len);
-}
-
-#define __maybe_unused __attribute__((unused))
-
-#define uninitialized_var(x) x = x
-
-/* This will lead to very weird behaviour... */
-#define NLA_BINARY NLA_STRING
-
-static inline int pci_set_mwi(struct pci_dev *dev)
-{
- return -ENOSYS;
-}
-
-static inline void pci_clear_mwi(struct pci_dev *dev)
-{
-}
-
-#define list_first_entry(ptr, type, member) \
- list_entry((ptr)->next, type, member)
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) */
-
-#endif /* LINUX_26_22_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_23_COMPAT_H
-#define LINUX_26_23_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for < 2.6.23 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
-
-#include <linux/netdevice.h>
-#include <linux/sched.h>
-#include <linux/workqueue.h>
-#include <linux/genetlink.h>
-#include <net/sch_generic.h>
-
-/*
- * Tell gcc if a function is cold. The compiler will assume any path
- * directly leading to the call is unlikely.
- */
-
-#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 3)
-/* Mark functions as cold. gcc will assume any path leading to a call
- * to them will be unlikely. This means a lot of manual unlikely()s
- * are unnecessary now for any paths leading to the usual suspects
- * like BUG(), printk(), panic() etc. [but let's keep them for now for
- * older compilers]
- *
- * Early snapshots of gcc 4.3 don't support this and we can't detect this
- * in the preprocessor, but we can live with this because they're unreleased.
- * Maketime probing would be overkill here.
- *
- * gcc also has a __attribute__((__hot__)) to move hot functions into
- * a special section, but I don't see any sense in this right now in
- * the kernel context */
-#define __cold __attribute__((__cold__))
-#endif /* gcc 4.3 check */
-
-#ifndef __cold
-#define __cold
-#endif
-
-/* Added as of 2.6.23 in include/linux/netdevice.h */
-#define alloc_netdev_mq(sizeof_priv, name, setup, queue) \
- alloc_netdev(sizeof_priv, name, setup)
-#define NETIF_F_MULTI_QUEUE 16384
-
-/* Added as of 2.6.23 on include/linux/netdevice.h */
-static inline int netif_is_multiqueue(const struct net_device *dev)
-{
- return (!!(NETIF_F_MULTI_QUEUE & dev->features));
-}
-
-/* 2.6.23 fixed a bug in tcf_destroy_chain and the parameter changed */
-static inline void tcf_destroy_chain_compat(struct tcf_proto **fl)
-{
- struct tcf_proto *tp;
-
- while ((tp = *fl) != NULL) {
- *fl = tp->next;
- tp->ops->destroy(tp);
- module_put(tp->ops->owner);
- kfree(tp);
- }
-}
-
-/* dev_mc_list was replaced with dev_addr_list as of 2.6.23,
- * only new member added is da_synced. */
-#define dev_addr_list dev_mc_list
-#define da_addr dmi_addr
-#define da_addrlen dmi_addrlen
-#define da_users dmi_users
-#define da_gusers dmi_gusers
-
-/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and
- * dev_set_promiscuity() became a wrapper. */
-#define __dev_set_promiscuity dev_set_promiscuity
-
-/* Our own 2.6.22 port on compat.c */
-#define dev_mc_unsync LINUX_BACKPORT(dev_mc_unsync)
-#define dev_mc_sync LINUX_BACKPORT(dev_mc_sync)
-extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
-extern int dev_mc_sync(struct net_device *to, struct net_device *from);
-
-/* Our own 2.6.22 port on compat.c */
-extern void __dev_set_rx_mode(struct net_device *dev);
-
-/* Simple to add this */
-extern int cancel_delayed_work_sync(struct delayed_work *work);
-
-#define cancel_delayed_work_sync cancel_rearming_delayed_work
-
-#define debugfs_rename(a, b, c, d) 1
-
-/* nl80211 requires multicast group support which is new and added on
- * 2.6.23. We can't add support for it for older kernels to support it
- * genl_family structure was changed. Lets just let through the
- * genl_register_mc_group call. This means no multicast group suppport */
-
-#define genl_register_mc_group(a, b) 0
-
-/**
- * struct genl_multicast_group - generic netlink multicast group
- * @name: name of the multicast group, names are per-family
- * @id: multicast group ID, assigned by the core, to use with
- * genlmsg_multicast().
- * @list: list entry for linking
- * @family: pointer to family, need not be set before registering
- */
-struct genl_multicast_group
-{
- struct genl_family *family; /* private */
- struct list_head list; /* private */
- char name[GENL_NAMSIZ];
- u32 id;
-};
-
-
-/* Added as of 2.6.23 */
-#define pci_try_set_mwi LINUX_BACKPORT(pci_try_set_mwi)
-int pci_try_set_mwi(struct pci_dev *dev);
-
-/* Added as of 2.6.23 */
-#ifdef CONFIG_PM_SLEEP
-/*
- * Tell the freezer that the current task should be frozen by it
- */
-static inline void set_freezable(void)
-{
- current->flags &= ~PF_NOFREEZE;
-}
-
-#else
-static inline void set_freezable(void) {}
-#endif /* CONFIG_PM_SLEEP */
-
-#else
-#define tcf_destroy_chain_compat tcf_destroy_chain
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */
-
-#endif /* LINUX_26_23_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_24_COMPAT_H
-#define LINUX_26_24_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.21, 2.6.22 and 2.6.23 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
-
-#include <asm/atomic.h>
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/usb.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/scatterlist.h>
-
-#define KEY_BLUETOOTH 237
-#define KEY_WLAN 238
-#define KEY_UWB 239
-
-#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
-
-struct proc_dir_entry;
-struct net_device;
-struct net {
- atomic_t count; /* To decided when the network
- * namespace should be freed.
- */
- atomic_t use_count; /* To track references we
- * destroy on demand
- */
- struct list_head list; /* list of network namespaces */
- struct work_struct work; /* work struct for freeing */
-
- struct proc_dir_entry *proc_net;
- struct proc_dir_entry *proc_net_stat;
- struct proc_dir_entry *proc_net_root;
-
- struct net_device *loopback_dev; /* The loopback */
-
- struct list_head dev_base_head;
- struct hlist_head *dev_name_head;
- struct hlist_head *dev_index_head;
-};
-
-#ifdef CONFIG_NET
-/* Init's network namespace */
-#define init_net LINUX_BACKPORT(init_net)
-extern struct net init_net;
-#define INIT_NET_NS(net_ns) .net_ns = &init_net,
-#else
-#define INIT_NET_NS(net_ns)
-#endif
-
-/* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */
-typedef unsigned long uintptr_t;
-
-/* From include/linux/net.h */
-enum sock_shutdown_cmd {
- SHUT_RD = 0,
- SHUT_WR = 1,
- SHUT_RDWR = 2,
-};
-
-#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */
-/* Added as of 2.6.24 in include/linux/skbuff.h.
- *
- * Although 2.6.23 does support for CONFIG_NETDEVICES_MULTIQUEUE
- * this helper was not added until 2.6.24. This implementation
- * is exactly as it is on newer kernels.
- *
- * For older kernels we use the an internal mac80211 hack.
- * For details see changes to include/net/mac80211.h through
- * compat.diff and compat/mq_compat.h */
-static inline u16 skb_get_queue_mapping(struct sk_buff *skb)
-{
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
- return skb->queue_mapping;
-#else
- return 0;
-#endif
-}
-#endif /* Local 2.6.23 check */
-
-/* On older kernels we handle this a bit differently, so we yield to that
- * code for its implementation in mq_compat.h as we want to make
- * use of the internal mac80211 __ieee80211_queue_stopped() which itself
- * uses internal mac80211 data structure hacks. */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* Local check */
-/**
- * netif_subqueue_stopped - test status of subqueue
- * @dev: network device
- * @queue_index: sub queue index
- *
- * Check individual transmit queue of a device with multiple transmit queues.
- */
-static inline int __netif_subqueue_stopped(const struct net_device *dev,
- u16 queue_index)
-{
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
- return test_bit(__LINK_STATE_XOFF,
- &dev->egress_subqueue[queue_index].state);
-#else
- return 0;
-#endif
-}
-
-/* Note: although the backport implementation for netif_subqueue_stopped
- * on older kernels is identical to upstream __netif_subqueue_stopped()
- * (except for a const qualifier) we implement netif_subqueue_stopped()
- * as part of mac80211 as it relies on internal mac80211 structures we
- * use for MQ support. We this implement it in mq_compat.h */
-
-#endif /* Local 2.6.23 check */
-
-/*
- * Force link bug if constructor is used, can't be done compatibly
- * because constructor arguments were swapped since then!
- */
-extern void __incompatible_kmem_cache_create(void);
-
-/* 2.6.21 and 2.6.22 kmem_cache_create() takes 6 arguments */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
-#define kmem_cache_create(name, objsize, align, flags, ctor) \
- ({ \
- if (ctor) __incompatible_kmem_cache_create(); \
- kmem_cache_create((name), (objsize), (align), \
- (flags), NULL, NULL); \
- })
-#endif
-
-/* 2.6.23 kmem_cache_create() takes 5 arguments */
-#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23))
-#define kmem_cache_create(name, objsize, align, flags, ctor) \
- ({ \
- if (ctor) __incompatible_kmem_cache_create(); \
- kmem_cache_create((name), (objsize), (align), \
- (flags), NULL); \
- })
-#endif
-
-/* From include/linux/mod_devicetable.h */
-
-/* SSB core, see drivers/ssb/ */
-#ifndef SSB_DEVICE
-struct ssb_device_id {
- __u16 vendor;
- __u16 coreid;
- __u8 revision;
-};
-#define SSB_DEVICE(_vendor, _coreid, _revision) \
- { .vendor = _vendor, .coreid = _coreid, .revision = _revision, }
-#define SSB_DEVTABLE_END \
- { 0, },
-
-#define SSB_ANY_VENDOR 0xFFFF
-#define SSB_ANY_ID 0xFFFF
-#define SSB_ANY_REV 0xFF
-#endif
-
-
-/* Namespace stuff, introduced on 2.6.24 */
-#define dev_get_by_index(a, b) dev_get_by_index(b)
-#define __dev_get_by_index(a, b) __dev_get_by_index(b)
-
-#define eth_header LINUX_BACKPORT(eth_header)
-extern int eth_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr,
- void *saddr, unsigned len);
-#define eth_rebuild_header LINUX_BACKPORT(eth_rebuild_header)
-extern int eth_rebuild_header(struct sk_buff *skb);
-#define eth_header_cache_update LINUX_BACKPORT(eth_header_cache_update)
-extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
- unsigned char * haddr);
-#define eth_header_cache LINUX_BACKPORT(eth_header_cache)
-extern int eth_header_cache(struct neighbour *neigh,
- struct hh_cache *hh);
-
-/* This structure is simply not present on 2.6.22 and 2.6.23 */
-struct header_ops {
- int (*create) (struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr,
- void *saddr, unsigned len);
- int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
- int (*rebuild)(struct sk_buff *skb);
- #define HAVE_HEADER_CACHE
- int (*cache)(struct neighbour *neigh, struct hh_cache *hh);
- void (*cache_update)(struct hh_cache *hh,
- struct net_device *dev,
- unsigned char *haddr);
-};
-
-/* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on
- * 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore
- * the debug stuff. Note that adding this required changes to the struct
- * scatterlist on include/asm/scatterlist*, so the right way to port this
- * is to simply ignore the new structure changes and zero the scatterlist
- * array. We lave the kdoc intact for reference.
- */
-
-/**
- * sg_mark_end - Mark the end of the scatterlist
- * @sg: SG entryScatterlist
- *
- * Description:
- * Marks the passed in sg entry as the termination point for the sg
- * table. A call to sg_next() on this entry will return NULL.
- *
- **/
-static inline void sg_mark_end(struct scatterlist *sg)
-{
-#ifdef CONFIG_DEBUG_SG
- BUG_ON(sg->sg_magic != SG_MAGIC);
-#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
- /*
- * Set termination bit, clear potential chain bit
- */
- sg->page_link |= 0x02;
- sg->page_link &= ~0x01;
-#endif
-}
-
-/**
- * sg_init_table - Initialize SG table
- * @sgl: The SG table
- * @nents: Number of entries in table
- *
- * Notes:
- * If this is part of a chained sg table, sg_mark_end() should be
- * used only on the last table part.
- *
- **/
-static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
-{
- memset(sgl, 0, sizeof(*sgl) * nents);
-}
-
-/**
- * usb_endpoint_num - get the endpoint's number
- * @epd: endpoint to be checked
- *
- * Returns @epd's number: 0 to 15.
- */
-static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
-{
- return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-}
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
-
-#endif /* LINUX_26_24_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_25_COMPAT_H
-#define LINUX_26_25_COMPAT_H
-
-#include <linux/version.h>
-
-/* Compat work for 2.6.24 */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
-
-#include <linux/types.h>
-#include <linux/io.h>
-#include <linux/hw_random.h>
-#include <linux/leds.h>
-#include <linux/kernel.h>
-#include <linux/netdevice.h>
-#include <linux/pm.h>
-#include <asm-generic/bug.h>
-#include <linux/pm_qos_params.h>
-#include <linux/pci.h>
-#include <linux/in.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-
-/* Backports b718989da7 */
-#define pci_enable_device_mem LINUX_BACKPORT(pci_enable_device_mem)
-int __must_check pci_enable_device_mem(struct pci_dev *dev);
-
-/*
- * Backports 312b1485fb509c9bc32eda28ad29537896658cb8
- * Author: Sam Ravnborg <sam@ravnborg.org>
- * Date: Mon Jan 28 20:21:15 2008 +0100
- *
- * Introduce new section reference annotations tags: __ref, __refdata, __refconst
- */
-#define __ref __init_refok
-#define __refdata __initdata_refok
-
-/*
- * backports 2658fa803111dae1353602e7f586de8e537803e2
- */
-
-static inline bool ipv4_is_loopback(__be32 addr)
-{
- return (addr & htonl(0xff000000)) == htonl(0x7f000000);
-}
-
-static inline bool ipv4_is_multicast(__be32 addr)
-{
- return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
-}
-
-static inline bool ipv4_is_local_multicast(__be32 addr)
-{
- return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
-}
-
-static inline bool ipv4_is_lbcast(__be32 addr)
-{
- /* limited broadcast */
- return addr == htonl(INADDR_BROADCAST);
-}
-
-static inline bool ipv4_is_zeronet(__be32 addr)
-{
- return (addr & htonl(0xff000000)) == htonl(0x00000000);
-}
-
-/* Special-Use IPv4 Addresses (RFC3330) */
-
-static inline bool ipv4_is_private_10(__be32 addr)
-{
- return (addr & htonl(0xff000000)) == htonl(0x0a000000);
-}
-
-static inline bool ipv4_is_private_172(__be32 addr)
-{
- return (addr & htonl(0xfff00000)) == htonl(0xac100000);
-}
-
-static inline bool ipv4_is_private_192(__be32 addr)
-{
- return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
-}
-
-static inline bool ipv4_is_linklocal_169(__be32 addr)
-{
- return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
-}
-
-static inline bool ipv4_is_anycast_6to4(__be32 addr)
-{
- return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
-}
-
-static inline bool ipv4_is_test_192(__be32 addr)
-{
- return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
-}
-
-static inline bool ipv4_is_test_198(__be32 addr)
-{
- return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
-}
-
-/*
- * phys_addr_t was added as a generic arch typedef on 2.6.28,
- * that backport is dealt with in compat-2.6.28.h
- */
-#if defined(CONFIG_X86) || defined(CONFIG_X86_64)
-
-#if defined(CONFIG_64BIT) || defined(CONFIG_X86_PAE) || defined(CONFIG_PHYS_64BIT)
-typedef u64 phys_addr_t;
-#else
-typedef u32 phys_addr_t;
-#endif
-
-#endif /* x86 */
-
-/* The macro below uses a const upstream, this differs */
-
-/**
- * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
- * @_table: device table name
- *
- * This macro is used to create a struct pci_device_id array (a device table)
- * in a generic manner.
- */
-#define DEFINE_PCI_DEVICE_TABLE(_table) \
- const struct pci_device_id _table[] __devinitdata
-
-/*
- * Backport work for QoS dependencies (kernel/pm_qos_params.c)
- * pm-qos stuff written by mark gross mgross@linux.intel.com.
- *
- * ipw2100 now makes use of:
- *
- * pm_qos_add_requirement(),
- * pm_qos_update_requirement() and
- * pm_qos_remove_requirement() from it
- *
- * mac80211 uses the network latency to determine if to enable or not
- * dynamic PS. mac80211 also and registers a notifier for when
- * the latency changes. Since older kernels do no thave pm-qos stuff
- * we just implement it completley here and register it upon cfg80211
- * init. I haven't tested ipw2100 on 2.6.24 though.
- *
- * This pm-qos implementation is copied verbatim from the kernel
- * written by mark gross mgross@linux.intel.com. You don't have
- * to do anythinig to use pm-qos except use the same exported
- * routines as used in newer kernels. The backport_pm_qos_power_init()
- * defned below is used by the compat module to initialize pm-qos.
- */
-int backport_pm_qos_power_init(void);
-int backport_pm_qos_power_deinit(void);
-
-/*
- * 2.6.25 adds PM_EVENT_HIBERNATE as well here but
- * we don't have this on <= 2.6.23)
- */
-#ifndef PM_EVENT_SLEEP /* some distribution have mucked with their own headers to add this.. */
-#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND)
-#endif
-
-/* Although we don't care about wimax this is needed for rfkill input stuff */
-#define KEY_WIMAX 246
-
-/* Although pm_qos stuff is not implemented on <= 2.6.24 lets keep the define */
-#define PM_QOS_DEFAULT_VALUE -1
-
-#define __WARN(foo) dump_stack()
-
-#define dev_emerg(dev, format, arg...) \
- dev_printk(KERN_EMERG , dev , format , ## arg)
-#define dev_alert(dev, format, arg...) \
- dev_printk(KERN_ALERT , dev , format , ## arg)
-#define dev_crit(dev, format, arg...) \
- dev_printk(KERN_CRIT , dev , format , ## arg)
-
-#define __dev_addr_sync LINUX_BACKPORT(__dev_addr_sync)
-extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
-#define __dev_addr_unsync LINUX_BACKPORT(__dev_addr_unsync)
-extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
-
-#define seq_file_net &init_net;
-
-enum nf_inet_hooks {
- NF_INET_PRE_ROUTING = 0,
- NF_INET_LOCAL_IN = 1,
- NF_INET_FORWARD = 2,
- NF_INET_LOCAL_OUT = 3,
- NF_INET_POST_ROUTING = 4,
- NF_INET_NUMHOOKS = 5
-};
-
-/* The patch:
- * commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865
- * Author: Marcin Slusarz <marcin.slusarz@gmail.com>
- * Date: Fri Feb 8 04:20:12 2008 -0800
- *
- * byteorder: move le32_add_cpu & friends from OCFS2 to core
- *
- * moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core
- * header (1st) and converted some existing code to it. We port
- * it here as later kernels will most likely use it.
- */
-static inline void le16_add_cpu(__le16 *var, u16 val)
-{
- *var = cpu_to_le16(le16_to_cpu(*var) + val);
-}
-
-static inline void le32_add_cpu(__le32 *var, u32 val)
-{
- *var = cpu_to_le32(le32_to_cpu(*var) + val);
-}
-
-static inline void le64_add_cpu(__le64 *var, u64 val)
-{
- *var = cpu_to_le64(le64_to_cpu(*var) + val);
-}
-
-static inline void be16_add_cpu(__be16 *var, u16 val)
-{
- u16 v = be16_to_cpu(*var);
- *var = cpu_to_be16(v + val);
-}
-
-static inline void be32_add_cpu(__be32 *var, u32 val)
-{
- u32 v = be32_to_cpu(*var);
- *var = cpu_to_be32(v + val);
-}
-
-static inline void be64_add_cpu(__be64 *var, u64 val)
-{
- u64 v = be64_to_cpu(*var);
- *var = cpu_to_be64(v + val);
-}
-
-/* 2.6.25 changes hwrng_unregister()'s behaviour by supporting
- * suspend of its parent device (the misc device, which is itself the
- * hardware random number generator). It does this by passing a parameter to
- * unregister_miscdev() which is not supported in older kernels. The suspend
- * parameter allows us to enable access to the device's hardware
- * number generator during suspend. As far as wireless is concerned this means
- * if a driver goes to suspend it you won't have the HNR available in
- * older kernels. */
-static inline void __hwrng_unregister(struct hwrng *rng, bool suspended)
-{
- hwrng_unregister(rng);
-}
-
-static inline void led_classdev_unregister_suspended(struct led_classdev *lcd)
-{
- led_classdev_unregister(lcd);
-}
-
-/**
- * The following things are out of ./include/linux/kernel.h
- * The new iwlwifi driver is using them.
- */
-#define strict_strtoul LINUX_BACKPORT(strict_strtoul)
-extern int strict_strtoul(const char *, unsigned int, unsigned long *);
-#define strict_strtol LINUX_BACKPORT(strict_strtol)
-extern int strict_strtol(const char *, unsigned int, long *);
-
-#else
-/*
- * Kernels >= 2.6.25 have pm-qos and its initialized as part of
- * the bootup process
- */
-static inline int backport_pm_qos_power_init(void)
-{
- return 0;
-}
-
-static inline int backport_pm_qos_power_deinit(void)
-{
- return 0;
-}
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */
-
-#endif /* LINUX_26_25_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_26_COMPAT_H
-#define LINUX_26_26_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
-
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/kernel.h>
-#include <linux/jiffies.h>
-#include <net/sock.h>
-#include <linux/fs.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
-#include <net/net_namespace.h>
-#endif
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <asm/div64.h>
-
-/* These jiffie helpers added as of 2.6.26 */
-
-/*
- * These four macros compare jiffies and 'a' for convenience.
- */
-
-/* time_is_before_jiffies(a) return true if a is before jiffies */
-#define time_is_before_jiffies(a) time_after(jiffies, a)
-
-/* time_is_after_jiffies(a) return true if a is after jiffies */
-#define time_is_after_jiffies(a) time_before(jiffies, a)
-
-/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/
-#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
-
-/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/
-#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
-
-/* This comes from include/linux/input.h */
-#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any"
- set = radio enabled */
-
-/* From kernel.h */
-#define USHORT_MAX ((u16)(~0U))
-#define SHORT_MAX ((s16)(USHORT_MAX>>1))
-#define SHORT_MIN (-SHORT_MAX - 1)
-
-#define dev_set_name LINUX_BACKPORT(dev_set_name)
-extern int dev_set_name(struct device *dev, const char *name, ...)
- __attribute__((format(printf, 2, 3)));
-
-/**
- * clamp - return a value clamped to a given range with strict typechecking
- * @val: current value
- * @min: minimum allowable value
- * @max: maximum allowable value
- *
- * This macro does strict typechecking of min/max to make sure they are of the
- * same type as val. See the unnecessary pointer comparisons.
- */
-#define clamp(val, min, max) ({ \
- typeof(val) __val = (val); \
- typeof(min) __min = (min); \
- typeof(max) __max = (max); \
- (void) (&__val == &__min); \
- (void) (&__val == &__max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-
-/**
- * clamp_t - return a value clamped to a given range using a given type
- * @type: the type of variable to use
- * @val: current value
- * @min: minimum allowable value
- * @max: maximum allowable value
- *
- * This macro does no typechecking and uses temporary variables of type
- * 'type' to make all the comparisons.
- */
-#define clamp_t(type, val, min, max) ({ \
- type __val = (val); \
- type __min = (min); \
- type __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-
-
-/* from include/linux/device.h */
-/* device_create_drvdata() is new */
-extern struct device *device_create_drvdata(struct class *cls,
- struct device *parent,
- dev_t devt,
- void *drvdata,
- const char *fmt, ...)
-__attribute__((format(printf, 5, 6)));
-
-/* This is from include/linux/list.h */
-
-/**
- * list_is_singular - tests whether a list has just one entry.
- * @head: the list to test.
- */
-static inline int list_is_singular(const struct list_head *head)
-{
- return !list_empty(head) && (head->next == head->prev);
-}
-
-/* This is from include/linux/device.h, which was added as of 2.6.26 */
-static inline const char *dev_name(struct device *dev)
-{
- /* will be changed into kobject_name(&dev->kobj) in the near future */
- return dev->bus_id;
-}
-
-/* This is from include/linux/kernel.h, which was added as of 2.6.26 */
-
-/**
- * clamp_val - return a value clamped to a given range using val's type
- * @val: current value
- * @min: minimum allowable value
- * @max: maximum allowable value
- *
- * This macro does no typechecking and uses temporary variables of whatever
- * type the input argument 'val' is. This is useful when val is an unsigned
- * type and min and max are literals that will otherwise be assigned a signed
- * integer type.
- */
-
-#define clamp_val(val, min, max) ({ \
- typeof(val) __val = (val); \
- typeof(val) __min = (min); \
- typeof(val) __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-
-/* This comes from include/net/net_namespace.h */
-
-#ifdef CONFIG_NET_NS
-static inline
-int net_eq(const struct net *net1, const struct net *net2)
-{
- return net1 == net2;
-}
-#else
-static inline
-int net_eq(const struct net *net1, const struct net *net2)
-{
- return 1;
-}
-#endif
-
-static inline
-void dev_net_set(struct net_device *dev, struct net *net)
-{
-#ifdef CONFIG_NET_NS
- release_net(dev->nd_net);
- dev->nd_net = hold_net(net);
-#endif
-}
-
-static inline
-struct net *sock_net(const struct sock *sk)
-{
-#ifdef CONFIG_NET_NS
- return sk->sk_net;
-#else
- return &init_net;
-#endif
-}
-
-/* This comes from include/linux/netdevice.h */
-
-/*
- * Net namespace inlines
- */
-static inline
-struct net *dev_net(const struct net_device *dev)
-{
-#ifdef CONFIG_NET_NS
- /*
- * compat-wirelss backport note:
- * For older kernels we may just need to always return init_net,
- * not sure when we added dev->nd_net.
- */
- return dev->nd_net;
-#else
- return &init_net;
-#endif
-}
-
-
-/*
- * 2.6.26 added its own unaligned API which the
- * new drivers can use. Lets port it here by including it in older
- * kernels and also deal with the architecture handling here.
- */
-
-#ifdef CONFIG_ALPHA
-
-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* alpha */
-#ifdef CONFIG_ARM
-
-/* arm */
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* arm */
-#ifdef CONFIG_AVR32
-
-/*
- * AVR32 can handle some unaligned accesses, depending on the
- * implementation. The AVR32 AP implementation can handle unaligned
- * words, but halfwords must be halfword-aligned, and doublewords must
- * be word-aligned.
- *
- * However, swapped word loads must be word-aligned so we can't
- * optimize word loads in general.
- */
-
-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif
-#ifdef CONFIG_BLACKFIN
-
-#include <linux/unaligned/le_struct.h>
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* blackfin */
-#ifdef CONFIG_CRIS
-
-/*
- * CRIS can do unaligned accesses itself.
- */
-#include <linux/unaligned/access_ok.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* cris */
-#ifdef CONFIG_FRV
-
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* frv */
-#ifdef CONFIG_H8300
-
-#include <linux/unaligned/be_memmove.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* h8300 */
-#ifdef CONFIG_IA64
-
-#include <linux/unaligned/le_struct.h>
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* ia64 */
-#ifdef CONFIG_M32R
-
-#if defined(__LITTLE_ENDIAN__)
-# include <linux/unaligned/le_memmove.h>
-# include <linux/unaligned/be_byteshift.h>
-# include <linux/unaligned/generic.h>
-#else
-# include <linux/unaligned/be_memmove.h>
-# include <linux/unaligned/le_byteshift.h>
-# include <linux/unaligned/generic.h>
-#endif
-
-#endif /* m32r */
-#ifdef CONFIG_M68K /* this handles both m68k and m68knommu */
-
-#ifdef CONFIG_COLDFIRE
-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-#else
-
-/*
- * The m68k can do unaligned accesses itself.
- */
-#include <linux/unaligned/access_ok.h>
-#include <linux/unaligned/generic.h>
-#endif
-
-#endif /* m68k and m68knommu */
-#ifdef CONFIG_MIPS
-
-#if defined(__MIPSEB__)
-# include <linux/unaligned/be_struct.h>
-# include <linux/unaligned/le_byteshift.h>
-# include <linux/unaligned/generic.h>
-# define get_unaligned __get_unaligned_be
-# define put_unaligned __put_unaligned_be
-#elif defined(__MIPSEL__)
-# include <linux/unaligned/le_struct.h>
-# include <linux/unaligned/be_byteshift.h>
-# include <linux/unaligned/generic.h>
-#endif
-
-#endif /* mips */
-#ifdef CONFIG_MN10300
-
-#include <linux/unaligned/access_ok.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* mn10300 */
-#ifdef CONFIG_PARISC
-
-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* parisc */
-#ifdef CONFIG_PPC
-/*
- * The PowerPC can do unaligned accesses itself in big endian mode.
- */
-#include <linux/unaligned/access_ok.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* ppc */
-#ifdef CONFIG_S390
-
-/*
- * The S390 can do unaligned accesses itself.
- */
-#include <linux/unaligned/access_ok.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* s390 */
-#ifdef CONFIG_SUPERH
-
-/* SH can't handle unaligned accesses. */
-#ifdef __LITTLE_ENDIAN__
-# include <linux/unaligned/le_struct.h>
-# include <linux/unaligned/be_byteshift.h>
-# include <linux/unaligned/generic.h>
-#else
-# include <linux/unaligned/be_struct.h>
-# include <linux/unaligned/le_byteshift.h>
-# include <linux/unaligned/generic.h>
-#endif
-
-#endif /* sh - SUPERH */
-#ifdef CONFIG_SPARC
-
-/* sparc and sparc64 */
-#include <linux/unaligned/be_struct.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* sparc */
-#ifdef CONFIG_UML
-
-#include "asm/arch/unaligned.h"
-
-#endif /* um - uml */
-#ifdef CONFIG_V850
-
-#include <linux/unaligned/be_byteshift.h>
-#include <linux/unaligned/le_byteshift.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* v850 */
-#ifdef CONFIG_X86
-/*
- * The x86 can do unaligned accesses itself.
- */
-#include <linux/unaligned/access_ok.h>
-#include <linux/unaligned/generic.h>
-
-#endif /* x86 */
-#ifdef CONFIG_XTENSA
-
-#ifdef __XTENSA_EL__
-# include <linux/unaligned/le_memmove.h>
-# include <linux/unaligned/be_byteshift.h>
-# include <linux/unaligned/generic.h>
-#elif defined(__XTENSA_EB__)
-# include <linux/unaligned/be_memmove.h>
-# include <linux/unaligned/le_byteshift.h>
-# include <linux/unaligned/generic.h>
-#else
-# error processor byte order undefined!
-#endif
-
-#endif /* xtensa */
-
-#define PCIE_LINK_STATE_L0S 1
-#define PCIE_LINK_STATE_L1 2
-#define PCIE_LINK_STATE_CLKPM 4
-
-static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
-{
-}
-/* source: include/linux/pci-aspm.h */
-
-
-#if BITS_PER_LONG == 64
-
-/**
- * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
- *
- * This is commonly provided by 32bit archs to provide an optimized 64bit
- * divide.
- */
-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
-{
- *remainder = dividend % divisor;
- return dividend / divisor;
-}
-
-#elif BITS_PER_LONG == 32
-
-#ifndef div_u64_rem
-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
-{
- *remainder = do_div(dividend, divisor);
- return dividend;
-}
-#endif
-
-#endif /* BITS_PER_LONG */
-
-/**
- * div_u64 - unsigned 64bit divide with 32bit divisor
- *
- * This is the most common 64bit divide and should be used if possible,
- * as many 32bit archs can optimize this variant better than a full 64bit
- * divide.
- */
-#ifndef div_u64
-static inline u64 div_u64(u64 dividend, u32 divisor)
-{
- u32 remainder;
- return div_u64_rem(dividend, divisor, &remainder);
-}
-#endif
-/* source: include/math64.h */
-
-#define hex_asc_lo(x) hex_asc((x) & 0x0f)
-#define hex_asc_hi(x) hex_asc(((x) & 0xf0) >> 4)
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */
-
-#endif /* LINUX_26_26_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_27_COMPAT_H
-#define LINUX_26_27_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
-
-#include <linux/debugfs.h>
-#include <linux/list.h>
-#include <linux/pci.h>
-#include <linux/dma-mapping.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
-#include <linux/mmc/sdio.h>
-#include <linux/mmc/sdio_func.h>
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
-#include <linux/netdevice.h>
-#include <linux/workqueue.h>
-#include <net/iw_handler.h>
-#include <asm-generic/bug.h>
-#include <linux/wireless.h>
-#include <linux/skbuff.h>
-#include <net/sch_generic.h>
-#include <linux/ethtool.h>
-
-static inline struct net_device *qdisc_dev(const struct Qdisc *qdisc)
-{
- return qdisc->dev;
-}
-
-/*
- * Backports 378a2f09 and c27f339a
- * This may need a bit more work.
- */
-enum net_xmit_qdisc_t {
- __NET_XMIT_STOLEN = 0x00010000,
- __NET_XMIT_BYPASS = 0x00020000,
-};
-
-struct qdisc_skb_cb {
- unsigned int pkt_len;
- char data[];
-};
-
-static inline struct qdisc_skb_cb *qdisc_skb_cb(struct sk_buff *skb)
-{
- return (struct qdisc_skb_cb *)skb->cb;
-}
-
-static inline unsigned int qdisc_pkt_len(struct sk_buff *skb)
-{
- return qdisc_skb_cb(skb)->pkt_len;
-}
-
-#define PCI_PM_CAP_PME_SHIFT 11
-
-/* I can't find a more suitable replacement... */
-#define flush_work(work) cancel_work_sync(work)
-
-struct builtin_fw {
- char *name;
- void *data;
- unsigned long size;
-};
-
-/*
- * On older kernels we do not have net_device Multi Queue support, but
- * since we no longer use MQ on mac80211 we can simply use the 0 queue.
- * Note that if other fullmac drivers make use of this they then need
- * to be backported somehow or deal with just 1 queueue from MQ.
- */
-static inline void netif_tx_wake_all_queues(struct net_device *dev)
-{
- netif_wake_queue(dev);
-}
-static inline void netif_tx_start_all_queues(struct net_device *dev)
-{
- netif_start_queue(dev);
-}
-static inline void netif_tx_stop_all_queues(struct net_device *dev)
-{
- netif_stop_queue(dev);
-}
-
-/* Are all TX queues of the device empty? */
-static inline bool qdisc_all_tx_empty(const struct net_device *dev)
-{
- return skb_queue_empty(&dev->qdisc->q);
-}
-
-#define pci_pme_capable LINUX_BACKPORT(pci_pme_capable)
-bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
-
-/*
- * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck
- */
-#define netif_addr_lock_bh(dev)
-#define netif_addr_unlock_bh(dev)
-
-/*
- * To port this properly we'd have to port warn_slowpath_null(),
- * which I'm lazy to do so just do a regular print for now. If you
- * want to port this read kernel/panic.c
- */
-#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
-
-/* This is ported directly as-is on newer kernels */
-#ifndef WARN
-#define WARN(condition, format...) ({ \
- int __ret_warn_on = !!(condition); \
- if (unlikely(__ret_warn_on)) \
- __WARN_printf(format); \
- unlikely(__ret_warn_on); \
-})
-#endif
-
-/* On 2.6.27 a second argument was added, on older kernels we ignore it */
-#define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr)
-#define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr)
-
-/* This is from include/linux/ieee80211.h */
-#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
-
-/* New link list changes added as of 2.6.27, needed for ath9k */
-
-static inline void __list_cut_position(struct list_head *list,
- struct list_head *head, struct list_head *entry)
-{
- struct list_head *new_first = entry->next;
- list->next = head->next;
- list->next->prev = list;
- list->prev = entry;
- entry->next = list;
- head->next = new_first;
- new_first->prev = head;
-}
-
-/**
- * list_cut_position - cut a list into two
- * @list: a new list to add all removed entries
- * @head: a list with entries
- * @entry: an entry within head, could be the head itself
- * and if so we won't cut the list
- *
- * This helper moves the initial part of @head, up to and
- * including @entry, from @head to @list. You should
- * pass on @entry an element you know is on @head. @list
- * should be an empty list or a list you do not care about
- * losing its data.
- *
- */
-static inline void list_cut_position(struct list_head *list,
- struct list_head *head, struct list_head *entry)
-{
- if (list_empty(head))
- return;
- if (list_is_singular(head) &&
- (head->next != entry && head != entry))
- return;
- if (entry == head)
- INIT_LIST_HEAD(list);
- else
- __list_cut_position(list, head, entry);
-}
-
-
-/* __list_splice as re-implemented on 2.6.27, we backport it */
-static inline void __compat_list_splice_new_27(const struct list_head *list,
- struct list_head *prev,
- struct list_head *next)
-{
- struct list_head *first = list->next;
- struct list_head *last = list->prev;
-
- first->prev = prev;
- prev->next = first;
-
- last->next = next;
- next->prev = last;
-}
-
-/**
- * list_splice_tail - join two lists, each list being a queue
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- */
-static inline void list_splice_tail(struct list_head *list,
- struct list_head *head)
-{
- if (!list_empty(list))
- __compat_list_splice_new_27(list, head->prev, head);
-}
-
-/**
- * list_splice_tail_init - join two lists and reinitialise the emptied list
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- *
- * Each of the lists is a queue.
- * The list at @list is reinitialised
- */
-static inline void list_splice_tail_init(struct list_head *list,
- struct list_head *head)
-{
- if (!list_empty(list)) {
- __compat_list_splice_new_27(list, head->prev, head);
- INIT_LIST_HEAD(list);
- }
-}
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
-#define mmc_align_data_size LINUX_BACKPORT(mmc_align_data_size)
-extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
-#define sdio_align_size LINUX_BACKPORT(sdio_align_size)
-extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */
-
-#define iwe_stream_add_value(info, event, value, ends, iwe, event_len) iwe_stream_add_value(event, value, ends, iwe, event_len)
-#define iwe_stream_add_point(info, stream, ends, iwe, extra) iwe_stream_add_point(stream, ends, iwe, extra)
-#define iwe_stream_add_event(info, stream, ends, iwe, event_len) iwe_stream_add_event(stream, ends, iwe, event_len)
-
-/* Flags available in struct iw_request_info */
-#define IW_REQUEST_FLAG_COMPAT 0x0001 /* Compat ioctl call */
-
-static inline int iwe_stream_lcp_len(struct iw_request_info *info)
-{
-#ifdef CONFIG_COMPAT
- if (info->flags & IW_REQUEST_FLAG_COMPAT)
- return IW_EV_COMPAT_LCP_LEN;
-#endif
- return IW_EV_LCP_LEN;
-}
-
-#ifdef CONFIG_ARM
-
-/*
- * The caller asks to handle a range between offset and offset + size,
- * but we process a larger range from 0 to offset + size due to lack of
- * offset support.
- */
-
-static inline void dma_sync_single_range_for_cpu(struct device *dev,
- dma_addr_t handle, unsigned long offset, size_t size,
- enum dma_data_direction dir)
-{
- dma_sync_single_for_cpu(dev, handle, offset + size, dir);
-}
-
-static inline void dma_sync_single_range_for_device(struct device *dev,
- dma_addr_t handle, unsigned long offset, size_t size,
- enum dma_data_direction dir)
-{
- dma_sync_single_for_device(dev, handle, offset + size, dir);
-}
-
-#endif /* arm */
-
-#define debugfs_remove_recursive LINUX_BACKPORT(debugfs_remove_recursive)
-
-#if defined(CONFIG_DEBUG_FS)
-void debugfs_remove_recursive(struct dentry *dentry);
-#else
-static inline void debugfs_remove_recursive(struct dentry *dentry)
-{ }
-#endif
-
-#define device_create(cls, parent, devt, drvdata, fmt, ...) \
-({ \
- struct device *_dev; \
- _dev = (device_create)(cls, parent, devt, fmt, __VA_ARGS__); \
- dev_set_drvdata(_dev, drvdata); \
- _dev; \
-})
-
-#define dev_name(dev) dev_name((struct device *)dev)
-
-static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
- __u32 speed)
-{
- ep->speed = (__u16)speed;
-}
-
-static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
-{
- return ep->speed;
-}
-
-/**
- * lower_32_bits - return bits 0-31 of a number
- * @n: the number we're accessing
- */
-#define lower_32_bits(n) ((u32)(n))
-
-#define netif_wake_subqueue netif_start_subqueue
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */
-
-#endif /* LINUX_26_27_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_28_COMPAT_H
-#define LINUX_26_28_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
-
-#include <linux/skbuff.h>
-#include <linux/if_ether.h>
-#include <linux/usb.h>
-#include <linux/types.h>
-#include <linux/types.h>
-#include <linux/cpumask.h>
-
-#ifndef ETH_P_PAE
-#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
-#endif
-
-#include <linux/pci.h>
-
-typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } compat_cpumask_t;
-
-#if defined(CONFIG_X86) || defined(CONFIG_X86_64) || defined(CONFIG_PPC)
-/*
- * CONFIG_PHYS_ADDR_T_64BIT was added as new to all architectures
- * as of 2.6.28 but x86 and ppc had it already. x86 only got phys_addr_t
- * as of 2.6.25 but then is backported in compat-2.6.25.h
- */
-#else
-#if defined(CONFIG_64BIT) || defined(CONFIG_X86_PAE) || defned(CONFIG_PPC64) || defined(CONFIG_PHYS_64BIT)
-#define CONFIG_PHYS_ADDR_T_64BIT 1
-typedef u64 phys_addr_t;
-#else
-typedef u32 phys_addr_t;
-#endif
-
-#endif /* non x86 and ppc */
-
-#ifndef WARN_ONCE
-#define WARN_ONCE(condition, format...) ({ \
- static int __warned; \
- int __ret_warn_once = !!(condition); \
- \
- if (unlikely(__ret_warn_once)) \
- if (WARN(!__warned, format)) \
- __warned = 1; \
- unlikely(__ret_warn_once); \
-})
-#endif /* From include/asm-generic/bug.h */
-
-#define pci_ioremap_bar LINUX_BACKPORT(pci_ioremap_bar)
-void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
-
-/**
- * skb_queue_is_last - check if skb is the last entry in the queue
- * @list: queue head
- * @skb: buffer
- *
- * Returns true if @skb is the last buffer on the list.
- */
-static inline bool skb_queue_is_last(const struct sk_buff_head *list,
- const struct sk_buff *skb)
-{
- return (skb->next == (struct sk_buff *) list);
-}
-
-/**
- * skb_queue_next - return the next packet in the queue
- * @list: queue head
- * @skb: current buffer
- *
- * Return the next packet in @list after @skb. It is only valid to
- * call this if skb_queue_is_last() evaluates to false.
- */
-static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list,
- const struct sk_buff *skb)
-{
- /* This BUG_ON may seem severe, but if we just return then we
- * are going to dereference garbage.
- */
- BUG_ON(skb_queue_is_last(list, skb));
- return skb->next;
-}
-
-/**
- * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
- * @list: queue to initialize
- *
- * This initializes only the list and queue length aspects of
- * an sk_buff_head object. This allows to initialize the list
- * aspects of an sk_buff_head without reinitializing things like
- * the spinlock. It can also be used for on-stack sk_buff_head
- * objects where the spinlock is known to not be used.
- */
-static inline void __skb_queue_head_init(struct sk_buff_head *list)
-{
- list->prev = list->next = (struct sk_buff *)list;
- list->qlen = 0;
-}
-
-static inline void __skb_queue_splice(const struct sk_buff_head *list,
- struct sk_buff *prev,
- struct sk_buff *next)
-{
- struct sk_buff *first = list->next;
- struct sk_buff *last = list->prev;
-
- first->prev = prev;
- prev->next = first;
-
- last->next = next;
- next->prev = last;
-}
-
-/**
- * skb_queue_splice - join two skb lists, this is designed for stacks
- * @list: the new list to add
- * @head: the place to add it in the first list
- */
-static inline void skb_queue_splice(const struct sk_buff_head *list,
- struct sk_buff_head *head)
-{
- if (!skb_queue_empty(list)) {
- __skb_queue_splice(list, (struct sk_buff *) head, head->next);
- head->qlen += list->qlen;
- }
-}
-
-/**
- * skb_queue_splice - join two skb lists and reinitialise the emptied list
- * @list: the new list to add
- * @head: the place to add it in the first list
- *
- * The list at @list is reinitialised
- */
-static inline void skb_queue_splice_init(struct sk_buff_head *list,
- struct sk_buff_head *head)
-{
- if (!skb_queue_empty(list)) {
- __skb_queue_splice(list, (struct sk_buff *) head, head->next);
- head->qlen += list->qlen;
- __skb_queue_head_init(list);
- }
-}
-
-/**
- * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list
- * @list: the new list to add
- * @head: the place to add it in the first list
- *
- * Each of the lists is a queue.
- * The list at @list is reinitialised
- */
-static inline void skb_queue_splice_tail_init(struct sk_buff_head *list,
- struct sk_buff_head *head)
-{
- if (!skb_queue_empty(list)) {
- __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
- head->qlen += list->qlen;
- __skb_queue_head_init(list);
- }
-} /* From include/linux/skbuff.h */
-
-/**
- * skb_queue_splice_tail - join two skb lists, each list being a queue
- * @list: the new list to add
- * @head: the place to add it in the first list
- */
-static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
- struct sk_buff_head *head)
-{
- if (!skb_queue_empty(list)) {
- __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
- head->qlen += list->qlen;
- }
-}
-
-#define skb_queue_walk_from(queue, skb) \
- for (; skb != (struct sk_buff *)(queue); \
- skb = skb->next)
-
-#ifndef DECLARE_TRACE
-
-#define TP_PROTO(args...) args
-#define TP_ARGS(args...) args
-
-#define DECLARE_TRACE(name, proto, args) \
- static inline void _do_trace_##name(struct tracepoint *tp, proto) \
- { } \
- static inline void trace_##name(proto) \
- { } \
- static inline int register_trace_##name(void (*probe)(proto)) \
- { \
- return -ENOSYS; \
- } \
- static inline int unregister_trace_##name(void (*probe)(proto)) \
- { \
- return -ENOSYS; \
- }
-
-#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
-#define EXPORT_TRACEPOINT_SYMBOL(name)
-
-
-#endif
-
-#define round_jiffies_up LINUX_BACKPORT(round_jiffies_up)
-unsigned long round_jiffies_up(unsigned long j);
-
-extern void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
- int off, int size);
-
-#define wake_up_interruptible_poll(x, m) \
- __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))
-
-#define n_tty_ioctl_helper LINUX_BACKPORT(n_tty_ioctl_helper)
-extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
- unsigned int cmd, unsigned long arg);
-
-#define pci_wake_from_d3 LINUX_BACKPORT(pci_wake_from_d3)
-int pci_wake_from_d3(struct pci_dev *dev, bool enable);
-
-#define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active)
-
-#ifndef pr_fmt
-#define pr_fmt(fmt) fmt
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */
-
-#endif /* LINUX_26_28_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_29_COMPAT_H
-#define LINUX_26_29_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
-#include <linux/netdevice.h>
-#include <linux/if_link.h>
-
-#include <linux/skbuff.h>
-#include <linux/usb.h>
-#include <linux/types.h>
-
-/* backports */
-static inline void usb_autopm_put_interface_async(struct usb_interface *intf)
-{ }
-static inline int usb_autopm_get_interface_async(struct usb_interface *intf)
-{ return 0; }
-
-#if \
- defined(CONFIG_ALPHA) || defined(CONFIG_AVR32) || \
- defined(CONFIG_BLACKFIN) || defined(CONFIG_CRIS) || \
- defined(CONFIG_H8300) || defined(CONFIG_IA64) || \
- defined(CONFIG_M68K) || defined(CONFIG_MIPS) || \
- defined(CONFIG_PARISC) || defined(CONFIG_S390) || \
- defined(CONFIG_PPC64) || defined(CONFIG_PPC32) || \
- defined(CONFIG_SUPERH) || defined(CONFIG_SPARC) || \
- defined(CONFIG_FRV) || defined(CONFIG_X86) || \
- defined(CONFIG_M32R) || defined(CONFIG_M68K) || \
- defined(CONFIG_MN10300) || defined(CONFIG_XTENSA)
-#include <asm/atomic.h>
-#else
-typedef struct {
- volatile int counter;
-} atomic_t;
-
-#ifdef CONFIG_64BIT
-typedef struct {
- volatile long counter;
-} atomic64_t;
-#endif /* CONFIG_64BIT */
-
-#endif
-
-#define PCI_EXP_LNKCTL_ES 0x0080 /* Extended Synch */
-
-/*
- * Older kernels do not have struct net_device_ops but what we can
- * do is just define the data structure and use a caller to let us
- * set the data structure's routines onto the old netdev, essentially
- * doing it the old way. This avoids huge deltas on our backports.
- */
-
-/*
- * This structure defines the management hooks for network devices.
- * The following hooks can be defined; unless noted otherwise, they are
- * optional and can be filled with a null pointer.
- *
- * int (*ndo_init)(struct net_device *dev);
- * This function is called once when network device is registered.
- * The network device can use this to any late stage initializaton
- * or semantic validattion. It can fail with an error code which will
- * be propogated back to register_netdev
- *
- * void (*ndo_uninit)(struct net_device *dev);
- * This function is called when device is unregistered or when registration
- * fails. It is not called if init fails.
- *
- * int (*ndo_open)(struct net_device *dev);
- * This function is called when network device transistions to the up
- * state.
- *
- * int (*ndo_stop)(struct net_device *dev);
- * This function is called when network device transistions to the down
- * state.
- *
- * netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb,
- * struct net_device *dev);
- * Called when a packet needs to be transmitted.
- * Must return NETDEV_TX_OK , NETDEV_TX_BUSY.
- * (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
- * Required can not be NULL.
- *
- * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb);
- * Called to decide which queue to when device supports multiple
- * transmit queues.
- *
- * void (*ndo_change_rx_flags)(struct net_device *dev, int flags);
- * This function is called to allow device receiver to make
- * changes to configuration when multicast or promiscious is enabled.
- *
- * void (*ndo_set_rx_mode)(struct net_device *dev);
- * This function is called device changes address list filtering.
- *
- * void (*ndo_set_multicast_list)(struct net_device *dev);
- * This function is called when the multicast address list changes.
- *
- * int (*ndo_set_mac_address)(struct net_device *dev, void *addr);
- * This function is called when the Media Access Control address
- * needs to be changed. If this interface is not defined, the
- * mac address can not be changed.
- *
- * int (*ndo_validate_addr)(struct net_device *dev);
- * Test if Media Access Control address is valid for the device.
- *
- * int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
- * Called when a user request an ioctl which can't be handled by
- * the generic interface code. If not defined ioctl's return
- * not supported error code.
- *
- * int (*ndo_set_config)(struct net_device *dev, struct ifmap *map);
- * Used to set network devices bus interface parameters. This interface
- * is retained for legacy reason, new devices should use the bus
- * interface (PCI) for low level management.
- *
- * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu);
- * Called when a user wants to change the Maximum Transfer Unit
- * of a device. If not defined, any request to change MTU will
- * will return an error.
- *
- * void (*ndo_tx_timeout)(struct net_device *dev);
- * Callback uses when the transmitter has not made any progress
- * for dev->watchdog ticks.
- *
- * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
- * Called when a user wants to get the network device usage
- * statistics. If not defined, the counters in dev->stats will
- * be used.
- *
- * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp);
- * If device support VLAN receive accleration
- * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called
- * when vlan groups for the device changes. Note: grp is NULL
- * if no vlan's groups are being used.
- *
- * void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid);
- * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
- * this function is called when a VLAN id is registered.
- *
- * void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
- * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
- * this function is called when a VLAN id is unregistered.
- *
- * void (*ndo_poll_controller)(struct net_device *dev);
- *
- * SR-IOV management functions.
- * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac);
- * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos);
- * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate);
- * int (*ndo_get_vf_config)(struct net_device *dev,
- * int vf, struct ifla_vf_info *ivf);
- */
-#define HAVE_NET_DEVICE_OPS
-struct net_device_ops {
- int (*ndo_init)(struct net_device *dev);
- void (*ndo_uninit)(struct net_device *dev);
- int (*ndo_open)(struct net_device *dev);
- int (*ndo_stop)(struct net_device *dev);
- netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb,
- struct net_device *dev);
- u16 (*ndo_select_queue)(struct net_device *dev,
- struct sk_buff *skb);
- void (*ndo_change_rx_flags)(struct net_device *dev,
- int flags);
- void (*ndo_set_rx_mode)(struct net_device *dev);
- void (*ndo_set_multicast_list)(struct net_device *dev);
- int (*ndo_set_mac_address)(struct net_device *dev,
- void *addr);
- int (*ndo_validate_addr)(struct net_device *dev);
- int (*ndo_do_ioctl)(struct net_device *dev,
- struct ifreq *ifr, int cmd);
- int (*ndo_set_config)(struct net_device *dev,
- struct ifmap *map);
- int (*ndo_change_mtu)(struct net_device *dev,
- int new_mtu);
- int (*ndo_neigh_setup)(struct net_device *dev,
- struct neigh_parms *);
- void (*ndo_tx_timeout) (struct net_device *dev);
-
- struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
-
- void (*ndo_vlan_rx_register)(struct net_device *dev,
- struct vlan_group *grp);
- void (*ndo_vlan_rx_add_vid)(struct net_device *dev,
- unsigned short vid);
- void (*ndo_vlan_rx_kill_vid)(struct net_device *dev,
- unsigned short vid);
-#ifdef CONFIG_NET_POLL_CONTROLLER
- void (*ndo_poll_controller)(struct net_device *dev);
-#endif
- int (*ndo_set_vf_mac)(struct net_device *dev,
- int queue, u8 *mac);
- int (*ndo_set_vf_vlan)(struct net_device *dev,
- int queue, u16 vlan, u8 qos);
- int (*ndo_set_vf_tx_rate)(struct net_device *dev,
- int vf, int rate);
-/*
- * The struct ifla_vf_info was added via b280da8d54b8d82b52f368a8703b7ada6c1744d5
- * on the v2.6.34-rc1~233^2~338 release
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- int (*ndo_get_vf_config)(struct net_device *dev,
- int vf,
- struct ifla_vf_info *ivf);
-#endif
-#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
- int (*ndo_fcoe_enable)(struct net_device *dev);
- int (*ndo_fcoe_disable)(struct net_device *dev);
- int (*ndo_fcoe_ddp_setup)(struct net_device *dev,
- u16 xid,
- struct scatterlist *sgl,
- unsigned int sgc);
- int (*ndo_fcoe_ddp_done)(struct net_device *dev,
- u16 xid);
-#define NETDEV_FCOE_WWNN 0
-#define NETDEV_FCOE_WWPN 1
- int (*ndo_fcoe_get_wwn)(struct net_device *dev,
- u64 *wwn, int type);
-#endif
-};
-
-static inline int ndo_do_ioctl(struct net_device *dev,
- struct ifreq *ifr,
- int cmd)
-{
- if (dev->do_ioctl)
- return dev->do_ioctl(dev, ifr, cmd);
- return -EOPNOTSUPP;
-}
-
-
-#define netdev_attach_ops LINUX_BACKPORT(netdev_attach_ops)
-void netdev_attach_ops(struct net_device *dev,
- const struct net_device_ops *ops);
-
-/**
- * skb_queue_is_first - check if skb is the first entry in the queue
- * @list: queue head
- * @skb: buffer
- *
- * Returns true if @skb is the first buffer on the list.
- */
-static inline bool skb_queue_is_first(const struct sk_buff_head *list,
- const struct sk_buff *skb)
-{
- return (skb->prev == (struct sk_buff *) list);
-}
-
-/**
- * skb_queue_prev - return the prev packet in the queue
- * @list: queue head
- * @skb: current buffer
- *
- * Return the prev packet in @list before @skb. It is only valid to
- * call this if skb_queue_is_first() evaluates to false.
- */
-static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list,
- const struct sk_buff *skb)
-{
- /* This BUG_ON may seem severe, but if we just return then we
- * are going to dereference garbage.
- */
- BUG_ON(skb_queue_is_first(list, skb));
- return skb->prev;
-}
-
-
-static inline struct net_device_stats *dev_get_stats(struct net_device *dev)
-{
- return dev->get_stats(dev);
-}
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
-#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
-#define usb_unpoison_anchored_urbs LINUX_BACKPORT(usb_unpoison_anchored_urbs)
-extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor);
-#endif /* CONFIG_USB */
-#endif
-
-#define DIV_ROUND_CLOSEST(x, divisor)( \
-{ \
- typeof(divisor) __divisor = divisor; \
- (((x) + ((__divisor) / 2)) / (__divisor)); \
-} \
-)
-
-#define eth_mac_addr LINUX_BACKPORT(eth_mac_addr)
-extern int eth_mac_addr(struct net_device *dev, void *p);
-#define eth_change_mtu LINUX_BACKPORT(eth_change_mtu)
-extern int eth_change_mtu(struct net_device *dev, int new_mtu);
-#define eth_validate_addr LINUX_BACKPORT(eth_validate_addr)
-extern int eth_validate_addr(struct net_device *dev);
-
-#ifdef CONFIG_NET_NS
-
-static inline void write_pnet(struct net **pnet, struct net *net)
-{
- *pnet = net;
-}
-
-static inline struct net *read_pnet(struct net * const *pnet)
-{
- return *pnet;
-}
-
-#else
-
-#define write_pnet(pnet, net) do { (void)(net);} while (0)
-#define read_pnet(pnet) (&init_net)
-
-/*
- * swap - swap value of @a and @b
- */
-#define swap(a, b) \
- do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
-
-#endif
-
-#define init_dummy_netdev LINUX_BACKPORT(init_dummy_netdev)
-extern int init_dummy_netdev(struct net_device *dev);
-
-#define compat_pci_suspend(fn) \
- int fn##_compat(struct pci_dev *pdev, pm_message_t state) \
- { \
- int r; \
- \
- r = fn(&pdev->dev); \
- if (r) \
- return r; \
- \
- pci_save_state(pdev); \
- pci_disable_device(pdev); \
- pci_set_power_state(pdev, PCI_D3hot); \
- \
- return 0; \
- }
-
-#define compat_pci_resume(fn) \
- int fn##_compat(struct pci_dev *pdev) \
- { \
- int r; \
- \
- pci_set_power_state(pdev, PCI_D0); \
- r = pci_enable_device(pdev); \
- if (r) \
- return r; \
- pci_restore_state(pdev); \
- \
- return fn(&pdev->dev); \
- }
-
-#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
-
-/* Kernels >= 2.6.29 follows */
-
-/* XXX: this can probably just go upstream ! */
-static inline void netdev_attach_ops(struct net_device *dev,
- const struct net_device_ops *ops)
-{
- dev->netdev_ops = ops;
-}
-
-/* XXX: this can probably just go upstream! */
-static inline int ndo_do_ioctl(struct net_device *dev,
- struct ifreq *ifr,
- int cmd)
-{
- if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl)
- return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
- return -EOPNOTSUPP;
-}
-
-#define compat_pci_suspend(fn)
-#define compat_pci_resume(fn)
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
-
-#endif /* LINUX_26_29_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_30_COMPAT_H
-#define LINUX_26_30_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
-
-#include <linux/device.h>
-
-#ifndef TP_PROTO
-#define TP_PROTO(args...) TPPROTO(args)
-#endif
-#ifndef TP_ARGS
-#define TP_ARGS(args...) TPARGS(args)
-#endif
-
-#define IRQ_WAKE_THREAD (2)
-
-/* From : include/linux/pm.h */
-/* How to reorder dpm_list after device_move() */
-enum dpm_order {
- DPM_ORDER_NONE,
- DPM_ORDER_DEV_AFTER_PARENT,
- DPM_ORDER_PARENT_BEFORE_DEV,
- DPM_ORDER_DEV_LAST,
-};
-
-static inline void dev_set_uevent_suppress(struct device *dev, int val)
-{
- dev->uevent_suppress = val;
-}
-
-/*
- * Print a one-time message (analogous to WARN_ONCE() et al):
- */
-#define printk_once(x...) ({ \
- static bool __print_once; \
- \
- if (!__print_once) { \
- __print_once = true; \
- printk(x); \
- } \
-})
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */
-
-#endif /* LINUX_26_30_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_31_COMPAT_H
-#define LINUX_26_31_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
-
-#include <linux/skbuff.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <net/dst.h>
-#include <net/genetlink.h>
-#include <linux/ethtool.h>
-
-#define rfkill_get_led_trigger_name LINUX_BACKPORT(rfkill_get_led_trigger_name)
-#define rfkill_set_led_trigger_name LINUX_BACKPORT(rfkill_set_led_trigger_name)
-#define rfkill_set_hw_state LINUX_BACKPORT(rfkill_set_hw_state)
-#define rfkill_set_sw_state LINUX_BACKPORT(rfkill_set_sw_state)
-#define rfkill_init_sw_state LINUX_BACKPORT(rfkill_init_sw_state)
-#define rfkill_set_states LINUX_BACKPORT(rfkill_set_states)
-#define rfkill_pause_polling LINUX_BACKPORT(rfkill_pause_polling)
-#define rfkill_resume_polling LINUX_BACKPORT(rfkill_resume_polling)
-#define rfkill_blocked LINUX_BACKPORT(rfkill_blocked)
-#define rfkill_alloc LINUX_BACKPORT(rfkill_alloc)
-#define rfkill_register LINUX_BACKPORT(rfkill_register)
-#define rfkill_unregister LINUX_BACKPORT(rfkill_unregister)
-#define rfkill_destroy LINUX_BACKPORT(rfkill_destroy)
-
-#ifndef ERFKILL
-#if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC)
-#define ERFKILL 132 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_ALPHA
-#define ERFKILL 138 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_MIPS
-#define ERFKILL 167 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_PARISC
-#define ERFKILL 256 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_SPARC
-#define ERFKILL 134 /* Operation not possible due to RF-kill */
-#endif
-#endif
-
-#ifndef NETDEV_PRE_UP
-#define NETDEV_PRE_UP 0x000D
-#endif
-
-#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN
-#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104
-#endif
-
-struct compat_threaded_irq {
- unsigned int irq;
- irq_handler_t handler;
- irq_handler_t thread_fn;
- void *dev_id;
- char wq_name[64];
- struct workqueue_struct *wq;
- struct work_struct work;
-};
-
-/*
- * kmemleak was introduced on 2.6.31, since older kernels do not have
- * we simply ignore its tuning.
- */
-static inline void kmemleak_ignore(const void *ptr)
-{
- return;
-}
-
-static inline void kmemleak_not_leak(const void *ptr)
-{
- return;
-}
-
-static inline void kmemleak_no_scan(const void *ptr)
-{
- return;
-}
-
-/*
- * Added via adf30907d63893e4208dfe3f5c88ae12bc2f25d5
- *
- * There is no _sk_dst on older kernels, so just set the
- * old dst to NULL and release it directly.
- */
-static inline void skb_dst_drop(struct sk_buff *skb)
-{
- dst_release(skb->dst);
- skb->dst = NULL;
-}
-
-static inline struct dst_entry *skb_dst(const struct sk_buff *skb)
-{
- return (struct dst_entry *)skb->dst;
-}
-
-static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
-{
- skb->dst = dst;
-}
-
-static inline struct rtable *skb_rtable(const struct sk_buff *skb)
-{
- return (struct rtable *)skb_dst(skb);
-}
-
-/* Backport threaded IRQ support */
-
-static inline
-void compat_irq_work(struct work_struct *work)
-{
- struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work);
- comp->thread_fn(comp->irq, comp->dev_id);
-}
-
-static inline
-irqreturn_t compat_irq_dispatcher(int irq, void *dev_id)
-{
- struct compat_threaded_irq *comp = dev_id;
- irqreturn_t res;
-
- res = comp->handler(irq, comp->dev_id);
- if (res == IRQ_WAKE_THREAD) {
- queue_work(comp->wq, &comp->work);
- res = IRQ_HANDLED;
- }
-
- return res;
-}
-
-static inline
-int compat_request_threaded_irq(struct compat_threaded_irq *comp,
- unsigned int irq,
- irq_handler_t handler,
- irq_handler_t thread_fn,
- unsigned long flags,
- const char *name,
- void *dev_id)
-{
- comp->irq = irq;
- comp->handler = handler;
- comp->thread_fn = thread_fn;
- comp->dev_id = dev_id;
- INIT_WORK(&comp->work, compat_irq_work);
-
- if (!comp->wq) {
- snprintf(comp->wq_name, sizeof(comp->wq_name),
- "compirq/%u-%s", irq, name);
- comp->wq = create_singlethread_workqueue(comp->wq_name);
- if (!comp->wq) {
- printk(KERN_ERR "Failed to create compat-threaded-IRQ workqueue %s\n",
- comp->wq_name);
- return -ENOMEM;
- }
- }
- return request_irq(irq, compat_irq_dispatcher, flags, name, comp);
-}
-
-static inline
-void compat_free_threaded_irq(struct compat_threaded_irq *comp)
-{
- free_irq(comp->irq, comp);
-}
-
-static inline
-void compat_destroy_threaded_irq(struct compat_threaded_irq *comp)
-{
- if (comp->wq)
- destroy_workqueue(comp->wq);
- comp->wq = NULL;
-}
-
-static inline
-void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp)
-{
- synchronize_irq(comp->irq);
- cancel_work_sync(&comp->work);
-}
-
-/**
- * list_entry_rcu - get the struct for this entry
- * @ptr: the &struct list_head pointer.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- *
- * This primitive may safely run concurrently with the _rcu list-mutation
- * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
- */
-#define list_entry_rcu(ptr, type, member) \
- container_of(rcu_dereference(ptr), type, member)
-
-#define skb_walk_frags(skb, iter) \
- for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
-
-#ifndef CONFIG_64BIT
-
-typedef struct {
- long long counter;
-} atomic64_t;
-
-#define atomic64_read LINUX_BACKPORT(atomic64_read)
-extern long long atomic64_read(const atomic64_t *v);
-#define atomic64_add_return LINUX_BACKPORT(atomic64_add_return)
-extern long long atomic64_add_return(long long a, atomic64_t *v);
-
-#define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
-
-#endif
-
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
-
-#endif /* LINUX_26_31_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_32_COMPAT_H
-#define LINUX_26_32_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32))
-
-#include <linux/netdevice.h>
-#include <linux/compat.h>
-#include <net/iw_handler.h>
-#include <linux/workqueue.h>
-#include <net/genetlink.h>
-#include <net/sch_generic.h>
-
-#define TCQ_F_CAN_BYPASS 4
-
-static inline int qdisc_qlen(const struct Qdisc *q)
-{
- return q->q.qlen;
-}
-
-#define SDIO_VENDOR_ID_INTEL 0x0089
-#define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402
-#define SDIO_DEVICE_ID_INTEL_IWMC3200WIFI 0x1403
-#define SDIO_DEVICE_ID_INTEL_IWMC3200TOP 0x1404
-#define SDIO_DEVICE_ID_INTEL_IWMC3200GPS 0x1405
-#define SDIO_DEVICE_ID_INTEL_IWMC3200BT 0x1406
-
-/*
- * Backports 5e928f77a09a07f9dd595bb8a489965d69a83458
- * run-time power management cannot really be backported
- * given that the implementation added bus specific
- * callbacks that we won't have on older kernels. If
- * you really want run-time power management or good
- * power management upgrade your kernel. We'll just
- * compile this out as if run-time power management was
- * disabled just as the kernel disables run-time power management
- * when CONFIG_PM_RUNTIME is disabled.
- */
-static inline void pm_runtime_init(struct device *dev) {}
-static inline void pm_runtime_remove(struct device *dev) {}
-static inline int pm_runtime_get(struct device *dev)
-{
- return 0;
-}
-
-static inline int pm_runtime_get_sync(struct device *dev)
-{
- return 0;
-}
-
-static inline int pm_runtime_put(struct device *dev)
-{
- return 0;
-}
-
-static inline int pm_runtime_put_sync(struct device *dev)
-{
- return 0;
-}
-
-static inline int pm_runtime_set_active(struct device *dev)
-{
- return 0;
-}
-
-static inline void pm_runtime_set_suspended(struct device *dev)
-{
-}
-
-static inline void pm_runtime_disable(struct device *dev)
-{
-}
-
-static inline void pm_runtime_put_noidle(struct device *dev) {}
-static inline void pm_runtime_get_noresume(struct device *dev) {}
-
-static inline void flush_delayed_work(struct delayed_work *dwork)
-{
- if (del_timer_sync(&dwork->timer)) {
- /*
- * This is what would happen on 2.6.32 but since we don't have
- * access to the singlethread_cpu we can't really backport this,
- * so avoid really *flush*ing the work... Oh well. Any better ideas?
-
- struct cpu_workqueue_struct *cwq;
- cwq = wq_per_cpu(keventd_wq, get_cpu());
- __queue_work(cwq, &dwork->work);
- put_cpu();
-
- */
- }
- flush_work(&dwork->work);
-}
-
-/*
- * struct genl_multicast_group was made netns aware through
- * patch "genetlink: make netns aware" by johannes, we just
- * force this to always use the default init_net
- */
-#define genl_info_net(x) &init_net
-/* Just use init_net for older kernels */
-#define get_net_ns_by_pid(x) &init_net
-
-/* net namespace is lost */
-#define genlmsg_multicast_netns(a, b, c, d, e) genlmsg_multicast(b, c, d, e)
-#define genlmsg_multicast_allns(a, b, c, d) genlmsg_multicast(a, b, c, d)
-#define genlmsg_unicast(net, skb, pid) genlmsg_unicast(skb, pid)
-
-#define dev_change_net_namespace(a, b, c) (-EOPNOTSUPP)
-
-#define SET_NETDEV_DEVTYPE(netdev, type)
-
-#ifdef __KERNEL__
-/* Driver transmit return codes */
-enum netdev_tx {
- BACKPORT_NETDEV_TX_OK = NETDEV_TX_OK, /* driver took care of packet */
- BACKPORT_NETDEV_TX_BUSY = NETDEV_TX_BUSY, /* driver tx path was busy*/
- BACKPORT_NETDEV_TX_LOCKED = NETDEV_TX_LOCKED, /* driver tx lock was already taken */
-};
-typedef enum netdev_tx netdev_tx_t;
-#endif /* __KERNEL__ */
-
-/*
- * dev_pm_ops is only available on kernels >= 2.6.29, for
- * older kernels we rely on reverting the work to old
- * power management style stuff.
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
-/*
- * Use this if you want to use the same suspend and resume callbacks for suspend
- * to RAM and hibernation.
- */
-#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
-struct dev_pm_ops name = { \
- .suspend = suspend_fn, \
- .resume = resume_fn, \
- .freeze = suspend_fn, \
- .thaw = resume_fn, \
- .poweroff = suspend_fn, \
- .restore = resume_fn, \
-}
-#else
-#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn)
-#endif /* >= 2.6.29 */
-
-#define wireless_send_event(a, b, c, d) wireless_send_event(a, b, c, (char * ) d)
-
-/* The export symbol in changed in compat/patches/15-symbol-export-conflicts.patch */
-#define ieee80211_rx(hw, skb) mac80211_ieee80211_rx(hw, skb)
-
-#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
-
-#define lockdep_assert_held(l) do { } while (0)
-
-/*
- * Similar to the struct tm in userspace <time.h>, but it needs to be here so
- * that the kernel source is self contained.
- */
-struct tm {
- /*
- * the number of seconds after the minute, normally in the range
- * 0 to 59, but can be up to 60 to allow for leap seconds
- */
- int tm_sec;
- /* the number of minutes after the hour, in the range 0 to 59*/
- int tm_min;
- /* the number of hours past midnight, in the range 0 to 23 */
- int tm_hour;
- /* the day of the month, in the range 1 to 31 */
- int tm_mday;
- /* the number of months since January, in the range 0 to 11 */
- int tm_mon;
- /* the number of years since 1900 */
- long tm_year;
- /* the number of days since Sunday, in the range 0 to 6 */
- int tm_wday;
- /* the number of days since January 1, in the range 0 to 365 */
- int tm_yday;
-};
-
-#define time_to_tm LINUX_BACKPORT(time_to_tm)
-void time_to_tm(time_t totalsecs, int offset, struct tm *result);
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */
-
-#endif /* LINUX_26_32_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_33_COMPAT_H
-#define LINUX_26_33_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
-
-#include <linux/skbuff.h>
-#include <linux/pci.h>
-#if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
-#include <pcmcia/cs_types.h>
-#include <pcmcia/cistpl.h>
-#include <pcmcia/ds.h>
-#endif
-#include <linux/firmware.h>
-#include <linux/input.h>
-#include <linux/sched.h>
-
-#if defined(CONFIG_COMPAT_FIRMWARE_CLASS)
-#define request_firmware_nowait LINUX_BACKPORT(request_firmware_nowait)
-#define request_firmware LINUX_BACKPORT(request_firmware)
-#define release_firmware LINUX_BACKPORT(release_firmware)
-
-#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
-int request_firmware(const struct firmware **fw, const char *name,
- struct device *device);
-int request_firmware_nowait(
- struct module *module, int uevent,
- const char *name, struct device *device, gfp_t gfp, void *context,
- void (*cont)(const struct firmware *fw, void *context));
-
-void release_firmware(const struct firmware *fw);
-#else
-static inline int request_firmware(const struct firmware **fw,
- const char *name,
- struct device *device)
-{
- return -EINVAL;
-}
-static inline int request_firmware_nowait(
- struct module *module, int uevent,
- const char *name, struct device *device, gfp_t gfp, void *context,
- void (*cont)(const struct firmware *fw, void *context))
-{
- return -EINVAL;
-}
-
-static inline void release_firmware(const struct firmware *fw)
-{
-}
-#endif
-#endif
-
-/* mask KEY_RFKILL as RHEL6 backports this */
-#if !defined(KEY_RFKILL)
-#define KEY_RFKILL 247 /* Key that controls all radios */
-#endif
-/* source: include/linux/if.h */
-
-/* this will never happen on older kernels */
-#ifndef NETDEV_POST_INIT
-#define NETDEV_POST_INIT 0xffff
-#endif /* NETDEV_POST_INIT */
-
-/* mask netdev_alloc_skb_ip_align as debian squeeze also backports this */
-#define netdev_alloc_skb_ip_align(a, b) compat_netdev_alloc_skb_ip_align(a, b)
-
-static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
- unsigned int length)
-{
- struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN);
-
- if (NET_IP_ALIGN && skb)
- skb_reserve(skb, NET_IP_ALIGN);
- return skb;
-}
-
-/**
- * list_for_each_entry_continue_rcu - continue iteration over list of given type
- * @pos: the type * to use as a loop cursor.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- *
- * Continue to iterate over list of given type, continuing after
- * the current position.
- */
-#define list_for_each_entry_continue_rcu(pos, head, member) \
- for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
- pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
-
-#define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb)
-
-#define pci_pcie_cap LINUX_BACKPORT(pci_pcie_cap)
-
-/**
- * pci_pcie_cap - get the saved PCIe capability offset
- * @dev: PCI device
- *
- * PCIe capability offset is calculated at PCI device initialization
- * time and saved in the data structure. This function returns saved
- * PCIe capability offset. Using this instead of pci_find_capability()
- * reduces unnecessary search in the PCI configuration space. If you
- * need to calculate PCIe capability offset from raw device for some
- * reasons, please use pci_find_capability() instead.
- */
-static inline int pci_pcie_cap(struct pci_dev *dev)
-{
- return pci_find_capability(dev, PCI_CAP_ID_EXP);
-}
-
-#define pci_is_pcie LINUX_BACKPORT(pci_is_pcie)
-
-/**
- * pci_is_pcie - check if the PCI device is PCI Express capable
- * @dev: PCI device
- *
- * Retrun true if the PCI device is PCI Express capable, false otherwise.
- */
-static inline bool pci_is_pcie(struct pci_dev *dev)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
- return dev->is_pcie;
-#else
- return !!pci_pcie_cap(dev);
-#endif
-}
-
-#ifdef __GNUC__
-#define __always_unused __attribute__((unused))
-#else
-#define __always_unused /* unimplemented */
-#endif
-
-/* mask IS_ERR_OR_NULL as debian squeeze also backports this */
-#define IS_ERR_OR_NULL(a) compat_IS_ERR_OR_NULL(a)
-
-static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
-{
- return !ptr || IS_ERR_VALUE((unsigned long)ptr);
-}
-
-#define for_each_netdev_rcu(net, d) \
- list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
-
-#define IPV4_FLOW 0x10 /* hash only */
-#define IPV6_FLOW 0x11 /* hash only */
-
-#define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
-
-#ifndef CONFIG_COMPAT_IS_BITMAP
-
-extern void bitmap_set(unsigned long *map, int i, int len);
-extern void bitmap_clear(unsigned long *map, int start, int nr);
-extern unsigned long bitmap_find_next_zero_area(unsigned long *map,
- unsigned long size,
- unsigned long start,
- unsigned int nr,
- unsigned long align_mask);
-
-#endif /* CONFIG_COMPAT_IS_BITMAP */
-
-#ifdef CONFIG_PPC
-#ifndef NUMA_NO_NODE
-#define NUMA_NO_NODE (-1)
-#endif
-#endif /* CONFIG_PPC */
-
-#define strim LINUX_BACKPORT(strim)
-extern char *strim(char *);
-
-#define skip_spaces LINUX_BACKPORT(skip_spaces)
-extern char * __must_check skip_spaces(const char *);
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
-
-#endif /* LINUX_26_33_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_34_COMPAT_H
-#define LINUX_26_34_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34))
-
-#include <linux/netdevice.h>
-#include <linux/usb.h>
-
-#define netdev_uc_count(dev) ((dev)->uc.count)
-#define netdev_uc_empty(dev) ((dev)->uc.count == 0)
-#define netdev_for_each_uc_addr(ha, dev) \
- list_for_each_entry(ha, &dev->uc.list, list)
-
-#define netdev_mc_count(dev) ((dev)->mc_count)
-#define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0)
-
-#define netdev_for_each_mc_addr(mclist, dev) \
- for (mclist = dev->mc_list; mclist; mclist = mclist->next)
-/* source: include/linux/netdevice.h */
-
-
-/* Logging, debugging and troubleshooting/diagnostic helpers. */
-
-/* netdev_printk helpers, similar to dev_printk */
-
-#ifndef netdev_name
-#define netdev_name(__dev) \
- ((__dev->reg_state != NETREG_REGISTERED) ? \
- "(unregistered net_device)" : __dev->name)
-#endif
-
-#define netdev_printk(level, netdev, format, args...) \
- dev_printk(level, (netdev)->dev.parent, \
- "%s: " format, \
- netdev_name(netdev), ##args)
-
-#define netdev_emerg(dev, format, args...) \
- netdev_printk(KERN_EMERG, dev, format, ##args)
-#define netdev_alert(dev, format, args...) \
- netdev_printk(KERN_ALERT, dev, format, ##args)
-#define netdev_crit(dev, format, args...) \
- netdev_printk(KERN_CRIT, dev, format, ##args)
-#define netdev_err(dev, format, args...) \
- netdev_printk(KERN_ERR, dev, format, ##args)
-#define netdev_warn(dev, format, args...) \
- netdev_printk(KERN_WARNING, dev, format, ##args)
-#define netdev_notice(dev, format, args...) \
- netdev_printk(KERN_NOTICE, dev, format, ##args)
-#define netdev_info(dev, format, args...) \
- netdev_printk(KERN_INFO, dev, format, ##args)
-
-/* mask netdev_dbg as RHEL6 backports this */
-#if !defined(netdev_dbg)
-
-#if defined(DEBUG)
-#define netdev_dbg(__dev, format, args...) \
- netdev_printk(KERN_DEBUG, __dev, format, ##args)
-#elif defined(CONFIG_DYNAMIC_DEBUG)
-#define netdev_dbg(__dev, format, args...) \
-do { \
- dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \
- netdev_name(__dev), ##args); \
-} while (0)
-#else
-#define netdev_dbg(__dev, format, args...) \
-({ \
- if (0) \
- netdev_printk(KERN_DEBUG, __dev, format, ##args); \
- 0; \
-})
-#endif
-
-#endif
-
-/* mask netdev_vdbg as RHEL6 backports this */
-#if !defined(netdev_dbg)
-
-#if defined(VERBOSE_DEBUG)
-#define netdev_vdbg netdev_dbg
-#else
-
-#define netdev_vdbg(dev, format, args...) \
-({ \
- if (0) \
- netdev_printk(KERN_DEBUG, dev, format, ##args); \
- 0; \
-})
-#endif
-
-#endif
-
-/*
- * netdev_WARN() acts like dev_printk(), but with the key difference
- * of using a WARN/WARN_ON to get the message out, including the
- * file/line information and a backtrace.
- */
-#define netdev_WARN(dev, format, args...) \
- WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args);
-
-/* netif printk helpers, similar to netdev_printk */
-
-#define netif_printk(priv, type, level, dev, fmt, args...) \
-do { \
- if (netif_msg_##type(priv)) \
- netdev_printk(level, (dev), fmt, ##args); \
-} while (0)
-
-#define netif_emerg(priv, type, dev, fmt, args...) \
- netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args)
-#define netif_alert(priv, type, dev, fmt, args...) \
- netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args)
-#define netif_crit(priv, type, dev, fmt, args...) \
- netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args)
-#define netif_err(priv, type, dev, fmt, args...) \
- netif_printk(priv, type, KERN_ERR, dev, fmt, ##args)
-#define netif_warn(priv, type, dev, fmt, args...) \
- netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args)
-#define netif_notice(priv, type, dev, fmt, args...) \
- netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args)
-#define netif_info(priv, type, dev, fmt, args...) \
- netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args)
-
-/* mask netif_dbg as RHEL6 backports this */
-#if !defined(netif_dbg)
-
-#if defined(DEBUG)
-#define netif_dbg(priv, type, dev, format, args...) \
- netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
-#elif defined(CONFIG_DYNAMIC_DEBUG)
-#define netif_dbg(priv, type, netdev, format, args...) \
-do { \
- if (netif_msg_##type(priv)) \
- dynamic_dev_dbg((netdev)->dev.parent, \
- "%s: " format, \
- netdev_name(netdev), ##args); \
-} while (0)
-#else
-#define netif_dbg(priv, type, dev, format, args...) \
-({ \
- if (0) \
- netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
- 0; \
-})
-#endif
-
-#endif
-
-/* mask netif_vdbg as RHEL6 backports this */
-#if !defined(netif_vdbg)
-
-#if defined(VERBOSE_DEBUG)
-#define netif_vdbg netdev_dbg
-#else
-#define netif_vdbg(priv, type, dev, format, args...) \
-({ \
- if (0) \
- netif_printk(KERN_DEBUG, dev, format, ##args); \
- 0; \
-})
-#endif
-#endif
-/* source: include/linux/netdevice.h */
-
-
-#define device_lock LINUX_BACKPORT(device_lock)
-static inline void device_lock(struct device *dev)
-{
-#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
- mutex_lock(&dev->mutex);
-#else
- down(&dev->sem);
-#endif
-}
-
-#define device_trylock LINUX_BACKPORT(device_trylock)
-static inline int device_trylock(struct device *dev)
-{
-#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
- return mutex_trylock(&dev->mutex);
-#else
- return down_trylock(&dev->sem);
-#endif
-}
-
-#define device_unlock LINUX_BACKPORT(device_unlock)
-static inline void device_unlock(struct device *dev)
-{
-#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
- mutex_unlock(&dev->mutex);
-#else
- up(&dev->sem);
-#endif
-}
-
-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
-#define PCMCIA_DEVICE_PROD_ID3(v3, vh3) { \
- .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID3, \
- .prod_id = { NULL, NULL, (v3), NULL }, \
- .prod_id_hash = { 0, 0, (vh3), 0 }, }
-#endif
-
-#define rcu_dereference_check(p, c) rcu_dereference(p)
-
-#ifndef sysfs_attr_init
-/**
- * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
- * @attr: struct attribute to initialize
- */
-#define sysfs_attr_init(attr) do {} while(0)
-#endif /* sysfs_attr_init */
-
-/**
- * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
- * @attr: struct bin_attribute to initialize
- *
- * Initialize a dynamically allocated struct bin_attribute so we
- * can make lockdep happy. This is a new requirement for
- * attributes and initially this is only needed when lockdep is
- * enabled. Lockdep gives a nice error when your attribute is
- * added to sysfs if you don't have this.
- */
-#ifndef sysfs_bin_attr_init
-#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
-#endif /* sysfs_bin_attr_init */
-
-#define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma)
-#define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma)
-
-/* only include this if DEFINE_DMA_UNMAP_ADDR is not set as debian squeeze also backports this */
-#ifndef DEFINE_DMA_UNMAP_ADDR
-#ifdef CONFIG_NEED_DMA_MAP_STATE
-#define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME
-#define DEFINE_DMA_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME
-#define dma_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
-#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
-#define dma_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
-#define dma_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
-#else
-#define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
-#define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
-#define dma_unmap_addr(PTR, ADDR_NAME) (0)
-#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
-#define dma_unmap_len(PTR, LEN_NAME) (0)
-#define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
-#endif
-#endif
-
-/* mask dma_set_coherent_mask as debian squeeze also backports this */
-#define dma_set_coherent_mask(a, b) compat_dma_set_coherent_mask(a, b)
-
-static inline int dma_set_coherent_mask(struct device *dev, u64 mask)
-{
- if (!dma_supported(dev, mask))
- return -EIO;
- dev->coherent_dma_mask = mask;
- return 0;
-}
-
-/* USB autosuspend and autoresume */
-static inline int usb_enable_autosuspend(struct usb_device *udev)
-{ return 0; }
-static inline int usb_disable_autosuspend(struct usb_device *udev)
-{ return 0; }
-
-#ifndef rcu_dereference_protected
-#define rcu_dereference_protected(p, c) (p)
-#endif
-
-#define rcu_access_pointer(p) ACCESS_ONCE(p)
-
-#define rcu_dereference_raw(p) rcu_dereference(p)
-
-#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */
-
-/*
- * This looks more complex than it should be. But we need to
- * get the type for the ~ right in round_down (it needs to be
- * as wide as the result!), and we want to evaluate the macro
- * arguments just once each.
- */
-#define __round_mask(x, y) ((__typeof__(x))((y)-1))
-#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
-#define round_down(x, y) ((x) & ~__round_mask(x, y))
-
-#ifdef CONFIG_PROVE_LOCKING
-/*
- * Obviously, this is wrong. But the base kernel will have rtnl_mutex
- * declared static, with no way to access it. I think this is the best
- * we can do...
- */
-static inline int lockdep_rtnl_is_held(void)
-{
- return 1;
-}
-#endif /* #ifdef CONFIG_PROVE_LOCKING */
-
-#ifndef NETIF_F_NTUPLE
-#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */
-#endif
-
-
-#ifndef PCI_VPD_LRDT
-#define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */
-#define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT)
-
-/* Large Resource Data Type Tag Item Names */
-#define PCI_VPD_LTIN_ID_STRING 0x02 /* Identifier String */
-#define PCI_VPD_LTIN_RO_DATA 0x10 /* Read-Only Data */
-#define PCI_VPD_LTIN_RW_DATA 0x11 /* Read-Write Data */
-
-#define PCI_VPD_LRDT_ID_STRING PCI_VPD_LRDT_ID(PCI_VPD_LTIN_ID_STRING)
-#define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA)
-#define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
-#define PCI_VPD_LRDT_TAG_SIZE 3
-#define PCI_VPD_SRDT_TAG_SIZE 1
-
-#define PCI_VPD_INFO_FLD_HDR_SIZE 3
-
-/* Small Resource Data Type Tag Item Names */
-#define PCI_VPD_STIN_END 0x78 /* End */
-
-#define PCI_VPD_SRDT_END PCI_VPD_STIN_END
-
-#define PCI_VPD_SRDT_TIN_MASK 0x78
-#define PCI_VPD_SRDT_LEN_MASK 0x07
-#endif /* PCI_VPD_LRDT */
-
-/**
- * pci_vpd_info_field_size - Extracts the information field length
- * @lrdt: Pointer to the beginning of an information field header
- *
- * Returns the extracted information field length.
- */
-#define pci_vpd_info_field_size LINUX_BACKPORT(pci_vpd_info_field_size)
-static inline u8 pci_vpd_info_field_size(const u8 *info_field)
-{
- return info_field[2];
-}
-
-/**
- * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
- * @lrdt: Pointer to the beginning of the Large Resource Data Type tag
- *
- * Returns the extracted Large Resource Data Type length.
- */
-#define pci_vpd_lrdt_size LINUX_BACKPORT(pci_vpd_lrdt_size)
-static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
-{
- return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
-}
-
-/**
- * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD
- * @buf: Pointer to buffered vpd data
- * @off: The offset into the buffer at which to begin the search
- * @len: The length of the buffer area, relative to off, in which to search
- * @kw: The keyword to search for
- *
- * Returns the index where the information field keyword was found or
- * -ENOENT otherwise.
- */
-#define pci_vpd_find_info_keyword LINUX_BACKPORT(pci_vpd_find_info_keyword)
-int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
- unsigned int len, const char *kw);
-
-/**
- * pci_vpd_find_tag - Locates the Resource Data Type tag provided
- * @buf: Pointer to buffered vpd data
- * @off: The offset into the buffer at which to begin the search
- * @len: The length of the vpd buffer
- * @rdt: The Resource Data Type to search for
- *
- * Returns the index where the Resource Data Type was found or
- * -ENOENT otherwise.
- */
-#define pci_vpd_find_tag LINUX_BACKPORT(pci_vpd_find_tag)
-int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt);
-
-/**
- * pci_vpd_srdt_size - Extracts the Small Resource Data Type length
- * @lrdt: Pointer to the beginning of the Small Resource Data Type tag
- *
- * Returns the extracted Small Resource Data Type length.
- */
-#define pci_vpd_srdt_size LINUX_BACKPORT(pci_vpd_srdt_size)
-static inline u8 pci_vpd_srdt_size(const u8 *srdt)
-{
- return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
-}
-
-#ifndef HAVE_PCI_BUS_SPEED
-/* Based on the PCI Hotplug Spec, but some values are made up by us */
-enum pci_bus_speed {
- PCI_SPEED_33MHz = 0x00,
- PCI_SPEED_66MHz = 0x01,
- PCI_SPEED_66MHz_PCIX = 0x02,
- PCI_SPEED_100MHz_PCIX = 0x03,
- PCI_SPEED_133MHz_PCIX = 0x04,
- PCI_SPEED_66MHz_PCIX_ECC = 0x05,
- PCI_SPEED_100MHz_PCIX_ECC = 0x06,
- PCI_SPEED_133MHz_PCIX_ECC = 0x07,
- PCI_SPEED_66MHz_PCIX_266 = 0x09,
- PCI_SPEED_100MHz_PCIX_266 = 0x0a,
- PCI_SPEED_133MHz_PCIX_266 = 0x0b,
- AGP_UNKNOWN = 0x0c,
- AGP_1X = 0x0d,
- AGP_2X = 0x0e,
- AGP_4X = 0x0f,
- AGP_8X = 0x10,
- PCI_SPEED_66MHz_PCIX_533 = 0x11,
- PCI_SPEED_100MHz_PCIX_533 = 0x12,
- PCI_SPEED_133MHz_PCIX_533 = 0x13,
- PCIE_SPEED_2_5GT = 0x14,
- PCIE_SPEED_5_0GT = 0x15,
- PCIE_SPEED_8_0GT = 0x16,
- PCI_SPEED_UNKNOWN = 0xff,
-};
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */
-
-
-#endif /* LINUX_26_34_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_35_COMPAT_H
-#define LINUX_26_35_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
-#include <linux/etherdevice.h>
-#include <net/sock.h>
-#include <linux/types.h>
-#include <linux/usb.h>
-
-/* added on linux/kernel.h */
-#define USHRT_MAX ((u16)(~0U))
-#define SHRT_MAX ((s16)(USHRT_MAX>>1))
-#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
-
-#define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */
-#define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */
-
-#ifndef PCI_EXP_LNKSTA_CLS_2_5GB
-#define PCI_EXP_LNKSTA_CLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */
-#endif
-
-#ifndef PCI_EXP_LNKSTA_CLS_5_0GB
-#define PCI_EXP_LNKSTA_CLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */
-#endif
-
-/*
- * We cannot backport this guy as the IRQ data structure
- * was modified in the kernel itself to support this. We
- * treat the system as uni-processor in this case.
- */
-#define irq_set_affinity_hint LINUX_BACKPORT(irq_set_affinity_hint)
-
-static inline int irq_set_affinity_hint(unsigned int irq,
- const struct cpumask *m)
-{
- return -EINVAL;
-}
-
-static inline wait_queue_head_t *sk_sleep(struct sock *sk)
-{
- return sk->sk_sleep;
-}
-
-#define sdio_writeb_readb(func, write_byte, addr, err_ret) sdio_readb(func, addr, err_ret)
-
-#define hex_to_bin LINUX_BACKPORT(hex_to_bin)
-int hex_to_bin(char ch);
-
-#define noop_llseek LINUX_BACKPORT(noop_llseek)
-extern loff_t noop_llseek(struct file *file, loff_t offset, int origin);
-
-#define pm_qos_request(_qos) pm_qos_requirement(_qos)
-
-#ifndef __ALIGN_KERNEL
-#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
-#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */
-
-#endif /* LINUX_26_35_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_36_COMPAT_H
-#define LINUX_26_36_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
-
-#include <linux/pm_qos_params.h>
-#include <linux/smp_lock.h>
-
-#ifndef kparam_block_sysfs_write
-#define kparam_block_sysfs_write(a)
-#endif
-#ifndef kparam_unblock_sysfs_write
-#define kparam_unblock_sysfs_write(a)
-#endif
-
-/* mask va_format as RHEL6 backports this */
-#define va_format compat_va_format
-
-struct va_format {
- const char *fmt;
- va_list *va;
-};
-
-#define device_rename(dev, new_name) device_rename(dev, (char *)new_name)
-
-struct pm_qos_request_list {
- u32 qos;
- void *request;
-};
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
-
-#define pm_qos_add_request(_req, _class, _value) do { \
- (_req)->request = #_req; \
- (_req)->qos = _class; \
- pm_qos_add_requirement((_class), (_req)->request, (_value)); \
- } while(0)
-
-#define pm_qos_update_request(_req, _value) \
- pm_qos_update_requirement((_req)->qos, (_req)->request, (_value))
-
-#define pm_qos_remove_request(_req) \
- pm_qos_remove_requirement((_req)->qos, (_req)->request)
-
-#else
-
-#define pm_qos_add_request(_req, _class, _value) do { \
- (_req)->request = pm_qos_add_request((_class), (_value)); \
- } while (0)
-
-#define pm_qos_update_request(_req, _value) \
- pm_qos_update_request((_req)->request, (_value))
-
-#define pm_qos_remove_request(_req) \
- pm_qos_remove_request((_req)->request)
-
-#endif
-
-#ifdef CONFIG_COMPAT_NO_PRINTK_NEEDED
-/*
- * Dummy printk for disabled debugging statements to use whilst maintaining
- * gcc's format and side-effect checking.
- */
-static inline __attribute__ ((format (printf, 1, 2)))
-int no_printk(const char *s, ...) { return 0; }
-#endif /* CONFIG_COMPAT_NO_PRINTK_NEEDED */
-
-#ifndef alloc_workqueue
-#define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0)
-#endif
-
-#define EXTPROC 0200000
-#define TIOCPKT_IOCTL 64
-
-static inline void tty_lock(void) __acquires(kernel_lock)
-{
-#ifdef CONFIG_LOCK_KERNEL
- /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */
- WARN_ON(kernel_locked());
-#endif
- lock_kernel();
-}
-static inline void tty_unlock(void) __releases(kernel_lock)
-{
- unlock_kernel();
-}
-#define tty_locked() (kernel_locked())
-
-#define usleep_range(_min, _max) msleep((_max) / 1000)
-
-#define __rcu
-
-static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {}
-
-static inline bool skb_defer_rx_timestamp(struct sk_buff *skb)
-{
- return false;
-}
-
-#define skb_tx_timestamp LINUX_BACKPORT(skb_tx_timestamp)
-static inline void skb_tx_timestamp(struct sk_buff *skb)
-{
-}
-
-/*
- * System-wide workqueues which are always present.
- *
- * system_wq is the one used by schedule[_delayed]_work[_on]().
- * Multi-CPU multi-threaded. There are users which expect relatively
- * short queue flush time. Don't queue works which can run for too
- * long.
- *
- * system_long_wq is similar to system_wq but may host long running
- * works. Queue flushing might take relatively long.
- *
- * system_nrt_wq is non-reentrant and guarantees that any given work
- * item is never executed in parallel by multiple CPUs. Queue
- * flushing might take relatively long.
- */
-#define system_wq LINUX_BACKPORT(system_wq)
-extern struct workqueue_struct *system_wq;
-#define system_long_wq LINUX_BACKPORT(system_long_wq)
-extern struct workqueue_struct *system_long_wq;
-#define system_nrt_wq LINUX_BACKPORT(system_nrt_wq)
-extern struct workqueue_struct *system_nrt_wq;
-
-int backport_system_workqueue_create(void);
-void backport_system_workqueue_destroy(void);
-
-#define schedule_work LINUX_BACKPORT(schedule_work)
-int schedule_work(struct work_struct *work);
-#define schedule_work_on LINUX_BACKPORT(schedule_work_on)
-int schedule_work_on(int cpu, struct work_struct *work);
-#define schedule_delayed_work LINUX_BACKPORT(schedule_delayed_work)
-int schedule_delayed_work(struct delayed_work *dwork,
- unsigned long delay);
-#define schedule_delayed_work_on LINUX_BACKPORT(schedule_delayed_work_on)
-int schedule_delayed_work_on(int cpu,
- struct delayed_work *dwork,
- unsigned long delay);
-#define flush_scheduled_work LINUX_BACKPORT(flush_scheduled_work)
-void flush_scheduled_work(void);
-
-#ifndef CONFIG_COMPAT_IS_WORK_BUSY
-enum {
- /* bit mask for work_busy() return values */
- WORK_BUSY_PENDING = 1 << 0,
- WORK_BUSY_RUNNING = 1 << 1,
-};
-#endif
-
-#define work_busy LINUX_BACKPORT(work_busy)
-extern unsigned int work_busy(struct work_struct *work);
-
-#define br_port_exists(dev) (dev->br_port)
-
-#else
-
-static inline int backport_system_workqueue_create(void)
-{
- return 0;
-}
-
-static inline void backport_system_workqueue_destroy(void)
-{
-}
-
-/*
- * This is not part of The 2.6.37 kernel yet but we
- * we use it to optimize the backport code we
- * need to implement. Instead of using ifdefs
- * to check what version of the check we use
- * we just replace all checks on current code
- * with this. I'll submit this upstream too, that
- * way all we'd have to do is to implement this
- * for older kernels, then we would not have to
- * edit the upstrema code for backport efforts.
- */
-#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
-
-#ifndef __rcu
-#define __rcu
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
-
-#endif /* LINUX_26_36_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_37_COMPAT_H
-#define LINUX_26_37_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
-
-#include <linux/skbuff.h>
-#include <linux/leds.h>
-#include <linux/in.h>
-#include <linux/rcupdate.h>
-#include <linux/netdevice.h>
-#include <linux/errno.h>
-
-#ifndef HAVE_PROTO_PORTS_OFFSET
-static inline int proto_ports_offset(int proto)
-{
- switch (proto) {
- case IPPROTO_TCP:
- case IPPROTO_UDP:
- case IPPROTO_DCCP:
- case IPPROTO_ESP: /* SPI */
- case IPPROTO_SCTP:
- case IPPROTO_UDPLITE:
- return 0;
- case IPPROTO_AH: /* SPI */
- return 4;
- default:
- return -EINVAL;
- }
-}
-#endif
-
-/* supports eipoib flags, priv_flags is short till that version */
-#define CONFIG_COMPAT_IFF_EIPOIB_PIF 0x8000 /*== IFF_OVS_DATAPATH*/
-#define CONFIG_COMPAT_IFF_EIPOIB_VIF 0x4000 /*IFF_MACVLAN_PORT*/
-
-/* Definitions for tx_flags in struct skb_shared_info */
-enum {
- /* generate hardware time stamp */
- SKBTX_HW_TSTAMP = 1 << 0,
-
- /* generate software time stamp */
- SKBTX_SW_TSTAMP = 1 << 1,
-
- /* device driver is going to provide hardware time stamp */
- SKBTX_IN_PROGRESS = 1 << 2,
-
- /* ensure the originating sk reference is available on driver level */
- SKBTX_DRV_NEEDS_SK_REF = 1 << 3,
-};
-
-
-#define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */
-
-#define VLAN_N_VID 4096
-
-/*
- * netif_set_real_num_rx_queues - set actual number of RX queues used
- * @dev: Network device
- * @rxq: Actual number of RX queues
- *
- * This function actully sets the real_num_rx_queues field in struct
- * net_device. Since real_num_rx_queues field is not present in net_device
- * structure in 2.6.37 kernel making this function to set that field is not
- * possible. Hence adding this function to avoid changes in driver source
- * code and making this function to always return success.
- */
-/* mask netif_set_real_num_rx_queues as RHEL6.4 backports this */
-#ifndef HAVE_NETIF_SET_REAL_NUM_RX_QUEUES
-static inline int netif_set_real_num_rx_queues(struct net_device *dev,
- unsigned int rxq)
-{
- return 0;
-}
-#endif
-
-#define net_ns_type_operations LINUX_BACKPORT(net_ns_type_operations)
-extern struct kobj_ns_type_operations net_ns_type_operations;
-
-/* mask skb_checksum_none_assert as RHEL6 backports this */
-#define skb_checksum_none_assert(a) compat_skb_checksum_none_assert(a)
-
-/**
- * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
- * @skb: skb to check
- *
- * fresh skbs have their ip_summed set to CHECKSUM_NONE.
- * Instead of forcing ip_summed to CHECKSUM_NONE, we can
- * use this helper, to document places where we make this assertion.
- */
-static inline void skb_checksum_none_assert(struct sk_buff *skb)
-{
-#ifdef DEBUG
- BUG_ON(skb->ip_summed != CHECKSUM_NONE);
-#endif
-}
-
-#include <net/genetlink.h>
-
-struct compat_genl_info {
- struct genl_info *info;
-
- u32 snd_seq;
- u32 snd_pid;
- struct genlmsghdr *genlhdr;
- struct nlattr **attrs;
- void *user_ptr[2];
-};
-#define genl_info compat_genl_info
-
-struct compat_genl_ops {
- struct genl_ops ops;
-
- u8 cmd;
- u8 internal_flags;
- unsigned int flags;
- const struct nla_policy *policy;
-
- int (*doit)(struct sk_buff *skb, struct genl_info *info);
- int (*dumpit)(struct sk_buff *skb, struct netlink_callback *cb);
- int (*done)(struct netlink_callback *cb);
-};
-#define genl_ops compat_genl_ops
-
-struct compat_genl_family {
- struct genl_family family;
-
- struct list_head list;
-
- unsigned int id, hdrsize, version, maxattr;
- const char *name;
- bool netnsok;
-
- struct nlattr **attrbuf;
-
- int (*pre_doit)(struct genl_ops *ops, struct sk_buff *skb,
- struct genl_info *info);
-
- void (*post_doit)(struct genl_ops *ops, struct sk_buff *skb,
- struct genl_info *info);
-};
-
-#define genl_family compat_genl_family
-
-#define genl_register_family_with_ops compat_genl_register_family_with_ops
-
-int genl_register_family_with_ops(struct genl_family *family,
- struct genl_ops *ops, size_t n_ops);
-
-#define genl_unregister_family compat_genl_unregister_family
-
-int genl_unregister_family(struct genl_family *family);
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
-#define genl_info_net(_info) genl_info_net((_info)->info)
-#endif
-
-#define genlmsg_reply(_msg, _info) genlmsg_reply(_msg, (_info)->info)
-#define genlmsg_put(_skb, _pid, _seq, _fam, _flags, _cmd) genlmsg_put(_skb, _pid, _seq, &(_fam)->family, _flags, _cmd)
-#define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp)
-#define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp)
-
-
-#define led_blink_set LINUX_BACKPORT(led_blink_set)
-extern void led_blink_set(struct led_classdev *led_cdev,
- unsigned long *delay_on,
- unsigned long *delay_off);
-
-#define led_classdev_unregister compat_led_classdev_unregister
-extern void compat_led_classdev_unregister(struct led_classdev *led_cdev);
-
-#define led_brightness_set compat_led_brightness_set
-extern void compat_led_brightness_set(struct led_classdev *led_cdev,
- enum led_brightness brightness);
-
-#define alloc_ordered_workqueue(name, flags) create_singlethread_workqueue(name)
-
-#define netdev_refcnt_read(a) atomic_read(&a->refcnt)
-
-#define vzalloc LINUX_BACKPORT(vzalloc)
-#define vzalloc_node LINUX_BACKPORT(vzalloc_node)
-
-extern void *vzalloc(unsigned long size);
-extern void *vzalloc_node(unsigned long size, int node);
-
-#ifndef rtnl_dereference
-#define rtnl_dereference(p) \
- rcu_dereference_protected(p, lockdep_rtnl_is_held())
-#endif
-
-#ifndef rcu_dereference_protected
-#define rcu_dereference_protected(p, c) \
- rcu_dereference((p))
-#endif
-
-#ifndef rcu_dereference_bh
-#define rcu_dereference_bh(p) \
- rcu_dereference((p))
-#endif
-
-/**
- * RCU_INIT_POINTER() - initialize an RCU protected pointer
- *
- * Initialize an RCU-protected pointer in such a way to avoid RCU-lockdep
- * splats.
- */
-#define RCU_INIT_POINTER(p, v) \
- p = (typeof(*v) __force __rcu *)(v)
-
-#define skb_has_frag_list LINUX_BACKPORT(skb_has_frag_list)
-static inline bool skb_has_frag_list(const struct sk_buff *skb)
-{
- return skb_shinfo(skb)->frag_list != NULL;
-}
-
-/* boolean flags controlling per-interface behavior characteristics.
- * When reading, the flag indicates whether or not a certain behavior
- * is enabled/present. When writing, the flag indicates whether
- * or not the driver should turn on (set) or off (clear) a behavior.
- *
- * Some behaviors may read-only (unconditionally absent or present).
- * If such is the case, return EINVAL in the set-flags operation if the
- * flag differs from the read-only value.
- *
- * Adding missing enums for ethtool_flags in 2.6.32 kernel.
- */
-#ifndef CONFIG_COMPAT_IS_ETH_FLAG_TXVLAN
-enum additional_ethtool_flags {
- ETH_FLAG_TXVLAN = (1 << 7), /* TX VLAN offload enabled */
- ETH_FLAG_RXVLAN = (1 << 8), /* RX VLAN offload enabled */
-};
-#endif
-
-extern void unregister_netdevice_queue(struct net_device *dev,
- struct list_head *head);
-
-#ifndef max3
-#define max3(x, y, z) ({ \
- typeof(x) _max1 = (x); \
- typeof(y) _max2 = (y); \
- typeof(z) _max3 = (z); \
- (void) (&_max1 == &_max2); \
- (void) (&_max1 == &_max3); \
- _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
- (_max2 > _max3 ? _max2 : _max3); })
-#endif
-
-#ifndef CONFIG_COMPAT_XPRTRDMA_NEEDED
-struct rpc_xprt * xprt_alloc(int size, int max_req);
-void xprt_free(struct rpc_xprt *);
-#endif /* CONFIG_COMPAT_XPRTRDMA_NEEDED */
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */
-
-#endif /* LINUX_26_37_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_38_COMPAT_H
-#define LINUX_26_38_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
-
-#include <linux/kernel.h>
-#include <linux/skbuff.h>
-#include <linux/etherdevice.h>
-#include <net/sch_generic.h>
-
-#define __DEFERRED_WORK_INITIALIZER(n, f) { \
- .work = __WORK_INITIALIZER((n).work, (f)), \
- .timer = TIMER_DEFERRED_INITIALIZER(NULL, 0, 0), \
- }
-
-#define DECLARE_DEFERRED_WORK(n, f) \
- struct delayed_work n = __DEFERRED_WORK_INITIALIZER(n, f)
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
-static inline void bstats_update(struct gnet_stats_basic_packed *bstats,
- const struct sk_buff *skb)
-{
- bstats->bytes += qdisc_pkt_len((struct sk_buff *) skb);
- bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1;
-}
-static inline void qdisc_bstats_update(struct Qdisc *sch,
- const struct sk_buff *skb)
-{
- bstats_update(&sch->bstats, skb);
-}
-#else
-/*
- * kernels <= 2.6.30 do not pass a const skb to qdisc_pkt_len, and
- * gnet_stats_basic_packed did not exist (see c1a8f1f1c8)
- */
-static inline void bstats_update(struct gnet_stats_basic *bstats,
- struct sk_buff *skb)
-{
- bstats->bytes += qdisc_pkt_len(skb);
- bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1;
-}
-static inline void qdisc_bstats_update(struct Qdisc *sch,
- struct sk_buff *skb)
-{
- bstats_update(&sch->bstats, skb);
-}
-#endif
-
-
-/* rename member in struct mmc_host in include/linux/mmc/host.h */
-#define max_segs max_hw_segs
-
-
-/* Exponentially weighted moving average (EWMA) */
-
-/* For more documentation see lib/average.c */
-
-struct ewma {
- unsigned long internal;
- unsigned long factor;
- unsigned long weight;
-};
-
-#define ewma_init LINUX_BACKPORT(ewma_init)
-extern void ewma_init(struct ewma *avg, unsigned long factor,
- unsigned long weight);
-
-#define ewma_add LINUX_BACKPORT(ewma_add)
-extern struct ewma *ewma_add(struct ewma *avg, unsigned long val);
-
-#define ewma_read LINUX_BACKPORT(ewma_read)
-/**
- * ewma_read() - Get average value
- * @avg: Average structure
- *
- * Returns the average value held in @avg.
- */
-static inline unsigned long ewma_read(const struct ewma *avg)
-{
- return DIV_ROUND_CLOSEST(avg->internal, avg->factor);
-}
-
-#define pr_warn pr_warning
-#ifndef create_freezable_workqueue
-#define create_freezable_workqueue create_freezeable_workqueue
-#endif
-
-/* mask skb_checksum_start_offset as RHEL6.4 backports this */
-#define skb_checksum_start_offset(a) compat_skb_checksum_start_offset(a)
-static inline int skb_checksum_start_offset(const struct sk_buff *skb)
-{
- return skb->csum_start - skb_headroom(skb);
-}
-
-/* from include/linux/printk.h */
-#define pr_emerg_once(fmt, ...) \
- printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert_once(fmt, ...) \
- printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit_once(fmt, ...) \
- printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err_once(fmt, ...) \
- printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warn_once(fmt, ...) \
- printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_notice_once(fmt, ...) \
- printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info_once(fmt, ...) \
- printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_cont_once(fmt, ...) \
- printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
-#if defined(DEBUG)
-#define pr_debug_once(fmt, ...) \
- printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#else
-#define pr_debug_once(fmt, ...) \
- no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#endif
-
-/* include/linux/netdevice.h */
-#define alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs) \
- alloc_netdev_mq(sizeof_priv, name, setup, \
- max_t(unsigned int, txqs, rxqs))
-
-#define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */
-
-/**
- * is_unicast_ether_addr - Determine if the Ethernet address is unicast
- * @addr: Pointer to a six-byte array containing the Ethernet address
- *
- * Return true if the address is a unicast address.
- */
-#define is_unicast_ether_addr LINUX_BACKPORT(is_unicast_ether_addr)
-static inline int is_unicast_ether_addr(const u8 *addr)
-{
- return !is_multicast_ether_addr(addr);
-}
-
-static inline int netdev_queue_numa_node_read(const struct netdev_queue *q)
-{
-#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
- return q->numa_node;
-#else
- return NUMA_NO_NODE;
-#endif
-}
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */
-
-#endif /* LINUX_26_38_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_26_39_COMPAT_H
-#define LINUX_26_39_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
-
-#include <linux/tty.h>
-#include <linux/irq.h>
-#include <linux/kernel.h>
-#include <linux/netdevice.h>
-
-#define tiocmget(tty) tiocmget(tty, NULL)
-#define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear)
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
-#define tty_set_termios LINUX_BACKPORT(tty_set_termios)
-extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */
-
-#define netif_is_bond_slave LINUX_BACKPORT(netif_is_bond_slave)
-static inline int netif_is_bond_slave(struct net_device *dev)
-{
- return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
-}
-static inline int irq_set_irq_wake(unsigned int irq, unsigned int on)
-{
- return set_irq_wake(irq, on);
-}
-static inline int irq_set_chip(unsigned int irq, struct irq_chip *chip)
-{
- return set_irq_chip(irq, chip);
-}
-static inline int irq_set_handler_data(unsigned int irq, void *data)
-{
- return set_irq_data(irq, data);
-}
-static inline int irq_set_chip_data(unsigned int irq, void *data)
-{
- return set_irq_chip_data(irq, data);
-}
-#ifndef irq_set_irq_type
-static inline int irq_set_irq_type(unsigned int irq, unsigned int type)
-{
- return set_irq_type(irq, type);
-}
-#endif
-static inline int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
-{
- return set_irq_msi(irq, entry);
-}
-static inline struct irq_chip *irq_get_chip(unsigned int irq)
-{
- return get_irq_chip(irq);
-}
-static inline void *irq_get_chip_data(unsigned int irq)
-{
- return get_irq_chip_data(irq);
-}
-static inline void *irq_get_handler_data(unsigned int irq)
-{
- return get_irq_data(irq);
-}
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
-static inline void *irq_data_get_irq_handler_data(struct irq_data *d)
-{
- return irq_data_get_irq_data(d);
-}
-#endif
-
-static inline struct msi_desc *irq_get_msi_desc(unsigned int irq)
-{
- return get_irq_msi(irq);
-}
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-static inline void irq_set_noprobe(unsigned int irq)
-{
- set_irq_noprobe(irq);
-}
-static inline void irq_set_probe(unsigned int irq)
-{
- set_irq_probe(irq);
-}
-#endif
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
-static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
-{
- return get_irq_desc_chip(desc);
-}
-static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
-{
- return get_irq_desc_data(desc);
-}
-
-static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
-{
- return get_irq_desc_chip_data(desc);
-}
-
-static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
-{
- return get_irq_desc_msi(desc);
-}
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) */
-
-#ifndef CONFIG_COMPAT_IS_KSTRTOX
-/*
- * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the
- * version included in compat-wireless. We use strict_strtol to check if
- * kstrto* is already available.
- */
-#ifndef strict_strtoull
-/* Internal, do not use. */
-int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
-int __must_check _kstrtol(const char *s, unsigned int base, long *res);
-
-int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res);
-int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
-static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
-{
- /*
- * We want to shortcut function call, but
- * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
- */
- if (sizeof(unsigned long) == sizeof(unsigned long long) &&
- __alignof__(unsigned long) == __alignof__(unsigned long long))
- return kstrtoull(s, base, (unsigned long long *)res);
- else
- return _kstrtoul(s, base, res);
-}
-
-static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
-{
- /*
- * We want to shortcut function call, but
- * __builtin_types_compatible_p(long, long long) = 0.
- */
- if (sizeof(long) == sizeof(long long) &&
- __alignof__(long) == __alignof__(long long))
- return kstrtoll(s, base, (long long *)res);
- else
- return _kstrtol(s, base, res);
-}
-
-int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res);
-int __must_check kstrtoint(const char *s, unsigned int base, int *res);
-
-static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res)
-{
- return kstrtoull(s, base, res);
-}
-
-static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res)
-{
- return kstrtoll(s, base, res);
-}
-
-static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res)
-{
- return kstrtouint(s, base, res);
-}
-
-static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res)
-{
- return kstrtoint(s, base, res);
-}
-
-int __must_check kstrtou16(const char *s, unsigned int base, u16 *res);
-int __must_check kstrtos16(const char *s, unsigned int base, s16 *res);
-int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);
-int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
-#endif /* ifndef strict_strtol */
-#endif /* ifndef CONFIG_COMPAT_IS_KSTRTOX */
-
-#ifndef CONFIG_COMPAT_IS_BITOP
-static inline int test_bit_le(int nr, const void *addr)
-{
- return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
-}
-
-static inline void __set_bit_le(int nr, void *addr)
-{
- __set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
-}
-
-static inline void __clear_bit_le(int nr, void *addr)
-{
- __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
-}
-#endif
-
-#ifndef __ASSEMBLY__
-#ifndef PTR_RET
-#define PTR_RET LINUX_BACKPORT(PTR_RET)
-static inline int __must_check PTR_RET(const void *ptr)
-{
- if (IS_ERR(ptr))
- return PTR_ERR(ptr);
- else
- return 0;
-}
-#endif
-#endif
-
-#ifndef IEEE_8021QAZ_TSA_STRICT
-#define IEEE_8021QAZ_TSA_STRICT 0
-#endif
-#ifndef IEEE_8021QAZ_TSA_CB_SHAPER
-#define IEEE_8021QAZ_TSA_CB_SHAPER 1
-#endif
-#ifndef IEEE_8021QAZ_TSA_ETS
-#define IEEE_8021QAZ_TSA_ETS 2
-#endif
-#ifndef IEEE_8021QAZ_TSA_VENDOR
-#define IEEE_8021QAZ_TSA_VENDOR 255
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */
-
-#endif /* LINUX_26_39_COMPAT_H */
#include "../../compat/config.h"
#include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
#include <linux/kconfig.h>
#include <linux/if.h>
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
-#include <linux/kconfig.h>
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
-#include <generated/autoconf.h>
-#else
-#include <linux/autoconf.h>
-#endif
#include <linux/compat_autoconf.h>
#include <linux/init.h>
#include <linux/module.h>
* code introduced for *that* kernel revision.
*/
-#include <linux/compat-2.6.32.h>
-#include <linux/compat-2.6.33.h>
-#include <linux/compat-2.6.34.h>
-#include <linux/compat-2.6.35.h>
-#include <linux/compat-2.6.36.h>
-#include <linux/compat-2.6.37.h>
-#include <linux/compat-2.6.38.h>
-#include <linux/compat-2.6.39.h>
-#include <linux/compat-3.0.h>
-#include <linux/compat-3.1.h>
-#include <linux/compat-3.2.h>
-#include <linux/compat-3.3.h>
-#include <linux/compat-3.4.h>
-#include <linux/compat-3.5.h>
-#include <linux/compat-3.6.h>
-#include <linux/compat-3.7.h>
-#include <linux/compat-3.8.h>
-#include <linux/compat-3.9.h>
-#include <linux/compat-3.10.h>
#include <linux/compat-3.11.h>
#include <linux/compat-3.12.h>
#include <linux/compat-3.13.h>
+++ /dev/null
-#ifndef LINUX_3_0_COMPAT_H
-#define LINUX_3_0_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0))
-
-#include <linux/rcupdate.h>
-
-/*
- * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171
- * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is
- * called automatically. This is not implemented in older kernel
- * versions so it will result in device wrong names.
- */
-static inline int register_netdevice_name(struct net_device *dev)
-{
- int err;
-
- if (strchr(dev->name, '%')) {
- err = dev_alloc_name(dev, dev->name);
- if (err < 0)
- return err;
- }
-
- return register_netdevice(dev);
-}
-
-#define register_netdevice(dev) register_netdevice_name(dev)
-
-/* BCMA core, see drivers/bcma/ */
-#ifndef BCMA_CORE
-/* Broadcom's specific AMBA core, see drivers/bcma/ */
-struct bcma_device_id {
- __u16 manuf;
- __u16 id;
- __u8 rev;
- __u8 class;
-};
-#define BCMA_CORE(_manuf, _id, _rev, _class) \
- { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, }
-#define BCMA_CORETABLE_END \
- { 0, },
-
-#define BCMA_ANY_MANUF 0xFFFF
-#define BCMA_ANY_ID 0xFFFF
-#define BCMA_ANY_REV 0xFF
-#define BCMA_ANY_CLASS 0xFF
-#endif /* BCMA_CORE */
-
-#define mac_pton LINUX_BACKPORT(mac_pton)
-int mac_pton(const char *s, u8 *mac);
-
-#ifndef CONFIG_COMPAT_IS_KSTRTOX
-int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
-int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
-int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res);
-int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res);
-int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res);
-int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res);
-int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res);
-int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
-int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
-int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
-
-static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
-{
- return kstrtoull_from_user(s, count, base, res);
-}
-
-static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
-{
- return kstrtoll_from_user(s, count, base, res);
-}
-
-static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res)
-{
- return kstrtouint_from_user(s, count, base, res);
-}
-
-static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
-{
- return kstrtoint_from_user(s, count, base, res);
-}
-#endif
-
-#ifndef kfree_rcu
-/*
- * This adds a nested function everywhere kfree_rcu() was called. This
- * function frees the memory and is given as a function to call_rcu().
- * The rcu callback could happen every time also after the module was
- * unloaded and this will cause problems.
- */
-#define kfree_rcu(data, rcuhead) do { \
- void __kfree_rcu_fn(struct rcu_head *rcu_head) \
- { \
- void *___ptr; \
- ___ptr = container_of(rcu_head, typeof(*(data)), rcuhead);\
- kfree(___ptr); \
- } \
- call_rcu(&(data)->rcuhead, __kfree_rcu_fn); \
- } while (0)
-#endif
-
-#ifdef MODULE
-
-/*
- * The define overwriting module_exit is based on the original module_exit
- * which looks like this:
- * #define module_exit(exitfn) \
- * static inline exitcall_t __exittest(void) \
- * { return exitfn; } \
- * void cleanup_module(void) __attribute__((alias(#exitfn)));
- *
- * We replaced the call to the actual function exitfn() with a call to our
- * function which calls the original exitfn() and then rcu_barrier()
- *
- * As a module will not be unloaded that ofter it should not have a big
- * performance impact when rcu_barrier() is called on every module exit,
- * also when no kfree_rcu() backport is used in that module.
- */
-#undef module_exit
-#define module_exit(exitfn) \
- static void __exit __exit_compat(void) \
- { \
- exitfn(); \
- rcu_barrier(); \
- } \
- void cleanup_module(void) __attribute__((alias("__exit_compat")));
-
-#endif
-
-#ifndef CONFIG_COMPAT_IS_PHYS_ID_STATE
-/*
- * enum ethtool_phys_id_state - indicator state for physical identification
- * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
- * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
- * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
- * is not supported)
- * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
- * is not supported)
- */
-enum ethtool_phys_id_state {
- ETHTOOL_ID_INACTIVE,
- ETHTOOL_ID_ACTIVE,
- ETHTOOL_ID_ON,
- ETHTOOL_ID_OFF
-};
-#endif
-
-#ifndef NETLINK_RDMA
-#define NETLINK_RDMA 20
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */
-
-#endif /* LINUX_3_0_COMPAT_H */
+++ /dev/null
-#ifndef LINUX_3_1_COMPAT_H
-#define LINUX_3_1_COMPAT_H
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
-
-#include <linux/security.h>
-#include <linux/skbuff.h>
-#include <net/ip.h>
-#include <linux/idr.h>
-#include <net/dst.h>
-
-#ifndef HAVE_DST_GET_NEIGHBOUR
-static inline struct neighbour *dst_get_neighbour(struct dst_entry *dst)
-{
- return dst->neighbour;
-}
-
-static inline void dst_set_neighbour(struct dst_entry *dst, struct neighbour *neigh)
-{
- dst->neighbour = neigh;
-}
-
-static inline struct neighbour *dst_get_neighbour_raw(struct dst_entry *dst)
-{
- return rcu_dereference_raw(dst->neighbour);
-}
-#endif /* HAVE_DST_GET_NEIGHBOUR */
-
-/* Backports 56f8a75c */
-#define ip_is_fragment LINUX_BACKPORT(ip_is_fragment)
-static inline bool ip_is_fragment(const struct iphdr *iph)
-{
- return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0;
-}
-
-/* mask __netdev_alloc_skb_ip_align as RHEL6.3 backports it */
-#define __netdev_alloc_skb_ip_align(a, b, c) compat__netdev_alloc_skb_ip_align(a, b, c)
-
-static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev,
- unsigned int length, gfp_t gfp)
-{
- struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp);
-
- if (NET_IP_ALIGN && skb)
- skb_reserve(skb, NET_IP_ALIGN);
- return skb;
-}
-
-#ifdef HAVE_NETLINK_DUMP_START_5P
-#include <linux/netlink.h>
-/* remove last arg */
-#define netlink_dump_start(a, b, c, d, e, f) netlink_dump_start(a, b, c, d, e)
-#endif
-
-/*
- * Getting something that works in C and CPP for an arg that may or may
- * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1"
- * we match on the placeholder define, insert the "0," for arg1 and generate
- * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one).
- * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
- * the last step cherry picks the 2nd arg, we get a zero.
- */
-#define __ARG_PLACEHOLDER_1 0,
-#define config_enabled(cfg) _config_enabled(cfg)
-#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
-#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
-#define ___config_enabled(__ignored, val, ...) val
-#define genl_dump_check_consistent(cb, user_hdr, family)
-
-/*
- * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
- * 0 otherwise.
- *
- */
-#define IS_ENABLED(option) \
- (config_enabled(option) || config_enabled(option##_MODULE))
-
-#define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing
- * skbs on transmit */
-
-#define PCMCIA_DEVICE_MANF_CARD_PROD_ID3(manf, card, v3, vh3) { \
- .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \
- PCMCIA_DEV_ID_MATCH_CARD_ID| \
- PCMCIA_DEV_ID_MATCH_PROD_ID3, \
- .manf_id = (manf), \
- .card_id = (card), \
- .prod_id = { NULL, NULL, (v3), NULL }, \
- .prod_id_hash = { 0, 0, (vh3), 0 }, }
-
-/*
- * This has been defined in include/linux/security.h for some time, but was
- * only given an EXPORT_SYMBOL for 3.1. Add a compat_* definition to avoid
- * breaking the compile.
- */
-#define security_sk_clone(a, b) compat_security_sk_clone(a, b)
-
-static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
-{
-}
-
-/*
- * In many versions, several architectures do not seem to include an
- * atomic64_t implementation, and do not include the software emulation from
- * asm-generic/atomic64_t.
- * Detect and handle this here.
- */
-#include <asm/atomic.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && !defined(ATOMIC64_INIT) && !defined(CONFIG_X86) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64))
-#include <asm-generic/atomic64.h>
-#endif
-
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */
-
-#endif /* LINUX_3_1_COMPAT_H */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0))
#include <linux/netdevice.h>
-#include <linux/sched/prio.h>
#ifndef AF_IB
#define AF_IB 27 /* Native InfiniBand address */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0))
-#include <linux/sched/prio.h>
-
#ifndef HAVE_REINIT_COMPLETION
#define HAVE_REINIT_COMPLETION
+++ /dev/null
-/*
- * Copyright (c) 2011 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef __CORDIC_H_
-#define __CORDIC_H_
-
-#include <linux/types.h>
-
-/**
- * struct cordic_iq - i/q coordinate.
- *
- * @i: real part of coordinate (in phase).
- * @q: imaginary part of coordinate (quadrature).
- */
-struct cordic_iq {
- s32 i;
- s32 q;
-};
-
-/**
- * cordic_calc_iq() - calculates the i/q coordinate for given angle.
- *
- * @theta: angle in degrees for which i/q coordinate is to be calculated.
- * @coord: function output parameter holding the i/q coordinate.
- *
- * The function calculates the i/q coordinate for a given angle using
- * cordic algorithm. The coordinate consists of a real (i) and an
- * imaginary (q) part. The real part is essentially the cosine of the
- * angle and the imaginary part is the sine of the angle. The returned
- * values are scaled by 2^16 for precision. The range for theta is
- * for -180 degrees to +180 degrees. Passed values outside this range are
- * converted before doing the actual calculation.
- */
-struct cordic_iq cordic_calc_iq(s32 theta);
-
-#endif /* __CORDIC_H_ */
+++ /dev/null
-#ifndef _COMPAT_LINUX_CPU_RMAP_H
-#define _COMPAT_LINUX_CPU_RMAP_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) || defined (CONFIG_COMPAT_IS_LINUX_CPU_RMAP)
-#include_next <linux/cpu_rmap.h>
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */
-
-#endif /* _COMPAT_LINUX_CPU_RMAP_H */
+++ /dev/null
-/*
- * Copyright (c) 2011 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef __CRC8_H_
-#define __CRC8_H_
-
-#include <linux/types.h>
-
-/* see usage of this value in crc8() description */
-#define CRC8_INIT_VALUE 0xFF
-
-/*
- * Return value of crc8() indicating valid message+crc. This is true
- * if a CRC is inverted before transmission. The CRC computed over the
- * whole received bitstream is _table[x], where x is the bit pattern
- * of the modification (almost always 0xff).
- */
-#define CRC8_GOOD_VALUE(_table) (_table[0xFF])
-
-/* required table size for crc8 algorithm */
-#define CRC8_TABLE_SIZE 256
-
-/* helper macro assuring right table size is used */
-#define DECLARE_CRC8_TABLE(_table) \
- static u8 _table[CRC8_TABLE_SIZE]
-
-/**
- * crc8_populate_lsb - fill crc table for given polynomial in regular bit order.
- *
- * @table: table to be filled.
- * @polynomial: polynomial for which table is to be filled.
- *
- * This function fills the provided table according the polynomial provided for
- * regular bit order (lsb first). Polynomials in CRC algorithms are typically
- * represented as shown below.
- *
- * poly = x^8 + x^7 + x^6 + x^4 + x^2 + 1
- *
- * For lsb first direction x^7 maps to the lsb. So the polynomial is as below.
- *
- * - lsb first: poly = 10101011(1) = 0xAB
- */
-void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial);
-
-/**
- * crc8_populate_msb - fill crc table for given polynomial in reverse bit order.
- *
- * @table: table to be filled.
- * @polynomial: polynomial for which table is to be filled.
- *
- * This function fills the provided table according the polynomial provided for
- * reverse bit order (msb first). Polynomials in CRC algorithms are typically
- * represented as shown below.
- *
- * poly = x^8 + x^7 + x^6 + x^4 + x^2 + 1
- *
- * For msb first direction x^7 maps to the msb. So the polynomial is as below.
- *
- * - msb first: poly = (1)11010101 = 0xD5
- */
-void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial);
-
-/**
- * crc8() - calculate a crc8 over the given input data.
- *
- * @table: crc table used for calculation.
- * @pdata: pointer to data buffer.
- * @nbytes: number of bytes in data buffer.
- * @crc: previous returned crc8 value.
- *
- * The CRC8 is calculated using the polynomial given in crc8_populate_msb()
- * or crc8_populate_lsb().
- *
- * The caller provides the initial value (either %CRC8_INIT_VALUE
- * or the previous returned value) to allow for processing of
- * discontiguous blocks of data. When generating the CRC the
- * caller is responsible for complementing the final return value
- * and inserting it into the byte stream. When validating a byte
- * stream (including CRC8), a final return value of %CRC8_GOOD_VALUE
- * indicates the byte stream data can be considered valid.
- *
- * Reference:
- * "A Painless Guide to CRC Error Detection Algorithms", ver 3, Aug 1993
- * Williams, Ross N., ross<at>ross.net
- * (see URL http://www.ross.net/crc/download/crc_v3.txt).
- */
-u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc);
-
-#endif /* __CRC8_H_ */
+++ /dev/null
-#ifndef LINUX_DCBNL_H
-#define LINUX_DCBNL_H
-
-#include "../../compat/config.h"
-
-#include_next <linux/dcbnl.h>
-
-#ifndef HAVE_IEEE_GETQCN
-
-#ifndef HAVE_STRUCT_IEEE_QCN
-enum dcbnl_cndd_states {
- DCB_CNDD_RESET = 0,
- DCB_CNDD_EDGE,
- DCB_CNDD_INTERIOR,
- DCB_CNDD_INTERIOR_READY,
-};
-
-struct ieee_qcn {
- __u8 rpg_enable[IEEE_8021QAZ_MAX_TCS];
- __u32 rppp_max_rps[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_time_reset[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_byte_reset[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_threshold[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_max_rate[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_ai_rate[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_hai_rate[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_gd[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_min_dec_fac[IEEE_8021QAZ_MAX_TCS];
- __u32 rpg_min_rate[IEEE_8021QAZ_MAX_TCS];
- __u32 cndd_state_machine[IEEE_8021QAZ_MAX_TCS];
-};
-#endif /* HAVE_STRUCT_IEEE_QCN */
-
-/* RH7.3 backported this struct, but it does not have
- * all needed feilds as below
- * */
-#define ieee_qcn_stats mlnx_ofed_ieee_qcn_stats
-struct ieee_qcn_stats {
- __u64 rppp_rp_centiseconds[IEEE_8021QAZ_MAX_TCS];
- __u32 rppp_created_rps[IEEE_8021QAZ_MAX_TCS];
- __u32 ignored_cnm[IEEE_8021QAZ_MAX_TCS];
- __u32 estimated_total_rate[IEEE_8021QAZ_MAX_TCS];
- __u32 cnms_handled_successfully[IEEE_8021QAZ_MAX_TCS];
- __u32 min_total_limiters_rate[IEEE_8021QAZ_MAX_TCS];
- __u32 max_total_limiters_rate[IEEE_8021QAZ_MAX_TCS];
-};
-
-#endif
-
-#endif /* LINUX_DCBNL_H */
+++ /dev/null
-#ifndef LINUX_ETHERDEVICE_H
-#define LINUX_ETHERDEVICE_H
-
-#include "../../compat/config.h"
-
-#include_next <linux/etherdevice.h>
-
-#ifndef HAVE_ETHER_ADDR_COPY
-/**
- * ether_addr_copy - Copy an Ethernet address
- * @dst: Pointer to a six-byte array Ethernet address destination
- * @src: Pointer to a six-byte array Ethernet address source
- *
- * Please note: dst & src must both be aligned to u16.
- */
-static inline void ether_addr_copy(u8 *dst, const u8 *src)
-{
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
- *(u32 *)dst = *(const u32 *)src;
- *(u16 *)(dst + 4) = *(const u16 *)(src + 4);
-#else
- u16 *a = (u16 *)dst;
- const u16 *b = (const u16 *)src;
-
- a[0] = b[0];
- a[1] = b[1];
- a[2] = b[2];
-#endif
-}
-#endif /* HAVE_ETHER_ADDR_COPY*/
-
-#endif /* LINUX_ETHERDEVICE_H */
+++ /dev/null
-#ifndef __COMPAT_ETHTOOL_H
-#define __COMPAT_ETHTOOL_H
-
-#include_next <linux/ethtool.h>
-
-#ifndef ETH_MODULE_SFF_8636
-#define ETH_MODULE_SFF_8636 0x3
-#define ETH_MODULE_SFF_8636_LEN 256
-#endif
-
-#ifndef ETH_MODULE_SFF_8436
-#define ETH_MODULE_SFF_8436 0x4
-#define ETH_MODULE_SFF_8436_LEN 256
-#endif
-
-#ifndef SPEED_20000
-#define SPEED_20000 20000
-#define SUPPORTED_20000baseMLD2_Full (1 << 21)
-#define SUPPORTED_20000baseKR2_Full (1 << 22)
-#define ADVERTISED_20000baseMLD2_Full (1 << 21)
-#define ADVERTISED_20000baseKR2_Full (1 << 22)
-#endif
-
-#ifndef SPEED_40000
-#define SPEED_40000 40000
-#endif
-
-#ifndef SPEED_56000
-#define SPEED_56000 56000
-#define SUPPORTED_56000baseKR4_Full (1 << 27)
-#define SUPPORTED_56000baseCR4_Full (1 << 28)
-#define SUPPORTED_56000baseSR4_Full (1 << 29)
-#define SUPPORTED_56000baseLR4_Full (1 << 30)
-#define ADVERTISED_56000baseKR4_Full (1 << 27)
-#define ADVERTISED_56000baseCR4_Full (1 << 28)
-#define ADVERTISED_56000baseSR4_Full (1 << 29)
-#define ADVERTISED_56000baseLR4_Full (1 << 30)
-#endif
-
-#define SPEED_25000 25000
-#define SPEED_50000 50000
-#define SPEED_100000 100000
-/*TODO Ethtool new SPEED API */
-#define SUPPORTED_100000baseCR4_Full 0
-#define ADVERTISED_100000baseCR4_Full 0
-#define SUPPORTED_100000baseSR4_Full 0
-#define ADVERTISED_100000baseSR4_Full 0
-#define SUPPORTED_100000baseKR4_Full 0
-#define ADVERTISED_100000baseKR4_Full 0
-#define SUPPORTED_1000000baseLR4_Full 0
-#define ADVERTISED_1000000baseLR4_Full 0
-#define SUPPORTED_100baseTX_Full 0
-#define ADVERTISED_100baseTX_Full 0
-#define SUPPORTED_25000baseCR_Full 0
-#define ADVERTISED_25000baseCR_Full 0
-#define SUPPORTED_25000baseKR_Full 0
-#define ADVERTISED_25000baseKR_Full 0
-#define SUPPORTED_25000baseSR_Full 0
-#define ADVERTISED_25000baseSR_Full 0
-#define SUPPORTED_50000baseCR2_Full 0
-#define ADVERTISED_50000baseCR2_Full 0
-#define SUPPORTED_50000baseKR2_Full 0
-#define ADVERTISED_50000baseKR2_Full 0
-
-#ifndef SPEED_UNKNOWN
-#define SPEED_UNKNOWN -1
-#endif
-
-#ifndef DUPLEX_UNKNOWN
-#define DUPLEX_UNKNOWN -1
-#endif
-
-#ifndef SUPPORTED_40000baseKR4_Full
-/* Add missing defines for supported and advertised speed features */
-#define SUPPORTED_40000baseKR4_Full (1 << 23)
-#define SUPPORTED_40000baseCR4_Full (1 << 24)
-#define SUPPORTED_40000baseSR4_Full (1 << 25)
-#define SUPPORTED_40000baseLR4_Full (1 << 26)
-#define ADVERTISED_40000baseKR4_Full (1 << 23)
-#define ADVERTISED_40000baseCR4_Full (1 << 24)
-#define ADVERTISED_40000baseSR4_Full (1 << 25)
-#define ADVERTISED_40000baseLR4_Full (1 << 26)
-#endif
-#endif
+++ /dev/null
-#ifndef _COMPAT_LINUX_EXPORT_H
-#define _COMPAT_LINUX_EXPORT_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
-#include_next <linux/export.h>
-#else
-#include <linux/module.h>
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
-
-#endif /* _COMPAT_LINUX_EXPORT_H */
+++ /dev/null
-#ifndef LINUX_IF_VLAN_H
-#define LINUX_IF_VLAN_H
-
-#include "../../compat/config.h"
-
-#include_next <linux/if_vlan.h>
-
-#ifndef skb_vlan_tag_present
-#define skb_vlan_tag_present vlan_tx_tag_present
-#define skb_vlan_tag_get vlan_tx_tag_get
-#define skb_vlan_tag_get_id vlan_tx_tag_get_id
-#endif
-
-#ifndef HAVE_IS_VLAN_DEV
-static inline int is_vlan_dev(struct net_device *dev)
-{
- return dev->priv_flags & IFF_802_1Q_VLAN;
-}
-#endif
-
-#ifndef ETH_P_8021AD
-#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */
-#endif
-
-#ifndef HAVE_VLAN_GET_PROTOCOL
-/**
- * vlan_get_protocol - get protocol EtherType.
- * @skb: skbuff to query
- * @type: first vlan protocol
- * @depth: buffer to store length of eth and vlan tags in bytes
- *
- * Returns the EtherType of the packet, regardless of whether it is
- * vlan encapsulated (normal or hardware accelerated) or not.
- */
-static inline __be16 __vlan_get_protocol(struct sk_buff *skb, __be16 type,
- int *depth)
-{
- unsigned int vlan_depth = skb->mac_len;
-
- /* if type is 802.1Q/AD then the header should already be
- * present at mac_len - VLAN_HLEN (if mac_len > 0), or at
- * ETH_HLEN otherwise
- */
- if (type == htons(ETH_P_8021Q) || type == htons(ETH_P_8021AD)) {
- if (vlan_depth) {
- if (WARN_ON(vlan_depth < VLAN_HLEN))
- return 0;
- vlan_depth -= VLAN_HLEN;
- } else {
- vlan_depth = ETH_HLEN;
- }
- do {
- struct vlan_hdr *vh;
-
- if (unlikely(!pskb_may_pull(skb,
- vlan_depth + VLAN_HLEN)))
- return 0;
-
- vh = (struct vlan_hdr *)(skb->data + vlan_depth);
- type = vh->h_vlan_encapsulated_proto;
- vlan_depth += VLAN_HLEN;
- } while (type == htons(ETH_P_8021Q) ||
- type == htons(ETH_P_8021AD));
- }
-
- if (depth)
- *depth = vlan_depth;
-
- return type;
-}
-#endif
-
-#endif /* LINUX_IF_VLAN_H */
+++ /dev/null
-#ifndef _COMPAT_LINUX_IRQ_POLL_H
-#define _COMPAT_LINUX_IRQ_POLL_H 1
-
-#include "../../compat/config.h"
-
-#ifdef HAVE_IRQ_POLL_H
-#include_next <linux/irq_poll.h>
-#endif
-
-#endif /* _COMPAT_LINUX_IRQ_POLL_H */
+++ /dev/null
-#ifndef COMPAT_KERNEL_H
-#define COMPAT_KERNEL_H
-
-#include "../../compat/config.h"
-
-#include_next <linux/kernel.h>
-
-#ifndef DIV_ROUND_UP_ULL
-#define DIV_ROUND_UP_ULL(ll,d) \
- ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; })
-#endif
-
-#ifndef SIZE_MAX
-#define SIZE_MAX (~(size_t)0)
-#endif
-
-#ifndef U16_MAX
-#define U16_MAX ((u16)~0U)
-#endif
-
-#ifndef U32_MAX
-#define U32_MAX ((u32)~0U)
-#endif
-
-#ifndef U64_MAX
-#define U64_MAX ((u64)~0U)
-#endif
-
-#ifdef __KERNEL__
-#ifndef HAVE_RECIPROCAL_SCALE
-static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
-{
- return (u32)(((u64) val * ep_ro) >> 32);
-}
-#endif
-#endif /* __KERNEL__ */
-
-#endif /* COMPAT_KERNEL_H */
+++ /dev/null
-#include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
-#include_next <linux/kfifo.h>
-#else
-/*
- * A generic kernel FIFO implementation
- *
- * Copyright (C) 2009/2010 Stefani Seibold <stefani@seibold.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _LINUX_KFIFO_H
-#define _LINUX_KFIFO_H
-
-/*
- * How to porting drivers to the new generic FIFO API:
- *
- * - Modify the declaration of the "struct kfifo *" object into a
- * in-place "struct kfifo" object
- * - Init the in-place object with kfifo_alloc() or kfifo_init()
- * Note: The address of the in-place "struct kfifo" object must be
- * passed as the first argument to this functions
- * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get
- * into kfifo_out
- * - Replace the use of kfifo_put into kfifo_in_spinlocked and kfifo_get
- * into kfifo_out_spinlocked
- * Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc
- * must be passed now to the kfifo_in_spinlocked and kfifo_out_spinlocked
- * as the last parameter
- * - The formerly __kfifo_* functions are renamed into kfifo_*
- */
-
-/*
- * Note about locking : There is no locking required until only * one reader
- * and one writer is using the fifo and no kfifo_reset() will be * called
- * kfifo_reset_out() can be safely used, until it will be only called
- * in the reader thread.
- * For multiple writer and one reader there is only a need to lock the writer.
- * And vice versa for only one writer and multiple reader there is only a need
- * to lock the reader.
- */
-
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/stddef.h>
-#include <linux/scatterlist.h>
-
-struct __kfifo {
- unsigned int in;
- unsigned int out;
- unsigned int mask;
- unsigned int esize;
- void *data;
-};
-
-#define __STRUCT_KFIFO_COMMON(datatype, recsize, ptrtype) \
- union { \
- struct __kfifo kfifo; \
- datatype *type; \
- char (*rectype)[recsize]; \
- ptrtype *ptr; \
- const ptrtype *ptr_const; \
- }
-
-#define __STRUCT_KFIFO(type, size, recsize, ptrtype) \
-{ \
- __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
- type buf[((size < 2) || (size & (size - 1))) ? -1 : size]; \
-}
-
-#define STRUCT_KFIFO(type, size) \
- struct __STRUCT_KFIFO(type, size, 0, type)
-
-#define __STRUCT_KFIFO_PTR(type, recsize, ptrtype) \
-{ \
- __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
- type buf[0]; \
-}
-
-#define STRUCT_KFIFO_PTR(type) \
- struct __STRUCT_KFIFO_PTR(type, 0, type)
-
-/*
- * define compatibility "struct kfifo" for dynamic allocated fifos
- */
-struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void);
-
-#define STRUCT_KFIFO_REC_1(size) \
- struct __STRUCT_KFIFO(unsigned char, size, 1, void)
-
-#define STRUCT_KFIFO_REC_2(size) \
- struct __STRUCT_KFIFO(unsigned char, size, 2, void)
-
-/*
- * define kfifo_rec types
- */
-struct kfifo_rec_ptr_1 __STRUCT_KFIFO_PTR(unsigned char, 1, void);
-struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
-
-/*
- * helper macro to distinguish between real in place fifo where the fifo
- * array is a part of the structure and the fifo type where the array is
- * outside of the fifo structure.
- */
-#define __is_kfifo_ptr(fifo) (sizeof(*fifo) == sizeof(struct __kfifo))
-
-/**
- * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object
- * @fifo: name of the declared fifo
- * @type: type of the fifo elements
- */
-#define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo
-
-/**
- * DECLARE_KFIFO - macro to declare a fifo object
- * @fifo: name of the declared fifo
- * @type: type of the fifo elements
- * @size: the number of elements in the fifo, this must be a power of 2
- */
-#define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo
-
-/**
- * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
- * @fifo: name of the declared fifo datatype
- */
-#define INIT_KFIFO(fifo) \
-(void)({ \
- typeof(&(fifo)) __tmp = &(fifo); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- __kfifo->in = 0; \
- __kfifo->out = 0; \
- __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : ARRAY_SIZE(__tmp->buf) - 1;\
- __kfifo->esize = sizeof(*__tmp->buf); \
- __kfifo->data = __is_kfifo_ptr(__tmp) ? NULL : __tmp->buf; \
-})
-
-/**
- * DEFINE_KFIFO - macro to define and initialize a fifo
- * @fifo: name of the declared fifo datatype
- * @type: type of the fifo elements
- * @size: the number of elements in the fifo, this must be a power of 2
- *
- * Note: the macro can be used for global and local fifo data type variables.
- */
-#define DEFINE_KFIFO(fifo, type, size) \
- DECLARE_KFIFO(fifo, type, size) = \
- (typeof(fifo)) { \
- { \
- { \
- .in = 0, \
- .out = 0, \
- .mask = __is_kfifo_ptr(&(fifo)) ? \
- 0 : \
- ARRAY_SIZE((fifo).buf) - 1, \
- .esize = sizeof(*(fifo).buf), \
- .data = __is_kfifo_ptr(&(fifo)) ? \
- NULL : \
- (fifo).buf, \
- } \
- } \
- }
-
-
-static inline unsigned int __must_check
-__kfifo_uint_must_check_helper(unsigned int val)
-{
- return val;
-}
-
-static inline int __must_check
-__kfifo_int_must_check_helper(int val)
-{
- return val;
-}
-
-/**
- * kfifo_initialized - Check if the fifo is initialized
- * @fifo: address of the fifo to check
- *
- * Return %true if fifo is initialized, otherwise %false.
- * Assumes the fifo was 0 before.
- */
-#define kfifo_initialized(fifo) ((fifo)->kfifo.mask)
-
-/**
- * kfifo_esize - returns the size of the element managed by the fifo
- * @fifo: address of the fifo to be used
- */
-#define kfifo_esize(fifo) ((fifo)->kfifo.esize)
-
-/**
- * kfifo_recsize - returns the size of the record length field
- * @fifo: address of the fifo to be used
- */
-#define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype))
-
-/**
- * kfifo_size - returns the size of the fifo in elements
- * @fifo: address of the fifo to be used
- */
-#define kfifo_size(fifo) ((fifo)->kfifo.mask + 1)
-
-/**
- * kfifo_reset - removes the entire fifo content
- * @fifo: address of the fifo to be used
- *
- * Note: usage of kfifo_reset() is dangerous. It should be only called when the
- * fifo is exclusived locked or when it is secured that no other thread is
- * accessing the fifo.
- */
-#define kfifo_reset(fifo) \
-(void)({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- __tmp->kfifo.in = __tmp->kfifo.out = 0; \
-})
-
-/**
- * kfifo_reset_out - skip fifo content
- * @fifo: address of the fifo to be used
- *
- * Note: The usage of kfifo_reset_out() is safe until it will be only called
- * from the reader thread and there is only one concurrent reader. Otherwise
- * it is dangerous and must be handled in the same way as kfifo_reset().
- */
-#define kfifo_reset_out(fifo) \
-(void)({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- __tmp->kfifo.out = __tmp->kfifo.in; \
-})
-
-/**
- * kfifo_len - returns the number of used elements in the fifo
- * @fifo: address of the fifo to be used
- */
-#define kfifo_len(fifo) \
-({ \
- typeof((fifo) + 1) __tmpl = (fifo); \
- __tmpl->kfifo.in - __tmpl->kfifo.out; \
-})
-
-/**
- * kfifo_is_empty - returns true if the fifo is empty
- * @fifo: address of the fifo to be used
- */
-#define kfifo_is_empty(fifo) \
-({ \
- typeof((fifo) + 1) __tmpq = (fifo); \
- __tmpq->kfifo.in == __tmpq->kfifo.out; \
-})
-
-/**
- * kfifo_is_full - returns true if the fifo is full
- * @fifo: address of the fifo to be used
- */
-#define kfifo_is_full(fifo) \
-({ \
- typeof((fifo) + 1) __tmpq = (fifo); \
- kfifo_len(__tmpq) > __tmpq->kfifo.mask; \
-})
-
-/**
- * kfifo_avail - returns the number of unused elements in the fifo
- * @fifo: address of the fifo to be used
- */
-#define kfifo_avail(fifo) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmpq = (fifo); \
- const size_t __recsize = sizeof(*__tmpq->rectype); \
- unsigned int __avail = kfifo_size(__tmpq) - kfifo_len(__tmpq); \
- (__recsize) ? ((__avail <= __recsize) ? 0 : \
- __kfifo_max_r(__avail - __recsize, __recsize)) : \
- __avail; \
-}) \
-)
-
-/**
- * kfifo_skip - skip output data
- * @fifo: address of the fifo to be used
- */
-#define kfifo_skip(fifo) \
-(void)({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (__recsize) \
- __kfifo_skip_r(__kfifo, __recsize); \
- else \
- __kfifo->out++; \
-})
-
-/**
- * kfifo_peek_len - gets the size of the next fifo record
- * @fifo: address of the fifo to be used
- *
- * This function returns the size of the next fifo record in number of bytes.
- */
-#define kfifo_peek_len(fifo) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- (!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \
- __kfifo_len_r(__kfifo, __recsize); \
-}) \
-)
-
-/**
- * kfifo_alloc - dynamically allocates a new fifo buffer
- * @fifo: pointer to the fifo
- * @size: the number of elements in the fifo, this must be a power of 2
- * @gfp_mask: get_free_pages mask, passed to kmalloc()
- *
- * This macro dynamically allocates a new fifo buffer.
- *
- * The numer of elements will be rounded-up to a power of 2.
- * The fifo will be release with kfifo_free().
- * Return 0 if no error, otherwise an error code.
- */
-#define kfifo_alloc(fifo, size, gfp_mask) \
-__kfifo_int_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- __is_kfifo_ptr(__tmp) ? \
- __kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \
- -EINVAL; \
-}) \
-)
-
-/**
- * kfifo_free - frees the fifo
- * @fifo: the fifo to be freed
- */
-#define kfifo_free(fifo) \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (__is_kfifo_ptr(__tmp)) \
- __kfifo_free(__kfifo); \
-})
-
-/**
- * kfifo_init - initialize a fifo using a preallocated buffer
- * @fifo: the fifo to assign the buffer
- * @buffer: the preallocated buffer to be used
- * @size: the size of the internal buffer, this have to be a power of 2
- *
- * This macro initialize a fifo using a preallocated buffer.
- *
- * The numer of elements will be rounded-up to a power of 2.
- * Return 0 if no error, otherwise an error code.
- */
-#define kfifo_init(fifo, buffer, size) \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- __is_kfifo_ptr(__tmp) ? \
- __kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \
- -EINVAL; \
-})
-
-/**
- * kfifo_put - put data into the fifo
- * @fifo: address of the fifo to be used
- * @val: the data to be added
- *
- * This macro copies the given value into the fifo.
- * It returns 0 if the fifo was full. Otherwise it returns the number
- * processed elements.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_put(fifo, val) \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- typeof((val) + 1) __val = (val); \
- unsigned int __ret; \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
- __dummy = (typeof(__val))NULL; \
- } \
- if (__recsize) \
- __ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \
- __recsize); \
- else { \
- __ret = !kfifo_is_full(__tmp); \
- if (__ret) { \
- (__is_kfifo_ptr(__tmp) ? \
- ((typeof(__tmp->type))__kfifo->data) : \
- (__tmp->buf) \
- )[__kfifo->in & __tmp->kfifo.mask] = \
- *(typeof(__tmp->type))__val; \
- smp_wmb(); \
- __kfifo->in++; \
- } \
- } \
- __ret; \
-})
-
-/**
- * kfifo_get - get data from the fifo
- * @fifo: address of the fifo to be used
- * @val: the var where to store the data to be added
- *
- * This macro reads the data from the fifo.
- * It returns 0 if the fifo was empty. Otherwise it returns the number
- * processed elements.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_get(fifo, val) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- typeof((val) + 1) __val = (val); \
- unsigned int __ret; \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) \
- __val = (typeof(__tmp->ptr))0; \
- if (__recsize) \
- __ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \
- __recsize); \
- else { \
- __ret = !kfifo_is_empty(__tmp); \
- if (__ret) { \
- *(typeof(__tmp->type))__val = \
- (__is_kfifo_ptr(__tmp) ? \
- ((typeof(__tmp->type))__kfifo->data) : \
- (__tmp->buf) \
- )[__kfifo->out & __tmp->kfifo.mask]; \
- smp_wmb(); \
- __kfifo->out++; \
- } \
- } \
- __ret; \
-}) \
-)
-
-/**
- * kfifo_peek - get data from the fifo without removing
- * @fifo: address of the fifo to be used
- * @val: the var where to store the data to be added
- *
- * This reads the data from the fifo without removing it from the fifo.
- * It returns 0 if the fifo was empty. Otherwise it returns the number
- * processed elements.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_peek(fifo, val) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- typeof((val) + 1) __val = (val); \
- unsigned int __ret; \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) \
- __val = (typeof(__tmp->ptr))NULL; \
- if (__recsize) \
- __ret = __kfifo_out_peek_r(__kfifo, __val, sizeof(*__val), \
- __recsize); \
- else { \
- __ret = !kfifo_is_empty(__tmp); \
- if (__ret) { \
- *(typeof(__tmp->type))__val = \
- (__is_kfifo_ptr(__tmp) ? \
- ((typeof(__tmp->type))__kfifo->data) : \
- (__tmp->buf) \
- )[__kfifo->out & __tmp->kfifo.mask]; \
- smp_wmb(); \
- } \
- } \
- __ret; \
-}) \
-)
-
-/**
- * kfifo_in - put data into the fifo
- * @fifo: address of the fifo to be used
- * @buf: the data to be added
- * @n: number of elements to be added
- *
- * This macro copies the given buffer into the fifo and returns the
- * number of copied elements.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_in(fifo, buf, n) \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- typeof((buf) + 1) __buf = (buf); \
- unsigned long __n = (n); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
- __dummy = (typeof(__buf))NULL; \
- } \
- (__recsize) ?\
- __kfifo_in_r(__kfifo, __buf, __n, __recsize) : \
- __kfifo_in(__kfifo, __buf, __n); \
-})
-
-/**
- * kfifo_in_spinlocked - put data into the fifo using a spinlock for locking
- * @fifo: address of the fifo to be used
- * @buf: the data to be added
- * @n: number of elements to be added
- * @lock: pointer to the spinlock to use for locking
- *
- * This macro copies the given values buffer into the fifo and returns the
- * number of copied elements.
- */
-#define kfifo_in_spinlocked(fifo, buf, n, lock) \
-({ \
- unsigned long __flags; \
- unsigned int __ret; \
- spin_lock_irqsave(lock, __flags); \
- __ret = kfifo_in(fifo, buf, n); \
- spin_unlock_irqrestore(lock, __flags); \
- __ret; \
-})
-
-/* alias for kfifo_in_spinlocked, will be removed in a future release */
-#define kfifo_in_locked(fifo, buf, n, lock) \
- kfifo_in_spinlocked(fifo, buf, n, lock)
-
-/**
- * kfifo_out - get data from the fifo
- * @fifo: address of the fifo to be used
- * @buf: pointer to the storage buffer
- * @n: max. number of elements to get
- *
- * This macro get some data from the fifo and return the numbers of elements
- * copied.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_out(fifo, buf, n) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- typeof((buf) + 1) __buf = (buf); \
- unsigned long __n = (n); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr) __dummy = NULL; \
- __buf = __dummy; \
- } \
- (__recsize) ?\
- __kfifo_out_r(__kfifo, __buf, __n, __recsize) : \
- __kfifo_out(__kfifo, __buf, __n); \
-}) \
-)
-
-/**
- * kfifo_out_spinlocked - get data from the fifo using a spinlock for locking
- * @fifo: address of the fifo to be used
- * @buf: pointer to the storage buffer
- * @n: max. number of elements to get
- * @lock: pointer to the spinlock to use for locking
- *
- * This macro get the data from the fifo and return the numbers of elements
- * copied.
- */
-#define kfifo_out_spinlocked(fifo, buf, n, lock) \
-__kfifo_uint_must_check_helper( \
-({ \
- unsigned long __flags; \
- unsigned int __ret; \
- spin_lock_irqsave(lock, __flags); \
- __ret = kfifo_out(fifo, buf, n); \
- spin_unlock_irqrestore(lock, __flags); \
- __ret; \
-}) \
-)
-
-/* alias for kfifo_out_spinlocked, will be removed in a future release */
-#define kfifo_out_locked(fifo, buf, n, lock) \
- kfifo_out_spinlocked(fifo, buf, n, lock)
-
-/**
- * kfifo_from_user - puts some data from user space into the fifo
- * @fifo: address of the fifo to be used
- * @from: pointer to the data to be added
- * @len: the length of the data to be added
- * @copied: pointer to output variable to store the number of copied bytes
- *
- * This macro copies at most @len bytes from the @from into the
- * fifo, depending of the available space and returns -EFAULT/0.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_from_user(fifo, from, len, copied) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- const void __user *__from = (from); \
- unsigned int __len = (len); \
- unsigned int *__copied = (copied); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- (__recsize) ? \
- __kfifo_from_user_r(__kfifo, __from, __len, __copied, __recsize) : \
- __kfifo_from_user(__kfifo, __from, __len, __copied); \
-}) \
-)
-
-/**
- * kfifo_to_user - copies data from the fifo into user space
- * @fifo: address of the fifo to be used
- * @to: where the data must be copied
- * @len: the size of the destination buffer
- * @copied: pointer to output variable to store the number of copied bytes
- *
- * This macro copies at most @len bytes from the fifo into the
- * @to buffer and returns -EFAULT/0.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_to_user(fifo, to, len, copied) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- void __user *__to = (to); \
- unsigned int __len = (len); \
- unsigned int *__copied = (copied); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- (__recsize) ? \
- __kfifo_to_user_r(__kfifo, __to, __len, __copied, __recsize) : \
- __kfifo_to_user(__kfifo, __to, __len, __copied); \
-}) \
-)
-
-/**
- * kfifo_dma_in_prepare - setup a scatterlist for DMA input
- * @fifo: address of the fifo to be used
- * @sgl: pointer to the scatterlist array
- * @nents: number of entries in the scatterlist array
- * @len: number of elements to transfer
- *
- * This macro fills a scatterlist for DMA input.
- * It returns the number entries in the scatterlist array.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macros.
- */
-#define kfifo_dma_in_prepare(fifo, sgl, nents, len) \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- struct scatterlist *__sgl = (sgl); \
- int __nents = (nents); \
- unsigned int __len = (len); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- (__recsize) ? \
- __kfifo_dma_in_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \
- __kfifo_dma_in_prepare(__kfifo, __sgl, __nents, __len); \
-})
-
-/**
- * kfifo_dma_in_finish - finish a DMA IN operation
- * @fifo: address of the fifo to be used
- * @len: number of bytes to received
- *
- * This macro finish a DMA IN operation. The in counter will be updated by
- * the len parameter. No error checking will be done.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macros.
- */
-#define kfifo_dma_in_finish(fifo, len) \
-(void)({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- unsigned int __len = (len); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (__recsize) \
- __kfifo_dma_in_finish_r(__kfifo, __len, __recsize); \
- else \
- __kfifo->in += __len / sizeof(*__tmp->type); \
-})
-
-/**
- * kfifo_dma_out_prepare - setup a scatterlist for DMA output
- * @fifo: address of the fifo to be used
- * @sgl: pointer to the scatterlist array
- * @nents: number of entries in the scatterlist array
- * @len: number of elements to transfer
- *
- * This macro fills a scatterlist for DMA output which at most @len bytes
- * to transfer.
- * It returns the number entries in the scatterlist array.
- * A zero means there is no space available and the scatterlist is not filled.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macros.
- */
-#define kfifo_dma_out_prepare(fifo, sgl, nents, len) \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- struct scatterlist *__sgl = (sgl); \
- int __nents = (nents); \
- unsigned int __len = (len); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- (__recsize) ? \
- __kfifo_dma_out_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \
- __kfifo_dma_out_prepare(__kfifo, __sgl, __nents, __len); \
-})
-
-/**
- * kfifo_dma_out_finish - finish a DMA OUT operation
- * @fifo: address of the fifo to be used
- * @len: number of bytes transferd
- *
- * This macro finish a DMA OUT operation. The out counter will be updated by
- * the len parameter. No error checking will be done.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macros.
- */
-#define kfifo_dma_out_finish(fifo, len) \
-(void)({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- unsigned int __len = (len); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (__recsize) \
- __kfifo_dma_out_finish_r(__kfifo, __recsize); \
- else \
- __kfifo->out += __len / sizeof(*__tmp->type); \
-})
-
-/**
- * kfifo_out_peek - gets some data from the fifo
- * @fifo: address of the fifo to be used
- * @buf: pointer to the storage buffer
- * @n: max. number of elements to get
- *
- * This macro get the data from the fifo and return the numbers of elements
- * copied. The data is not removed from the fifo.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_out_peek(fifo, buf, n) \
-__kfifo_uint_must_check_helper( \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- typeof((buf) + 1) __buf = (buf); \
- unsigned long __n = (n); \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr) __dummy __attribute__ ((unused)) = NULL; \
- __buf = __dummy; \
- } \
- (__recsize) ? \
- __kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \
- __kfifo_out_peek(__kfifo, __buf, __n); \
-}) \
-)
-
-extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
- size_t esize, gfp_t gfp_mask);
-
-extern void __kfifo_free(struct __kfifo *fifo);
-
-extern int __kfifo_init(struct __kfifo *fifo, void *buffer,
- unsigned int size, size_t esize);
-
-extern unsigned int __kfifo_in(struct __kfifo *fifo,
- const void *buf, unsigned int len);
-
-extern unsigned int __kfifo_out(struct __kfifo *fifo,
- void *buf, unsigned int len);
-
-extern int __kfifo_from_user(struct __kfifo *fifo,
- const void __user *from, unsigned long len, unsigned int *copied);
-
-extern int __kfifo_to_user(struct __kfifo *fifo,
- void __user *to, unsigned long len, unsigned int *copied);
-
-extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len);
-
-extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len);
-
-extern unsigned int __kfifo_out_peek(struct __kfifo *fifo,
- void *buf, unsigned int len);
-
-extern unsigned int __kfifo_in_r(struct __kfifo *fifo,
- const void *buf, unsigned int len, size_t recsize);
-
-extern unsigned int __kfifo_out_r(struct __kfifo *fifo,
- void *buf, unsigned int len, size_t recsize);
-
-extern int __kfifo_from_user_r(struct __kfifo *fifo,
- const void __user *from, unsigned long len, unsigned int *copied,
- size_t recsize);
-
-extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to,
- unsigned long len, unsigned int *copied, size_t recsize);
-
-extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len, size_t recsize);
-
-extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo,
- unsigned int len, size_t recsize);
-
-extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
- struct scatterlist *sgl, int nents, unsigned int len, size_t recsize);
-
-extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize);
-
-extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize);
-
-extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize);
-
-extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo,
- void *buf, unsigned int len, size_t recsize);
-
-extern unsigned int __kfifo_max_r(unsigned int len, size_t recsize);
-
-#endif
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) */
+++ /dev/null
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
-#include_next <linux/kmemleak.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */
+++ /dev/null
-/*
- * Simple work processor based on kthread.
- *
- * This provides easier way to make use of kthreads. A kthread_work
- * can be queued and flushed using queue/flush_kthread_work()
- * respectively. Queued kthread_works are processed by a kthread
- * running kthread_worker_fn().
- *
- * A kthread_work can't be freed while it is executing.
- */
-#ifndef BACKPORT_LINUX_KTHREAD_H
-#define BACKPORT_LINUX_KTHREAD_H
-
-#include <linux/version.h>
-
-#include_next <linux/kthread.h>
-
-#ifndef CONFIG_COMPAT_IS_KTHREAD
-
-struct kthread_work;
-typedef void (*kthread_work_func_t)(struct kthread_work *work);
-
-struct kthread_worker {
- spinlock_t lock;
- struct list_head work_list;
- struct task_struct *task;
-};
-
-struct kthread_work {
- struct list_head node;
- kthread_work_func_t func;
- wait_queue_head_t done;
- atomic_t flushing;
- int queue_seq;
- int done_seq;
-};
-
-#define KTHREAD_WORKER_INIT(worker) { \
- .lock = __SPIN_LOCK_UNLOCKED((worker).lock), \
- .work_list = LIST_HEAD_INIT((worker).work_list), \
- }
-
-#define KTHREAD_WORK_INIT(work, fn) { \
- .node = LIST_HEAD_INIT((work).node), \
- .func = (fn), \
- .done = __WAIT_QUEUE_HEAD_INITIALIZER((work).done), \
- .flushing = ATOMIC_INIT(0), \
- }
-
-#define DEFINE_KTHREAD_WORKER(worker) \
- struct kthread_worker worker = KTHREAD_WORKER_INIT(worker)
-
-#define DEFINE_KTHREAD_WORK(work, fn) \
- struct kthread_work work = KTHREAD_WORK_INIT(work, fn)
-
-/*
- * kthread_worker.lock and kthread_work.done need their own lockdep class
- * keys if they are defined on stack with lockdep enabled. Use the
- * following macros when defining them on stack.
- */
-#ifdef CONFIG_LOCKDEP
-# define KTHREAD_WORKER_INIT_ONSTACK(worker) \
- ({ init_kthread_worker(&worker); worker; })
-# define DEFINE_KTHREAD_WORKER_ONSTACK(worker) \
- struct kthread_worker worker = KTHREAD_WORKER_INIT_ONSTACK(worker)
-# define KTHREAD_WORK_INIT_ONSTACK(work, fn) \
- ({ init_kthread_work((&work), fn); work; })
-# define DEFINE_KTHREAD_WORK_ONSTACK(work, fn) \
- struct kthread_work work = KTHREAD_WORK_INIT_ONSTACK(work, fn)
-#else
-# define DEFINE_KTHREAD_WORKER_ONSTACK(worker) DEFINE_KTHREAD_WORKER(worker)
-# define DEFINE_KTHREAD_WORK_ONSTACK(work, fn) DEFINE_KTHREAD_WORK(work, fn)
-#endif
-
-extern void __init_kthread_worker(struct kthread_worker *worker,
- const char *name, struct lock_class_key *key);
-
-#define init_kthread_worker(worker) \
- do { \
- static struct lock_class_key __key; \
- __init_kthread_worker((worker), "("#worker")->lock", &__key); \
- } while (0)
-
-#define init_kthread_work(work, fn) \
- do { \
- memset((work), 0, sizeof(struct kthread_work)); \
- INIT_LIST_HEAD(&(work)->node); \
- (work)->func = (fn); \
- init_waitqueue_head(&(work)->done); \
- } while (0)
-
-int kthread_worker_fn(void *worker_ptr);
-
-bool queue_kthread_work(struct kthread_worker *worker,
- struct kthread_work *work);
-void flush_kthread_work(struct kthread_work *work);
-void flush_kthread_worker(struct kthread_worker *worker);
-
-#endif /* LINUX_VERSION_CODE < 2.6.35 */
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
-/*
- * Kernels between 2.6.36 and 2.6.38 have the above functions but still lack the
- * following.
- */
-#define kthread_create_on_node(threadfn, data, node, namefmt, arg...) \
- kthread_create(threadfn, data, namefmt, ##arg)
-
-#endif /* CONFIG_COMPAT_IS_KTHREAD */
-
-#endif /* _LINUX_KTHREAD_H */
-
+++ /dev/null
-#include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
-#include_next <linux/llist.h>
-
-#else
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) || (defined(CONFIG_SUSE_KERNEL) && defined(CONFIG_COMPAT_SLES_11_2))
-#include_next <linux/llist.h>
-#define llist_add_batch LINUX_BACKPORT(llist_add_batch)
-extern bool llist_add_batch(struct llist_node *new_first,
- struct llist_node *new_last,
- struct llist_head *head);
-#define llist_del_first LINUX_BACKPORT(llist_del_first)
-extern struct llist_node *llist_del_first(struct llist_head *head);
-
-#else
-
-#ifndef LLIST_H
-#define LLIST_H
-/*
- * Lock-less NULL terminated single linked list
- *
- * If there are multiple producers and multiple consumers, llist_add
- * can be used in producers and llist_del_all can be used in
- * consumers. They can work simultaneously without lock. But
- * llist_del_first can not be used here. Because llist_del_first
- * depends on list->first->next does not changed if list->first is not
- * changed during its operation, but llist_del_first, llist_add,
- * llist_add (or llist_del_all, llist_add, llist_add) sequence in
- * another consumer may violate that.
- *
- * If there are multiple producers and one consumer, llist_add can be
- * used in producers and llist_del_all or llist_del_first can be used
- * in the consumer.
- *
- * This can be summarized as follow:
- *
- * | add | del_first | del_all
- * add | - | - | -
- * del_first | | L | L
- * del_all | | | -
- *
- * Where "-" stands for no lock is needed, while "L" stands for lock
- * is needed.
- *
- * The list entries deleted via llist_del_all can be traversed with
- * traversing function such as llist_for_each etc. But the list
- * entries can not be traversed safely before deleted from the list.
- * The order of deleted entries is from the newest to the oldest added
- * one. If you want to traverse from the oldest to the newest, you
- * must reverse the order by yourself before traversing.
- *
- * The basic atomic operation of this list is cmpxchg on long. On
- * architectures that don't have NMI-safe cmpxchg implementation, the
- * list can NOT be used in NMI handlers. So code that uses the list in
- * an NMI handler should depend on CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG.
- *
- * Copyright 2010,2011 Intel Corp.
- * Author: Huang Ying <ying.huang@intel.com>
- *
- * 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;
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <linux/kernel.h>
-#include <asm/system.h>
-#include <asm/processor.h>
-
-struct llist_head {
- struct llist_node *first;
-};
-
-struct llist_node {
- struct llist_node *next;
-};
-
-#ifndef LLIST_HEAD_INIT
-#define LLIST_HEAD_INIT(name) { NULL }
-#endif
-#ifndef LLIST_HEAD
-#define LLIST_HEAD(name) struct llist_head name = LLIST_HEAD_INIT(name)
-#endif
-
-/**
- * init_llist_head - initialize lock-less list head
- * @head: the head for your lock-less list
- */
-#define init_llist_head LINUX_BACKPORT(init_llist_head)
-static inline void init_llist_head(struct llist_head *list)
-{
- list->first = NULL;
-}
-
-/**
- * llist_entry - get the struct of this entry
- * @ptr: the &struct llist_node pointer.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the llist_node within the struct.
- */
-#ifndef llist_entry
-#define llist_entry(ptr, type, member) \
- container_of(ptr, type, member)
-#endif
-
-/**
- * llist_for_each - iterate over some deleted entries of a lock-less list
- * @pos: the &struct llist_node to use as a loop cursor
- * @node: the first entry of deleted list entries
- *
- * In general, some entries of the lock-less list can be traversed
- * safely only after being deleted from list, so start with an entry
- * instead of list head.
- *
- * If being used on entries deleted from lock-less list directly, the
- * traverse order is from the newest to the oldest added entry. If
- * you want to traverse from the oldest to the newest, you must
- * reverse the order by yourself before traversing.
- */
-#ifndef llist_for_each
-#define llist_for_each(pos, node) \
- for ((pos) = (node); pos; (pos) = (pos)->next)
-#endif
-
-/**
- * llist_for_each_entry - iterate over some deleted entries of lock-less list of given type
- * @pos: the type * to use as a loop cursor.
- * @node: the fist entry of deleted list entries.
- * @member: the name of the llist_node with the struct.
- *
- * In general, some entries of the lock-less list can be traversed
- * safely only after being removed from list, so start with an entry
- * instead of list head.
- *
- * If being used on entries deleted from lock-less list directly, the
- * traverse order is from the newest to the oldest added entry. If
- * you want to traverse from the oldest to the newest, you must
- * reverse the order by yourself before traversing.
- */
-#ifndef llist_for_each_entry
-#define llist_for_each_entry(pos, node, member) \
- for ((pos) = llist_entry((node), typeof(*(pos)), member); \
- &(pos)->member != NULL; \
- (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
-#endif
-
-/**
- * llist_empty - tests whether a lock-less list is empty
- * @head: the list to test
- *
- * Not guaranteed to be accurate or up to date. Just a quick way to
- * test whether the list is empty without deleting something from the
- * list.
- */
-#define llist_empty LINUX_BACKPORT(llist_empty)
-static inline bool llist_empty(const struct llist_head *head)
-{
- return ACCESS_ONCE(head->first) == NULL;
-}
-
-#define llist_next LINUX_BACKPORT(llist_next)
-static inline struct llist_node *llist_next(struct llist_node *node)
-{
- return node->next;
-}
-
-/**
- * llist_add - add a new entry
- * @new: new entry to be added
- * @head: the head for your lock-less list
- *
- * Returns true if the list was empty prior to adding this entry.
- */
-#define llist_add LINUX_BACKPORT(llist_add)
-static inline bool llist_add(struct llist_node *new, struct llist_head *head)
-{
- struct llist_node *entry, *old_entry;
-
- entry = head->first;
- for (;;) {
- old_entry = entry;
- new->next = entry;
- entry = cmpxchg(&head->first, old_entry, new);
- if (entry == old_entry)
- break;
- }
-
- return old_entry == NULL;
-}
-
-/**
- * llist_del_all - delete all entries from lock-less list
- * @head: the head of lock-less list to delete all entries
- *
- * If list is empty, return NULL, otherwise, delete all entries and
- * return the pointer to the first entry. The order of entries
- * deleted is from the newest to the oldest added one.
- */
-#define llist_del_all LINUX_BACKPORT(llist_del_all)
-static inline struct llist_node *llist_del_all(struct llist_head *head)
-{
- return xchg(&head->first, NULL);
-}
-
-#define llist_add_batch LINUX_BACKPORT(llist_add_batch)
-extern bool llist_add_batch(struct llist_node *new_first,
- struct llist_node *new_last,
- struct llist_head *head);
-
-#define llist_del_first LINUX_BACKPORT(llist_del_first)
-extern struct llist_node *llist_del_first(struct llist_head *head);
-
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) || (defined(CONFIG_SUSE_KERNEL) && defined(CONFIG_COMPAT_SLES_11_2)) */
-#endif /* LLIST_H */
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */
+++ /dev/null
-#ifndef _COMPAT_LINUX_MATH64_H
-#define _COMPAT_LINUX_MATH64_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
-#include_next <linux/math64.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */
-
-#endif /* _COMPAT_LINUX_MATH64_H */
+++ /dev/null
-#ifndef _COMPAT_LINUX_MM_H
-#define _COMPAT_LINUX_MM_H 1
-
-#include "../../compat/config.h"
-#include_next <linux/mm.h>
-
-#ifndef HAVE_GET_USER_PAGES_REMOTE
-#define get_user_pages_remote get_user_pages
-#endif
-
-#endif /* _COMPAT_LINUX_MM_H */
+++ /dev/null
-#ifndef _COMPAT_LINUX_NETDEVICE_H
-#define _COMPAT_LINUX_NETDEVICE_H 1
-
-#include "../../compat/config.h"
-
-#include_next <linux/netdevice.h>
-
-#ifndef SET_ETHTOOL_OPS
-#define SET_ETHTOOL_OPS(netdev,ops) \
- ( (netdev)->ethtool_ops = (ops) )
-#endif
-
-#if !defined(HAVE_NETDEV_EXTENDED_HW_FEATURES) && \
- !defined(HAVE_NETDEV_OPS_EXT_NDO_FIX_FEATURES) && \
- !defined(HAVE_NETDEV_OPS_EXT_NDO_SET_FEATURES) && \
- !defined(HAVE_NDO_SET_FEATURES)
-#define LEGACY_ETHTOOL_OPS
-#endif
-
-#ifndef NETDEV_BONDING_INFO
-#define NETDEV_BONDING_INFO 0x0019
-#endif
-
-
-#ifndef HAVE_NETDEV_MASTER_UPPER_DEV_GET_RCU
-#define netdev_master_upper_dev_get_rcu(x) (x)->master
-#endif
-
-#ifndef HAVE_NETIF_KEEP_DST
-/* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */
-static inline void netif_keep_dst(struct net_device *dev)
-{
- /* IFF_XMIT_DST_RELEASE_PERM = 1<<17 */
- dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | (1<<17) );
-}
-#endif
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)
-#ifdef HAVE_ALLOC_ETHERDEV_MQ
-#ifndef HAVE_NETIF_SET_REAL_NUM_TX_QUEUES
-static inline void netif_set_real_num_tx_queues(struct net_device *netdev,
- unsigned int txq)
-{
- netdev->real_num_tx_queues = txq;
-}
-#endif
-#endif
-#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) */
-
-#ifndef HAVE_NETDEV_RSS_KEY_FILL
-static inline void netdev_rss_key_fill(void *addr, size_t len)
-{
- __be32 *hkey;
-
- hkey = (__be32 *)addr;
- hkey[0] = cpu_to_be32(0xD181C62C);
- hkey[1] = cpu_to_be32(0xF7F4DB5B);
- hkey[2] = cpu_to_be32(0x1983A2FC);
- hkey[3] = cpu_to_be32(0x943E1ADB);
- hkey[4] = cpu_to_be32(0xD9389E6B);
- hkey[5] = cpu_to_be32(0xD1039C2C);
- hkey[6] = cpu_to_be32(0xA74499AD);
- hkey[7] = cpu_to_be32(0x593D56D9);
- hkey[8] = cpu_to_be32(0xF3253C06);
- hkey[9] = cpu_to_be32(0x2ADC1FFC);
-}
-#endif
-
-#ifndef NAPI_POLL_WEIGHT
-/* Default NAPI poll() weight
- * Device drivers are strongly advised to not use bigger value
- */
-#define NAPI_POLL_WEIGHT 64
-#endif
-
-#ifndef NETDEV_JOIN
-#define NETDEV_JOIN 0x0014
-#endif
-
-#ifndef NETDEV_MASTER_UPPER_DEV_LINK_4_PARAMS
-#define netdev_master_upper_dev_link(a,b,c,d) netdev_master_upper_dev_link(a,b)
-#endif
-
-#ifdef HAVE_ALLOC_NETDEV_MQS_6_PARAMS
-#define alloc_netdev_mqs(a, b, c, d, e) alloc_netdev_mqs(a, b, NET_NAME_UNKNOWN, c, d, e)
-#endif
-
-#ifdef alloc_netdev_mq
-#undef alloc_netdev_mq
-#define alloc_netdev_mq(sizeof_priv, name, setup, count) \
- alloc_netdev_mqs(sizeof_priv, name, setup, count, count)
-#endif
-
-#ifdef alloc_netdev
-#undef alloc_netdev
-#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
- alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
-#endif
-
-#ifndef HAVE_NETIF_TRANS_UPDATE
-/* legacy drivers only, netdev_start_xmit() sets txq->trans_start */
-static inline void netif_trans_update(struct net_device *dev)
-{
- struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
-
- if (txq->trans_start != jiffies)
- txq->trans_start = jiffies;
-}
-#endif
-
-#ifdef HAVE_REGISTER_NETDEVICE_NOTIFIER_RH
-#define register_netdevice_notifier register_netdevice_notifier_rh
-#define unregister_netdevice_notifier unregister_netdevice_notifier_rh
-#endif
-
-#ifndef HAVE_NETDEV_NOTIFIER_INFO_TO_DEV
-#define netdev_notifier_info_to_dev LINUX_BACKPORT(netdev_notifier_info_to_dev)
-static inline struct net_device *
-netdev_notifier_info_to_dev(void *ptr)
-{
- return (struct net_device *)ptr;
-}
-#endif
-
-#endif /* _COMPAT_LINUX_NETDEVICE_H */
+++ /dev/null
-#ifndef _COMPAT_LINUX_OF_H
-#define _COMPAT_LINUX_OF_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
-#include_next <linux/of.h>
-#else
-
-#ifdef CONFIG_OF
-#include_next <linux/of.h>
-#endif /* CONFIG_OF */
-
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */
-
-#endif /* _COMPAT_LINUX_OF_H */
+++ /dev/null
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
-#include_next <linux/pci-aspm.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */
+++ /dev/null
-#ifndef _COMPAT_LINUX_PERCPU_H
-#define _COMPAT_LINUX_PERCPU_H 1
-
-#include <linux/version.h>
-
-#include_next <linux/percpu.h>
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
-
-#ifndef this_cpu_inc
-#define this_cpu_inc(pcp) \
-do { \
- unsigned long flags; \
- raw_local_irq_save(flags); \
- *this_cpu_ptr(&(pcp)) += 1; \
- raw_local_irq_restore(flags); \
-} while (0)
-#endif /* this_cpu_inc */
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
-
-#endif /* _COMPAT_LINUX_PERCPU_H */
+++ /dev/null
-#ifndef _COMPAT_LINUX_PM_QOS_H
-#define _COMPAT_LINUX_PM_QOS_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
-#include_next <linux/pm_qos.h>
-#else
-#include <linux/pm_qos_params.h>
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
-
-#endif /* _COMPAT_LINUX_PM_QOS_H */
+++ /dev/null
-#include <linux/version.h>
-
-#ifndef __COMPAT_LINUX_PM_QOS_PARAMS_H
-#define __COMPAT_LINUX_PM_QOS_PARAMS_H
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
-#include_next <linux/pm_qos_params.h>
-#else
-/* interface for the pm_qos_power infrastructure of the linux kernel.
- *
- * Mark Gross <mgross@linux.intel.com>
- */
-#include <linux/list.h>
-#include <linux/notifier.h>
-#include <linux/miscdevice.h>
-
-#define PM_QOS_RESERVED 0
-#define PM_QOS_CPU_DMA_LATENCY 1
-#define PM_QOS_NETWORK_LATENCY 2
-#define PM_QOS_NETWORK_THROUGHPUT 3
-#define PM_QOS_SYSTEM_BUS_FREQ 4
-
-#define PM_QOS_NUM_CLASSES 5
-#define PM_QOS_DEFAULT_VALUE -1
-
-int pm_qos_add_requirement(int qos, char *name, s32 value);
-int pm_qos_update_requirement(int qos, char *name, s32 new_value);
-void pm_qos_remove_requirement(int qos, char *name);
-
-int pm_qos_requirement(int qos);
-
-int pm_qos_add_notifier(int qos, struct notifier_block *notifier);
-int pm_qos_remove_notifier(int qos, struct notifier_block *notifier);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */
-
-#endif
+++ /dev/null
-#include <linux/version.h>
-
-#ifndef __COMPAT_LINUX_PM_RUNTIME_H
-#define __COMPAT_LINUX_PM_RUNTIME_H
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
-#include_next <linux/pm_runtime.h>
-#else
-
-static inline void pm_runtime_enable(struct device *dev) {}
-
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) */
-
-#endif
+++ /dev/null
-#ifndef _COMPAT_LINUX_PRINTK_H
-#define _COMPAT_LINUX_PRINTK_H 1
-
-#include <linux/version.h>
-#include "../../compat/config.h"
-
-#ifdef HAVE_LINUX_PRINTK_H
-#include_next <linux/printk.h>
-#else /* HAVE_LINUX_PRINTK_H */
-#include <linux/kernel.h>
-
-#define pr_emerg_once(fmt, ...) \
- printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert_once(fmt, ...) \
- printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit_once(fmt, ...) \
- printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err_once(fmt, ...) \
- printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warn_once(fmt, ...) \
- printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warn pr_warning
-#define pr_notice_once(fmt, ...) \
- printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info_once(fmt, ...) \
- printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_cont_once(fmt, ...) \
- printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
-#if defined(DEBUG)
-#define pr_debug_once(fmt, ...) \
- printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#else
-#define pr_debug_once(fmt, ...) \
- no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#endif
-
-/*
- * ratelimited messages with local ratelimit_state,
- * no local ratelimit_state used in the !PRINTK case
- */
-#ifndef printk_ratelimited
-#ifdef CONFIG_PRINTK
-#define printk_ratelimited(fmt, ...) \
-({ \
- static DEFINE_RATELIMIT_STATE(_rs, \
- DEFAULT_RATELIMIT_INTERVAL, \
- DEFAULT_RATELIMIT_BURST); \
- \
- if (__ratelimit(&_rs)) \
- printk(fmt, ##__VA_ARGS__); \
-})
-#else
-#define printk_ratelimited(fmt, ...) \
- no_printk(fmt, ##__VA_ARGS__)
-#endif
-#endif /* ifndef printk_ratelimited */
-
-#ifndef printk_once
-#define printk_once(fmt, ...) \
-({ \
- static bool __print_once; \
- \
- if (!__print_once) { \
- __print_once = true; \
- printk(fmt, ##__VA_ARGS__); \
- } \
-})
-#endif
-
-#endif /* HAVE_LINUX_PRINTK_H */
-
-#endif /* _COMPAT_LINUX_PRINTK_H */
+++ /dev/null
-#ifndef __COMPAT_RFKILL_H
-#define __COMPAT_RFKILL_H
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
-
-#include_next <linux/rfkill.h>
-
-#else
-
-#include <linux/compat-2.6.h>
-
-#undef CONFIG_RFKILL
-#undef CONFIG_RFKILL_INPUT
-#undef CONFIG_RFKILL_LEDS
-
-#ifdef CONFIG_RFKILL_BACKPORT
-#define CONFIG_RFKILL 1
-#endif
-
-#ifdef CONFIG_RFKILL_BACKPORT_INPUT
-#define CONFIG_RFKILL_INPUT
-#endif
-
-#ifdef CONFIG_RFKILL_BACKPORT_LEDS
-#define CONFIG_RFKILL_LEDS
-#endif
-
-#include <linux/rfkill_backport.h>
-
-#endif
-
-#endif
+++ /dev/null
-#ifndef _COMPAT_LINUX_PRIO_H
-#define _COMPAT_LINUX_PRIO_H 1
-
-#include "../../../compat/config.h"
-
-#ifdef HAVE_MIN_NICE
-#include_next <linux/sched/prio.h>
-#else
-#define MAX_NICE 19
-#define MIN_NICE -20
-#define NICE_WIDTH (MAX_NICE - MIN_NICE + 1)
-#endif /* HAVE_MIN_NICE */
-#endif /* _COMPAT_LINUX_PRIO_H */
-
+++ /dev/null
-#ifndef _COMPAT_LINUX_SEMAPHORE_H
-#define _COMPAT_LINUX_SEMAPHORE_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
-#include_next <linux/semaphore.h>
-#else
-#include <asm/semaphore.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */
-
-#endif /* _COMPAT_LINUX_SEMAPHORE_H */
+++ /dev/null
-#ifndef _COMPAT_LINUX_SKBUFF_H
-#define _COMPAT_LINUX_SKBUFF_H
-
-#include <linux/version.h>
-#include "../../compat/config.h"
-
-#include_next <linux/skbuff.h>
-
-#ifndef HAVE_DEV_ALLOC_PAGES
-static inline struct page *dev_alloc_pages(unsigned int order)
-{
- gfp_t gfp_mask = GFP_ATOMIC | __GFP_NOWARN | __GFP_COLD | __GFP_COMP | __GFP_MEMALLOC;
- return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
-}
-
-static inline struct page *dev_alloc_page(void)
-{
- return dev_alloc_pages(0);
-}
-#endif
-#endif /* _COMPAT_LINUX_SKBUFF_H */
+++ /dev/null
-#ifndef COMPAT_LINUX_TIMEKEEPING_H
-#define COMPAT_LINUX_TIMEKEEPING_H
-
-#include "../../compat/config.h"
-
-#include_next <linux/timekeeping.h>
-
-#ifndef HAVE_KTIME_GET_NS
-static inline u64 ktime_get_ns(void)
-{
- return ktime_to_ns(ktime_get());
-}
-#endif
-
-#endif /* COMPAT_LINUX_TIMEKEEPING_H */
+++ /dev/null
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
-#include_next <linux/uidgid.h>
-#else
-
-#ifndef _LINUX_UIDGID_H
-#define _LINUX_UIDGID_H
-
-/*
- * A set of types for the internal kernel types representing uids and gids.
- *
- * The types defined in this header allow distinguishing which uids and gids in
- * the kernel are values used by userspace and which uid and gid values are
- * the internal kernel values. With the addition of user namespaces the values
- * can be different. Using the type system makes it possible for the compiler
- * to detect when we overlook these differences.
- *
- */
-#include <linux/types.h>
-#include <linux/highuid.h>
-
-struct user_namespace;
-extern struct user_namespace init_user_ns;
-
-#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
-
-typedef struct {
- uid_t val;
-} kuid_t;
-
-
-typedef struct {
- gid_t val;
-} kgid_t;
-
-#define KUIDT_INIT(value) (kuid_t){ value }
-#define KGIDT_INIT(value) (kgid_t){ value }
-
-static inline uid_t __kuid_val(kuid_t uid)
-{
- return uid.val;
-}
-
-static inline gid_t __kgid_val(kgid_t gid)
-{
- return gid.val;
-}
-
-#else
-
-typedef uid_t kuid_t;
-typedef gid_t kgid_t;
-
-static inline uid_t __kuid_val(kuid_t uid)
-{
- return uid;
-}
-
-static inline gid_t __kgid_val(kgid_t gid)
-{
- return gid;
-}
-
-#define KUIDT_INIT(value) ((kuid_t) value )
-#define KGIDT_INIT(value) ((kgid_t) value )
-
-#endif
-
-#define GLOBAL_ROOT_UID KUIDT_INIT(0)
-#define GLOBAL_ROOT_GID KGIDT_INIT(0)
-
-#define INVALID_UID KUIDT_INIT(-1)
-#define INVALID_GID KGIDT_INIT(-1)
-
-static inline bool uid_eq(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) == __kuid_val(right);
-}
-
-static inline bool gid_eq(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) == __kgid_val(right);
-}
-
-static inline bool uid_gt(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) > __kuid_val(right);
-}
-
-static inline bool gid_gt(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) > __kgid_val(right);
-}
-
-static inline bool uid_gte(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) >= __kuid_val(right);
-}
-
-static inline bool gid_gte(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) >= __kgid_val(right);
-}
-
-static inline bool uid_lt(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) < __kuid_val(right);
-}
-
-static inline bool gid_lt(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) < __kgid_val(right);
-}
-
-static inline bool uid_lte(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) <= __kuid_val(right);
-}
-
-static inline bool gid_lte(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) <= __kgid_val(right);
-}
-
-static inline bool uid_valid(kuid_t uid)
-{
- return !uid_eq(uid, INVALID_UID);
-}
-
-static inline bool gid_valid(kgid_t gid)
-{
- return !gid_eq(gid, INVALID_GID);
-}
-
-#ifdef CONFIG_USER_NS
-
-#define make_kuid LINUX_BACKPORT(make_kuid)
-extern kuid_t make_kuid(struct user_namespace *from, uid_t uid);
-#define make_kgid LINUX_BACKPORT(make_kgid)
-extern kgid_t make_kgid(struct user_namespace *from, gid_t gid);
-
-#define from_kuid LINUX_BACKPORT(from_kuid)
-extern uid_t from_kuid(struct user_namespace *to, kuid_t uid);
-#define from_kgid LINUX_BACKPORT(from_kgid)
-extern gid_t from_kgid(struct user_namespace *to, kgid_t gid);
-#define from_kuid_munged LINUX_BACKPORT(from_kuid_munged)
-extern uid_t from_kuid_munged(struct user_namespace *to, kuid_t uid);
-#define from_kgid_munged LINUX_BACKPORT(from_kgid_munged)
-extern gid_t from_kgid_munged(struct user_namespace *to, kgid_t gid);
-
-#define kuid_has_mapping LINUX_BACKPORT(kuid_has_mapping)
-static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid)
-{
- return from_kuid(ns, uid) != (uid_t) -1;
-}
-
-#define kgid_has_mapping LINUX_BACKPORT(kgid_has_mapping)
-static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
-{
- return from_kgid(ns, gid) != (gid_t) -1;
-}
-
-#else
-
-#define make_kuid LINUX_BACKPORT(make_kuid)
-static inline kuid_t make_kuid(struct user_namespace *from, uid_t uid)
-{
- return KUIDT_INIT(uid);
-}
-
-#define make_kgid LINUX_BACKPORT(make_kgid)
-static inline kgid_t make_kgid(struct user_namespace *from, gid_t gid)
-{
- return KGIDT_INIT(gid);
-}
-
-#define from_kuid LINUX_BACKPORT(from_kuid)
-static inline uid_t from_kuid(struct user_namespace *to, kuid_t kuid)
-{
- return __kuid_val(kuid);
-}
-
-#define from_kgid LINUX_BACKPORT(from_kgid)
-static inline gid_t from_kgid(struct user_namespace *to, kgid_t kgid)
-{
- return __kgid_val(kgid);
-}
-
-#define from_kuid_munged LINUX_BACKPORT(from_kuid_munged)
-static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid)
-{
- uid_t uid = from_kuid(to, kuid);
- if (uid == (uid_t)-1)
- uid = overflowuid;
- return uid;
-}
-
-#define from_kgid_munged LINUX_BACKPORT(from_kgid_munged)
-static inline gid_t from_kgid_munged(struct user_namespace *to, kgid_t kgid)
-{
- gid_t gid = from_kgid(to, kgid);
- if (gid == (gid_t)-1)
- gid = overflowgid;
- return gid;
-}
-
-#define kuid_has_mapping LINUX_BACKPORT(kuid_has_mapping)
-static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid)
-{
- return true;
-}
-
-#define kgid_has_mapping LINUX_BACKPORT(kgid_has_mapping)
-static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
-{
- return true;
-}
-
-#endif /* CONFIG_USER_NS */
-
-#endif /* _LINUX_UIDGID_H */
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_ACCESS_OK_H
-#define _LINUX_UNALIGNED_ACCESS_OK_H
-
-#include <linux/kernel.h>
-#include <asm/byteorder.h>
-
-static inline u16 get_unaligned_le16(const void *p)
-{
- return le16_to_cpup((__le16 *)p);
-}
-
-static inline u32 get_unaligned_le32(const void *p)
-{
- return le32_to_cpup((__le32 *)p);
-}
-
-static inline u64 get_unaligned_le64(const void *p)
-{
- return le64_to_cpup((__le64 *)p);
-}
-
-static inline u16 get_unaligned_be16(const void *p)
-{
- return be16_to_cpup((__be16 *)p);
-}
-
-static inline u32 get_unaligned_be32(const void *p)
-{
- return be32_to_cpup((__be32 *)p);
-}
-
-static inline u64 get_unaligned_be64(const void *p)
-{
- return be64_to_cpup((__be64 *)p);
-}
-
-static inline void put_unaligned_le16(u16 val, void *p)
-{
- *((__le16 *)p) = cpu_to_le16(val);
-}
-
-static inline void put_unaligned_le32(u32 val, void *p)
-{
- *((__le32 *)p) = cpu_to_le32(val);
-}
-
-static inline void put_unaligned_le64(u64 val, void *p)
-{
- *((__le64 *)p) = cpu_to_le64(val);
-}
-
-static inline void put_unaligned_be16(u16 val, void *p)
-{
- *((__be16 *)p) = cpu_to_be16(val);
-}
-
-static inline void put_unaligned_be32(u32 val, void *p)
-{
- *((__be32 *)p) = cpu_to_be32(val);
-}
-
-static inline void put_unaligned_be64(u64 val, void *p)
-{
- *((__be64 *)p) = cpu_to_be64(val);
-}
-
-#endif /* _LINUX_UNALIGNED_ACCESS_OK_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H
-#define _LINUX_UNALIGNED_BE_BYTESHIFT_H
-
-#include <linux/types.h>
-
-static inline u16 __get_unaligned_be16(const u8 *p)
-{
- return p[0] << 8 | p[1];
-}
-
-static inline u32 __get_unaligned_be32(const u8 *p)
-{
- return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
-}
-
-static inline u64 __get_unaligned_be64(const u8 *p)
-{
- return (u64)__get_unaligned_be32(p) << 32 |
- __get_unaligned_be32(p + 4);
-}
-
-static inline void __put_unaligned_be16(u16 val, u8 *p)
-{
- *p++ = val >> 8;
- *p++ = val;
-}
-
-static inline void __put_unaligned_be32(u32 val, u8 *p)
-{
- __put_unaligned_be16(val >> 16, p);
- __put_unaligned_be16(val, p + 2);
-}
-
-static inline void __put_unaligned_be64(u64 val, u8 *p)
-{
- __put_unaligned_be32(val >> 32, p);
- __put_unaligned_be32(val, p + 4);
-}
-
-static inline u16 get_unaligned_be16(const void *p)
-{
- return __get_unaligned_be16((const u8 *)p);
-}
-
-static inline u32 get_unaligned_be32(const void *p)
-{
- return __get_unaligned_be32((const u8 *)p);
-}
-
-static inline u64 get_unaligned_be64(const void *p)
-{
- return __get_unaligned_be64((const u8 *)p);
-}
-
-static inline void put_unaligned_be16(u16 val, void *p)
-{
- __put_unaligned_be16(val, p);
-}
-
-static inline void put_unaligned_be32(u32 val, void *p)
-{
- __put_unaligned_be32(val, p);
-}
-
-static inline void put_unaligned_be64(u64 val, void *p)
-{
- __put_unaligned_be64(val, p);
-}
-
-#endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_BE_MEMMOVE_H
-#define _LINUX_UNALIGNED_BE_MEMMOVE_H
-
-#include <linux/unaligned/memmove.h>
-
-static inline u16 get_unaligned_be16(const void *p)
-{
- return __get_unaligned_memmove16((const u8 *)p);
-}
-
-static inline u32 get_unaligned_be32(const void *p)
-{
- return __get_unaligned_memmove32((const u8 *)p);
-}
-
-static inline u64 get_unaligned_be64(const void *p)
-{
- return __get_unaligned_memmove64((const u8 *)p);
-}
-
-static inline void put_unaligned_be16(u16 val, void *p)
-{
- __put_unaligned_memmove16(val, p);
-}
-
-static inline void put_unaligned_be32(u32 val, void *p)
-{
- __put_unaligned_memmove32(val, p);
-}
-
-static inline void put_unaligned_be64(u64 val, void *p)
-{
- __put_unaligned_memmove64(val, p);
-}
-
-#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_BE_STRUCT_H
-#define _LINUX_UNALIGNED_BE_STRUCT_H
-
-#include <linux/unaligned/packed_struct.h>
-
-static inline u16 get_unaligned_be16(const void *p)
-{
- return __get_unaligned_cpu16((const u8 *)p);
-}
-
-static inline u32 get_unaligned_be32(const void *p)
-{
- return __get_unaligned_cpu32((const u8 *)p);
-}
-
-static inline u64 get_unaligned_be64(const void *p)
-{
- return __get_unaligned_cpu64((const u8 *)p);
-}
-
-static inline void put_unaligned_be16(u16 val, void *p)
-{
- __put_unaligned_cpu16(val, p);
-}
-
-static inline void put_unaligned_be32(u32 val, void *p)
-{
- __put_unaligned_cpu32(val, p);
-}
-
-static inline void put_unaligned_be64(u64 val, void *p)
-{
- __put_unaligned_cpu64(val, p);
-}
-
-#endif /* _LINUX_UNALIGNED_BE_STRUCT_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_GENERIC_H
-#define _LINUX_UNALIGNED_GENERIC_H
-
-/*
- * Cause a link-time error if we try an unaligned access other than
- * 1,2,4 or 8 bytes long
- */
-extern void __bad_unaligned_access_size(void);
-
-#define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \
- __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
- __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \
- __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \
- __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \
- __bad_unaligned_access_size())))); \
- }))
-
-#define __get_unaligned_be(ptr) ((__force typeof(*(ptr)))({ \
- __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
- __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \
- __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \
- __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \
- __bad_unaligned_access_size())))); \
- }))
-
-#define __put_unaligned_le(val, ptr) ({ \
- void *__gu_p = (ptr); \
- switch (sizeof(*(ptr))) { \
- case 1: \
- *(u8 *)__gu_p = (__force u8)(val); \
- break; \
- case 2: \
- put_unaligned_le16((__force u16)(val), __gu_p); \
- break; \
- case 4: \
- put_unaligned_le32((__force u32)(val), __gu_p); \
- break; \
- case 8: \
- put_unaligned_le64((__force u64)(val), __gu_p); \
- break; \
- default: \
- __bad_unaligned_access_size(); \
- break; \
- } \
- (void)0; })
-
-#define __put_unaligned_be(val, ptr) ({ \
- void *__gu_p = (ptr); \
- switch (sizeof(*(ptr))) { \
- case 1: \
- *(u8 *)__gu_p = (__force u8)(val); \
- break; \
- case 2: \
- put_unaligned_be16((__force u16)(val), __gu_p); \
- break; \
- case 4: \
- put_unaligned_be32((__force u32)(val), __gu_p); \
- break; \
- case 8: \
- put_unaligned_be64((__force u64)(val), __gu_p); \
- break; \
- default: \
- __bad_unaligned_access_size(); \
- break; \
- } \
- (void)0; })
-
-#endif /* _LINUX_UNALIGNED_GENERIC_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_LE_BYTESHIFT_H
-#define _LINUX_UNALIGNED_LE_BYTESHIFT_H
-
-#include <linux/types.h>
-
-static inline u16 __get_unaligned_le16(const u8 *p)
-{
- return p[0] | p[1] << 8;
-}
-
-static inline u32 __get_unaligned_le32(const u8 *p)
-{
- return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
-}
-
-static inline u64 __get_unaligned_le64(const u8 *p)
-{
- return (u64)__get_unaligned_le32(p + 4) << 32 |
- __get_unaligned_le32(p);
-}
-
-static inline void __put_unaligned_le16(u16 val, u8 *p)
-{
- *p++ = val;
- *p++ = val >> 8;
-}
-
-static inline void __put_unaligned_le32(u32 val, u8 *p)
-{
- __put_unaligned_le16(val >> 16, p + 2);
- __put_unaligned_le16(val, p);
-}
-
-static inline void __put_unaligned_le64(u64 val, u8 *p)
-{
- __put_unaligned_le32(val >> 32, p + 4);
- __put_unaligned_le32(val, p);
-}
-
-static inline u16 get_unaligned_le16(const void *p)
-{
- return __get_unaligned_le16((const u8 *)p);
-}
-
-static inline u32 get_unaligned_le32(const void *p)
-{
- return __get_unaligned_le32((const u8 *)p);
-}
-
-static inline u64 get_unaligned_le64(const void *p)
-{
- return __get_unaligned_le64((const u8 *)p);
-}
-
-static inline void put_unaligned_le16(u16 val, void *p)
-{
- __put_unaligned_le16(val, p);
-}
-
-static inline void put_unaligned_le32(u32 val, void *p)
-{
- __put_unaligned_le32(val, p);
-}
-
-static inline void put_unaligned_le64(u64 val, void *p)
-{
- __put_unaligned_le64(val, p);
-}
-
-#endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_LE_MEMMOVE_H
-#define _LINUX_UNALIGNED_LE_MEMMOVE_H
-
-#include <linux/unaligned/memmove.h>
-
-static inline u16 get_unaligned_le16(const void *p)
-{
- return __get_unaligned_memmove16((const u8 *)p);
-}
-
-static inline u32 get_unaligned_le32(const void *p)
-{
- return __get_unaligned_memmove32((const u8 *)p);
-}
-
-static inline u64 get_unaligned_le64(const void *p)
-{
- return __get_unaligned_memmove64((const u8 *)p);
-}
-
-static inline void put_unaligned_le16(u16 val, void *p)
-{
- __put_unaligned_memmove16(val, p);
-}
-
-static inline void put_unaligned_le32(u32 val, void *p)
-{
- __put_unaligned_memmove32(val, p);
-}
-
-static inline void put_unaligned_le64(u64 val, void *p)
-{
- __put_unaligned_memmove64(val, p);
-}
-
-#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_LE_STRUCT_H
-#define _LINUX_UNALIGNED_LE_STRUCT_H
-
-#include <linux/unaligned/packed_struct.h>
-
-static inline u16 get_unaligned_le16(const void *p)
-{
- return __get_unaligned_cpu16((const u8 *)p);
-}
-
-static inline u32 get_unaligned_le32(const void *p)
-{
- return __get_unaligned_cpu32((const u8 *)p);
-}
-
-static inline u64 get_unaligned_le64(const void *p)
-{
- return __get_unaligned_cpu64((const u8 *)p);
-}
-
-static inline void put_unaligned_le16(u16 val, void *p)
-{
- __put_unaligned_cpu16(val, p);
-}
-
-static inline void put_unaligned_le32(u32 val, void *p)
-{
- __put_unaligned_cpu32(val, p);
-}
-
-static inline void put_unaligned_le64(u64 val, void *p)
-{
- __put_unaligned_cpu64(val, p);
-}
-
-#endif /* _LINUX_UNALIGNED_LE_STRUCT_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_MEMMOVE_H
-#define _LINUX_UNALIGNED_MEMMOVE_H
-
-#include <linux/kernel.h>
-#include <linux/string.h>
-
-/* Use memmove here, so gcc does not insert a __builtin_memcpy. */
-
-static inline u16 __get_unaligned_memmove16(const void *p)
-{
- u16 tmp;
- memmove(&tmp, p, 2);
- return tmp;
-}
-
-static inline u32 __get_unaligned_memmove32(const void *p)
-{
- u32 tmp;
- memmove(&tmp, p, 4);
- return tmp;
-}
-
-static inline u64 __get_unaligned_memmove64(const void *p)
-{
- u64 tmp;
- memmove(&tmp, p, 8);
- return tmp;
-}
-
-static inline void __put_unaligned_memmove16(u16 val, void *p)
-{
- memmove(p, &val, 2);
-}
-
-static inline void __put_unaligned_memmove32(u32 val, void *p)
-{
- memmove(p, &val, 4);
-}
-
-static inline void __put_unaligned_memmove64(u64 val, void *p)
-{
- memmove(p, &val, 8);
-}
-
-#endif /* _LINUX_UNALIGNED_MEMMOVE_H */
+++ /dev/null
-#ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H
-#define _LINUX_UNALIGNED_PACKED_STRUCT_H
-
-#include <linux/kernel.h>
-
-struct __una_u16 { u16 x __attribute__((packed)); };
-struct __una_u32 { u32 x __attribute__((packed)); };
-struct __una_u64 { u64 x __attribute__((packed)); };
-
-static inline u16 __get_unaligned_cpu16(const void *p)
-{
- const struct __una_u16 *ptr = (const struct __una_u16 *)p;
- return ptr->x;
-}
-
-static inline u32 __get_unaligned_cpu32(const void *p)
-{
- const struct __una_u32 *ptr = (const struct __una_u32 *)p;
- return ptr->x;
-}
-
-static inline u64 __get_unaligned_cpu64(const void *p)
-{
- const struct __una_u64 *ptr = (const struct __una_u64 *)p;
- return ptr->x;
-}
-
-static inline void __put_unaligned_cpu16(u16 val, void *p)
-{
- struct __una_u16 *ptr = (struct __una_u16 *)p;
- ptr->x = val;
-}
-
-static inline void __put_unaligned_cpu32(u32 val, void *p)
-{
- struct __una_u32 *ptr = (struct __una_u32 *)p;
- ptr->x = val;
-}
-
-static inline void __put_unaligned_cpu64(u64 val, void *p)
-{
- struct __una_u64 *ptr = (struct __una_u64 *)p;
- ptr->x = val;
-}
-
-#endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */
+++ /dev/null
-/*
- * This file define a set of standard wireless extensions
- *
- * Version : 22 16.3.07
- *
- * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
- * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved.
- */
-
-#ifndef _LINUX_WIRELESS_H
-#define _LINUX_WIRELESS_H
-
-/************************** DOCUMENTATION **************************/
-/*
- * Initial APIs (1996 -> onward) :
- * -----------------------------
- * Basically, the wireless extensions are for now a set of standard ioctl
- * call + /proc/net/wireless
- *
- * The entry /proc/net/wireless give statistics and information on the
- * driver.
- * This is better than having each driver having its entry because
- * its centralised and we may remove the driver module safely.
- *
- * Ioctl are used to configure the driver and issue commands. This is
- * better than command line options of insmod because we may want to
- * change dynamically (while the driver is running) some parameters.
- *
- * The ioctl mechanimsm are copied from standard devices ioctl.
- * We have the list of command plus a structure descibing the
- * data exchanged...
- * Note that to add these ioctl, I was obliged to modify :
- * # net/core/dev.c (two place + add include)
- * # net/ipv4/af_inet.c (one place + add include)
- *
- * /proc/net/wireless is a copy of /proc/net/dev.
- * We have a structure for data passed from the driver to /proc/net/wireless
- * Too add this, I've modified :
- * # net/core/dev.c (two other places)
- * # include/linux/netdevice.h (one place)
- * # include/linux/proc_fs.h (one place)
- *
- * New driver API (2002 -> onward) :
- * -------------------------------
- * This file is only concerned with the user space API and common definitions.
- * The new driver API is defined and documented in :
- * # include/net/iw_handler.h
- *
- * Note as well that /proc/net/wireless implementation has now moved in :
- * # net/core/wireless.c
- *
- * Wireless Events (2002 -> onward) :
- * --------------------------------
- * Events are defined at the end of this file, and implemented in :
- * # net/core/wireless.c
- *
- * Other comments :
- * --------------
- * Do not add here things that are redundant with other mechanisms
- * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
- * wireless specific.
- *
- * These wireless extensions are not magic : each driver has to provide
- * support for them...
- *
- * IMPORTANT NOTE : As everything in the kernel, this is very much a
- * work in progress. Contact me if you have ideas of improvements...
- */
-
-/***************************** INCLUDES *****************************/
-
-#include <linux/types.h> /* for __u* and __s* typedefs */
-#include <linux/socket.h> /* for "struct sockaddr" et al */
-#include <linux/if.h> /* for IFNAMSIZ and co... */
-
-/***************************** VERSION *****************************/
-/*
- * This constant is used to know the availability of the wireless
- * extensions and to know which version of wireless extensions it is
- * (there is some stuff that will be added in the future...)
- * I just plan to increment with each new version.
- */
-#define WIRELESS_EXT 22
-
-/*
- * Changes :
- *
- * V2 to V3
- * --------
- * Alan Cox start some incompatibles changes. I've integrated a bit more.
- * - Encryption renamed to Encode to avoid US regulation problems
- * - Frequency changed from float to struct to avoid problems on old 386
- *
- * V3 to V4
- * --------
- * - Add sensitivity
- *
- * V4 to V5
- * --------
- * - Missing encoding definitions in range
- * - Access points stuff
- *
- * V5 to V6
- * --------
- * - 802.11 support (ESSID ioctls)
- *
- * V6 to V7
- * --------
- * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
- *
- * V7 to V8
- * --------
- * - Changed my e-mail address
- * - More 802.11 support (nickname, rate, rts, frag)
- * - List index in frequencies
- *
- * V8 to V9
- * --------
- * - Support for 'mode of operation' (ad-hoc, managed...)
- * - Support for unicast and multicast power saving
- * - Change encoding to support larger tokens (>64 bits)
- * - Updated iw_params (disable, flags) and use it for NWID
- * - Extracted iw_point from iwreq for clarity
- *
- * V9 to V10
- * ---------
- * - Add PM capability to range structure
- * - Add PM modifier : MAX/MIN/RELATIVE
- * - Add encoding option : IW_ENCODE_NOKEY
- * - Add TxPower ioctls (work like TxRate)
- *
- * V10 to V11
- * ----------
- * - Add WE version in range (help backward/forward compatibility)
- * - Add retry ioctls (work like PM)
- *
- * V11 to V12
- * ----------
- * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
- * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
- * - Add new statistics (frag, retry, beacon)
- * - Add average quality (for user space calibration)
- *
- * V12 to V13
- * ----------
- * - Document creation of new driver API.
- * - Extract union iwreq_data from struct iwreq (for new driver API).
- * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
- *
- * V13 to V14
- * ----------
- * - Wireless Events support : define struct iw_event
- * - Define additional specific event numbers
- * - Add "addr" and "param" fields in union iwreq_data
- * - AP scanning stuff (SIOCSIWSCAN and friends)
- *
- * V14 to V15
- * ----------
- * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
- * - Make struct iw_freq signed (both m & e), add explicit padding
- * - Add IWEVCUSTOM for driver specific event/scanning token
- * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
- * - Add IW_TXPOW_RANGE for range of Tx Powers
- * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
- * - Add IW_MODE_MONITOR for passive monitor
- *
- * V15 to V16
- * ----------
- * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
- * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
- * - Reshuffle struct iw_range for increases, add filler
- * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
- * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
- * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
- * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
- *
- * V16 to V17
- * ----------
- * - Add flags to frequency -> auto/fixed
- * - Document (struct iw_quality *)->updated, add new flags (INVALID)
- * - Wireless Event capability in struct iw_range
- * - Add support for relative TxPower (yick !)
- *
- * V17 to V18 (From Jouni Malinen <j@w1.fi>)
- * ----------
- * - Add support for WPA/WPA2
- * - Add extended encoding configuration (SIOCSIWENCODEEXT and
- * SIOCGIWENCODEEXT)
- * - Add SIOCSIWGENIE/SIOCGIWGENIE
- * - Add SIOCSIWMLME
- * - Add SIOCSIWPMKSA
- * - Add struct iw_range bit field for supported encoding capabilities
- * - Add optional scan request parameters for SIOCSIWSCAN
- * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
- * related parameters (extensible up to 4096 parameter values)
- * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
- * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
- *
- * V18 to V19
- * ----------
- * - Remove (struct iw_point *)->pointer from events and streams
- * - Remove header includes to help user space
- * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
- * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
- * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
- * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
- *
- * V19 to V20
- * ----------
- * - RtNetlink requests support (SET/GET)
- *
- * V20 to V21
- * ----------
- * - Remove (struct net_device *)->get_wireless_stats()
- * - Change length in ESSID and NICK to strlen() instead of strlen()+1
- * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
- * - Power/Retry relative values no longer * 100000
- * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
- *
- * V21 to V22
- * ----------
- * - Prevent leaking of kernel space in stream on 64 bits.
- */
-
-/**************************** CONSTANTS ****************************/
-
-/* -------------------------- IOCTL LIST -------------------------- */
-
-/* Wireless Identification */
-#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
-#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
-/* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
- * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
- * Don't put the name of your driver there, it's useless. */
-
-/* Basic operations */
-#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
-#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
-#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
-#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
-#define SIOCSIWMODE 0x8B06 /* set operation mode */
-#define SIOCGIWMODE 0x8B07 /* get operation mode */
-#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
-#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
-
-/* Informative stuff */
-#define SIOCSIWRANGE 0x8B0A /* Unused */
-#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
-#define SIOCSIWPRIV 0x8B0C /* Unused */
-#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
-#define SIOCSIWSTATS 0x8B0E /* Unused */
-#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
-/* SIOCGIWSTATS is strictly used between user space and the kernel, and
- * is never passed to the driver (i.e. the driver will never see it). */
-
-/* Spy support (statistics per MAC address - used for Mobile IP support) */
-#define SIOCSIWSPY 0x8B10 /* set spy addresses */
-#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
-#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
-#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
-
-/* Access Point manipulation */
-#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
-#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
-#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
-#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
-#define SIOCGIWSCAN 0x8B19 /* get scanning results */
-
-/* 802.11 specific support */
-#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
-#define SIOCGIWESSID 0x8B1B /* get ESSID */
-#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
-#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
-/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
- * within the 'iwreq' structure, so we need to use the 'data' member to
- * point to a string in user space, like it is done for RANGE... */
-
-/* Other parameters useful in 802.11 and some other devices */
-#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
-#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
-#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
-#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
-#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
-#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
-#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
-#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
-#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
-#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
-
-/* Encoding stuff (scrambling, hardware security, WEP...) */
-#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
-#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
-/* Power saving stuff (power management, unicast and multicast) */
-#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
-#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
-
-/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
- * This ioctl uses struct iw_point and data buffer that includes IE id and len
- * fields. More than one IE may be included in the request. Setting the generic
- * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
- * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
- * are required to report the used IE as a wireless event, e.g., when
- * associating with an AP. */
-#define SIOCSIWGENIE 0x8B30 /* set generic IE */
-#define SIOCGIWGENIE 0x8B31 /* get generic IE */
-
-/* WPA : IEEE 802.11 MLME requests */
-#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
- * struct iw_mlme */
-/* WPA : Authentication mode parameters */
-#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
-#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
-
-/* WPA : Extended version of encoding configuration */
-#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
-#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
-
-/* WPA2 : PMKSA cache management */
-#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
-
-/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
-
-/* These 32 ioctl are wireless device private, for 16 commands.
- * Each driver is free to use them for whatever purpose it chooses,
- * however the driver *must* export the description of those ioctls
- * with SIOCGIWPRIV and *must* use arguments as defined below.
- * If you don't follow those rules, DaveM is going to hate you (reason :
- * it make mixed 32/64bit operation impossible).
- */
-#define SIOCIWFIRSTPRIV 0x8BE0
-#define SIOCIWLASTPRIV 0x8BFF
-/* Previously, we were using SIOCDEVPRIVATE, but we now have our
- * separate range because of collisions with other tools such as
- * 'mii-tool'.
- * We now have 32 commands, so a bit more space ;-).
- * Also, all 'even' commands are only usable by root and don't return the
- * content of ifr/iwr to user (but you are not obliged to use the set/get
- * convention, just use every other two command). More details in iwpriv.c.
- * And I repeat : you are not forced to use them with iwpriv, but you
- * must be compliant with it.
- */
-
-/* ------------------------- IOCTL STUFF ------------------------- */
-
-/* The first and the last (range) */
-#define SIOCIWFIRST 0x8B00
-#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
-#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
-#define IW_HANDLER(id, func) \
- [IW_IOCTL_IDX(id)] = func
-
-/* Odd : get (world access), even : set (root access) */
-#define IW_IS_SET(cmd) (!((cmd) & 0x1))
-#define IW_IS_GET(cmd) ((cmd) & 0x1)
-
-/* ----------------------- WIRELESS EVENTS ----------------------- */
-/* Those are *NOT* ioctls, do not issue request on them !!! */
-/* Most events use the same identifier as ioctl requests */
-
-#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
-#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
-#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
-#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
-#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
-#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
- * (scan results); This includes id and
- * length fields. One IWEVGENIE may
- * contain more than one IE. Scan
- * results may contain one or more
- * IWEVGENIE events. */
-#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
- * (struct iw_michaelmicfailure)
- */
-#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
- * The data includes id and length
- * fields and may contain more than one
- * IE. This event is required in
- * Managed mode if the driver
- * generates its own WPA/RSN IE. This
- * should be sent just before
- * IWEVREGISTERED event for the
- * association. */
-#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
- * Response. The data includes id and
- * length fields and may contain more
- * than one IE. This may be sent
- * between IWEVASSOCREQIE and
- * IWEVREGISTERED events for the
- * association. */
-#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
- * pre-authentication
- * (struct iw_pmkid_cand) */
-
-#define IWEVFIRST 0x8C00
-#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
-
-/* ------------------------- PRIVATE INFO ------------------------- */
-/*
- * The following is used with SIOCGIWPRIV. It allow a driver to define
- * the interface (name, type of data) for its private ioctl.
- * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
- */
-
-#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
-#define IW_PRIV_TYPE_NONE 0x0000
-#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
-#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
-#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
-#define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
-#define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
-
-#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
-
-#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
-
-/*
- * Note : if the number of args is fixed and the size < 16 octets,
- * instead of passing a pointer we will put args in the iwreq struct...
- */
-
-/* ----------------------- OTHER CONSTANTS ----------------------- */
-
-/* Maximum frequencies in the range struct */
-#define IW_MAX_FREQUENCIES 32
-/* Note : if you have something like 80 frequencies,
- * don't increase this constant and don't fill the frequency list.
- * The user will be able to set by channel anyway... */
-
-/* Maximum bit rates in the range struct */
-#define IW_MAX_BITRATES 32
-
-/* Maximum tx powers in the range struct */
-#define IW_MAX_TXPOWER 8
-/* Note : if you more than 8 TXPowers, just set the max and min or
- * a few of them in the struct iw_range. */
-
-/* Maximum of address that you may set with SPY */
-#define IW_MAX_SPY 8
-
-/* Maximum of address that you may get in the
- list of access points in range */
-#define IW_MAX_AP 64
-
-/* Maximum size of the ESSID and NICKN strings */
-#define IW_ESSID_MAX_SIZE 32
-
-/* Modes of operation */
-#define IW_MODE_AUTO 0 /* Let the driver decides */
-#define IW_MODE_ADHOC 1 /* Single cell network */
-#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
-#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
-#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
-#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
-#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
-#define IW_MODE_MESH 7 /* Mesh (IEEE 802.11s) network */
-
-/* Statistics flags (bitmask in updated) */
-#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
-#define IW_QUAL_LEVEL_UPDATED 0x02
-#define IW_QUAL_NOISE_UPDATED 0x04
-#define IW_QUAL_ALL_UPDATED 0x07
-#define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
-#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
-#define IW_QUAL_LEVEL_INVALID 0x20
-#define IW_QUAL_NOISE_INVALID 0x40
-#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
-#define IW_QUAL_ALL_INVALID 0x70
-
-/* Frequency flags */
-#define IW_FREQ_AUTO 0x00 /* Let the driver decides */
-#define IW_FREQ_FIXED 0x01 /* Force a specific value */
-
-/* Maximum number of size of encoding token available
- * they are listed in the range structure */
-#define IW_MAX_ENCODING_SIZES 8
-
-/* Maximum size of the encoding token in bytes */
-#define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
-
-/* Flags for encoding (along with the token) */
-#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
-#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
-#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
-#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
-#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
-#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
-#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
-#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
-#define IW_ENCODE_TEMP 0x0400 /* Temporary key */
-
-/* Power management flags available (along with the value, if any) */
-#define IW_POWER_ON 0x0000 /* No details... */
-#define IW_POWER_TYPE 0xF000 /* Type of parameter */
-#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
-#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
-#define IW_POWER_MODE 0x0F00 /* Power Management mode */
-#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
-#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
-#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
-#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
-#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
-#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
-#define IW_POWER_MIN 0x0001 /* Value is a minimum */
-#define IW_POWER_MAX 0x0002 /* Value is a maximum */
-#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
-
-/* Transmit Power flags available */
-#define IW_TXPOW_TYPE 0x00FF /* Type of value */
-#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
-#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
-#define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
-#define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
-
-/* Retry limits and lifetime flags available */
-#define IW_RETRY_ON 0x0000 /* No details... */
-#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
-#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
-#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
-#define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */
-#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
-#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
-#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
-#define IW_RETRY_SHORT 0x0010 /* Value is for short packets */
-#define IW_RETRY_LONG 0x0020 /* Value is for long packets */
-
-/* Scanning request flags */
-#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
-#define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
-#define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
-#define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
-#define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
-#define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
-#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
-#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
-#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
-/* struct iw_scan_req scan_type */
-#define IW_SCAN_TYPE_ACTIVE 0
-#define IW_SCAN_TYPE_PASSIVE 1
-/* Maximum size of returned data */
-#define IW_SCAN_MAX_DATA 4096 /* In bytes */
-
-/* Scan capability flags - in (struct iw_range *)->scan_capa */
-#define IW_SCAN_CAPA_NONE 0x00
-#define IW_SCAN_CAPA_ESSID 0x01
-#define IW_SCAN_CAPA_BSSID 0x02
-#define IW_SCAN_CAPA_CHANNEL 0x04
-#define IW_SCAN_CAPA_MODE 0x08
-#define IW_SCAN_CAPA_RATE 0x10
-#define IW_SCAN_CAPA_TYPE 0x20
-#define IW_SCAN_CAPA_TIME 0x40
-
-/* Max number of char in custom event - use multiple of them if needed */
-#define IW_CUSTOM_MAX 256 /* In bytes */
-
-/* Generic information element */
-#define IW_GENERIC_IE_MAX 1024
-
-/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
-#define IW_MLME_DEAUTH 0
-#define IW_MLME_DISASSOC 1
-#define IW_MLME_AUTH 2
-#define IW_MLME_ASSOC 3
-
-/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
-#define IW_AUTH_INDEX 0x0FFF
-#define IW_AUTH_FLAGS 0xF000
-/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
- * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
- * parameter that is being set/get to; value will be read/written to
- * struct iw_param value field) */
-#define IW_AUTH_WPA_VERSION 0
-#define IW_AUTH_CIPHER_PAIRWISE 1
-#define IW_AUTH_CIPHER_GROUP 2
-#define IW_AUTH_KEY_MGMT 3
-#define IW_AUTH_TKIP_COUNTERMEASURES 4
-#define IW_AUTH_DROP_UNENCRYPTED 5
-#define IW_AUTH_80211_AUTH_ALG 6
-#define IW_AUTH_WPA_ENABLED 7
-#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
-#define IW_AUTH_ROAMING_CONTROL 9
-#define IW_AUTH_PRIVACY_INVOKED 10
-#define IW_AUTH_CIPHER_GROUP_MGMT 11
-#define IW_AUTH_MFP 12
-
-/* IW_AUTH_WPA_VERSION values (bit field) */
-#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
-#define IW_AUTH_WPA_VERSION_WPA 0x00000002
-#define IW_AUTH_WPA_VERSION_WPA2 0x00000004
-
-/* IW_AUTH_PAIRWISE_CIPHER, IW_AUTH_GROUP_CIPHER, and IW_AUTH_CIPHER_GROUP_MGMT
- * values (bit field) */
-#define IW_AUTH_CIPHER_NONE 0x00000001
-#define IW_AUTH_CIPHER_WEP40 0x00000002
-#define IW_AUTH_CIPHER_TKIP 0x00000004
-#define IW_AUTH_CIPHER_CCMP 0x00000008
-#define IW_AUTH_CIPHER_WEP104 0x00000010
-#define IW_AUTH_CIPHER_AES_CMAC 0x00000020
-
-/* IW_AUTH_KEY_MGMT values (bit field) */
-#define IW_AUTH_KEY_MGMT_802_1X 1
-#define IW_AUTH_KEY_MGMT_PSK 2
-
-/* IW_AUTH_80211_AUTH_ALG values (bit field) */
-#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
-#define IW_AUTH_ALG_SHARED_KEY 0x00000002
-#define IW_AUTH_ALG_LEAP 0x00000004
-
-/* IW_AUTH_ROAMING_CONTROL values */
-#define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
-#define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
- * control */
-
-/* IW_AUTH_MFP (management frame protection) values */
-#define IW_AUTH_MFP_DISABLED 0 /* MFP disabled */
-#define IW_AUTH_MFP_OPTIONAL 1 /* MFP optional */
-#define IW_AUTH_MFP_REQUIRED 2 /* MFP required */
-
-/* SIOCSIWENCODEEXT definitions */
-#define IW_ENCODE_SEQ_MAX_SIZE 8
-/* struct iw_encode_ext ->alg */
-#define IW_ENCODE_ALG_NONE 0
-#define IW_ENCODE_ALG_WEP 1
-#define IW_ENCODE_ALG_TKIP 2
-#define IW_ENCODE_ALG_CCMP 3
-#define IW_ENCODE_ALG_PMK 4
-#define IW_ENCODE_ALG_AES_CMAC 5
-/* struct iw_encode_ext ->ext_flags */
-#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
-#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
-#define IW_ENCODE_EXT_GROUP_KEY 0x00000004
-#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
-
-/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
-#define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
-#define IW_MICFAILURE_GROUP 0x00000004
-#define IW_MICFAILURE_PAIRWISE 0x00000008
-#define IW_MICFAILURE_STAKEY 0x00000010
-#define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
- */
-
-/* Bit field values for enc_capa in struct iw_range */
-#define IW_ENC_CAPA_WPA 0x00000001
-#define IW_ENC_CAPA_WPA2 0x00000002
-#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
-#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
-#define IW_ENC_CAPA_4WAY_HANDSHAKE 0x00000010
-
-/* Event capability macros - in (struct iw_range *)->event_capa
- * Because we have more than 32 possible events, we use an array of
- * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
-#define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
- (cmd - SIOCIWFIRSTPRIV + 0x60) : \
- (cmd - SIOCIWFIRST))
-#define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
-#define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
-/* Event capability constants - event autogenerated by the kernel
- * This list is valid for most 802.11 devices, customise as needed... */
-#define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
- IW_EVENT_CAPA_MASK(0x8B06) | \
- IW_EVENT_CAPA_MASK(0x8B1A))
-#define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
-/* "Easy" macro to set events in iw_range (less efficient) */
-#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
-#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
-
-
-/****************************** TYPES ******************************/
-
-/* --------------------------- SUBTYPES --------------------------- */
-/*
- * Generic format for most parameters that fit in an int
- */
-struct iw_param
-{
- __s32 value; /* The value of the parameter itself */
- __u8 fixed; /* Hardware should not use auto select */
- __u8 disabled; /* Disable the feature */
- __u16 flags; /* Various specifc flags (if any) */
-};
-
-/*
- * For all data larger than 16 octets, we need to use a
- * pointer to memory allocated in user space.
- */
-struct iw_point
-{
- void __user *pointer; /* Pointer to the data (in user space) */
- __u16 length; /* number of fields or size in bytes */
- __u16 flags; /* Optional params */
-};
-
-#ifdef __KERNEL__
-#ifdef CONFIG_COMPAT
-
-#include <linux/compat.h>
-
-struct compat_iw_point {
- compat_caddr_t pointer;
- __u16 length;
- __u16 flags;
-};
-#endif
-#endif
-
-/*
- * A frequency
- * For numbers lower than 10^9, we encode the number in 'm' and
- * set 'e' to 0
- * For number greater than 10^9, we divide it by the lowest power
- * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
- * The power of 10 is in 'e', the result of the division is in 'm'.
- */
-struct iw_freq
-{
- __s32 m; /* Mantissa */
- __s16 e; /* Exponent */
- __u8 i; /* List index (when in range struct) */
- __u8 flags; /* Flags (fixed/auto) */
-};
-
-/*
- * Quality of the link
- */
-struct iw_quality
-{
- __u8 qual; /* link quality (%retries, SNR,
- %missed beacons or better...) */
- __u8 level; /* signal level (dBm) */
- __u8 noise; /* noise level (dBm) */
- __u8 updated; /* Flags to know if updated */
-};
-
-/*
- * Packet discarded in the wireless adapter due to
- * "wireless" specific problems...
- * Note : the list of counter and statistics in net_device_stats
- * is already pretty exhaustive, and you should use that first.
- * This is only additional stats...
- */
-struct iw_discarded
-{
- __u32 nwid; /* Rx : Wrong nwid/essid */
- __u32 code; /* Rx : Unable to code/decode (WEP) */
- __u32 fragment; /* Rx : Can't perform MAC reassembly */
- __u32 retries; /* Tx : Max MAC retries num reached */
- __u32 misc; /* Others cases */
-};
-
-/*
- * Packet/Time period missed in the wireless adapter due to
- * "wireless" specific problems...
- */
-struct iw_missed
-{
- __u32 beacon; /* Missed beacons/superframe */
-};
-
-/*
- * Quality range (for spy threshold)
- */
-struct iw_thrspy
-{
- struct sockaddr addr; /* Source address (hw/mac) */
- struct iw_quality qual; /* Quality of the link */
- struct iw_quality low; /* Low threshold */
- struct iw_quality high; /* High threshold */
-};
-
-/*
- * Optional data for scan request
- *
- * Note: these optional parameters are controlling parameters for the
- * scanning behavior, these do not apply to getting scan results
- * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
- * provide a merged results with all BSSes even if the previous scan
- * request limited scanning to a subset, e.g., by specifying an SSID.
- * Especially, scan results are required to include an entry for the
- * current BSS if the driver is in Managed mode and associated with an AP.
- */
-struct iw_scan_req
-{
- __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
- __u8 essid_len;
- __u8 num_channels; /* num entries in channel_list;
- * 0 = scan all allowed channels */
- __u8 flags; /* reserved as padding; use zero, this may
- * be used in the future for adding flags
- * to request different scan behavior */
- struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
- * individual address of a specific BSS */
-
- /*
- * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
- * the current ESSID. This allows scan requests for specific ESSID
- * without having to change the current ESSID and potentially breaking
- * the current association.
- */
- __u8 essid[IW_ESSID_MAX_SIZE];
-
- /*
- * Optional parameters for changing the default scanning behavior.
- * These are based on the MLME-SCAN.request from IEEE Std 802.11.
- * TU is 1.024 ms. If these are set to 0, driver is expected to use
- * reasonable default values. min_channel_time defines the time that
- * will be used to wait for the first reply on each channel. If no
- * replies are received, next channel will be scanned after this. If
- * replies are received, total time waited on the channel is defined by
- * max_channel_time.
- */
- __u32 min_channel_time; /* in TU */
- __u32 max_channel_time; /* in TU */
-
- struct iw_freq channel_list[IW_MAX_FREQUENCIES];
-};
-
-/* ------------------------- WPA SUPPORT ------------------------- */
-
-/*
- * Extended data structure for get/set encoding (this is used with
- * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
- * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
- * only the data contents changes (key data -> this structure, including
- * key data).
- *
- * If the new key is the first group key, it will be set as the default
- * TX key. Otherwise, default TX key index is only changed if
- * IW_ENCODE_EXT_SET_TX_KEY flag is set.
- *
- * Key will be changed with SIOCSIWENCODEEXT in all cases except for
- * special "change TX key index" operation which is indicated by setting
- * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
- *
- * tx_seq/rx_seq are only used when respective
- * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
- * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
- * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
- * used only by an Authenticator (AP or an IBSS station) to get the
- * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
- * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
- * debugging/testing.
- */
-struct iw_encode_ext
-{
- __u32 ext_flags; /* IW_ENCODE_EXT_* */
- __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
- __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
- struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
- * (group) keys or unicast address for
- * individual keys */
- __u16 alg; /* IW_ENCODE_ALG_* */
- __u16 key_len;
- __u8 key[0];
-};
-
-/* SIOCSIWMLME data */
-struct iw_mlme
-{
- __u16 cmd; /* IW_MLME_* */
- __u16 reason_code;
- struct sockaddr addr;
-};
-
-/* SIOCSIWPMKSA data */
-#define IW_PMKSA_ADD 1
-#define IW_PMKSA_REMOVE 2
-#define IW_PMKSA_FLUSH 3
-
-#define IW_PMKID_LEN 16
-
-struct iw_pmksa
-{
- __u32 cmd; /* IW_PMKSA_* */
- struct sockaddr bssid;
- __u8 pmkid[IW_PMKID_LEN];
-};
-
-/* IWEVMICHAELMICFAILURE data */
-struct iw_michaelmicfailure
-{
- __u32 flags;
- struct sockaddr src_addr;
- __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
-};
-
-/* IWEVPMKIDCAND data */
-#define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
-struct iw_pmkid_cand
-{
- __u32 flags; /* IW_PMKID_CAND_* */
- __u32 index; /* the smaller the index, the higher the
- * priority */
- struct sockaddr bssid;
-};
-
-/* ------------------------ WIRELESS STATS ------------------------ */
-/*
- * Wireless statistics (used for /proc/net/wireless)
- */
-struct iw_statistics
-{
- __u16 status; /* Status
- * - device dependent for now */
-
- struct iw_quality qual; /* Quality of the link
- * (instant/mean/max) */
- struct iw_discarded discard; /* Packet discarded counts */
- struct iw_missed miss; /* Packet missed counts */
-};
-
-/* ------------------------ IOCTL REQUEST ------------------------ */
-/*
- * This structure defines the payload of an ioctl, and is used
- * below.
- *
- * Note that this structure should fit on the memory footprint
- * of iwreq (which is the same as ifreq), which mean a max size of
- * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
- * You should check this when increasing the structures defined
- * above in this file...
- */
-union iwreq_data
-{
- /* Config - generic */
- char name[IFNAMSIZ];
- /* Name : used to verify the presence of wireless extensions.
- * Name of the protocol/provider... */
-
- struct iw_point essid; /* Extended network name */
- struct iw_param nwid; /* network id (or domain - the cell) */
- struct iw_freq freq; /* frequency or channel :
- * 0-1000 = channel
- * > 1000 = frequency in Hz */
-
- struct iw_param sens; /* signal level threshold */
- struct iw_param bitrate; /* default bit rate */
- struct iw_param txpower; /* default transmit power */
- struct iw_param rts; /* RTS threshold threshold */
- struct iw_param frag; /* Fragmentation threshold */
- __u32 mode; /* Operation mode */
- struct iw_param retry; /* Retry limits & lifetime */
-
- struct iw_point encoding; /* Encoding stuff : tokens */
- struct iw_param power; /* PM duration/timeout */
- struct iw_quality qual; /* Quality part of statistics */
-
- struct sockaddr ap_addr; /* Access point address */
- struct sockaddr addr; /* Destination address (hw/mac) */
-
- struct iw_param param; /* Other small parameters */
- struct iw_point data; /* Other large parameters */
-};
-
-/*
- * The structure to exchange data for ioctl.
- * This structure is the same as 'struct ifreq', but (re)defined for
- * convenience...
- * Do I need to remind you about structure size (32 octets) ?
- */
-struct iwreq
-{
- union
- {
- char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
- } ifr_ifrn;
-
- /* Data part (defined just above) */
- union iwreq_data u;
-};
-
-/* -------------------------- IOCTL DATA -------------------------- */
-/*
- * For those ioctl which want to exchange mode data that what could
- * fit in the above structure...
- */
-
-/*
- * Range of parameters
- */
-
-struct iw_range
-{
- /* Informative stuff (to choose between different interface) */
- __u32 throughput; /* To give an idea... */
- /* In theory this value should be the maximum benchmarked
- * TCP/IP throughput, because with most of these devices the
- * bit rate is meaningless (overhead an co) to estimate how
- * fast the connection will go and pick the fastest one.
- * I suggest people to play with Netperf or any benchmark...
- */
-
- /* NWID (or domain id) */
- __u32 min_nwid; /* Minimal NWID we are able to set */
- __u32 max_nwid; /* Maximal NWID we are able to set */
-
- /* Old Frequency (backward compat - moved lower ) */
- __u16 old_num_channels;
- __u8 old_num_frequency;
-
- /* Scan capabilities */
- __u8 scan_capa; /* IW_SCAN_CAPA_* bit field */
-
- /* Wireless event capability bitmasks */
- __u32 event_capa[6];
-
- /* signal level threshold range */
- __s32 sensitivity;
-
- /* Quality of link & SNR stuff */
- /* Quality range (link, level, noise)
- * If the quality is absolute, it will be in the range [0 ; max_qual],
- * if the quality is dBm, it will be in the range [max_qual ; 0].
- * Don't forget that we use 8 bit arithmetics... */
- struct iw_quality max_qual; /* Quality of the link */
- /* This should contain the average/typical values of the quality
- * indicator. This should be the threshold between a "good" and
- * a "bad" link (example : monitor going from green to orange).
- * Currently, user space apps like quality monitors don't have any
- * way to calibrate the measurement. With this, they can split
- * the range between 0 and max_qual in different quality level
- * (using a geometric subdivision centered on the average).
- * I expect that people doing the user space apps will feedback
- * us on which value we need to put in each driver... */
- struct iw_quality avg_qual; /* Quality of the link */
-
- /* Rates */
- __u8 num_bitrates; /* Number of entries in the list */
- __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
-
- /* RTS threshold */
- __s32 min_rts; /* Minimal RTS threshold */
- __s32 max_rts; /* Maximal RTS threshold */
-
- /* Frag threshold */
- __s32 min_frag; /* Minimal frag threshold */
- __s32 max_frag; /* Maximal frag threshold */
-
- /* Power Management duration & timeout */
- __s32 min_pmp; /* Minimal PM period */
- __s32 max_pmp; /* Maximal PM period */
- __s32 min_pmt; /* Minimal PM timeout */
- __s32 max_pmt; /* Maximal PM timeout */
- __u16 pmp_flags; /* How to decode max/min PM period */
- __u16 pmt_flags; /* How to decode max/min PM timeout */
- __u16 pm_capa; /* What PM options are supported */
-
- /* Encoder stuff */
- __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
- __u8 num_encoding_sizes; /* Number of entry in the list */
- __u8 max_encoding_tokens; /* Max number of tokens */
- /* For drivers that need a "login/passwd" form */
- __u8 encoding_login_index; /* token index for login token */
-
- /* Transmit power */
- __u16 txpower_capa; /* What options are supported */
- __u8 num_txpower; /* Number of entries in the list */
- __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
-
- /* Wireless Extension version info */
- __u8 we_version_compiled; /* Must be WIRELESS_EXT */
- __u8 we_version_source; /* Last update of source */
-
- /* Retry limits and lifetime */
- __u16 retry_capa; /* What retry options are supported */
- __u16 retry_flags; /* How to decode max/min retry limit */
- __u16 r_time_flags; /* How to decode max/min retry life */
- __s32 min_retry; /* Minimal number of retries */
- __s32 max_retry; /* Maximal number of retries */
- __s32 min_r_time; /* Minimal retry lifetime */
- __s32 max_r_time; /* Maximal retry lifetime */
-
- /* Frequency */
- __u16 num_channels; /* Number of channels [0; num - 1] */
- __u8 num_frequency; /* Number of entry in the list */
- struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
- /* Note : this frequency list doesn't need to fit channel numbers,
- * because each entry contain its channel index */
-
- __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
-};
-
-/*
- * Private ioctl interface information
- */
-
-struct iw_priv_args
-{
- __u32 cmd; /* Number of the ioctl to issue */
- __u16 set_args; /* Type and number of args */
- __u16 get_args; /* Type and number of args */
- char name[IFNAMSIZ]; /* Name of the extension */
-};
-
-/* ----------------------- WIRELESS EVENTS ----------------------- */
-/*
- * Wireless events are carried through the rtnetlink socket to user
- * space. They are encapsulated in the IFLA_WIRELESS field of
- * a RTM_NEWLINK message.
- */
-
-/*
- * A Wireless Event. Contains basically the same data as the ioctl...
- */
-struct iw_event
-{
- __u16 len; /* Real length of this stuff */
- __u16 cmd; /* Wireless IOCTL */
- union iwreq_data u; /* IOCTL fixed payload */
-};
-
-/* Size of the Event prefix (including padding and alignement junk) */
-#define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
-/* Size of the various events */
-#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
-#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
-#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
-#define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
-#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
-#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
-
-/* iw_point events are special. First, the payload (extra data) come at
- * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
- * we omit the pointer, so start at an offset. */
-#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
- (char *) NULL)
-#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
- IW_EV_POINT_OFF)
-
-#ifdef __KERNEL__
-#ifdef CONFIG_COMPAT
-struct __compat_iw_event {
- __u16 len; /* Real length of this stuff */
- __u16 cmd; /* Wireless IOCTL */
- compat_caddr_t pointer;
-};
-#define IW_EV_COMPAT_LCP_LEN offsetof(struct __compat_iw_event, pointer)
-#define IW_EV_COMPAT_POINT_OFF offsetof(struct compat_iw_point, length)
-
-/* Size of the various events for compat */
-#define IW_EV_COMPAT_CHAR_LEN (IW_EV_COMPAT_LCP_LEN + IFNAMSIZ)
-#define IW_EV_COMPAT_UINT_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(__u32))
-#define IW_EV_COMPAT_FREQ_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct iw_freq))
-#define IW_EV_COMPAT_PARAM_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct iw_param))
-#define IW_EV_COMPAT_ADDR_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct sockaddr))
-#define IW_EV_COMPAT_QUAL_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct iw_quality))
-#define IW_EV_COMPAT_POINT_LEN \
- (IW_EV_COMPAT_LCP_LEN + sizeof(struct compat_iw_point) - \
- IW_EV_COMPAT_POINT_OFF)
-#endif
-#endif
-
-/* Size of the Event prefix when packed in stream */
-#define IW_EV_LCP_PK_LEN (4)
-/* Size of the various events when packed in stream */
-#define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ)
-#define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(__u32))
-#define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
-#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
-#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
-#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
-#define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4)
-
-#endif /* _LINUX_WIRELESS_H */
+++ /dev/null
-#ifndef LINUX_ADDRCONF_H
-#define LINUX_ADDRCONF_H
-
-#include "../../compat/config.h"
-
-#include_next <net/addrconf.h>
-
-#ifndef HAVE_ADDRCONF_IFID_EUI48
-static inline int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
-{
- if (dev->addr_len != ETH_ALEN)
- return -1;
- memcpy(eui, dev->dev_addr, 3);
- memcpy(eui + 5, dev->dev_addr + 3, 3);
-
- /*
- * The zSeries OSA network cards can be shared among various
- * OS instances, but the OSA cards have only one MAC address.
- * This leads to duplicate address conflicts in conjunction
- * with IPv6 if more than one instance uses the same card.
- *
- * The driver for these cards can deliver a unique 16-bit
- * identifier for each instance sharing the same card. It is
- * placed instead of 0xFFFE in the interface identifier. The
- * "u" bit of the interface identifier is not inverted in this
- * case. Hence the resulting interface identifier has local
- * scope according to RFC2373.
- */
- if (dev->dev_id) {
- eui[3] = (dev->dev_id >> 8) & 0xFF;
- eui[4] = dev->dev_id & 0xFF;
- } else {
- eui[3] = 0xFF;
- eui[4] = 0xFE;
- eui[0] ^= 2;
- }
- return 0;
-}
-#endif
-
-#endif /* LINUX_ADDRCONF_H */
+++ /dev/null
-#ifndef LINUX_BONDING_H
-#define LINUX_BONDING_H
-
-#include "../../compat/config.h"
-
-#ifdef HAVE_BONDING_H
-#include_next <net/bonding.h>
-
-#define MLX_USES_PRIMARY(mode) \
- (((mode) == BOND_MODE_ACTIVEBACKUP) || \
- ((mode) == BOND_MODE_TLB) || \
- ((mode) == BOND_MODE_ALB))
-
-#define bond_option_active_slave_get_rcu LINUX_BACKPORT(bond_option_active_slave_get_rcu)
-static inline struct net_device *bond_option_active_slave_get_rcu(struct bonding
- *bond)
-{
- struct slave *slave = rcu_dereference(bond->curr_active_slave);
-
- return MLX_USES_PRIMARY(bond->params.mode) && slave ? slave->dev : NULL;
-}
-#endif /* HAVE_BONDING_H */
-
-#endif /* LINUX_BONDING_H */
+++ /dev/null
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
-#include_next <net/codel.h>
-#else
-
-#ifndef __NET_SCHED_CODEL_H
-#define __NET_SCHED_CODEL_H
-
-/*
- * Codel - The Controlled-Delay Active Queue Management algorithm
- *
- * Copyright (C) 2011-2012 Kathleen Nichols <nichols@pollere.com>
- * Copyright (C) 2011-2012 Van Jacobson <van@pollere.net>
- * Copyright (C) 2012 Michael D. Taht <dave.taht@bufferbloat.net>
- * Copyright (C) 2012 Eric Dumazet <edumazet@google.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The names of the authors may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- */
-
-#include <linux/types.h>
-#include <linux/ktime.h>
-#include <linux/skbuff.h>
-#include <net/pkt_sched.h>
-#include <net/inet_ecn.h>
-#include <linux/reciprocal_div.h>
-
-/* Controlling Queue Delay (CoDel) algorithm
- * =========================================
- * Source : Kathleen Nichols and Van Jacobson
- * http://queue.acm.org/detail.cfm?id=2209336
- *
- * Implemented on linux by Dave Taht and Eric Dumazet
- */
-
-
-/* CoDel uses a 1024 nsec clock, encoded in u32
- * This gives a range of 2199 seconds, because of signed compares
- */
-typedef u32 codel_time_t;
-typedef s32 codel_tdiff_t;
-#define CODEL_SHIFT 10
-#define MS2TIME(a) ((a * NSEC_PER_MSEC) >> CODEL_SHIFT)
-
-static inline codel_time_t codel_get_time(void)
-{
- u64 ns = ktime_to_ns(ktime_get());
-
- return ns >> CODEL_SHIFT;
-}
-
-#define codel_time_after(a, b) ((s32)(a) - (s32)(b) > 0)
-#define codel_time_after_eq(a, b) ((s32)(a) - (s32)(b) >= 0)
-#define codel_time_before(a, b) ((s32)(a) - (s32)(b) < 0)
-#define codel_time_before_eq(a, b) ((s32)(a) - (s32)(b) <= 0)
-
-/* Qdiscs using codel plugin must use codel_skb_cb in their own cb[] */
-struct codel_skb_cb {
- codel_time_t enqueue_time;
-};
-
-static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb)
-{
- qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb));
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37))
- return (struct codel_skb_cb *)qdisc_skb_cb((struct sk_buff *) skb)->data;
-#else
- return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data;
-#endif
-}
-
-static codel_time_t codel_get_enqueue_time(const struct sk_buff *skb)
-{
- return get_codel_cb(skb)->enqueue_time;
-}
-
-static void codel_set_enqueue_time(struct sk_buff *skb)
-{
- get_codel_cb(skb)->enqueue_time = codel_get_time();
-}
-
-static inline u32 codel_time_to_us(codel_time_t val)
-{
- u64 valns = ((u64)val << CODEL_SHIFT);
-
- do_div(valns, NSEC_PER_USEC);
- return (u32)valns;
-}
-
-/**
- * struct codel_params - contains codel parameters
- * @target: target queue size (in time units)
- * @interval: width of moving time window
- * @ecn: is Explicit Congestion Notification enabled
- */
-struct codel_params {
- codel_time_t target;
- codel_time_t interval;
- bool ecn;
-};
-
-/**
- * struct codel_vars - contains codel variables
- * @count: how many drops we've done since the last time we
- * entered dropping state
- * @lastcount: count at entry to dropping state
- * @dropping: set to true if in dropping state
- * @rec_inv_sqrt: reciprocal value of sqrt(count) >> 1
- * @first_above_time: when we went (or will go) continuously above target
- * for interval
- * @drop_next: time to drop next packet, or when we dropped last
- * @ldelay: sojourn time of last dequeued packet
- */
-struct codel_vars {
- u32 count;
- u32 lastcount;
- bool dropping;
- u16 rec_inv_sqrt;
- codel_time_t first_above_time;
- codel_time_t drop_next;
- codel_time_t ldelay;
-};
-
-#define REC_INV_SQRT_BITS (8 * sizeof(u16)) /* or sizeof_in_bits(rec_inv_sqrt) */
-/* needed shift to get a Q0.32 number from rec_inv_sqrt */
-#define REC_INV_SQRT_SHIFT (32 - REC_INV_SQRT_BITS)
-
-/**
- * struct codel_stats - contains codel shared variables and stats
- * @maxpacket: largest packet we've seen so far
- * @drop_count: temp count of dropped packets in dequeue()
- * ecn_mark: number of packets we ECN marked instead of dropping
- */
-struct codel_stats {
- u32 maxpacket;
- u32 drop_count;
- u32 ecn_mark;
-};
-
-static void codel_params_init(struct codel_params *params)
-{
- params->interval = MS2TIME(100);
- params->target = MS2TIME(5);
- params->ecn = false;
-}
-
-static void codel_vars_init(struct codel_vars *vars)
-{
- memset(vars, 0, sizeof(*vars));
-}
-
-static void codel_stats_init(struct codel_stats *stats)
-{
- stats->maxpacket = 256;
-}
-
-/*
- * http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots
- * new_invsqrt = (invsqrt / 2) * (3 - count * invsqrt^2)
- *
- * Here, invsqrt is a fixed point number (< 1.0), 32bit mantissa, aka Q0.32
- */
-static void codel_Newton_step(struct codel_vars *vars)
-{
- u32 invsqrt = ((u32)vars->rec_inv_sqrt) << REC_INV_SQRT_SHIFT;
- u32 invsqrt2 = ((u64)invsqrt * invsqrt) >> 32;
- u64 val = (3LL << 32) - ((u64)vars->count * invsqrt2);
-
- val >>= 2; /* avoid overflow in following multiply */
- val = (val * invsqrt) >> (32 - 2 + 1);
-
- vars->rec_inv_sqrt = val >> REC_INV_SQRT_SHIFT;
-}
-
-/*
- * CoDel control_law is t + interval/sqrt(count)
- * We maintain in rec_inv_sqrt the reciprocal value of sqrt(count) to avoid
- * both sqrt() and divide operation.
- */
-static codel_time_t codel_control_law(codel_time_t t,
- codel_time_t interval,
- u32 rec_inv_sqrt)
-{
- return t + reciprocal_divide(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT);
-}
-
-
-static bool codel_should_drop(const struct sk_buff *skb,
- struct Qdisc *sch,
- struct codel_vars *vars,
- struct codel_params *params,
- struct codel_stats *stats,
- codel_time_t now)
-{
- bool ok_to_drop;
-
- if (!skb) {
- vars->first_above_time = 0;
- return false;
- }
-
- vars->ldelay = now - codel_get_enqueue_time(skb);
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37))
- sch->qstats.backlog -= qdisc_pkt_len((struct sk_buff *)skb);
-#else
- sch->qstats.backlog -= qdisc_pkt_len(skb);
-#endif
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37))
- if (unlikely(qdisc_pkt_len((struct sk_buff *)skb) > stats->maxpacket))
- stats->maxpacket = qdisc_pkt_len((struct sk_buff *)skb);
-#else
- if (unlikely(qdisc_pkt_len(skb) > stats->maxpacket))
- stats->maxpacket = qdisc_pkt_len(skb);
-#endif
-
- if (codel_time_before(vars->ldelay, params->target) ||
- sch->qstats.backlog <= stats->maxpacket) {
- /* went below - stay below for at least interval */
- vars->first_above_time = 0;
- return false;
- }
- ok_to_drop = false;
- if (vars->first_above_time == 0) {
- /* just went above from below. If we stay above
- * for at least interval we'll say it's ok to drop
- */
- vars->first_above_time = now + params->interval;
- } else if (codel_time_after(now, vars->first_above_time)) {
- ok_to_drop = true;
- }
- return ok_to_drop;
-}
-
-typedef struct sk_buff * (*codel_skb_dequeue_t)(struct codel_vars *vars,
- struct Qdisc *sch);
-
-static struct sk_buff *codel_dequeue(struct Qdisc *sch,
- struct codel_params *params,
- struct codel_vars *vars,
- struct codel_stats *stats,
- codel_skb_dequeue_t dequeue_func)
-{
- struct sk_buff *skb = dequeue_func(vars, sch);
- codel_time_t now;
- bool drop;
-
- if (!skb) {
- vars->dropping = false;
- return skb;
- }
- now = codel_get_time();
- drop = codel_should_drop(skb, sch, vars, params, stats, now);
- if (vars->dropping) {
- if (!drop) {
- /* sojourn time below target - leave dropping state */
- vars->dropping = false;
- } else if (codel_time_after_eq(now, vars->drop_next)) {
- /* It's time for the next drop. Drop the current
- * packet and dequeue the next. The dequeue might
- * take us out of dropping state.
- * If not, schedule the next drop.
- * A large backlog might result in drop rates so high
- * that the next drop should happen now,
- * hence the while loop.
- */
- while (vars->dropping &&
- codel_time_after_eq(now, vars->drop_next)) {
- vars->count++; /* dont care of possible wrap
- * since there is no more divide
- */
- codel_Newton_step(vars);
- if (params->ecn && INET_ECN_set_ce(skb)) {
- stats->ecn_mark++;
- vars->drop_next =
- codel_control_law(vars->drop_next,
- params->interval,
- vars->rec_inv_sqrt);
- goto end;
- }
- qdisc_drop(skb, sch);
- stats->drop_count++;
- skb = dequeue_func(vars, sch);
- if (!codel_should_drop(skb, sch,
- vars, params, stats, now)) {
- /* leave dropping state */
- vars->dropping = false;
- } else {
- /* and schedule the next drop */
- vars->drop_next =
- codel_control_law(vars->drop_next,
- params->interval,
- vars->rec_inv_sqrt);
- }
- }
- }
- } else if (drop) {
- if (params->ecn && INET_ECN_set_ce(skb)) {
- stats->ecn_mark++;
- } else {
- qdisc_drop(skb, sch);
- stats->drop_count++;
-
- skb = dequeue_func(vars, sch);
- drop = codel_should_drop(skb, sch, vars, params,
- stats, now);
- }
- vars->dropping = true;
- /* if min went above target close to when we last went below it
- * assume that the drop rate that controlled the queue on the
- * last cycle is a good starting point to control it now.
- */
- if (codel_time_before(now - vars->drop_next,
- 16 * params->interval)) {
- vars->count = (vars->count - vars->lastcount) | 1;
- /* we dont care if rec_inv_sqrt approximation
- * is not very precise :
- * Next Newton steps will correct it quadratically.
- */
- codel_Newton_step(vars);
- } else {
- vars->count = 1;
- vars->rec_inv_sqrt = ~0U >> REC_INV_SQRT_SHIFT;
- }
- vars->lastcount = vars->count;
- vars->drop_next = codel_control_law(now, params->interval,
- vars->rec_inv_sqrt);
- }
-end:
- return skb;
-}
-#endif
-#endif
+++ /dev/null
-#ifndef _COMPAT_NET_DEVLINK_H
-#define _COMPAT_NET_DEVLINK_H 1
-
-#include "../../compat/config.h"
-
-#ifdef HAVE_NET_DEVLINK_H
-#include_next <net/devlink.h>
-#endif
-
-#endif /* _COMPAT_NET_DEVLINK_H */
+++ /dev/null
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
-#include_next <net/flow_keys.h>
-#else
-
-#ifndef _NET_FLOW_KEYS_H
-#define _NET_FLOW_KEYS_H
-
-struct flow_keys {
- /* (src,dst) must be grouped, in the same way than in IP header */
- __be32 src;
- __be32 dst;
- union {
- __be32 ports;
- __be16 port16[2];
- };
- u8 ip_proto;
-};
-
-extern bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow);
-#endif
-#endif
+++ /dev/null
-#ifndef _COMPAT_NET_NET_NAMESPACE_H
-#define _COMPAT_NET_NET_NAMESPACE_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23))
-#include_next <net/net_namespace.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) */
-
-#endif /* _COMPAT_NET_NET_NAMESPACE_H */
+++ /dev/null
-#include <linux/version.h>
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
-#include <pcmcia/cs_types.h>
-#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
-#include <pcmcia/cs.h>
-#endif
-
-#include_next <pcmcia/cistpl.h>
+++ /dev/null
-#ifndef COMPAT_SCSI_SCSI_H
-#define COMPAT_SCSI_SCSI_H
-
-#include_next <scsi/scsi.h>
-
-#ifndef SCSI_MAX_SG_CHAIN_SEGMENTS
-#define SCSI_MAX_SG_CHAIN_SEGMENTS SG_MAX_SEGMENTS
-#endif
-
-#endif /* COMPAT_SCSI_SCSI_H */
+++ /dev/null
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
-#include_next <trace/define_trace.h>
-#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) */
+++ /dev/null
-# do not edit this file, it will be overwritten on update
-
-# compat_firmware-class requests, copies files into the kernel
-SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
+++ /dev/null
-#!/bin/sh -e
-
-# This is ported from Ubuntu but ubuntu uses these directories which
-# other distributions don't care about:
-# FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
-# /lib/firmware/$(uname -r) /lib/firmware"
-# If your distribution looks for firmware in other directories
-# feel free to extend this and add your own directory here.
-#
-FIRMWARE_DIRS="/lib/firmware"
-
-err() {
- echo "$@" >&2
- logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
-}
-
-if [ ! -e /sys$DEVPATH/loading ]; then
- err "udev firmware loader misses sysfs directory"
- exit 1
-fi
-
-for DIR in $FIRMWARE_DIRS; do
- [ -e "$DIR/$FIRMWARE" ] || continue
- echo 1 > /sys$DEVPATH/loading
- cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
- echo 0 > /sys$DEVPATH/loading
- exit 0
-done
-
-echo -1 > /sys$DEVPATH/loading
-err "Cannot find firmware file '$FIRMWARE'"
-mkdir -p /dev/.udev/firmware-missing
-file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
-ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
-exit 1
+++ /dev/null
-# do not edit this file, it will be overwritten on update
-
-# compat_firmware-class requests, copies files into the kernel
-SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
+++ /dev/null
-#!/bin/sh -e
-
-FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
- /lib/firmware/$(uname -r) /lib/firmware"
-
-err() {
- echo "$@" >&2
- logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
-}
-
-if [ ! -e /sys$DEVPATH/loading ]; then
- err "udev firmware loader misses sysfs directory"
- exit 1
-fi
-
-for DIR in $FIRMWARE_DIRS; do
- [ -e "$DIR/$FIRMWARE" ] || continue
- echo 1 > /sys$DEVPATH/loading
- cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
- echo 0 > /sys$DEVPATH/loading
- exit 0
-done
-
-echo -1 > /sys$DEVPATH/loading
-err "Cannot find firmware file '$FIRMWARE'"
-mkdir -p /dev/.udev/firmware-missing
-file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
-ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
-exit 1