2005-08-31 16:53:10 +00:00
|
|
|
/*
|
|
|
|
* ASIX AX8817X based USB 2.0 Ethernet Devices
|
2006-07-29 14:12:50 +00:00
|
|
|
* Copyright (C) 2003-2006 David Hollis <dhollis@davehollis.com>
|
2005-08-31 16:53:10 +00:00
|
|
|
* Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
|
2006-07-29 14:12:50 +00:00
|
|
|
* Copyright (C) 2006 James Painter <jamie.painter@iname.com>
|
2005-08-31 16:53:10 +00:00
|
|
|
* Copyright (c) 2002-2003 TiVo Inc.
|
|
|
|
*
|
|
|
|
* 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
|
2013-12-06 14:28:46 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2005-08-31 16:53:10 +00:00
|
|
|
*/
|
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
#ifndef _ASIX_H
|
|
|
|
#define _ASIX_H
|
|
|
|
|
2005-08-31 16:53:10 +00:00
|
|
|
// #define DEBUG // error path messages, extra info
|
|
|
|
// #define VERBOSE // more; success messages
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/mii.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/crc32.h>
|
2008-01-25 22:51:45 +00:00
|
|
|
#include <linux/usb/usbnet.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2012-05-28 22:31:41 +00:00
|
|
|
#include <linux/if_vlan.h>
|
2005-08-31 16:53:10 +00:00
|
|
|
|
2011-12-22 20:38:51 +00:00
|
|
|
#define DRIVER_VERSION "22-Dec-2011"
|
2011-10-04 09:55:18 +00:00
|
|
|
#define DRIVER_NAME "asix"
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2005-08-31 16:53:10 +00:00
|
|
|
/* ASIX AX8817X based USB 2.0 Ethernet Devices */
|
|
|
|
|
|
|
|
#define AX_CMD_SET_SW_MII 0x06
|
|
|
|
#define AX_CMD_READ_MII_REG 0x07
|
|
|
|
#define AX_CMD_WRITE_MII_REG 0x08
|
|
|
|
#define AX_CMD_SET_HW_MII 0x0a
|
|
|
|
#define AX_CMD_READ_EEPROM 0x0b
|
|
|
|
#define AX_CMD_WRITE_EEPROM 0x0c
|
|
|
|
#define AX_CMD_WRITE_ENABLE 0x0d
|
|
|
|
#define AX_CMD_WRITE_DISABLE 0x0e
|
2006-07-29 14:12:50 +00:00
|
|
|
#define AX_CMD_READ_RX_CTL 0x0f
|
2005-08-31 16:53:10 +00:00
|
|
|
#define AX_CMD_WRITE_RX_CTL 0x10
|
|
|
|
#define AX_CMD_READ_IPG012 0x11
|
|
|
|
#define AX_CMD_WRITE_IPG0 0x12
|
|
|
|
#define AX_CMD_WRITE_IPG1 0x13
|
2006-07-29 14:12:50 +00:00
|
|
|
#define AX_CMD_READ_NODE_ID 0x13
|
2010-03-09 12:24:38 +00:00
|
|
|
#define AX_CMD_WRITE_NODE_ID 0x14
|
2005-08-31 16:53:10 +00:00
|
|
|
#define AX_CMD_WRITE_IPG2 0x14
|
|
|
|
#define AX_CMD_WRITE_MULTI_FILTER 0x16
|
2006-07-29 14:12:50 +00:00
|
|
|
#define AX88172_CMD_READ_NODE_ID 0x17
|
2005-08-31 16:53:10 +00:00
|
|
|
#define AX_CMD_READ_PHY_ID 0x19
|
|
|
|
#define AX_CMD_READ_MEDIUM_STATUS 0x1a
|
|
|
|
#define AX_CMD_WRITE_MEDIUM_MODE 0x1b
|
|
|
|
#define AX_CMD_READ_MONITOR_MODE 0x1c
|
|
|
|
#define AX_CMD_WRITE_MONITOR_MODE 0x1d
|
2006-07-29 14:12:50 +00:00
|
|
|
#define AX_CMD_READ_GPIOS 0x1e
|
2005-08-31 16:53:10 +00:00
|
|
|
#define AX_CMD_WRITE_GPIOS 0x1f
|
|
|
|
#define AX_CMD_SW_RESET 0x20
|
|
|
|
#define AX_CMD_SW_PHY_STATUS 0x21
|
|
|
|
#define AX_CMD_SW_PHY_SELECT 0x22
|
|
|
|
|
2012-07-13 05:26:31 +00:00
|
|
|
#define AX_PHY_SELECT_MASK (BIT(3) | BIT(2))
|
|
|
|
#define AX_PHY_SELECT_INTERNAL 0
|
|
|
|
#define AX_PHY_SELECT_EXTERNAL BIT(2)
|
|
|
|
|
2005-08-31 16:53:10 +00:00
|
|
|
#define AX_MONITOR_MODE 0x01
|
|
|
|
#define AX_MONITOR_LINK 0x02
|
|
|
|
#define AX_MONITOR_MAGIC 0x04
|
|
|
|
#define AX_MONITOR_HSFS 0x10
|
|
|
|
|
|
|
|
/* AX88172 Medium Status Register values */
|
2006-07-29 14:12:50 +00:00
|
|
|
#define AX88172_MEDIUM_FD 0x02
|
|
|
|
#define AX88172_MEDIUM_TX 0x04
|
|
|
|
#define AX88172_MEDIUM_FC 0x10
|
|
|
|
#define AX88172_MEDIUM_DEFAULT \
|
|
|
|
( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC )
|
2005-08-31 16:53:10 +00:00
|
|
|
|
|
|
|
#define AX_MCAST_FILTER_SIZE 8
|
|
|
|
#define AX_MAX_MCAST 64
|
|
|
|
|
|
|
|
#define AX_SWRESET_CLEAR 0x00
|
|
|
|
#define AX_SWRESET_RR 0x01
|
|
|
|
#define AX_SWRESET_RT 0x02
|
|
|
|
#define AX_SWRESET_PRTE 0x04
|
|
|
|
#define AX_SWRESET_PRL 0x08
|
|
|
|
#define AX_SWRESET_BZ 0x10
|
|
|
|
#define AX_SWRESET_IPRL 0x20
|
|
|
|
#define AX_SWRESET_IPPD 0x40
|
|
|
|
|
|
|
|
#define AX88772_IPG0_DEFAULT 0x15
|
|
|
|
#define AX88772_IPG1_DEFAULT 0x0c
|
|
|
|
#define AX88772_IPG2_DEFAULT 0x12
|
|
|
|
|
2006-07-29 14:12:50 +00:00
|
|
|
/* AX88772 & AX88178 Medium Mode Register */
|
|
|
|
#define AX_MEDIUM_PF 0x0080
|
|
|
|
#define AX_MEDIUM_JFE 0x0040
|
|
|
|
#define AX_MEDIUM_TFC 0x0020
|
|
|
|
#define AX_MEDIUM_RFC 0x0010
|
|
|
|
#define AX_MEDIUM_ENCK 0x0008
|
|
|
|
#define AX_MEDIUM_AC 0x0004
|
|
|
|
#define AX_MEDIUM_FD 0x0002
|
|
|
|
#define AX_MEDIUM_GM 0x0001
|
|
|
|
#define AX_MEDIUM_SM 0x1000
|
|
|
|
#define AX_MEDIUM_SBP 0x0800
|
|
|
|
#define AX_MEDIUM_PS 0x0200
|
|
|
|
#define AX_MEDIUM_RE 0x0100
|
|
|
|
|
|
|
|
#define AX88178_MEDIUM_DEFAULT \
|
|
|
|
(AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
|
|
|
|
AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
|
2011-10-04 09:55:18 +00:00
|
|
|
AX_MEDIUM_RE)
|
2005-08-31 16:53:10 +00:00
|
|
|
|
2006-07-29 14:12:50 +00:00
|
|
|
#define AX88772_MEDIUM_DEFAULT \
|
|
|
|
(AX_MEDIUM_FD | AX_MEDIUM_RFC | \
|
|
|
|
AX_MEDIUM_TFC | AX_MEDIUM_PS | \
|
2011-10-04 09:55:18 +00:00
|
|
|
AX_MEDIUM_AC | AX_MEDIUM_RE)
|
2006-07-29 14:12:50 +00:00
|
|
|
|
|
|
|
/* AX88772 & AX88178 RX_CTL values */
|
2011-10-04 09:55:18 +00:00
|
|
|
#define AX_RX_CTL_SO 0x0080
|
|
|
|
#define AX_RX_CTL_AP 0x0020
|
|
|
|
#define AX_RX_CTL_AM 0x0010
|
|
|
|
#define AX_RX_CTL_AB 0x0008
|
|
|
|
#define AX_RX_CTL_SEP 0x0004
|
|
|
|
#define AX_RX_CTL_AMALL 0x0002
|
|
|
|
#define AX_RX_CTL_PRO 0x0001
|
|
|
|
#define AX_RX_CTL_MFB_2048 0x0000
|
|
|
|
#define AX_RX_CTL_MFB_4096 0x0100
|
|
|
|
#define AX_RX_CTL_MFB_8192 0x0200
|
|
|
|
#define AX_RX_CTL_MFB_16384 0x0300
|
|
|
|
|
|
|
|
#define AX_DEFAULT_RX_CTL (AX_RX_CTL_SO | AX_RX_CTL_AB)
|
2006-07-29 14:12:50 +00:00
|
|
|
|
|
|
|
/* GPIO 0 .. 2 toggles */
|
|
|
|
#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */
|
|
|
|
#define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */
|
|
|
|
#define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */
|
|
|
|
#define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */
|
|
|
|
#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */
|
|
|
|
#define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */
|
|
|
|
#define AX_GPIO_RESERVED 0x40 /* Reserved */
|
|
|
|
#define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */
|
|
|
|
|
|
|
|
#define AX_EEPROM_MAGIC 0xdeadbeef
|
2012-07-19 00:23:06 +00:00
|
|
|
#define AX_EEPROM_LEN 0x200
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2005-08-31 16:53:10 +00:00
|
|
|
/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
|
2006-03-29 01:15:42 +00:00
|
|
|
struct asix_data {
|
2005-08-31 16:53:10 +00:00
|
|
|
u8 multi_filter[AX_MCAST_FILTER_SIZE];
|
2010-03-09 12:24:38 +00:00
|
|
|
u8 mac_addr[ETH_ALEN];
|
2006-07-29 14:12:50 +00:00
|
|
|
u8 phymode;
|
|
|
|
u8 ledmode;
|
2012-07-19 00:23:06 +00:00
|
|
|
u8 res;
|
2005-08-31 16:53:10 +00:00
|
|
|
};
|
|
|
|
|
2013-01-16 04:24:07 +00:00
|
|
|
struct asix_rx_fixup_info {
|
|
|
|
struct sk_buff *ax_skb;
|
|
|
|
u32 header;
|
2015-10-02 13:29:04 +00:00
|
|
|
u16 remaining;
|
2013-01-16 04:24:07 +00:00
|
|
|
bool split_head;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct asix_common_private {
|
|
|
|
struct asix_rx_fixup_info rx_fixup_info;
|
|
|
|
};
|
|
|
|
|
2013-08-09 17:31:22 +00:00
|
|
|
extern const struct driver_info ax88172a_info;
|
|
|
|
|
2013-01-16 04:24:06 +00:00
|
|
|
/* ASIX specific flags */
|
|
|
|
#define FLAG_EEPROM_MAC (1UL << 0) /* init device MAC from eeprom */
|
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
|
|
|
|
u16 size, void *data);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
|
|
|
|
u16 size, void *data);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
|
|
|
|
u16 index, u16 size, void *data);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2013-01-16 04:24:07 +00:00
|
|
|
int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
|
|
|
|
struct asix_rx_fixup_info *rx);
|
|
|
|
int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
|
|
|
|
gfp_t flags);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_set_sw_mii(struct usbnet *dev);
|
|
|
|
int asix_set_hw_mii(struct usbnet *dev);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:31 +00:00
|
|
|
int asix_read_phy_addr(struct usbnet *dev, int internal);
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_get_phy_addr(struct usbnet *dev);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_sw_reset(struct usbnet *dev, u8 flags);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
u16 asix_read_rx_ctl(struct usbnet *dev);
|
|
|
|
int asix_write_rx_ctl(struct usbnet *dev, u16 mode);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
u16 asix_read_medium_status(struct usbnet *dev);
|
|
|
|
int asix_write_medium_mode(struct usbnet *dev, u16 mode);
|
2005-08-31 16:53:10 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_write_gpio(struct usbnet *dev, u16 value, int sleep);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
void asix_set_multicast(struct net_device *net);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_mdio_read(struct net_device *netdev, int phy_id, int loc);
|
|
|
|
void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
|
|
|
|
int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
|
2006-07-29 14:12:50 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_get_eeprom_len(struct net_device *net);
|
|
|
|
int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
|
|
|
|
u8 *data);
|
2012-07-19 00:23:07 +00:00
|
|
|
int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
|
|
|
|
u8 *data);
|
2005-08-31 16:53:10 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info);
|
2005-08-31 16:53:10 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
int asix_set_mac_address(struct net_device *net, void *p);
|
2005-08-31 16:53:10 +00:00
|
|
|
|
2012-07-13 05:26:30 +00:00
|
|
|
#endif /* _ASIX_H */
|