| 1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
/* |
| 3 |
* ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices |
| 4 |
* |
| 5 |
* Copyright (C) 2011-2013 ASIX |
| 6 |
*/ |
| 7 |
|
| 8 |
#include <linux/module.h> |
| 9 |
#include <linux/etherdevice.h> |
| 10 |
#include <linux/mii.h> |
| 11 |
#include <linux/usb.h> |
| 12 |
#include <linux/crc32.h> |
| 13 |
#include <linux/usb/usbnet.h> |
| 14 |
#include <uapi/linux/mdio.h> |
| 15 |
#include <linux/mdio.h> |
| 16 |
|
| 17 |
#define AX88179_PHY_ID 0x03 |
| 18 |
#define AX_EEPROM_LEN 0x100 |
| 19 |
#define AX88179_EEPROM_MAGIC 0x17900b95 |
| 20 |
#define AX_MCAST_FLTSIZE 8 |
| 21 |
#define AX_MAX_MCAST 64 |
| 22 |
#define AX_INT_PPLS_LINK ((u32)BIT(16)) |
| 23 |
#define AX_RXHDR_L4_TYPE_MASK 0x1c |
| 24 |
#define AX_RXHDR_L4_TYPE_UDP 4 |
| 25 |
#define AX_RXHDR_L4_TYPE_TCP 16 |
| 26 |
#define AX_RXHDR_L3CSUM_ERR 2 |
| 27 |
#define AX_RXHDR_L4CSUM_ERR 1 |
| 28 |
#define AX_RXHDR_CRC_ERR ((u32)BIT(29)) |
| 29 |
#define AX_RXHDR_DROP_ERR ((u32)BIT(31)) |
| 30 |
#define AX_ACCESS_MAC 0x01 |
| 31 |
#define AX_ACCESS_PHY 0x02 |
| 32 |
#define AX_ACCESS_EEPROM 0x04 |
| 33 |
#define AX_ACCESS_EFUS 0x05 |
| 34 |
#define AX_RELOAD_EEPROM_EFUSE 0x06 |
| 35 |
#define AX_PAUSE_WATERLVL_HIGH 0x54 |
| 36 |
#define AX_PAUSE_WATERLVL_LOW 0x55 |
| 37 |
|
| 38 |
#define PHYSICAL_LINK_STATUS 0x02 |
| 39 |
#define AX_USB_SS 0x04 |
| 40 |
#define AX_USB_HS 0x02 |
| 41 |
|
| 42 |
#define GENERAL_STATUS 0x03 |
| 43 |
/* Check AX88179 version. UA1:Bit2 = 0, UA2:Bit2 = 1 */ |
| 44 |
#define AX_SECLD 0x04 |
| 45 |
|
| 46 |
#define AX_SROM_ADDR 0x07 |
| 47 |
#define AX_SROM_CMD 0x0a |
| 48 |
#define EEP_RD 0x04 |
| 49 |
#define EEP_BUSY 0x10 |
| 50 |
|
| 51 |
#define AX_SROM_DATA_LOW 0x08 |
| 52 |
#define AX_SROM_DATA_HIGH 0x09 |
| 53 |
|
| 54 |
#define AX_RX_CTL 0x0b |
| 55 |
#define AX_RX_CTL_DROPCRCERR 0x0100 |
| 56 |
#define AX_RX_CTL_IPE 0x0200 |
| 57 |
#define AX_RX_CTL_START 0x0080 |
| 58 |
#define AX_RX_CTL_AP 0x0020 |
| 59 |
#define AX_RX_CTL_AM 0x0010 |
| 60 |
#define AX_RX_CTL_AB 0x0008 |
| 61 |
#define AX_RX_CTL_AMALL 0x0002 |
| 62 |
#define AX_RX_CTL_PRO 0x0001 |
| 63 |
#define AX_RX_CTL_STOP 0x0000 |
| 64 |
|
| 65 |
#define AX_NODE_ID 0x10 |
| 66 |
#define AX_MULFLTARY 0x16 |
| 67 |
|
| 68 |
#define AX_MEDIUM_STATUS_MODE 0x22 |
| 69 |
#define AX_MEDIUM_GIGAMODE 0x01 |
| 70 |
#define AX_MEDIUM_FULL_DUPLEX 0x02 |
| 71 |
#define AX_MEDIUM_EN_125MHZ 0x08 |
| 72 |
#define AX_MEDIUM_RXFLOW_CTRLEN 0x10 |
| 73 |
#define AX_MEDIUM_TXFLOW_CTRLEN 0x20 |
| 74 |
#define AX_MEDIUM_RECEIVE_EN 0x100 |
| 75 |
#define AX_MEDIUM_PS 0x200 |
| 76 |
#define AX_MEDIUM_JUMBO_EN 0x8040 |
| 77 |
|
| 78 |
#define AX_MONITOR_MOD 0x24 |
| 79 |
#define AX_MONITOR_MODE_RWLC 0x02 |
| 80 |
#define AX_MONITOR_MODE_RWMP 0x04 |
| 81 |
#define AX_MONITOR_MODE_PMEPOL 0x20 |
| 82 |
#define AX_MONITOR_MODE_PMETYPE 0x40 |
| 83 |
|
| 84 |
#define AX_GPIO_CTRL 0x25 |
| 85 |
#define AX_GPIO_CTRL_GPIO3EN 0x80 |
| 86 |
#define AX_GPIO_CTRL_GPIO2EN 0x40 |
| 87 |
#define AX_GPIO_CTRL_GPIO1EN 0x20 |
| 88 |
|
| 89 |
#define AX_PHYPWR_RSTCTL 0x26 |
| 90 |
#define AX_PHYPWR_RSTCTL_BZ 0x0010 |
| 91 |
#define AX_PHYPWR_RSTCTL_IPRL 0x0020 |
| 92 |
#define AX_PHYPWR_RSTCTL_AT 0x1000 |
| 93 |
|
| 94 |
#define AX_RX_BULKIN_QCTRL 0x2e |
| 95 |
#define AX_CLK_SELECT 0x33 |
| 96 |
#define AX_CLK_SELECT_BCS 0x01 |
| 97 |
#define AX_CLK_SELECT_ACS 0x02 |
| 98 |
#define AX_CLK_SELECT_ULR 0x08 |
| 99 |
|
| 100 |
#define AX_RXCOE_CTL 0x34 |
| 101 |
#define AX_RXCOE_IP 0x01 |
| 102 |
#define AX_RXCOE_TCP 0x02 |
| 103 |
#define AX_RXCOE_UDP 0x04 |
| 104 |
#define AX_RXCOE_TCPV6 0x20 |
| 105 |
#define AX_RXCOE_UDPV6 0x40 |
| 106 |
|
| 107 |
#define AX_TXCOE_CTL 0x35 |
| 108 |
#define AX_TXCOE_IP 0x01 |
| 109 |
#define AX_TXCOE_TCP 0x02 |
| 110 |
#define AX_TXCOE_UDP 0x04 |
| 111 |
#define AX_TXCOE_TCPV6 0x20 |
| 112 |
#define AX_TXCOE_UDPV6 0x40 |
| 113 |
|
| 114 |
#define AX_LEDCTRL 0x73 |
| 115 |
|
| 116 |
#define GMII_PHY_PHYSR 0x11 |
| 117 |
#define GMII_PHY_PHYSR_SMASK 0xc000 |
| 118 |
#define GMII_PHY_PHYSR_GIGA 0x8000 |
| 119 |
#define GMII_PHY_PHYSR_100 0x4000 |
| 120 |
#define GMII_PHY_PHYSR_FULL 0x2000 |
| 121 |
#define GMII_PHY_PHYSR_LINK 0x400 |
| 122 |
|
| 123 |
#define GMII_LED_ACT 0x1a |
| 124 |
#define GMII_LED_ACTIVE_MASK 0xff8f |
| 125 |
#define GMII_LED0_ACTIVE BIT(4) |
| 126 |
#define GMII_LED1_ACTIVE BIT(5) |
| 127 |
#define GMII_LED2_ACTIVE BIT(6) |
| 128 |
|
| 129 |
#define GMII_LED_LINK 0x1c |
| 130 |
#define GMII_LED_LINK_MASK 0xf888 |
| 131 |
#define GMII_LED0_LINK_10 BIT(0) |
| 132 |
#define GMII_LED0_LINK_100 BIT(1) |
| 133 |
#define GMII_LED0_LINK_1000 BIT(2) |
| 134 |
#define GMII_LED1_LINK_10 BIT(4) |
| 135 |
#define GMII_LED1_LINK_100 BIT(5) |
| 136 |
#define GMII_LED1_LINK_1000 BIT(6) |
| 137 |
#define GMII_LED2_LINK_10 BIT(8) |
| 138 |
#define GMII_LED2_LINK_100 BIT(9) |
| 139 |
#define GMII_LED2_LINK_1000 BIT(10) |
| 140 |
#define LED0_ACTIVE BIT(0) |
| 141 |
#define LED0_LINK_10 BIT(1) |
| 142 |
#define LED0_LINK_100 BIT(2) |
| 143 |
#define LED0_LINK_1000 BIT(3) |
| 144 |
#define LED0_FD BIT(4) |
| 145 |
#define LED0_USB3_MASK 0x001f |
| 146 |
#define LED1_ACTIVE BIT(5) |
| 147 |
#define LED1_LINK_10 BIT(6) |
| 148 |
#define LED1_LINK_100 BIT(7) |
| 149 |
#define LED1_LINK_1000 BIT(8) |
| 150 |
#define LED1_FD BIT(9) |
| 151 |
#define LED1_USB3_MASK 0x03e0 |
| 152 |
#define LED2_ACTIVE BIT(10) |
| 153 |
#define LED2_LINK_1000 BIT(13) |
| 154 |
#define LED2_LINK_100 BIT(12) |
| 155 |
#define LED2_LINK_10 BIT(11) |
| 156 |
#define LED2_FD BIT(14) |
| 157 |
#define LED_VALID BIT(15) |
| 158 |
#define LED2_USB3_MASK 0x7c00 |
| 159 |
|
| 160 |
#define GMII_PHYPAGE 0x1e |
| 161 |
#define GMII_PHY_PAGE_SELECT 0x1f |
| 162 |
#define GMII_PHY_PGSEL_EXT 0x0007 |
| 163 |
#define GMII_PHY_PGSEL_PAGE0 0x0000 |
| 164 |
#define GMII_PHY_PGSEL_PAGE3 0x0003 |
| 165 |
#define GMII_PHY_PGSEL_PAGE5 0x0005 |
| 166 |
|
| 167 |
static int ax88179_reset(struct usbnet *dev); |
| 168 |
|
| 169 |
struct ax88179_data { |
| 170 |
u8 eee_enabled; |
| 171 |
u8 eee_active; |
| 172 |
u16 rxctl; |
| 173 |
u8 in_pm; |
| 174 |
u32 wol_supported; |
| 175 |
u32 wolopts; |
| 176 |
u8 disconnecting; |
| 177 |
}; |
| 178 |
|
| 179 |
struct ax88179_int_data { |
| 180 |
__le32 intdata1; |
| 181 |
__le32 intdata2; |
| 182 |
}; |
| 183 |
|
| 184 |
static const struct { |
| 185 |
unsigned char ctrl, timer_l, timer_h, size, ifg; |
| 186 |
} AX88179_BULKIN_SIZE[] = { |
| 187 |
{7, 0x4f, 0, 0x12, 0xff}, |
| 188 |
{7, 0x20, 3, 0x16, 0xff}, |
| 189 |
{7, 0xae, 7, 0x18, 0xff}, |
| 190 |
{7, 0xcc, 0x4c, 0x18, 8}, |
| 191 |
}; |
| 192 |
|
| 193 |
static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode) |
| 194 |
{ |
| 195 |
struct ax88179_data *ax179_data = dev->driver_priv; |
| 196 |
|
| 197 |
ax179_data->in_pm = pm_mode; |
| 198 |
} |
| 199 |
|
| 200 |
static int ax88179_in_pm(struct usbnet *dev) |
| 201 |
{ |
| 202 |
struct ax88179_data *ax179_data = dev->driver_priv; |
| 203 |
|
| 204 |
return ax179_data->in_pm; |
| 205 |
} |
| 206 |
|
| 207 |
static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, |
| 208 |
u16 size, void *data) |
| 209 |
{ |
| 210 |
int ret; |
| 211 |
int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); |
| 212 |
struct ax88179_data *ax179_data = dev->driver_priv; |
| 213 |
|
| 214 |
BUG_ON(!dev); |
| 215 |
|
| 216 |
if (!ax88179_in_pm(dev)) |
| 217 |
fn = usbnet_read_cmd; |
| 218 |
else |
| 219 |
fn = usbnet_read_cmd_nopm; |
| 220 |
|
| 221 |
ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 222 |
value, index, data, size); |
| 223 |
|
| 224 |
if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting))) |
| 225 |
netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", |
| 226 |
index, ret); |
| 227 |
|
| 228 |
return ret; |
| 229 |
} |
| 230 |
|
| 231 |
static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, |
| 232 |
u16 size, const void *data) |
| 233 |
{ |
| 234 |
int ret; |
| 235 |
int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); |
| 236 |
struct ax88179_data *ax179_data = dev->driver_priv; |
| 237 |
|
| 238 |
BUG_ON(!dev); |
| 239 |
|
| 240 |
if (!ax88179_in_pm(dev)) |
| 241 |
fn = usbnet_write_cmd; |
| 242 |
else |
| 243 |
fn = usbnet_write_cmd_nopm; |
| 244 |
|
| 245 |
ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 246 |
value, index, data, size); |
| 247 |
|
| 248 |
if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting))) |
| 249 |
netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", |
| 250 |
index, ret); |
| 251 |
|
| 252 |
return ret; |
| 253 |
} |
| 254 |
|
| 255 |
static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, |
| 256 |
u16 index, u16 size, void *data) |
| 257 |
{ |
| 258 |
u16 buf; |
| 259 |
|
| 260 |
if (2 == size) { |
| 261 |
buf = *((u16 *)data); |
| 262 |
cpu_to_le16s(&buf); |
| 263 |
usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | |
| 264 |
USB_RECIP_DEVICE, value, index, &buf, |
| 265 |
size); |
| 266 |
} else { |
| 267 |
usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | |
| 268 |
USB_RECIP_DEVICE, value, index, data, |
| 269 |
size); |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, |
| 274 |
u16 size, void *data) |
| 275 |
{ |
| 276 |
int ret; |
| 277 |
|
| 278 |
if (2 == size) { |
| 279 |
u16 buf = 0; |
| 280 |
ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf); |
| 281 |
le16_to_cpus(&buf); |
| 282 |
*((u16 *)data) = buf; |
| 283 |
} else if (4 == size) { |
| 284 |
u32 buf = 0; |
| 285 |
ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf); |
| 286 |
le32_to_cpus(&buf); |
| 287 |
*((u32 *)data) = buf; |
| 288 |
} else { |
| 289 |
ret = __ax88179_read_cmd(dev, cmd, value, index, size, data); |
| 290 |
} |
| 291 |
|
| 292 |
return ret; |
| 293 |
} |
| 294 |
|
| 295 |
static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, |
| 296 |
u16 size, const void *data) |
| 297 |
{ |
| 298 |
int ret; |
| 299 |
|
| 300 |
if (2 == size) { |
| 301 |
u16 buf; |
| 302 |
buf = *((u16 *)data); |
| 303 |
cpu_to_le16s(&buf); |
| 304 |
ret = __ax88179_write_cmd(dev, cmd, value, index, |
| 305 |
size, &buf); |
| 306 |
} else { |
| 307 |
ret = __ax88179_write_cmd(dev, cmd, value, index, |
| 308 |
size, data); |
| 309 |
} |
| 310 |
|
| 311 |
return ret; |
| 312 |
} |
| 313 |
|
| 314 |
static void ax88179_status(struct usbnet *dev, struct urb *urb) |
| 315 |
{ |
| 316 |
struct ax88179_int_data *event; |
| 317 |
u32 link; |
| 318 |
|
| 319 |
if (urb->actual_length < 8) |
| 320 |
return; |
| 321 |
|
| 322 |
event = urb->transfer_buffer; |
| 323 |
le32_to_cpus((void *)&event->intdata1); |
| 324 |
|
| 325 |
link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16; |
| 326 |
|
| 327 |
if (netif_carrier_ok(dev->net) != link) { |
| 328 |
usbnet_link_change(dev, link, 1); |
| 329 |
if (!link) |
| 330 |
netdev_info(dev->net, "ax88179 - Link status is: 0\n"); |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc) |
| 335 |
{ |
| 336 |
struct usbnet *dev = netdev_priv(netdev); |
| 337 |
u16 res; |
| 338 |
|
| 339 |
ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); |
| 340 |
return res; |
| 341 |
} |
| 342 |
|
| 343 |
static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, |
| 344 |
int val) |
| 345 |
{ |
| 346 |
struct usbnet *dev = netdev_priv(netdev); |
| 347 |
u16 res = (u16) val; |
| 348 |
|
| 349 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); |
| 350 |
} |
| 351 |
|
| 352 |
static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad, |
| 353 |
u16 devad) |
| 354 |
{ |
| 355 |
u16 tmp16; |
| 356 |
int ret; |
| 357 |
|
| 358 |
tmp16 = devad; |
| 359 |
ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 360 |
MII_MMD_CTRL, 2, &tmp16); |
| 361 |
|
| 362 |
tmp16 = prtad; |
| 363 |
ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 364 |
MII_MMD_DATA, 2, &tmp16); |
| 365 |
|
| 366 |
tmp16 = devad | MII_MMD_CTRL_NOINCR; |
| 367 |
ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 368 |
MII_MMD_CTRL, 2, &tmp16); |
| 369 |
|
| 370 |
return ret; |
| 371 |
} |
| 372 |
|
| 373 |
static int |
| 374 |
ax88179_phy_read_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad) |
| 375 |
{ |
| 376 |
int ret; |
| 377 |
u16 tmp16; |
| 378 |
|
| 379 |
ax88179_phy_mmd_indirect(dev, prtad, devad); |
| 380 |
|
| 381 |
ret = ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 382 |
MII_MMD_DATA, 2, &tmp16); |
| 383 |
if (ret < 0) |
| 384 |
return ret; |
| 385 |
|
| 386 |
return tmp16; |
| 387 |
} |
| 388 |
|
| 389 |
static int |
| 390 |
ax88179_phy_write_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad, |
| 391 |
u16 data) |
| 392 |
{ |
| 393 |
int ret; |
| 394 |
|
| 395 |
ax88179_phy_mmd_indirect(dev, prtad, devad); |
| 396 |
|
| 397 |
ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 398 |
MII_MMD_DATA, 2, &data); |
| 399 |
|
| 400 |
if (ret < 0) |
| 401 |
return ret; |
| 402 |
|
| 403 |
return 0; |
| 404 |
} |
| 405 |
|
| 406 |
static int ax88179_suspend(struct usb_interface *intf, pm_message_t message) |
| 407 |
{ |
| 408 |
struct usbnet *dev = usb_get_intfdata(intf); |
| 409 |
struct ax88179_data *priv = dev->driver_priv; |
| 410 |
u16 tmp16; |
| 411 |
u8 tmp8; |
| 412 |
|
| 413 |
ax88179_set_pm_mode(dev, true); |
| 414 |
|
| 415 |
usbnet_suspend(intf, message); |
| 416 |
|
| 417 |
/* Enable WoL */ |
| 418 |
if (priv->wolopts) { |
| 419 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, |
| 420 |
1, 1, &tmp8); |
| 421 |
if (priv->wolopts & WAKE_PHY) |
| 422 |
tmp8 |= AX_MONITOR_MODE_RWLC; |
| 423 |
if (priv->wolopts & WAKE_MAGIC) |
| 424 |
tmp8 |= AX_MONITOR_MODE_RWMP; |
| 425 |
|
| 426 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, |
| 427 |
1, 1, &tmp8); |
| 428 |
} |
| 429 |
|
| 430 |
/* Disable RX path */ |
| 431 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 432 |
2, 2, &tmp16); |
| 433 |
tmp16 &= ~AX_MEDIUM_RECEIVE_EN; |
| 434 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 435 |
2, 2, &tmp16); |
| 436 |
|
| 437 |
/* Force bulk-in zero length */ |
| 438 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, |
| 439 |
2, 2, &tmp16); |
| 440 |
|
| 441 |
tmp16 |= AX_PHYPWR_RSTCTL_BZ | AX_PHYPWR_RSTCTL_IPRL; |
| 442 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, |
| 443 |
2, 2, &tmp16); |
| 444 |
|
| 445 |
/* change clock */ |
| 446 |
tmp8 = 0; |
| 447 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); |
| 448 |
|
| 449 |
/* Configure RX control register => stop operation */ |
| 450 |
tmp16 = AX_RX_CTL_STOP; |
| 451 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); |
| 452 |
|
| 453 |
ax88179_set_pm_mode(dev, false); |
| 454 |
|
| 455 |
return 0; |
| 456 |
} |
| 457 |
|
| 458 |
/* This function is used to enable the autodetach function. */ |
| 459 |
/* This function is determined by offset 0x43 of EEPROM */ |
| 460 |
static int ax88179_auto_detach(struct usbnet *dev) |
| 461 |
{ |
| 462 |
u16 tmp16; |
| 463 |
u8 tmp8; |
| 464 |
|
| 465 |
if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM, 0x43, 1, 2, &tmp16) < 0) |
| 466 |
return 0; |
| 467 |
|
| 468 |
if ((tmp16 == 0xFFFF) || (!(tmp16 & 0x0100))) |
| 469 |
return 0; |
| 470 |
|
| 471 |
/* Enable Auto Detach bit */ |
| 472 |
tmp8 = 0; |
| 473 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); |
| 474 |
tmp8 |= AX_CLK_SELECT_ULR; |
| 475 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); |
| 476 |
|
| 477 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); |
| 478 |
tmp16 |= AX_PHYPWR_RSTCTL_AT; |
| 479 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); |
| 480 |
|
| 481 |
return 0; |
| 482 |
} |
| 483 |
|
| 484 |
static int ax88179_resume(struct usb_interface *intf) |
| 485 |
{ |
| 486 |
struct usbnet *dev = usb_get_intfdata(intf); |
| 487 |
|
| 488 |
ax88179_set_pm_mode(dev, true); |
| 489 |
|
| 490 |
usbnet_link_change(dev, 0, 0); |
| 491 |
|
| 492 |
ax88179_reset(dev); |
| 493 |
|
| 494 |
ax88179_set_pm_mode(dev, false); |
| 495 |
|
| 496 |
return usbnet_resume(intf); |
| 497 |
} |
| 498 |
|
| 499 |
static void ax88179_disconnect(struct usb_interface *intf) |
| 500 |
{ |
| 501 |
struct usbnet *dev = usb_get_intfdata(intf); |
| 502 |
struct ax88179_data *ax179_data; |
| 503 |
|
| 504 |
if (!dev) |
| 505 |
return; |
| 506 |
|
| 507 |
ax179_data = dev->driver_priv; |
| 508 |
ax179_data->disconnecting = 1; |
| 509 |
|
| 510 |
usbnet_disconnect(intf); |
| 511 |
} |
| 512 |
|
| 513 |
static void |
| 514 |
ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) |
| 515 |
{ |
| 516 |
struct usbnet *dev = netdev_priv(net); |
| 517 |
struct ax88179_data *priv = dev->driver_priv; |
| 518 |
|
| 519 |
wolinfo->supported = priv->wol_supported; |
| 520 |
wolinfo->wolopts = priv->wolopts; |
| 521 |
} |
| 522 |
|
| 523 |
static int |
| 524 |
ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) |
| 525 |
{ |
| 526 |
struct usbnet *dev = netdev_priv(net); |
| 527 |
struct ax88179_data *priv = dev->driver_priv; |
| 528 |
|
| 529 |
if (wolinfo->wolopts & ~(priv->wol_supported)) |
| 530 |
return -EINVAL; |
| 531 |
|
| 532 |
priv->wolopts = wolinfo->wolopts; |
| 533 |
|
| 534 |
return 0; |
| 535 |
} |
| 536 |
|
| 537 |
static int ax88179_get_eeprom_len(struct net_device *net) |
| 538 |
{ |
| 539 |
return AX_EEPROM_LEN; |
| 540 |
} |
| 541 |
|
| 542 |
static int |
| 543 |
ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, |
| 544 |
u8 *data) |
| 545 |
{ |
| 546 |
struct usbnet *dev = netdev_priv(net); |
| 547 |
u16 *eeprom_buff; |
| 548 |
int first_word, last_word; |
| 549 |
int i, ret; |
| 550 |
|
| 551 |
if (eeprom->len == 0) |
| 552 |
return -EINVAL; |
| 553 |
|
| 554 |
eeprom->magic = AX88179_EEPROM_MAGIC; |
| 555 |
|
| 556 |
first_word = eeprom->offset >> 1; |
| 557 |
last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 558 |
eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 559 |
GFP_KERNEL); |
| 560 |
if (!eeprom_buff) |
| 561 |
return -ENOMEM; |
| 562 |
|
| 563 |
/* ax88179/178A returns 2 bytes from eeprom on read */ |
| 564 |
for (i = first_word; i <= last_word; i++) { |
| 565 |
ret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2, |
| 566 |
&eeprom_buff[i - first_word]); |
| 567 |
if (ret < 0) { |
| 568 |
kfree(eeprom_buff); |
| 569 |
return -EIO; |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); |
| 574 |
kfree(eeprom_buff); |
| 575 |
return 0; |
| 576 |
} |
| 577 |
|
| 578 |
static int |
| 579 |
ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, |
| 580 |
u8 *data) |
| 581 |
{ |
| 582 |
struct usbnet *dev = netdev_priv(net); |
| 583 |
u16 *eeprom_buff; |
| 584 |
int first_word; |
| 585 |
int last_word; |
| 586 |
int ret; |
| 587 |
int i; |
| 588 |
|
| 589 |
netdev_dbg(net, "write EEPROM len %d, offset %d, magic 0x%x\n", |
| 590 |
eeprom->len, eeprom->offset, eeprom->magic); |
| 591 |
|
| 592 |
if (eeprom->len == 0) |
| 593 |
return -EINVAL; |
| 594 |
|
| 595 |
if (eeprom->magic != AX88179_EEPROM_MAGIC) |
| 596 |
return -EINVAL; |
| 597 |
|
| 598 |
first_word = eeprom->offset >> 1; |
| 599 |
last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 600 |
|
| 601 |
eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 602 |
GFP_KERNEL); |
| 603 |
if (!eeprom_buff) |
| 604 |
return -ENOMEM; |
| 605 |
|
| 606 |
/* align data to 16 bit boundaries, read the missing data from |
| 607 |
the EEPROM */ |
| 608 |
if (eeprom->offset & 1) { |
| 609 |
ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2, |
| 610 |
&eeprom_buff[0]); |
| 611 |
if (ret < 0) { |
| 612 |
netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word); |
| 613 |
goto free; |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
if ((eeprom->offset + eeprom->len) & 1) { |
| 618 |
ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2, |
| 619 |
&eeprom_buff[last_word - first_word]); |
| 620 |
if (ret < 0) { |
| 621 |
netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word); |
| 622 |
goto free; |
| 623 |
} |
| 624 |
} |
| 625 |
|
| 626 |
memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len); |
| 627 |
|
| 628 |
for (i = first_word; i <= last_word; i++) { |
| 629 |
netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n", |
| 630 |
i, eeprom_buff[i - first_word]); |
| 631 |
ret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2, |
| 632 |
&eeprom_buff[i - first_word]); |
| 633 |
if (ret < 0) { |
| 634 |
netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", i); |
| 635 |
goto free; |
| 636 |
} |
| 637 |
msleep(20); |
| 638 |
} |
| 639 |
|
| 640 |
/* reload EEPROM data */ |
| 641 |
ret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL); |
| 642 |
if (ret < 0) { |
| 643 |
netdev_err(net, "Failed to reload EEPROM data\n"); |
| 644 |
goto free; |
| 645 |
} |
| 646 |
|
| 647 |
ret = 0; |
| 648 |
free: |
| 649 |
kfree(eeprom_buff); |
| 650 |
return ret; |
| 651 |
} |
| 652 |
|
| 653 |
static int ax88179_get_link_ksettings(struct net_device *net, |
| 654 |
struct ethtool_link_ksettings *cmd) |
| 655 |
{ |
| 656 |
struct usbnet *dev = netdev_priv(net); |
| 657 |
|
| 658 |
mii_ethtool_get_link_ksettings(&dev->mii, cmd); |
| 659 |
|
| 660 |
return 0; |
| 661 |
} |
| 662 |
|
| 663 |
static int ax88179_set_link_ksettings(struct net_device *net, |
| 664 |
const struct ethtool_link_ksettings *cmd) |
| 665 |
{ |
| 666 |
struct usbnet *dev = netdev_priv(net); |
| 667 |
return mii_ethtool_set_link_ksettings(&dev->mii, cmd); |
| 668 |
} |
| 669 |
|
| 670 |
static int |
| 671 |
ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data) |
| 672 |
{ |
| 673 |
int val; |
| 674 |
|
| 675 |
/* Get Supported EEE */ |
| 676 |
val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE, |
| 677 |
MDIO_MMD_PCS); |
| 678 |
if (val < 0) |
| 679 |
return val; |
| 680 |
mii_eee_cap1_mod_linkmode_t(data->supported, val); |
| 681 |
|
| 682 |
/* Get advertisement EEE */ |
| 683 |
val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV, |
| 684 |
MDIO_MMD_AN); |
| 685 |
if (val < 0) |
| 686 |
return val; |
| 687 |
mii_eee_cap1_mod_linkmode_t(data->advertised, val); |
| 688 |
|
| 689 |
/* Get LP advertisement EEE */ |
| 690 |
val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE, |
| 691 |
MDIO_MMD_AN); |
| 692 |
if (val < 0) |
| 693 |
return val; |
| 694 |
mii_eee_cap1_mod_linkmode_t(data->lp_advertised, val); |
| 695 |
|
| 696 |
return 0; |
| 697 |
} |
| 698 |
|
| 699 |
static int |
| 700 |
ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_keee *data) |
| 701 |
{ |
| 702 |
u16 tmp16 = linkmode_to_mii_eee_cap1_t(data->advertised); |
| 703 |
|
| 704 |
return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV, |
| 705 |
MDIO_MMD_AN, tmp16); |
| 706 |
} |
| 707 |
|
| 708 |
static int ax88179_chk_eee(struct usbnet *dev) |
| 709 |
{ |
| 710 |
struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; |
| 711 |
struct ax88179_data *priv = dev->driver_priv; |
| 712 |
|
| 713 |
mii_ethtool_gset(&dev->mii, &ecmd); |
| 714 |
|
| 715 |
if (ecmd.duplex & DUPLEX_FULL) { |
| 716 |
int eee_lp, eee_cap, eee_adv; |
| 717 |
u32 lp, cap, adv, supported = 0; |
| 718 |
|
| 719 |
eee_cap = ax88179_phy_read_mmd_indirect(dev, |
| 720 |
MDIO_PCS_EEE_ABLE, |
| 721 |
MDIO_MMD_PCS); |
| 722 |
if (eee_cap < 0) { |
| 723 |
priv->eee_active = 0; |
| 724 |
return false; |
| 725 |
} |
| 726 |
|
| 727 |
cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap); |
| 728 |
if (!cap) { |
| 729 |
priv->eee_active = 0; |
| 730 |
return false; |
| 731 |
} |
| 732 |
|
| 733 |
eee_lp = ax88179_phy_read_mmd_indirect(dev, |
| 734 |
MDIO_AN_EEE_LPABLE, |
| 735 |
MDIO_MMD_AN); |
| 736 |
if (eee_lp < 0) { |
| 737 |
priv->eee_active = 0; |
| 738 |
return false; |
| 739 |
} |
| 740 |
|
| 741 |
eee_adv = ax88179_phy_read_mmd_indirect(dev, |
| 742 |
MDIO_AN_EEE_ADV, |
| 743 |
MDIO_MMD_AN); |
| 744 |
|
| 745 |
if (eee_adv < 0) { |
| 746 |
priv->eee_active = 0; |
| 747 |
return false; |
| 748 |
} |
| 749 |
|
| 750 |
adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); |
| 751 |
lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); |
| 752 |
supported = (ecmd.speed == SPEED_1000) ? |
| 753 |
SUPPORTED_1000baseT_Full : |
| 754 |
SUPPORTED_100baseT_Full; |
| 755 |
|
| 756 |
if (!(lp & adv & supported)) { |
| 757 |
priv->eee_active = 0; |
| 758 |
return false; |
| 759 |
} |
| 760 |
|
| 761 |
priv->eee_active = 1; |
| 762 |
return true; |
| 763 |
} |
| 764 |
|
| 765 |
priv->eee_active = 0; |
| 766 |
return false; |
| 767 |
} |
| 768 |
|
| 769 |
static void ax88179_disable_eee(struct usbnet *dev) |
| 770 |
{ |
| 771 |
u16 tmp16; |
| 772 |
|
| 773 |
tmp16 = GMII_PHY_PGSEL_PAGE3; |
| 774 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 775 |
GMII_PHY_PAGE_SELECT, 2, &tmp16); |
| 776 |
|
| 777 |
tmp16 = 0x3246; |
| 778 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 779 |
MII_PHYADDR, 2, &tmp16); |
| 780 |
|
| 781 |
tmp16 = GMII_PHY_PGSEL_PAGE0; |
| 782 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 783 |
GMII_PHY_PAGE_SELECT, 2, &tmp16); |
| 784 |
} |
| 785 |
|
| 786 |
static void ax88179_enable_eee(struct usbnet *dev) |
| 787 |
{ |
| 788 |
u16 tmp16; |
| 789 |
|
| 790 |
tmp16 = GMII_PHY_PGSEL_PAGE3; |
| 791 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 792 |
GMII_PHY_PAGE_SELECT, 2, &tmp16); |
| 793 |
|
| 794 |
tmp16 = 0x3247; |
| 795 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 796 |
MII_PHYADDR, 2, &tmp16); |
| 797 |
|
| 798 |
tmp16 = GMII_PHY_PGSEL_PAGE5; |
| 799 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 800 |
GMII_PHY_PAGE_SELECT, 2, &tmp16); |
| 801 |
|
| 802 |
tmp16 = 0x0680; |
| 803 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 804 |
MII_BMSR, 2, &tmp16); |
| 805 |
|
| 806 |
tmp16 = GMII_PHY_PGSEL_PAGE0; |
| 807 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 808 |
GMII_PHY_PAGE_SELECT, 2, &tmp16); |
| 809 |
} |
| 810 |
|
| 811 |
static int ax88179_get_eee(struct net_device *net, struct ethtool_keee *edata) |
| 812 |
{ |
| 813 |
struct usbnet *dev = netdev_priv(net); |
| 814 |
struct ax88179_data *priv = dev->driver_priv; |
| 815 |
|
| 816 |
edata->eee_enabled = priv->eee_enabled; |
| 817 |
edata->eee_active = priv->eee_active; |
| 818 |
|
| 819 |
return ax88179_ethtool_get_eee(dev, edata); |
| 820 |
} |
| 821 |
|
| 822 |
static int ax88179_set_eee(struct net_device *net, struct ethtool_keee *edata) |
| 823 |
{ |
| 824 |
struct usbnet *dev = netdev_priv(net); |
| 825 |
struct ax88179_data *priv = dev->driver_priv; |
| 826 |
int ret; |
| 827 |
|
| 828 |
priv->eee_enabled = edata->eee_enabled; |
| 829 |
if (!priv->eee_enabled) { |
| 830 |
ax88179_disable_eee(dev); |
| 831 |
} else { |
| 832 |
priv->eee_enabled = ax88179_chk_eee(dev); |
| 833 |
if (!priv->eee_enabled) |
| 834 |
return -EOPNOTSUPP; |
| 835 |
|
| 836 |
ax88179_enable_eee(dev); |
| 837 |
} |
| 838 |
|
| 839 |
ret = ax88179_ethtool_set_eee(dev, edata); |
| 840 |
if (ret) |
| 841 |
return ret; |
| 842 |
|
| 843 |
mii_nway_restart(&dev->mii); |
| 844 |
|
| 845 |
usbnet_link_change(dev, 0, 0); |
| 846 |
|
| 847 |
return ret; |
| 848 |
} |
| 849 |
|
| 850 |
static const struct ethtool_ops ax88179_ethtool_ops = { |
| 851 |
.get_link = ethtool_op_get_link, |
| 852 |
.get_msglevel = usbnet_get_msglevel, |
| 853 |
.set_msglevel = usbnet_set_msglevel, |
| 854 |
.get_wol = ax88179_get_wol, |
| 855 |
.set_wol = ax88179_set_wol, |
| 856 |
.get_eeprom_len = ax88179_get_eeprom_len, |
| 857 |
.get_eeprom = ax88179_get_eeprom, |
| 858 |
.set_eeprom = ax88179_set_eeprom, |
| 859 |
.get_eee = ax88179_get_eee, |
| 860 |
.set_eee = ax88179_set_eee, |
| 861 |
.nway_reset = usbnet_nway_reset, |
| 862 |
.get_link_ksettings = ax88179_get_link_ksettings, |
| 863 |
.set_link_ksettings = ax88179_set_link_ksettings, |
| 864 |
.get_ts_info = ethtool_op_get_ts_info, |
| 865 |
}; |
| 866 |
|
| 867 |
static void ax88179_set_multicast(struct net_device *net) |
| 868 |
{ |
| 869 |
struct usbnet *dev = netdev_priv(net); |
| 870 |
struct ax88179_data *data = dev->driver_priv; |
| 871 |
u8 *m_filter = ((u8 *)dev->data); |
| 872 |
|
| 873 |
data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE); |
| 874 |
|
| 875 |
if (net->flags & IFF_PROMISC) { |
| 876 |
data->rxctl |= AX_RX_CTL_PRO; |
| 877 |
} else if (net->flags & IFF_ALLMULTI || |
| 878 |
netdev_mc_count(net) > AX_MAX_MCAST) { |
| 879 |
data->rxctl |= AX_RX_CTL_AMALL; |
| 880 |
} else if (netdev_mc_empty(net)) { |
| 881 |
/* just broadcast and directed */ |
| 882 |
} else { |
| 883 |
/* We use dev->data for our 8 byte filter buffer |
| 884 |
* to avoid allocating memory that is tricky to free later |
| 885 |
*/ |
| 886 |
u32 crc_bits; |
| 887 |
struct netdev_hw_addr *ha; |
| 888 |
|
| 889 |
memset(m_filter, 0, AX_MCAST_FLTSIZE); |
| 890 |
|
| 891 |
netdev_for_each_mc_addr(ha, net) { |
| 892 |
crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; |
| 893 |
*(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7)); |
| 894 |
} |
| 895 |
|
| 896 |
ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY, |
| 897 |
AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE, |
| 898 |
m_filter); |
| 899 |
|
| 900 |
data->rxctl |= AX_RX_CTL_AM; |
| 901 |
} |
| 902 |
|
| 903 |
ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, |
| 904 |
2, 2, &data->rxctl); |
| 905 |
} |
| 906 |
|
| 907 |
static int |
| 908 |
ax88179_set_features(struct net_device *net, netdev_features_t features) |
| 909 |
{ |
| 910 |
u8 tmp; |
| 911 |
struct usbnet *dev = netdev_priv(net); |
| 912 |
netdev_features_t changed = net->features ^ features; |
| 913 |
|
| 914 |
if (changed & NETIF_F_IP_CSUM) { |
| 915 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); |
| 916 |
tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP; |
| 917 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); |
| 918 |
} |
| 919 |
|
| 920 |
if (changed & NETIF_F_IPV6_CSUM) { |
| 921 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); |
| 922 |
tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; |
| 923 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); |
| 924 |
} |
| 925 |
|
| 926 |
if (changed & NETIF_F_RXCSUM) { |
| 927 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); |
| 928 |
tmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | |
| 929 |
AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; |
| 930 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); |
| 931 |
} |
| 932 |
|
| 933 |
return 0; |
| 934 |
} |
| 935 |
|
| 936 |
static int ax88179_change_mtu(struct net_device *net, int new_mtu) |
| 937 |
{ |
| 938 |
struct usbnet *dev = netdev_priv(net); |
| 939 |
u16 tmp16; |
| 940 |
|
| 941 |
WRITE_ONCE(net->mtu, new_mtu); |
| 942 |
dev->hard_mtu = net->mtu + net->hard_header_len; |
| 943 |
|
| 944 |
if (net->mtu > 1500) { |
| 945 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 946 |
2, 2, &tmp16); |
| 947 |
tmp16 |= AX_MEDIUM_JUMBO_EN; |
| 948 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 949 |
2, 2, &tmp16); |
| 950 |
} else { |
| 951 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 952 |
2, 2, &tmp16); |
| 953 |
tmp16 &= ~AX_MEDIUM_JUMBO_EN; |
| 954 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 955 |
2, 2, &tmp16); |
| 956 |
} |
| 957 |
|
| 958 |
/* max qlen depend on hard_mtu and rx_urb_size */ |
| 959 |
usbnet_update_max_qlen(dev); |
| 960 |
|
| 961 |
return 0; |
| 962 |
} |
| 963 |
|
| 964 |
static int ax88179_set_mac_addr(struct net_device *net, void *p) |
| 965 |
{ |
| 966 |
struct usbnet *dev = netdev_priv(net); |
| 967 |
struct sockaddr *addr = p; |
| 968 |
int ret; |
| 969 |
|
| 970 |
if (netif_running(net)) |
| 971 |
return -EBUSY; |
| 972 |
if (!is_valid_ether_addr(addr->sa_data)) |
| 973 |
return -EADDRNOTAVAIL; |
| 974 |
|
| 975 |
eth_hw_addr_set(net, addr->sa_data); |
| 976 |
|
| 977 |
/* Set the MAC address */ |
| 978 |
ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, |
| 979 |
ETH_ALEN, net->dev_addr); |
| 980 |
if (ret < 0) |
| 981 |
return ret; |
| 982 |
|
| 983 |
return 0; |
| 984 |
} |
| 985 |
|
| 986 |
static const struct net_device_ops ax88179_netdev_ops = { |
| 987 |
.ndo_open = usbnet_open, |
| 988 |
.ndo_stop = usbnet_stop, |
| 989 |
.ndo_start_xmit = usbnet_start_xmit, |
| 990 |
.ndo_tx_timeout = usbnet_tx_timeout, |
| 991 |
.ndo_get_stats64 = dev_get_tstats64, |
| 992 |
.ndo_change_mtu = ax88179_change_mtu, |
| 993 |
.ndo_set_mac_address = ax88179_set_mac_addr, |
| 994 |
.ndo_validate_addr = eth_validate_addr, |
| 995 |
.ndo_eth_ioctl = usbnet_mii_ioctl, |
| 996 |
.ndo_set_rx_mode = ax88179_set_multicast, |
| 997 |
.ndo_set_features = ax88179_set_features, |
| 998 |
}; |
| 999 |
|
| 1000 |
static int ax88179_check_eeprom(struct usbnet *dev) |
| 1001 |
{ |
| 1002 |
u8 i, buf, eeprom[20]; |
| 1003 |
u16 csum, delay = HZ / 10; |
| 1004 |
unsigned long jtimeout; |
| 1005 |
|
| 1006 |
/* Read EEPROM content */ |
| 1007 |
for (i = 0; i < 6; i++) { |
| 1008 |
buf = i; |
| 1009 |
if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, |
| 1010 |
1, 1, &buf) < 0) |
| 1011 |
return -EINVAL; |
| 1012 |
|
| 1013 |
buf = EEP_RD; |
| 1014 |
if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, |
| 1015 |
1, 1, &buf) < 0) |
| 1016 |
return -EINVAL; |
| 1017 |
|
| 1018 |
jtimeout = jiffies + delay; |
| 1019 |
do { |
| 1020 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, |
| 1021 |
1, 1, &buf); |
| 1022 |
|
| 1023 |
if (time_after(jiffies, jtimeout)) |
| 1024 |
return -EINVAL; |
| 1025 |
|
| 1026 |
} while (buf & EEP_BUSY); |
| 1027 |
|
| 1028 |
__ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, |
| 1029 |
2, 2, &eeprom[i * 2]); |
| 1030 |
|
| 1031 |
if ((i == 0) && (eeprom[0] == 0xFF)) |
| 1032 |
return -EINVAL; |
| 1033 |
} |
| 1034 |
|
| 1035 |
csum = eeprom[6] + eeprom[7] + eeprom[8] + eeprom[9]; |
| 1036 |
csum = (csum >> 8) + (csum & 0xff); |
| 1037 |
if ((csum + eeprom[10]) != 0xff) |
| 1038 |
return -EINVAL; |
| 1039 |
|
| 1040 |
return 0; |
| 1041 |
} |
| 1042 |
|
| 1043 |
static int ax88179_check_efuse(struct usbnet *dev, u16 *ledmode) |
| 1044 |
{ |
| 1045 |
u8 i; |
| 1046 |
u8 efuse[64]; |
| 1047 |
u16 csum = 0; |
| 1048 |
|
| 1049 |
if (ax88179_read_cmd(dev, AX_ACCESS_EFUS, 0, 64, 64, efuse) < 0) |
| 1050 |
return -EINVAL; |
| 1051 |
|
| 1052 |
if (*efuse == 0xFF) |
| 1053 |
return -EINVAL; |
| 1054 |
|
| 1055 |
for (i = 0; i < 64; i++) |
| 1056 |
csum = csum + efuse[i]; |
| 1057 |
|
| 1058 |
while (csum > 255) |
| 1059 |
csum = (csum & 0x00FF) + ((csum >> 8) & 0x00FF); |
| 1060 |
|
| 1061 |
if (csum != 0xFF) |
| 1062 |
return -EINVAL; |
| 1063 |
|
| 1064 |
*ledmode = (efuse[51] << 8) | efuse[52]; |
| 1065 |
|
| 1066 |
return 0; |
| 1067 |
} |
| 1068 |
|
| 1069 |
static int ax88179_convert_old_led(struct usbnet *dev, u16 *ledvalue) |
| 1070 |
{ |
| 1071 |
u16 led; |
| 1072 |
|
| 1073 |
/* Loaded the old eFuse LED Mode */ |
| 1074 |
if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM, 0x3C, 1, 2, &led) < 0) |
| 1075 |
return -EINVAL; |
| 1076 |
|
| 1077 |
led >>= 8; |
| 1078 |
switch (led) { |
| 1079 |
case 0xFF: |
| 1080 |
led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | |
| 1081 |
LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | |
| 1082 |
LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; |
| 1083 |
break; |
| 1084 |
case 0xFE: |
| 1085 |
led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | LED_VALID; |
| 1086 |
break; |
| 1087 |
case 0xFD: |
| 1088 |
led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | |
| 1089 |
LED2_LINK_10 | LED_VALID; |
| 1090 |
break; |
| 1091 |
case 0xFC: |
| 1092 |
led = LED0_ACTIVE | LED1_ACTIVE | LED1_LINK_1000 | LED2_ACTIVE | |
| 1093 |
LED2_LINK_100 | LED2_LINK_10 | LED_VALID; |
| 1094 |
break; |
| 1095 |
default: |
| 1096 |
led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | |
| 1097 |
LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | |
| 1098 |
LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; |
| 1099 |
break; |
| 1100 |
} |
| 1101 |
|
| 1102 |
*ledvalue = led; |
| 1103 |
|
| 1104 |
return 0; |
| 1105 |
} |
| 1106 |
|
| 1107 |
static int ax88179_led_setting(struct usbnet *dev) |
| 1108 |
{ |
| 1109 |
u8 ledfd, value = 0; |
| 1110 |
u16 tmp, ledact, ledlink, ledvalue = 0, delay = HZ / 10; |
| 1111 |
unsigned long jtimeout; |
| 1112 |
|
| 1113 |
/* Check AX88179 version. UA1 or UA2*/ |
| 1114 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, GENERAL_STATUS, 1, 1, &value); |
| 1115 |
|
| 1116 |
if (!(value & AX_SECLD)) { /* UA1 */ |
| 1117 |
value = AX_GPIO_CTRL_GPIO3EN | AX_GPIO_CTRL_GPIO2EN | |
| 1118 |
AX_GPIO_CTRL_GPIO1EN; |
| 1119 |
if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_GPIO_CTRL, |
| 1120 |
1, 1, &value) < 0) |
| 1121 |
return -EINVAL; |
| 1122 |
} |
| 1123 |
|
| 1124 |
/* Check EEPROM */ |
| 1125 |
if (!ax88179_check_eeprom(dev)) { |
| 1126 |
value = 0x42; |
| 1127 |
if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, |
| 1128 |
1, 1, &value) < 0) |
| 1129 |
return -EINVAL; |
| 1130 |
|
| 1131 |
value = EEP_RD; |
| 1132 |
if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, |
| 1133 |
1, 1, &value) < 0) |
| 1134 |
return -EINVAL; |
| 1135 |
|
| 1136 |
jtimeout = jiffies + delay; |
| 1137 |
do { |
| 1138 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, |
| 1139 |
1, 1, &value); |
| 1140 |
|
| 1141 |
if (time_after(jiffies, jtimeout)) |
| 1142 |
return -EINVAL; |
| 1143 |
|
| 1144 |
} while (value & EEP_BUSY); |
| 1145 |
|
| 1146 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_HIGH, |
| 1147 |
1, 1, &value); |
| 1148 |
ledvalue = (value << 8); |
| 1149 |
|
| 1150 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, |
| 1151 |
1, 1, &value); |
| 1152 |
ledvalue |= value; |
| 1153 |
|
| 1154 |
/* load internal ROM for defaule setting */ |
| 1155 |
if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) |
| 1156 |
ax88179_convert_old_led(dev, &ledvalue); |
| 1157 |
|
| 1158 |
} else if (!ax88179_check_efuse(dev, &ledvalue)) { |
| 1159 |
if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) |
| 1160 |
ax88179_convert_old_led(dev, &ledvalue); |
| 1161 |
} else { |
| 1162 |
ax88179_convert_old_led(dev, &ledvalue); |
| 1163 |
} |
| 1164 |
|
| 1165 |
tmp = GMII_PHY_PGSEL_EXT; |
| 1166 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1167 |
GMII_PHY_PAGE_SELECT, 2, &tmp); |
| 1168 |
|
| 1169 |
tmp = 0x2c; |
| 1170 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1171 |
GMII_PHYPAGE, 2, &tmp); |
| 1172 |
|
| 1173 |
ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1174 |
GMII_LED_ACT, 2, &ledact); |
| 1175 |
|
| 1176 |
ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1177 |
GMII_LED_LINK, 2, &ledlink); |
| 1178 |
|
| 1179 |
ledact &= GMII_LED_ACTIVE_MASK; |
| 1180 |
ledlink &= GMII_LED_LINK_MASK; |
| 1181 |
|
| 1182 |
if (ledvalue & LED0_ACTIVE) |
| 1183 |
ledact |= GMII_LED0_ACTIVE; |
| 1184 |
|
| 1185 |
if (ledvalue & LED1_ACTIVE) |
| 1186 |
ledact |= GMII_LED1_ACTIVE; |
| 1187 |
|
| 1188 |
if (ledvalue & LED2_ACTIVE) |
| 1189 |
ledact |= GMII_LED2_ACTIVE; |
| 1190 |
|
| 1191 |
if (ledvalue & LED0_LINK_10) |
| 1192 |
ledlink |= GMII_LED0_LINK_10; |
| 1193 |
|
| 1194 |
if (ledvalue & LED1_LINK_10) |
| 1195 |
ledlink |= GMII_LED1_LINK_10; |
| 1196 |
|
| 1197 |
if (ledvalue & LED2_LINK_10) |
| 1198 |
ledlink |= GMII_LED2_LINK_10; |
| 1199 |
|
| 1200 |
if (ledvalue & LED0_LINK_100) |
| 1201 |
ledlink |= GMII_LED0_LINK_100; |
| 1202 |
|
| 1203 |
if (ledvalue & LED1_LINK_100) |
| 1204 |
ledlink |= GMII_LED1_LINK_100; |
| 1205 |
|
| 1206 |
if (ledvalue & LED2_LINK_100) |
| 1207 |
ledlink |= GMII_LED2_LINK_100; |
| 1208 |
|
| 1209 |
if (ledvalue & LED0_LINK_1000) |
| 1210 |
ledlink |= GMII_LED0_LINK_1000; |
| 1211 |
|
| 1212 |
if (ledvalue & LED1_LINK_1000) |
| 1213 |
ledlink |= GMII_LED1_LINK_1000; |
| 1214 |
|
| 1215 |
if (ledvalue & LED2_LINK_1000) |
| 1216 |
ledlink |= GMII_LED2_LINK_1000; |
| 1217 |
|
| 1218 |
tmp = ledact; |
| 1219 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1220 |
GMII_LED_ACT, 2, &tmp); |
| 1221 |
|
| 1222 |
tmp = ledlink; |
| 1223 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1224 |
GMII_LED_LINK, 2, &tmp); |
| 1225 |
|
| 1226 |
tmp = GMII_PHY_PGSEL_PAGE0; |
| 1227 |
ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1228 |
GMII_PHY_PAGE_SELECT, 2, &tmp); |
| 1229 |
|
| 1230 |
/* LED full duplex setting */ |
| 1231 |
ledfd = 0; |
| 1232 |
if (ledvalue & LED0_FD) |
| 1233 |
ledfd |= 0x01; |
| 1234 |
else if ((ledvalue & LED0_USB3_MASK) == 0) |
| 1235 |
ledfd |= 0x02; |
| 1236 |
|
| 1237 |
if (ledvalue & LED1_FD) |
| 1238 |
ledfd |= 0x04; |
| 1239 |
else if ((ledvalue & LED1_USB3_MASK) == 0) |
| 1240 |
ledfd |= 0x08; |
| 1241 |
|
| 1242 |
if (ledvalue & LED2_FD) |
| 1243 |
ledfd |= 0x10; |
| 1244 |
else if ((ledvalue & LED2_USB3_MASK) == 0) |
| 1245 |
ledfd |= 0x20; |
| 1246 |
|
| 1247 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_LEDCTRL, 1, 1, &ledfd); |
| 1248 |
|
| 1249 |
return 0; |
| 1250 |
} |
| 1251 |
|
| 1252 |
static void ax88179_get_mac_addr(struct usbnet *dev) |
| 1253 |
{ |
| 1254 |
u8 mac[ETH_ALEN]; |
| 1255 |
|
| 1256 |
memset(mac, 0, sizeof(mac)); |
| 1257 |
|
| 1258 |
/* Maybe the boot loader passed the MAC address via device tree */ |
| 1259 |
if (!eth_platform_get_mac_address(&dev->udev->dev, mac)) { |
| 1260 |
netif_dbg(dev, ifup, dev->net, |
| 1261 |
"MAC address read from device tree"); |
| 1262 |
} else { |
| 1263 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, |
| 1264 |
ETH_ALEN, mac); |
| 1265 |
netif_dbg(dev, ifup, dev->net, |
| 1266 |
"MAC address read from ASIX chip"); |
| 1267 |
} |
| 1268 |
|
| 1269 |
if (is_valid_ether_addr(mac)) { |
| 1270 |
eth_hw_addr_set(dev->net, mac); |
| 1271 |
if (!is_local_ether_addr(mac)) |
| 1272 |
dev->net->addr_assign_type = NET_ADDR_PERM; |
| 1273 |
} else { |
| 1274 |
netdev_info(dev->net, "invalid MAC address, using random\n"); |
| 1275 |
} |
| 1276 |
|
| 1277 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN, |
| 1278 |
dev->net->dev_addr); |
| 1279 |
} |
| 1280 |
|
| 1281 |
static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) |
| 1282 |
{ |
| 1283 |
struct ax88179_data *ax179_data; |
| 1284 |
int ret; |
| 1285 |
|
| 1286 |
ret = usbnet_get_endpoints(dev, intf); |
| 1287 |
if (ret < 0) |
| 1288 |
return ret; |
| 1289 |
|
| 1290 |
ax179_data = kzalloc_obj(*ax179_data); |
| 1291 |
if (!ax179_data) |
| 1292 |
return -ENOMEM; |
| 1293 |
|
| 1294 |
dev->driver_priv = ax179_data; |
| 1295 |
|
| 1296 |
dev->net->netdev_ops = &ax88179_netdev_ops; |
| 1297 |
dev->net->ethtool_ops = &ax88179_ethtool_ops; |
| 1298 |
dev->net->needed_headroom = 8; |
| 1299 |
dev->net->max_mtu = 4088; |
| 1300 |
|
| 1301 |
/* Initialize MII structure */ |
| 1302 |
dev->mii.dev = dev->net; |
| 1303 |
dev->mii.mdio_read = ax88179_mdio_read; |
| 1304 |
dev->mii.mdio_write = ax88179_mdio_write; |
| 1305 |
dev->mii.phy_id_mask = 0xff; |
| 1306 |
dev->mii.reg_num_mask = 0xff; |
| 1307 |
dev->mii.phy_id = 0x03; |
| 1308 |
dev->mii.supports_gmii = 1; |
| 1309 |
|
| 1310 |
dev->net->features |= NETIF_F_SG | NETIF_F_IP_CSUM | |
| 1311 |
NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO; |
| 1312 |
|
| 1313 |
dev->net->hw_features |= dev->net->features; |
| 1314 |
|
| 1315 |
netif_set_tso_max_size(dev->net, 16384); |
| 1316 |
|
| 1317 |
ax88179_reset(dev); |
| 1318 |
|
| 1319 |
return 0; |
| 1320 |
} |
| 1321 |
|
| 1322 |
static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf) |
| 1323 |
{ |
| 1324 |
struct ax88179_data *ax179_data = dev->driver_priv; |
| 1325 |
u16 tmp16; |
| 1326 |
|
| 1327 |
/* Configure RX control register => stop operation */ |
| 1328 |
tmp16 = AX_RX_CTL_STOP; |
| 1329 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); |
| 1330 |
|
| 1331 |
tmp16 = 0; |
| 1332 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp16); |
| 1333 |
|
| 1334 |
/* Power down ethernet PHY */ |
| 1335 |
tmp16 = 0; |
| 1336 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); |
| 1337 |
|
| 1338 |
kfree(ax179_data); |
| 1339 |
} |
| 1340 |
|
| 1341 |
static void |
| 1342 |
ax88179_rx_checksum(struct sk_buff *skb, u32 *pkt_hdr) |
| 1343 |
{ |
| 1344 |
skb->ip_summed = CHECKSUM_NONE; |
| 1345 |
|
| 1346 |
/* checksum error bit is set */ |
| 1347 |
if ((*pkt_hdr & AX_RXHDR_L3CSUM_ERR) || |
| 1348 |
(*pkt_hdr & AX_RXHDR_L4CSUM_ERR)) |
| 1349 |
return; |
| 1350 |
|
| 1351 |
/* It must be a TCP or UDP packet with a valid checksum */ |
| 1352 |
if (((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_TCP) || |
| 1353 |
((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_UDP)) |
| 1354 |
skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 1355 |
} |
| 1356 |
|
| 1357 |
static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) |
| 1358 |
{ |
| 1359 |
struct sk_buff *ax_skb; |
| 1360 |
int pkt_cnt; |
| 1361 |
u32 rx_hdr; |
| 1362 |
u16 hdr_off; |
| 1363 |
u32 *pkt_hdr; |
| 1364 |
|
| 1365 |
/* At the end of the SKB, there's a header telling us how many packets |
| 1366 |
* are bundled into this buffer and where we can find an array of |
| 1367 |
* per-packet metadata (which contains elements encoded into u16). |
| 1368 |
*/ |
| 1369 |
|
| 1370 |
/* SKB contents for current firmware: |
| 1371 |
* <packet 1> <padding> |
| 1372 |
* ... |
| 1373 |
* <packet N> <padding> |
| 1374 |
* <per-packet metadata entry 1> <dummy header> |
| 1375 |
* ... |
| 1376 |
* <per-packet metadata entry N> <dummy header> |
| 1377 |
* <padding2> <rx_hdr> |
| 1378 |
* |
| 1379 |
* where: |
| 1380 |
* <packet N> contains pkt_len bytes: |
| 1381 |
* 2 bytes of IP alignment pseudo header |
| 1382 |
* packet received |
| 1383 |
* <per-packet metadata entry N> contains 4 bytes: |
| 1384 |
* pkt_len and fields AX_RXHDR_* |
| 1385 |
* <padding> 0-7 bytes to terminate at |
| 1386 |
* 8 bytes boundary (64-bit). |
| 1387 |
* <padding2> 4 bytes to make rx_hdr terminate at |
| 1388 |
* 8 bytes boundary (64-bit) |
| 1389 |
* <dummy-header> contains 4 bytes: |
| 1390 |
* pkt_len=0 and AX_RXHDR_DROP_ERR |
| 1391 |
* <rx-hdr> contains 4 bytes: |
| 1392 |
* pkt_cnt and hdr_off (offset of |
| 1393 |
* <per-packet metadata entry 1>) |
| 1394 |
* |
| 1395 |
* pkt_cnt is number of entrys in the per-packet metadata. |
| 1396 |
* In current firmware there is 2 entrys per packet. |
| 1397 |
* The first points to the packet and the |
| 1398 |
* second is a dummy header. |
| 1399 |
* This was done probably to align fields in 64-bit and |
| 1400 |
* maintain compatibility with old firmware. |
| 1401 |
* This code assumes that <dummy header> and <padding2> are |
| 1402 |
* optional. |
| 1403 |
*/ |
| 1404 |
|
| 1405 |
if (skb->len < 4) |
| 1406 |
return 0; |
| 1407 |
skb_trim(skb, skb->len - 4); |
| 1408 |
rx_hdr = get_unaligned_le32(skb_tail_pointer(skb)); |
| 1409 |
pkt_cnt = (u16)rx_hdr; |
| 1410 |
hdr_off = (u16)(rx_hdr >> 16); |
| 1411 |
|
| 1412 |
if (pkt_cnt == 0) |
| 1413 |
return 0; |
| 1414 |
|
| 1415 |
/* Make sure that the bounds of the metadata array are inside the SKB |
| 1416 |
* (and in front of the counter at the end). |
| 1417 |
*/ |
| 1418 |
if (pkt_cnt * 4 + hdr_off > skb->len) |
| 1419 |
return 0; |
| 1420 |
pkt_hdr = (u32 *)(skb->data + hdr_off); |
| 1421 |
|
| 1422 |
/* Packets must not overlap the metadata array */ |
| 1423 |
skb_trim(skb, hdr_off); |
| 1424 |
|
| 1425 |
for (; pkt_cnt > 0; pkt_cnt--, pkt_hdr++) { |
| 1426 |
u16 pkt_len_plus_padd; |
| 1427 |
u16 pkt_len; |
| 1428 |
|
| 1429 |
le32_to_cpus(pkt_hdr); |
| 1430 |
pkt_len = (*pkt_hdr >> 16) & 0x1fff; |
| 1431 |
pkt_len_plus_padd = (pkt_len + 7) & 0xfff8; |
| 1432 |
|
| 1433 |
/* Skip dummy header used for alignment |
| 1434 |
*/ |
| 1435 |
if (pkt_len == 0) |
| 1436 |
continue; |
| 1437 |
|
| 1438 |
if (pkt_len_plus_padd > skb->len) |
| 1439 |
return 0; |
| 1440 |
|
| 1441 |
/* Check CRC or runt packet */ |
| 1442 |
if ((*pkt_hdr & (AX_RXHDR_CRC_ERR | AX_RXHDR_DROP_ERR)) || |
| 1443 |
pkt_len < 2 + ETH_HLEN) { |
| 1444 |
dev->net->stats.rx_errors++; |
| 1445 |
skb_pull(skb, pkt_len_plus_padd); |
| 1446 |
continue; |
| 1447 |
} |
| 1448 |
|
| 1449 |
/* last packet */ |
| 1450 |
if (pkt_len_plus_padd == skb->len) { |
| 1451 |
skb_trim(skb, pkt_len); |
| 1452 |
|
| 1453 |
/* Skip IP alignment pseudo header */ |
| 1454 |
skb_pull(skb, 2); |
| 1455 |
|
| 1456 |
ax88179_rx_checksum(skb, pkt_hdr); |
| 1457 |
return 1; |
| 1458 |
} |
| 1459 |
|
| 1460 |
ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len); |
| 1461 |
if (!ax_skb) |
| 1462 |
return 0; |
| 1463 |
skb_put(ax_skb, pkt_len); |
| 1464 |
memcpy(ax_skb->data, skb->data + 2, pkt_len); |
| 1465 |
|
| 1466 |
ax88179_rx_checksum(ax_skb, pkt_hdr); |
| 1467 |
usbnet_skb_return(dev, ax_skb); |
| 1468 |
|
| 1469 |
skb_pull(skb, pkt_len_plus_padd); |
| 1470 |
} |
| 1471 |
|
| 1472 |
return 0; |
| 1473 |
} |
| 1474 |
|
| 1475 |
static struct sk_buff * |
| 1476 |
ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
| 1477 |
{ |
| 1478 |
u32 tx_hdr1, tx_hdr2; |
| 1479 |
int frame_size = dev->maxpacket; |
| 1480 |
int headroom; |
| 1481 |
void *ptr; |
| 1482 |
|
| 1483 |
tx_hdr1 = skb->len; |
| 1484 |
tx_hdr2 = skb_shinfo(skb)->gso_size; /* Set TSO mss */ |
| 1485 |
if (((skb->len + 8) % frame_size) == 0) |
| 1486 |
tx_hdr2 |= 0x80008000; /* Enable padding */ |
| 1487 |
|
| 1488 |
headroom = skb_headroom(skb) - 8; |
| 1489 |
|
| 1490 |
if ((dev->net->features & NETIF_F_SG) && skb_linearize(skb)) |
| 1491 |
return NULL; |
| 1492 |
|
| 1493 |
if ((skb_header_cloned(skb) || headroom < 0) && |
| 1494 |
pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) { |
| 1495 |
dev_kfree_skb_any(skb); |
| 1496 |
return NULL; |
| 1497 |
} |
| 1498 |
|
| 1499 |
ptr = skb_push(skb, 8); |
| 1500 |
put_unaligned_le32(tx_hdr1, ptr); |
| 1501 |
put_unaligned_le32(tx_hdr2, ptr + 4); |
| 1502 |
|
| 1503 |
usbnet_set_skb_tx_stats(skb, (skb_shinfo(skb)->gso_segs ?: 1), 0); |
| 1504 |
|
| 1505 |
return skb; |
| 1506 |
} |
| 1507 |
|
| 1508 |
static int ax88179_link_reset(struct usbnet *dev) |
| 1509 |
{ |
| 1510 |
struct ax88179_data *ax179_data = dev->driver_priv; |
| 1511 |
u8 tmp[5], link_sts; |
| 1512 |
u16 mode, tmp16, delay = HZ / 10; |
| 1513 |
u32 tmp32 = 0x40000000; |
| 1514 |
unsigned long jtimeout; |
| 1515 |
|
| 1516 |
jtimeout = jiffies + delay; |
| 1517 |
while (tmp32 & 0x40000000) { |
| 1518 |
mode = 0; |
| 1519 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &mode); |
| 1520 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, |
| 1521 |
&ax179_data->rxctl); |
| 1522 |
|
| 1523 |
/*link up, check the usb device control TX FIFO full or empty*/ |
| 1524 |
ax88179_read_cmd(dev, 0x81, 0x8c, 0, 4, &tmp32); |
| 1525 |
|
| 1526 |
if (time_after(jiffies, jtimeout)) |
| 1527 |
return 0; |
| 1528 |
} |
| 1529 |
|
| 1530 |
mode = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | |
| 1531 |
AX_MEDIUM_RXFLOW_CTRLEN; |
| 1532 |
|
| 1533 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, |
| 1534 |
1, 1, &link_sts); |
| 1535 |
|
| 1536 |
ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, |
| 1537 |
GMII_PHY_PHYSR, 2, &tmp16); |
| 1538 |
|
| 1539 |
if (!(tmp16 & GMII_PHY_PHYSR_LINK)) { |
| 1540 |
netdev_info(dev->net, "ax88179 - Link status is: 0\n"); |
| 1541 |
return 0; |
| 1542 |
} else if (GMII_PHY_PHYSR_GIGA == (tmp16 & GMII_PHY_PHYSR_SMASK)) { |
| 1543 |
mode |= AX_MEDIUM_GIGAMODE | AX_MEDIUM_EN_125MHZ; |
| 1544 |
if (dev->net->mtu > 1500) |
| 1545 |
mode |= AX_MEDIUM_JUMBO_EN; |
| 1546 |
|
| 1547 |
if (link_sts & AX_USB_SS) |
| 1548 |
memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); |
| 1549 |
else if (link_sts & AX_USB_HS) |
| 1550 |
memcpy(tmp, &AX88179_BULKIN_SIZE[1], 5); |
| 1551 |
else |
| 1552 |
memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); |
| 1553 |
} else if (GMII_PHY_PHYSR_100 == (tmp16 & GMII_PHY_PHYSR_SMASK)) { |
| 1554 |
mode |= AX_MEDIUM_PS; |
| 1555 |
|
| 1556 |
if (link_sts & (AX_USB_SS | AX_USB_HS)) |
| 1557 |
memcpy(tmp, &AX88179_BULKIN_SIZE[2], 5); |
| 1558 |
else |
| 1559 |
memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); |
| 1560 |
} else { |
| 1561 |
memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); |
| 1562 |
} |
| 1563 |
|
| 1564 |
/* RX bulk configuration */ |
| 1565 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); |
| 1566 |
|
| 1567 |
dev->rx_urb_size = (1024 * (tmp[3] + 2)); |
| 1568 |
|
| 1569 |
if (tmp16 & GMII_PHY_PHYSR_FULL) |
| 1570 |
mode |= AX_MEDIUM_FULL_DUPLEX; |
| 1571 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 1572 |
2, 2, &mode); |
| 1573 |
|
| 1574 |
ax179_data->eee_enabled = ax88179_chk_eee(dev); |
| 1575 |
|
| 1576 |
netif_carrier_on(dev->net); |
| 1577 |
|
| 1578 |
netdev_info(dev->net, "ax88179 - Link status is: 1\n"); |
| 1579 |
|
| 1580 |
return 0; |
| 1581 |
} |
| 1582 |
|
| 1583 |
static int ax88179_reset(struct usbnet *dev) |
| 1584 |
{ |
| 1585 |
u8 buf[5]; |
| 1586 |
u16 *tmp16; |
| 1587 |
u8 *tmp; |
| 1588 |
struct ax88179_data *ax179_data = dev->driver_priv; |
| 1589 |
struct ethtool_keee eee_data; |
| 1590 |
|
| 1591 |
tmp16 = (u16 *)buf; |
| 1592 |
tmp = (u8 *)buf; |
| 1593 |
|
| 1594 |
/* Power up ethernet PHY */ |
| 1595 |
*tmp16 = 0; |
| 1596 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); |
| 1597 |
|
| 1598 |
*tmp16 = AX_PHYPWR_RSTCTL_IPRL; |
| 1599 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); |
| 1600 |
msleep(500); |
| 1601 |
|
| 1602 |
*tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; |
| 1603 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); |
| 1604 |
msleep(200); |
| 1605 |
|
| 1606 |
/* Ethernet PHY Auto Detach*/ |
| 1607 |
ax88179_auto_detach(dev); |
| 1608 |
|
| 1609 |
/* Read MAC address from DTB or asix chip */ |
| 1610 |
ax88179_get_mac_addr(dev); |
| 1611 |
memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); |
| 1612 |
|
| 1613 |
/* RX bulk configuration */ |
| 1614 |
memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); |
| 1615 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); |
| 1616 |
|
| 1617 |
dev->rx_urb_size = 1024 * 20; |
| 1618 |
|
| 1619 |
*tmp = 0x34; |
| 1620 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); |
| 1621 |
|
| 1622 |
*tmp = 0x52; |
| 1623 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, |
| 1624 |
1, 1, tmp); |
| 1625 |
|
| 1626 |
/* Enable checksum offload */ |
| 1627 |
*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | |
| 1628 |
AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; |
| 1629 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); |
| 1630 |
|
| 1631 |
*tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | |
| 1632 |
AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; |
| 1633 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); |
| 1634 |
|
| 1635 |
/* Configure RX control register => start operation */ |
| 1636 |
*tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | |
| 1637 |
AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; |
| 1638 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); |
| 1639 |
|
| 1640 |
*tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | |
| 1641 |
AX_MONITOR_MODE_RWMP; |
| 1642 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); |
| 1643 |
|
| 1644 |
/* Configure default medium type => giga */ |
| 1645 |
*tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | |
| 1646 |
AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX | |
| 1647 |
AX_MEDIUM_GIGAMODE; |
| 1648 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 1649 |
2, 2, tmp16); |
| 1650 |
|
| 1651 |
/* Check if WoL is supported */ |
| 1652 |
ax179_data->wol_supported = 0; |
| 1653 |
if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, |
| 1654 |
1, 1, &tmp) > 0) |
| 1655 |
ax179_data->wol_supported = WAKE_MAGIC | WAKE_PHY; |
| 1656 |
|
| 1657 |
ax88179_led_setting(dev); |
| 1658 |
|
| 1659 |
ax179_data->eee_enabled = 0; |
| 1660 |
ax179_data->eee_active = 0; |
| 1661 |
|
| 1662 |
ax88179_disable_eee(dev); |
| 1663 |
|
| 1664 |
ax88179_ethtool_get_eee(dev, &eee_data); |
| 1665 |
linkmode_zero(eee_data.advertised); |
| 1666 |
ax88179_ethtool_set_eee(dev, &eee_data); |
| 1667 |
|
| 1668 |
/* Restart autoneg */ |
| 1669 |
mii_nway_restart(&dev->mii); |
| 1670 |
|
| 1671 |
usbnet_link_change(dev, 0, 0); |
| 1672 |
|
| 1673 |
return 0; |
| 1674 |
} |
| 1675 |
|
| 1676 |
static int ax88179_net_reset(struct usbnet *dev) |
| 1677 |
{ |
| 1678 |
u16 tmp16; |
| 1679 |
|
| 1680 |
ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, GMII_PHY_PHYSR, |
| 1681 |
2, &tmp16); |
| 1682 |
if (tmp16) { |
| 1683 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 1684 |
2, 2, &tmp16); |
| 1685 |
if (!(tmp16 & AX_MEDIUM_RECEIVE_EN)) { |
| 1686 |
tmp16 |= AX_MEDIUM_RECEIVE_EN; |
| 1687 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 1688 |
2, 2, &tmp16); |
| 1689 |
} |
| 1690 |
} else { |
| 1691 |
ax88179_reset(dev); |
| 1692 |
} |
| 1693 |
|
| 1694 |
return 0; |
| 1695 |
} |
| 1696 |
|
| 1697 |
static int ax88179_stop(struct usbnet *dev) |
| 1698 |
{ |
| 1699 |
u16 tmp16; |
| 1700 |
|
| 1701 |
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 1702 |
2, 2, &tmp16); |
| 1703 |
tmp16 &= ~AX_MEDIUM_RECEIVE_EN; |
| 1704 |
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, |
| 1705 |
2, 2, &tmp16); |
| 1706 |
|
| 1707 |
return 0; |
| 1708 |
} |
| 1709 |
|
| 1710 |
static const struct driver_info ax88179_info = { |
| 1711 |
.description = "ASIX AX88179 USB 3.0 Gigabit Ethernet", |
| 1712 |
.bind = ax88179_bind, |
| 1713 |
.unbind = ax88179_unbind, |
| 1714 |
.status = ax88179_status, |
| 1715 |
.link_reset = ax88179_link_reset, |
| 1716 |
.reset = ax88179_net_reset, |
| 1717 |
.stop = ax88179_stop, |
| 1718 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1719 |
.rx_fixup = ax88179_rx_fixup, |
| 1720 |
.tx_fixup = ax88179_tx_fixup, |
| 1721 |
}; |
| 1722 |
|
| 1723 |
static const struct driver_info ax88178a_info = { |
| 1724 |
.description = "ASIX AX88178A USB 2.0 Gigabit Ethernet", |
| 1725 |
.bind = ax88179_bind, |
| 1726 |
.unbind = ax88179_unbind, |
| 1727 |
.status = ax88179_status, |
| 1728 |
.link_reset = ax88179_link_reset, |
| 1729 |
.reset = ax88179_net_reset, |
| 1730 |
.stop = ax88179_stop, |
| 1731 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1732 |
.rx_fixup = ax88179_rx_fixup, |
| 1733 |
.tx_fixup = ax88179_tx_fixup, |
| 1734 |
}; |
| 1735 |
|
| 1736 |
static const struct driver_info cypress_GX3_info = { |
| 1737 |
.description = "Cypress GX3 SuperSpeed to Gigabit Ethernet Controller", |
| 1738 |
.bind = ax88179_bind, |
| 1739 |
.unbind = ax88179_unbind, |
| 1740 |
.status = ax88179_status, |
| 1741 |
.link_reset = ax88179_link_reset, |
| 1742 |
.reset = ax88179_net_reset, |
| 1743 |
.stop = ax88179_stop, |
| 1744 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1745 |
.rx_fixup = ax88179_rx_fixup, |
| 1746 |
.tx_fixup = ax88179_tx_fixup, |
| 1747 |
}; |
| 1748 |
|
| 1749 |
static const struct driver_info dlink_dub1312_info = { |
| 1750 |
.description = "D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter", |
| 1751 |
.bind = ax88179_bind, |
| 1752 |
.unbind = ax88179_unbind, |
| 1753 |
.status = ax88179_status, |
| 1754 |
.link_reset = ax88179_link_reset, |
| 1755 |
.reset = ax88179_net_reset, |
| 1756 |
.stop = ax88179_stop, |
| 1757 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1758 |
.rx_fixup = ax88179_rx_fixup, |
| 1759 |
.tx_fixup = ax88179_tx_fixup, |
| 1760 |
}; |
| 1761 |
|
| 1762 |
static const struct driver_info sitecom_info = { |
| 1763 |
.description = "Sitecom USB 3.0 to Gigabit Adapter", |
| 1764 |
.bind = ax88179_bind, |
| 1765 |
.unbind = ax88179_unbind, |
| 1766 |
.status = ax88179_status, |
| 1767 |
.link_reset = ax88179_link_reset, |
| 1768 |
.reset = ax88179_net_reset, |
| 1769 |
.stop = ax88179_stop, |
| 1770 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1771 |
.rx_fixup = ax88179_rx_fixup, |
| 1772 |
.tx_fixup = ax88179_tx_fixup, |
| 1773 |
}; |
| 1774 |
|
| 1775 |
static const struct driver_info samsung_info = { |
| 1776 |
.description = "Samsung USB Ethernet Adapter", |
| 1777 |
.bind = ax88179_bind, |
| 1778 |
.unbind = ax88179_unbind, |
| 1779 |
.status = ax88179_status, |
| 1780 |
.link_reset = ax88179_link_reset, |
| 1781 |
.reset = ax88179_net_reset, |
| 1782 |
.stop = ax88179_stop, |
| 1783 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1784 |
.rx_fixup = ax88179_rx_fixup, |
| 1785 |
.tx_fixup = ax88179_tx_fixup, |
| 1786 |
}; |
| 1787 |
|
| 1788 |
static const struct driver_info lenovo_info = { |
| 1789 |
.description = "Lenovo OneLinkDock Gigabit LAN", |
| 1790 |
.bind = ax88179_bind, |
| 1791 |
.unbind = ax88179_unbind, |
| 1792 |
.status = ax88179_status, |
| 1793 |
.link_reset = ax88179_link_reset, |
| 1794 |
.reset = ax88179_net_reset, |
| 1795 |
.stop = ax88179_stop, |
| 1796 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1797 |
.rx_fixup = ax88179_rx_fixup, |
| 1798 |
.tx_fixup = ax88179_tx_fixup, |
| 1799 |
}; |
| 1800 |
|
| 1801 |
static const struct driver_info belkin_info = { |
| 1802 |
.description = "Belkin USB Ethernet Adapter", |
| 1803 |
.bind = ax88179_bind, |
| 1804 |
.unbind = ax88179_unbind, |
| 1805 |
.status = ax88179_status, |
| 1806 |
.link_reset = ax88179_link_reset, |
| 1807 |
.reset = ax88179_net_reset, |
| 1808 |
.stop = ax88179_stop, |
| 1809 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1810 |
.rx_fixup = ax88179_rx_fixup, |
| 1811 |
.tx_fixup = ax88179_tx_fixup, |
| 1812 |
}; |
| 1813 |
|
| 1814 |
static const struct driver_info toshiba_info = { |
| 1815 |
.description = "Toshiba USB Ethernet Adapter", |
| 1816 |
.bind = ax88179_bind, |
| 1817 |
.unbind = ax88179_unbind, |
| 1818 |
.status = ax88179_status, |
| 1819 |
.link_reset = ax88179_link_reset, |
| 1820 |
.reset = ax88179_net_reset, |
| 1821 |
.stop = ax88179_stop, |
| 1822 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1823 |
.rx_fixup = ax88179_rx_fixup, |
| 1824 |
.tx_fixup = ax88179_tx_fixup, |
| 1825 |
}; |
| 1826 |
|
| 1827 |
static const struct driver_info mct_info = { |
| 1828 |
.description = "MCT USB 3.0 Gigabit Ethernet Adapter", |
| 1829 |
.bind = ax88179_bind, |
| 1830 |
.unbind = ax88179_unbind, |
| 1831 |
.status = ax88179_status, |
| 1832 |
.link_reset = ax88179_link_reset, |
| 1833 |
.reset = ax88179_net_reset, |
| 1834 |
.stop = ax88179_stop, |
| 1835 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1836 |
.rx_fixup = ax88179_rx_fixup, |
| 1837 |
.tx_fixup = ax88179_tx_fixup, |
| 1838 |
}; |
| 1839 |
|
| 1840 |
static const struct driver_info at_umc2000_info = { |
| 1841 |
.description = "AT-UMC2000 USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter", |
| 1842 |
.bind = ax88179_bind, |
| 1843 |
.unbind = ax88179_unbind, |
| 1844 |
.status = ax88179_status, |
| 1845 |
.link_reset = ax88179_link_reset, |
| 1846 |
.reset = ax88179_net_reset, |
| 1847 |
.stop = ax88179_stop, |
| 1848 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1849 |
.rx_fixup = ax88179_rx_fixup, |
| 1850 |
.tx_fixup = ax88179_tx_fixup, |
| 1851 |
}; |
| 1852 |
|
| 1853 |
static const struct driver_info at_umc200_info = { |
| 1854 |
.description = "AT-UMC200 USB 3.0/USB 3.1 Gen 1 to Fast Ethernet Adapter", |
| 1855 |
.bind = ax88179_bind, |
| 1856 |
.unbind = ax88179_unbind, |
| 1857 |
.status = ax88179_status, |
| 1858 |
.link_reset = ax88179_link_reset, |
| 1859 |
.reset = ax88179_net_reset, |
| 1860 |
.stop = ax88179_stop, |
| 1861 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1862 |
.rx_fixup = ax88179_rx_fixup, |
| 1863 |
.tx_fixup = ax88179_tx_fixup, |
| 1864 |
}; |
| 1865 |
|
| 1866 |
static const struct driver_info at_umc2000sp_info = { |
| 1867 |
.description = "AT-UMC2000/SP USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter", |
| 1868 |
.bind = ax88179_bind, |
| 1869 |
.unbind = ax88179_unbind, |
| 1870 |
.status = ax88179_status, |
| 1871 |
.link_reset = ax88179_link_reset, |
| 1872 |
.reset = ax88179_net_reset, |
| 1873 |
.stop = ax88179_stop, |
| 1874 |
.flags = FLAG_ETHER | FLAG_FRAMING_AX, |
| 1875 |
.rx_fixup = ax88179_rx_fixup, |
| 1876 |
.tx_fixup = ax88179_tx_fixup, |
| 1877 |
}; |
| 1878 |
|
| 1879 |
static const struct usb_device_id products[] = { |
| 1880 |
{ |
| 1881 |
/* ASIX AX88179 10/100/1000 */ |
| 1882 |
USB_DEVICE_AND_INTERFACE_INFO(0x0b95, 0x1790, 0xff, 0xff, 0), |
| 1883 |
.driver_info = (unsigned long)&ax88179_info, |
| 1884 |
}, { |
| 1885 |
/* ASIX AX88178A 10/100/1000 */ |
| 1886 |
USB_DEVICE_AND_INTERFACE_INFO(0x0b95, 0x178a, 0xff, 0xff, 0), |
| 1887 |
.driver_info = (unsigned long)&ax88178a_info, |
| 1888 |
}, { |
| 1889 |
/* Cypress GX3 SuperSpeed to Gigabit Ethernet Bridge Controller */ |
| 1890 |
USB_DEVICE_AND_INTERFACE_INFO(0x04b4, 0x3610, 0xff, 0xff, 0), |
| 1891 |
.driver_info = (unsigned long)&cypress_GX3_info, |
| 1892 |
}, { |
| 1893 |
/* D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter */ |
| 1894 |
USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x4a00, 0xff, 0xff, 0), |
| 1895 |
.driver_info = (unsigned long)&dlink_dub1312_info, |
| 1896 |
}, { |
| 1897 |
/* Sitecom USB 3.0 to Gigabit Adapter */ |
| 1898 |
USB_DEVICE_AND_INTERFACE_INFO(0x0df6, 0x0072, 0xff, 0xff, 0), |
| 1899 |
.driver_info = (unsigned long)&sitecom_info, |
| 1900 |
}, { |
| 1901 |
/* Samsung USB Ethernet Adapter */ |
| 1902 |
USB_DEVICE_AND_INTERFACE_INFO(0x04e8, 0xa100, 0xff, 0xff, 0), |
| 1903 |
.driver_info = (unsigned long)&samsung_info, |
| 1904 |
}, { |
| 1905 |
/* Lenovo OneLinkDock Gigabit LAN */ |
| 1906 |
USB_DEVICE_AND_INTERFACE_INFO(0x17ef, 0x304b, 0xff, 0xff, 0), |
| 1907 |
.driver_info = (unsigned long)&lenovo_info, |
| 1908 |
}, { |
| 1909 |
/* Belkin B2B128 USB 3.0 Hub + Gigabit Ethernet Adapter */ |
| 1910 |
USB_DEVICE_AND_INTERFACE_INFO(0x050d, 0x0128, 0xff, 0xff, 0), |
| 1911 |
.driver_info = (unsigned long)&belkin_info, |
| 1912 |
}, { |
| 1913 |
/* Toshiba USB 3.0 GBit Ethernet Adapter */ |
| 1914 |
USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x0a13, 0xff, 0xff, 0), |
| 1915 |
.driver_info = (unsigned long)&toshiba_info, |
| 1916 |
}, { |
| 1917 |
/* Magic Control Technology U3-A9003 USB 3.0 Gigabit Ethernet Adapter */ |
| 1918 |
USB_DEVICE_AND_INTERFACE_INFO(0x0711, 0x0179, 0xff, 0xff, 0), |
| 1919 |
.driver_info = (unsigned long)&mct_info, |
| 1920 |
}, { |
| 1921 |
/* Allied Telesis AT-UMC2000 USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter */ |
| 1922 |
USB_DEVICE_AND_INTERFACE_INFO(0x07c9, 0x000e, 0xff, 0xff, 0), |
| 1923 |
.driver_info = (unsigned long)&at_umc2000_info, |
| 1924 |
}, { |
| 1925 |
/* Allied Telesis AT-UMC200 USB 3.0/USB 3.1 Gen 1 to Fast Ethernet Adapter */ |
| 1926 |
USB_DEVICE_AND_INTERFACE_INFO(0x07c9, 0x000f, 0xff, 0xff, 0), |
| 1927 |
.driver_info = (unsigned long)&at_umc200_info, |
| 1928 |
}, { |
| 1929 |
/* Allied Telesis AT-UMC2000/SP USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter */ |
| 1930 |
USB_DEVICE_AND_INTERFACE_INFO(0x07c9, 0x0010, 0xff, 0xff, 0), |
| 1931 |
.driver_info = (unsigned long)&at_umc2000sp_info, |
| 1932 |
}, |
| 1933 |
{ }, |
| 1934 |
}; |
| 1935 |
MODULE_DEVICE_TABLE(usb, products); |
| 1936 |
|
| 1937 |
static struct usb_driver ax88179_178a_driver = { |
| 1938 |
.name = "ax88179_178a", |
| 1939 |
.id_table = products, |
| 1940 |
.probe = usbnet_probe, |
| 1941 |
.suspend = ax88179_suspend, |
| 1942 |
.resume = ax88179_resume, |
| 1943 |
.reset_resume = ax88179_resume, |
| 1944 |
.disconnect = ax88179_disconnect, |
| 1945 |
.supports_autosuspend = 1, |
| 1946 |
.disable_hub_initiated_lpm = 1, |
| 1947 |
}; |
| 1948 |
|
| 1949 |
module_usb_driver(ax88179_178a_driver); |
| 1950 |
|
| 1951 |
MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices"); |
| 1952 |
MODULE_LICENSE("GPL"); |