diff options
Diffstat (limited to 'drivers/net/atlx')
| -rw-r--r-- | drivers/net/atlx/Makefile | 3 | ||||
| -rw-r--r-- | drivers/net/atlx/atl1.c | 3675 | ||||
| -rw-r--r-- | drivers/net/atlx/atl1.h | 792 | ||||
| -rw-r--r-- | drivers/net/atlx/atl2.c | 3119 | ||||
| -rw-r--r-- | drivers/net/atlx/atl2.h | 525 | ||||
| -rw-r--r-- | drivers/net/atlx/atlx.c | 269 | ||||
| -rw-r--r-- | drivers/net/atlx/atlx.h | 503 |
7 files changed, 8886 insertions, 0 deletions
diff --git a/drivers/net/atlx/Makefile b/drivers/net/atlx/Makefile new file mode 100644 index 00000000000..e4f6022ca55 --- /dev/null +++ b/drivers/net/atlx/Makefile | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | obj-$(CONFIG_ATL1) += atl1.o | ||
| 2 | obj-$(CONFIG_ATL2) += atl2.o | ||
| 3 | |||
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c new file mode 100644 index 00000000000..97e6954304e --- /dev/null +++ b/drivers/net/atlx/atl1.c | |||
| @@ -0,0 +1,3675 @@ | |||
| 1 | /* | ||
| 2 | * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. | ||
| 3 | * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> | ||
| 4 | * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com> | ||
| 5 | * | ||
| 6 | * Derived from Intel e1000 driver | ||
| 7 | * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | ||
| 10 | * under the terms of the GNU General Public License as published by the Free | ||
| 11 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 12 | * any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 17 | * more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License along with | ||
| 20 | * this program; if not, write to the Free Software Foundation, Inc., 59 | ||
| 21 | * Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 22 | * | ||
| 23 | * The full GNU General Public License is included in this distribution in the | ||
| 24 | * file called COPYING. | ||
| 25 | * | ||
| 26 | * Contact Information: | ||
| 27 | * Xiong Huang <xiong.huang@atheros.com> | ||
| 28 | * Jie Yang <jie.yang@atheros.com> | ||
| 29 | * Chris Snook <csnook@redhat.com> | ||
| 30 | * Jay Cliburn <jcliburn@gmail.com> | ||
| 31 | * | ||
| 32 | * This version is adapted from the Attansic reference driver. | ||
| 33 | * | ||
| 34 | * TODO: | ||
| 35 | * Add more ethtool functions. | ||
| 36 | * Fix abstruse irq enable/disable condition described here: | ||
| 37 | * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2 | ||
| 38 | * | ||
| 39 | * NEEDS TESTING: | ||
| 40 | * VLAN | ||
| 41 | * multicast | ||
| 42 | * promiscuous mode | ||
| 43 | * interrupt coalescing | ||
| 44 | * SMP torture testing | ||
| 45 | */ | ||
| 46 | |||
| 47 | #include <linux/atomic.h> | ||
| 48 | #include <asm/byteorder.h> | ||
| 49 | |||
| 50 | #include <linux/compiler.h> | ||
| 51 | #include <linux/crc32.h> | ||
| 52 | #include <linux/delay.h> | ||
| 53 | #include <linux/dma-mapping.h> | ||
| 54 | #include <linux/etherdevice.h> | ||
| 55 | #include <linux/hardirq.h> | ||
| 56 | #include <linux/if_ether.h> | ||
| 57 | #include <linux/if_vlan.h> | ||
| 58 | #include <linux/in.h> | ||
| 59 | #include <linux/interrupt.h> | ||
| 60 | #include <linux/ip.h> | ||
| 61 | #include <linux/irqflags.h> | ||
| 62 | #include <linux/irqreturn.h> | ||
| 63 | #include <linux/jiffies.h> | ||
| 64 | #include <linux/mii.h> | ||
| 65 | #include <linux/module.h> | ||
| 66 | #include <linux/moduleparam.h> | ||
| 67 | #include <linux/net.h> | ||
| 68 | #include <linux/netdevice.h> | ||
| 69 | #include <linux/pci.h> | ||
| 70 | #include <linux/pci_ids.h> | ||
| 71 | #include <linux/pm.h> | ||
| 72 | #include <linux/skbuff.h> | ||
| 73 | #include <linux/slab.h> | ||
| 74 | #include <linux/spinlock.h> | ||
| 75 | #include <linux/string.h> | ||
| 76 | #include <linux/tcp.h> | ||
| 77 | #include <linux/timer.h> | ||
| 78 | #include <linux/types.h> | ||
| 79 | #include <linux/workqueue.h> | ||
| 80 | |||
| 81 | #include <net/checksum.h> | ||
| 82 | |||
| 83 | #include "atl1.h" | ||
| 84 | |||
| 85 | #define ATLX_DRIVER_VERSION "2.1.3" | ||
| 86 | MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, " | ||
| 87 | "Chris Snook <csnook@redhat.com>, " | ||
| 88 | "Jay Cliburn <jcliburn@gmail.com>"); | ||
| 89 | MODULE_LICENSE("GPL"); | ||
| 90 | MODULE_VERSION(ATLX_DRIVER_VERSION); | ||
| 91 | |||
| 92 | /* Temporary hack for merging atl1 and atl2 */ | ||
| 93 | #include "atlx.c" | ||
| 94 | |||
| 95 | static const struct ethtool_ops atl1_ethtool_ops; | ||
| 96 | |||
| 97 | /* | ||
| 98 | * This is the only thing that needs to be changed to adjust the | ||
| 99 | * maximum number of ports that the driver can manage. | ||
| 100 | */ | ||
| 101 | #define ATL1_MAX_NIC 4 | ||
| 102 | |||
| 103 | #define OPTION_UNSET -1 | ||
| 104 | #define OPTION_DISABLED 0 | ||
| 105 | #define OPTION_ENABLED 1 | ||
| 106 | |||
| 107 | #define ATL1_PARAM_INIT { [0 ... ATL1_MAX_NIC] = OPTION_UNSET } | ||
| 108 | |||
| 109 | /* | ||
| 110 | * Interrupt Moderate Timer in units of 2 us | ||
| 111 | * | ||
| 112 | * Valid Range: 10-65535 | ||
| 113 | * | ||
| 114 | * Default Value: 100 (200us) | ||
| 115 | */ | ||
| 116 | static int __devinitdata int_mod_timer[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT; | ||
| 117 | static unsigned int num_int_mod_timer; | ||
| 118 | module_param_array_named(int_mod_timer, int_mod_timer, int, | ||
| 119 | &num_int_mod_timer, 0); | ||
| 120 | MODULE_PARM_DESC(int_mod_timer, "Interrupt moderator timer"); | ||
| 121 | |||
| 122 | #define DEFAULT_INT_MOD_CNT 100 /* 200us */ | ||
| 123 | #define MAX_INT_MOD_CNT 65000 | ||
| 124 | #define MIN_INT_MOD_CNT 50 | ||
| 125 | |||
| 126 | struct atl1_option { | ||
| 127 | enum { enable_option, range_option, list_option } type; | ||
| 128 | char *name; | ||
| 129 | char *err; | ||
| 130 | int def; | ||
| 131 | union { | ||
| 132 | struct { /* range_option info */ | ||
| 133 | int min; | ||
| 134 | int max; | ||
| 135 | } r; | ||
| 136 | struct { /* list_option info */ | ||
| 137 | int nr; | ||
| 138 | struct atl1_opt_list { | ||
| 139 | int i; | ||
| 140 | char *str; | ||
| 141 | } *p; | ||
| 142 | } l; | ||
| 143 | } arg; | ||
| 144 | }; | ||
| 145 | |||
| 146 | static int __devinit atl1_validate_option(int *value, struct atl1_option *opt, | ||
| 147 | struct pci_dev *pdev) | ||
| 148 | { | ||
| 149 | if (*value == OPTION_UNSET) { | ||
| 150 | *value = opt->def; | ||
| 151 | return 0; | ||
| 152 | } | ||
| 153 | |||
| 154 | switch (opt->type) { | ||
| 155 | case enable_option: | ||
| 156 | switch (*value) { | ||
| 157 | case OPTION_ENABLED: | ||
| 158 | dev_info(&pdev->dev, "%s enabled\n", opt->name); | ||
| 159 | return 0; | ||
| 160 | case OPTION_DISABLED: | ||
| 161 | dev_info(&pdev->dev, "%s disabled\n", opt->name); | ||
| 162 | return 0; | ||
| 163 | } | ||
| 164 | break; | ||
| 165 | case range_option: | ||
| 166 | if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { | ||
| 167 | dev_info(&pdev->dev, "%s set to %i\n", opt->name, | ||
| 168 | *value); | ||
| 169 | return 0; | ||
| 170 | } | ||
| 171 | break; | ||
| 172 | case list_option:{ | ||
| 173 | int i; | ||
| 174 | struct atl1_opt_list *ent; | ||
| 175 | |||
| 176 | for (i = 0; i < opt->arg.l.nr; i++) { | ||
| 177 | ent = &opt->arg.l.p[i]; | ||
| 178 | if (*value == ent->i) { | ||
| 179 | if (ent->str[0] != '\0') | ||
| 180 | dev_info(&pdev->dev, "%s\n", | ||
| 181 | ent->str); | ||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | } | ||
| 186 | break; | ||
| 187 | |||
| 188 | default: | ||
| 189 | break; | ||
| 190 | } | ||
| 191 | |||
| 192 | dev_info(&pdev->dev, "invalid %s specified (%i) %s\n", | ||
| 193 | opt->name, *value, opt->err); | ||
| 194 | *value = opt->def; | ||
| 195 | return -1; | ||
| 196 | } | ||
| 197 | |||
| 198 | /* | ||
| 199 | * atl1_check_options - Range Checking for Command Line Parameters | ||
| 200 | * @adapter: board private structure | ||
| 201 | * | ||
| 202 | * This routine checks all command line parameters for valid user | ||
| 203 | * input. If an invalid value is given, or if no user specified | ||
| 204 | * value exists, a default value is used. The final value is stored | ||
| 205 | * in a variable in the adapter structure. | ||
| 206 | */ | ||
| 207 | static void __devinit atl1_check_options(struct atl1_adapter *adapter) | ||
| 208 | { | ||
| 209 | struct pci_dev *pdev = adapter->pdev; | ||
| 210 | int bd = adapter->bd_number; | ||
| 211 | |||
