1 /***************************************************************************
3 * Copyright (C) 2007-2010 SMSC
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *****************************************************************************/
21 #include <linux/module.h>
22 #include <linux/kmod.h>
23 #include <linux/init.h>
24 #include <linux/netdevice.h>
25 #include <linux/etherdevice.h>
26 #include <linux/ethtool.h>
27 #include <linux/mii.h>
28 #include <linux/usb.h>
29 #include <linux/crc32.h>
30 #include <linux/usb/usbnet.h>
31 #include <linux/slab.h>
34 #define SMSC_CHIPNAME "smsc75xx"
35 #define SMSC_DRIVER_VERSION "1.0.0"
36 #define HS_USB_PKT_SIZE (512)
37 #define FS_USB_PKT_SIZE (64)
38 #define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE)
39 #define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE)
40 #define DEFAULT_BULK_IN_DELAY (0x00002000)
41 #define MAX_SINGLE_PACKET_SIZE (9000)
42 #define LAN75XX_EEPROM_MAGIC (0x7500)
43 #define EEPROM_MAC_OFFSET (0x01)
44 #define DEFAULT_TX_CSUM_ENABLE (true)
45 #define DEFAULT_RX_CSUM_ENABLE (true)
46 #define DEFAULT_TSO_ENABLE (true)
47 #define SMSC75XX_INTERNAL_PHY_ID (1)
48 #define SMSC75XX_TX_OVERHEAD (8)
49 #define MAX_RX_FIFO_SIZE (20 * 1024)
50 #define MAX_TX_FIFO_SIZE (12 * 1024)
51 #define USB_VENDOR_ID_SMSC (0x0424)
52 #define USB_PRODUCT_ID_LAN7500 (0x7500)
53 #define USB_PRODUCT_ID_LAN7505 (0x7505)
55 #define check_warn(ret, fmt, args...) \
56 ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); })
58 #define check_warn_return(ret, fmt, args...) \
59 ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); return ret; } })
61 #define check_warn_goto_done(ret, fmt, args...) \
62 ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); goto done; } })
64 struct smsc75xx_priv
{
67 u32 multicast_hash_table
[DP_SEL_VHF_HASH_LEN
];
69 struct mutex dataport_mutex
;
70 spinlock_t rfe_ctl_lock
;
71 struct work_struct set_multicast
;
75 struct usb_ctrlrequest req
;
79 static int turbo_mode
= true;
80 module_param(turbo_mode
, bool, 0644);
81 MODULE_PARM_DESC(turbo_mode
, "Enable multiple frames per Rx transaction");
83 static int __must_check
smsc75xx_read_reg(struct usbnet
*dev
, u32 index
,
86 u32
*buf
= kmalloc(4, GFP_KERNEL
);
94 ret
= usb_control_msg(dev
->udev
, usb_rcvctrlpipe(dev
->udev
, 0),
95 USB_VENDOR_REQUEST_READ_REGISTER
,
96 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
97 00, index
, buf
, 4, USB_CTRL_GET_TIMEOUT
);
99 if (unlikely(ret
< 0))
100 netdev_warn(dev
->net
,
101 "Failed to read register index 0x%08x", index
);
110 static int __must_check
smsc75xx_write_reg(struct usbnet
*dev
, u32 index
,
113 u32
*buf
= kmalloc(4, GFP_KERNEL
);
124 ret
= usb_control_msg(dev
->udev
, usb_sndctrlpipe(dev
->udev
, 0),
125 USB_VENDOR_REQUEST_WRITE_REGISTER
,
126 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
127 00, index
, buf
, 4, USB_CTRL_SET_TIMEOUT
);
129 if (unlikely(ret
< 0))
130 netdev_warn(dev
->net
,
131 "Failed to write register index 0x%08x", index
);
138 /* Loop until the read is completed with timeout
139 * called with phy_mutex held */
140 static int smsc75xx_phy_wait_not_busy(struct usbnet
*dev
)
142 unsigned long start_time
= jiffies
;
147 ret
= smsc75xx_read_reg(dev
, MII_ACCESS
, &val
);
148 check_warn_return(ret
, "Error reading MII_ACCESS");
150 if (!(val
& MII_ACCESS_BUSY
))
152 } while (!time_after(jiffies
, start_time
+ HZ
));
157 static int smsc75xx_mdio_read(struct net_device
*netdev
, int phy_id
, int idx
)
159 struct usbnet
*dev
= netdev_priv(netdev
);
163 mutex_lock(&dev
->phy_mutex
);
165 /* confirm MII not busy */
166 ret
= smsc75xx_phy_wait_not_busy(dev
);
167 check_warn_goto_done(ret
, "MII is busy in smsc75xx_mdio_read");
169 /* set the address, index & direction (read from PHY) */
170 phy_id
&= dev
->mii
.phy_id_mask
;
171 idx
&= dev
->mii
.reg_num_mask
;
172 addr
= ((phy_id
<< MII_ACCESS_PHY_ADDR_SHIFT
) & MII_ACCESS_PHY_ADDR
)
173 | ((idx
<< MII_ACCESS_REG_ADDR_SHIFT
) & MII_ACCESS_REG_ADDR
)
175 ret
= smsc75xx_write_reg(dev
, MII_ACCESS
, addr
);
176 check_warn_goto_done(ret
, "Error writing MII_ACCESS");
178 ret
= smsc75xx_phy_wait_not_busy(dev
);
179 check_warn_goto_done(ret
, "Timed out reading MII reg %02X", idx
);
181 ret
= smsc75xx_read_reg(dev
, MII_DATA
, &val
);
182 check_warn_goto_done(ret
, "Error reading MII_DATA");
184 ret
= (u16
)(val
& 0xFFFF);
187 mutex_unlock(&dev
->phy_mutex
);
191 static void smsc75xx_mdio_write(struct net_device
*netdev
, int phy_id
, int idx
,
194 struct usbnet
*dev
= netdev_priv(netdev
);
198 mutex_lock(&dev
->phy_mutex
);
200 /* confirm MII not busy */
201 ret
= smsc75xx_phy_wait_not_busy(dev
);
202 check_warn_goto_done(ret
, "MII is busy in smsc75xx_mdio_write");
205 ret
= smsc75xx_write_reg(dev
, MII_DATA
, val
);
206 check_warn_goto_done(ret
, "Error writing MII_DATA");
208 /* set the address, index & direction (write to PHY) */
209 phy_id
&= dev
->mii
.phy_id_mask
;
210 idx
&= dev
->mii
.reg_num_mask
;
211 addr
= ((phy_id
<< MII_ACCESS_PHY_ADDR_SHIFT
) & MII_ACCESS_PHY_ADDR
)
212 | ((idx
<< MII_ACCESS_REG_ADDR_SHIFT
) & MII_ACCESS_REG_ADDR
)
214 ret
= smsc75xx_write_reg(dev
, MII_ACCESS
, addr
);
215 check_warn_goto_done(ret
, "Error writing MII_ACCESS");
217 ret
= smsc75xx_phy_wait_not_busy(dev
);
218 check_warn_goto_done(ret
, "Timed out writing MII reg %02X", idx
);
221 mutex_unlock(&dev
->phy_mutex
);
224 static int smsc75xx_wait_eeprom(struct usbnet
*dev
)
226 unsigned long start_time
= jiffies
;
231 ret
= smsc75xx_read_reg(dev
, E2P_CMD
, &val
);
232 check_warn_return(ret
, "Error reading E2P_CMD");
234 if (!(val
& E2P_CMD_BUSY
) || (val
& E2P_CMD_TIMEOUT
))
237 } while (!time_after(jiffies
, start_time
+ HZ
));
239 if (val
& (E2P_CMD_TIMEOUT
| E2P_CMD_BUSY
)) {
240 netdev_warn(dev
->net
, "EEPROM read operation timeout");
247 static int smsc75xx_eeprom_confirm_not_busy(struct usbnet
*dev
)
249 unsigned long start_time
= jiffies
;
254 ret
= smsc75xx_read_reg(dev
, E2P_CMD
, &val
);
255 check_warn_return(ret
, "Error reading E2P_CMD");
257 if (!(val
& E2P_CMD_BUSY
))
261 } while (!time_after(jiffies
, start_time
+ HZ
));
263 netdev_warn(dev
->net
, "EEPROM is busy");
267 static int smsc75xx_read_eeprom(struct usbnet
*dev
, u32 offset
, u32 length
,
276 ret
= smsc75xx_eeprom_confirm_not_busy(dev
);
280 for (i
= 0; i
< length
; i
++) {
281 val
= E2P_CMD_BUSY
| E2P_CMD_READ
| (offset
& E2P_CMD_ADDR
);
282 ret
= smsc75xx_write_reg(dev
, E2P_CMD
, val
);
283 check_warn_return(ret
, "Error writing E2P_CMD");
285 ret
= smsc75xx_wait_eeprom(dev
);
289 ret
= smsc75xx_read_reg(dev
, E2P_DATA
, &val
);
290 check_warn_return(ret
, "Error reading E2P_DATA");
292 data
[i
] = val
& 0xFF;
299 static int smsc75xx_write_eeprom(struct usbnet
*dev
, u32 offset
, u32 length
,
308 ret
= smsc75xx_eeprom_confirm_not_busy(dev
);
312 /* Issue write/erase enable command */
313 val
= E2P_CMD_BUSY
| E2P_CMD_EWEN
;
314 ret
= smsc75xx_write_reg(dev
, E2P_CMD
, val
);
315 check_warn_return(ret
, "Error writing E2P_CMD");
317 ret
= smsc75xx_wait_eeprom(dev
);
321 for (i
= 0; i
< length
; i
++) {
323 /* Fill data register */
325 ret
= smsc75xx_write_reg(dev
, E2P_DATA
, val
);
326 check_warn_return(ret
, "Error writing E2P_DATA");
328 /* Send "write" command */
329 val
= E2P_CMD_BUSY
| E2P_CMD_WRITE
| (offset
& E2P_CMD_ADDR
);
330 ret
= smsc75xx_write_reg(dev
, E2P_CMD
, val
);
331 check_warn_return(ret
, "Error writing E2P_CMD");
333 ret
= smsc75xx_wait_eeprom(dev
);
343 static int smsc75xx_dataport_wait_not_busy(struct usbnet
*dev
)
347 for (i
= 0; i
< 100; i
++) {
349 ret
= smsc75xx_read_reg(dev
, DP_SEL
, &dp_sel
);
350 check_warn_return(ret
, "Error reading DP_SEL");
352 if (dp_sel
& DP_SEL_DPRDY
)
358 netdev_warn(dev
->net
, "smsc75xx_dataport_wait_not_busy timed out");
363 static int smsc75xx_dataport_write(struct usbnet
*dev
, u32 ram_select
, u32 addr
,
364 u32 length
, u32
*buf
)
366 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
370 mutex_lock(&pdata
->dataport_mutex
);
372 ret
= smsc75xx_dataport_wait_not_busy(dev
);
373 check_warn_goto_done(ret
, "smsc75xx_dataport_write busy on entry");
375 ret
= smsc75xx_read_reg(dev
, DP_SEL
, &dp_sel
);
376 check_warn_goto_done(ret
, "Error reading DP_SEL");
378 dp_sel
&= ~DP_SEL_RSEL
;
379 dp_sel
|= ram_select
;
380 ret
= smsc75xx_write_reg(dev
, DP_SEL
, dp_sel
);
381 check_warn_goto_done(ret
, "Error writing DP_SEL");
383 for (i
= 0; i
< length
; i
++) {
384 ret
= smsc75xx_write_reg(dev
, DP_ADDR
, addr
+ i
);
385 check_warn_goto_done(ret
, "Error writing DP_ADDR");
387 ret
= smsc75xx_write_reg(dev
, DP_DATA
, buf
[i
]);
388 check_warn_goto_done(ret
, "Error writing DP_DATA");
390 ret
= smsc75xx_write_reg(dev
, DP_CMD
, DP_CMD_WRITE
);
391 check_warn_goto_done(ret
, "Error writing DP_CMD");
393 ret
= smsc75xx_dataport_wait_not_busy(dev
);
394 check_warn_goto_done(ret
, "smsc75xx_dataport_write timeout");
398 mutex_unlock(&pdata
->dataport_mutex
);
402 /* returns hash bit number for given MAC address */
403 static u32
smsc75xx_hash(char addr
[ETH_ALEN
])
405 return (ether_crc(ETH_ALEN
, addr
) >> 23) & 0x1ff;
408 static void smsc75xx_deferred_multicast_write(struct work_struct
*param
)
410 struct smsc75xx_priv
*pdata
=
411 container_of(param
, struct smsc75xx_priv
, set_multicast
);
412 struct usbnet
*dev
= pdata
->dev
;
415 netif_dbg(dev
, drv
, dev
->net
, "deferred multicast write 0x%08x",
418 smsc75xx_dataport_write(dev
, DP_SEL_VHF
, DP_SEL_VHF_VLAN_LEN
,
419 DP_SEL_VHF_HASH_LEN
, pdata
->multicast_hash_table
);
421 ret
= smsc75xx_write_reg(dev
, RFE_CTL
, pdata
->rfe_ctl
);
422 check_warn(ret
, "Error writing RFE_CRL");
425 static void smsc75xx_set_multicast(struct net_device
*netdev
)
427 struct usbnet
*dev
= netdev_priv(netdev
);
428 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
432 spin_lock_irqsave(&pdata
->rfe_ctl_lock
, flags
);
435 ~(RFE_CTL_AU
| RFE_CTL_AM
| RFE_CTL_DPF
| RFE_CTL_MHF
);
436 pdata
->rfe_ctl
|= RFE_CTL_AB
;
438 for (i
= 0; i
< DP_SEL_VHF_HASH_LEN
; i
++)
439 pdata
->multicast_hash_table
[i
] = 0;
441 if (dev
->net
->flags
& IFF_PROMISC
) {
442 netif_dbg(dev
, drv
, dev
->net
, "promiscuous mode enabled");
443 pdata
->rfe_ctl
|= RFE_CTL_AM
| RFE_CTL_AU
;
444 } else if (dev
->net
->flags
& IFF_ALLMULTI
) {
445 netif_dbg(dev
, drv
, dev
->net
, "receive all multicast enabled");
446 pdata
->rfe_ctl
|= RFE_CTL_AM
| RFE_CTL_DPF
;
447 } else if (!netdev_mc_empty(dev
->net
)) {
448 struct netdev_hw_addr
*ha
;
450 netif_dbg(dev
, drv
, dev
->net
, "receive multicast hash filter");
452 pdata
->rfe_ctl
|= RFE_CTL_MHF
| RFE_CTL_DPF
;
454 netdev_for_each_mc_addr(ha
, netdev
) {
455 u32 bitnum
= smsc75xx_hash(ha
->addr
);
456 pdata
->multicast_hash_table
[bitnum
/ 32] |=
457 (1 << (bitnum
% 32));
460 netif_dbg(dev
, drv
, dev
->net
, "receive own packets only");
461 pdata
->rfe_ctl
|= RFE_CTL_DPF
;
464 spin_unlock_irqrestore(&pdata
->rfe_ctl_lock
, flags
);
466 /* defer register writes to a sleepable context */
467 schedule_work(&pdata
->set_multicast
);
470 static int smsc75xx_update_flowcontrol(struct usbnet
*dev
, u8 duplex
,
471 u16 lcladv
, u16 rmtadv
)
473 u32 flow
= 0, fct_flow
= 0;
476 if (duplex
== DUPLEX_FULL
) {
477 u8 cap
= mii_resolve_flowctrl_fdx(lcladv
, rmtadv
);
479 if (cap
& FLOW_CTRL_TX
) {
480 flow
= (FLOW_TX_FCEN
| 0xFFFF);
481 /* set fct_flow thresholds to 20% and 80% */
482 fct_flow
= (8 << 8) | 32;
485 if (cap
& FLOW_CTRL_RX
)
486 flow
|= FLOW_RX_FCEN
;
488 netif_dbg(dev
, link
, dev
->net
, "rx pause %s, tx pause %s",
489 (cap
& FLOW_CTRL_RX
? "enabled" : "disabled"),
490 (cap
& FLOW_CTRL_TX
? "enabled" : "disabled"));
492 netif_dbg(dev
, link
, dev
->net
, "half duplex");
495 ret
= smsc75xx_write_reg(dev
, FLOW
, flow
);
496 check_warn_return(ret
, "Error writing FLOW");
498 ret
= smsc75xx_write_reg(dev
, FCT_FLOW
, fct_flow
);
499 check_warn_return(ret
, "Error writing FCT_FLOW");
504 static int smsc75xx_link_reset(struct usbnet
*dev
)
506 struct mii_if_info
*mii
= &dev
->mii
;
507 struct ethtool_cmd ecmd
;
511 /* clear interrupt status */
512 ret
= smsc75xx_mdio_read(dev
->net
, mii
->phy_id
, PHY_INT_SRC
);
513 check_warn_return(ret
, "Error reading PHY_INT_SRC");
515 ret
= smsc75xx_write_reg(dev
, INT_STS
, INT_STS_CLEAR_ALL
);
516 check_warn_return(ret
, "Error writing INT_STS");
518 mii_check_media(mii
, 1, 1);
519 mii_ethtool_gset(&dev
->mii
, &ecmd
);
520 lcladv
= smsc75xx_mdio_read(dev
->net
, mii
->phy_id
, MII_ADVERTISE
);
521 rmtadv
= smsc75xx_mdio_read(dev
->net
, mii
->phy_id
, MII_LPA
);
523 netif_dbg(dev
, link
, dev
->net
, "speed: %d duplex: %d lcladv: %04x"
524 " rmtadv: %04x", ecmd
.speed
, ecmd
.duplex
, lcladv
, rmtadv
);
526 return smsc75xx_update_flowcontrol(dev
, ecmd
.duplex
, lcladv
, rmtadv
);
529 static void smsc75xx_status(struct usbnet
*dev
, struct urb
*urb
)
533 if (urb
->actual_length
!= 4) {
534 netdev_warn(dev
->net
,
535 "unexpected urb length %d", urb
->actual_length
);
539 memcpy(&intdata
, urb
->transfer_buffer
, 4);
540 le32_to_cpus(&intdata
);
542 netif_dbg(dev
, link
, dev
->net
, "intdata: 0x%08X", intdata
);
544 if (intdata
& INT_ENP_PHY_INT
)
545 usbnet_defer_kevent(dev
, EVENT_LINK_RESET
);
547 netdev_warn(dev
->net
,
548 "unexpected interrupt, intdata=0x%08X", intdata
);
551 /* Enable or disable Rx checksum offload engine */
552 static int smsc75xx_set_rx_csum_offload(struct usbnet
*dev
)
554 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
558 spin_lock_irqsave(&pdata
->rfe_ctl_lock
, flags
);
560 if (pdata
->use_rx_csum
)
561 pdata
->rfe_ctl
|= RFE_CTL_TCPUDP_CKM
| RFE_CTL_IP_CKM
;
563 pdata
->rfe_ctl
&= ~(RFE_CTL_TCPUDP_CKM
| RFE_CTL_IP_CKM
);
565 spin_unlock_irqrestore(&pdata
->rfe_ctl_lock
, flags
);
567 ret
= smsc75xx_write_reg(dev
, RFE_CTL
, pdata
->rfe_ctl
);
568 check_warn_return(ret
, "Error writing RFE_CTL");
573 static int smsc75xx_ethtool_get_eeprom_len(struct net_device
*net
)
575 return MAX_EEPROM_SIZE
;
578 static int smsc75xx_ethtool_get_eeprom(struct net_device
*netdev
,
579 struct ethtool_eeprom
*ee
, u8
*data
)
581 struct usbnet
*dev
= netdev_priv(netdev
);
583 ee
->magic
= LAN75XX_EEPROM_MAGIC
;
585 return smsc75xx_read_eeprom(dev
, ee
->offset
, ee
->len
, data
);
588 static int smsc75xx_ethtool_set_eeprom(struct net_device
*netdev
,
589 struct ethtool_eeprom
*ee
, u8
*data
)
591 struct usbnet
*dev
= netdev_priv(netdev
);
593 if (ee
->magic
!= LAN75XX_EEPROM_MAGIC
) {
594 netdev_warn(dev
->net
,
595 "EEPROM: magic value mismatch: 0x%x", ee
->magic
);
599 return smsc75xx_write_eeprom(dev
, ee
->offset
, ee
->len
, data
);
602 static u32
smsc75xx_ethtool_get_rx_csum(struct net_device
*netdev
)
604 struct usbnet
*dev
= netdev_priv(netdev
);
605 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
607 return pdata
->use_rx_csum
;
610 static int smsc75xx_ethtool_set_rx_csum(struct net_device
*netdev
, u32 val
)
612 struct usbnet
*dev
= netdev_priv(netdev
);
613 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
615 pdata
->use_rx_csum
= !!val
;
617 return smsc75xx_set_rx_csum_offload(dev
);
620 static int smsc75xx_ethtool_set_tso(struct net_device
*netdev
, u32 data
)
623 netdev
->features
|= NETIF_F_TSO
| NETIF_F_TSO6
;
625 netdev
->features
&= ~(NETIF_F_TSO
| NETIF_F_TSO6
);
630 static const struct ethtool_ops smsc75xx_ethtool_ops
= {
631 .get_link
= usbnet_get_link
,
632 .nway_reset
= usbnet_nway_reset
,
633 .get_drvinfo
= usbnet_get_drvinfo
,
634 .get_msglevel
= usbnet_get_msglevel
,
635 .set_msglevel
= usbnet_set_msglevel
,
636 .get_settings
= usbnet_get_settings
,
637 .set_settings
= usbnet_set_settings
,
638 .get_eeprom_len
= smsc75xx_ethtool_get_eeprom_len
,
639 .get_eeprom
= smsc75xx_ethtool_get_eeprom
,
640 .set_eeprom
= smsc75xx_ethtool_set_eeprom
,
641 .get_tx_csum
= ethtool_op_get_tx_csum
,
642 .set_tx_csum
= ethtool_op_set_tx_hw_csum
,
643 .get_rx_csum
= smsc75xx_ethtool_get_rx_csum
,
644 .set_rx_csum
= smsc75xx_ethtool_set_rx_csum
,
645 .get_tso
= ethtool_op_get_tso
,
646 .set_tso
= smsc75xx_ethtool_set_tso
,
649 static int smsc75xx_ioctl(struct net_device
*netdev
, struct ifreq
*rq
, int cmd
)
651 struct usbnet
*dev
= netdev_priv(netdev
);
653 if (!netif_running(netdev
))
656 return generic_mii_ioctl(&dev
->mii
, if_mii(rq
), cmd
, NULL
);
659 static void smsc75xx_init_mac_address(struct usbnet
*dev
)
661 /* try reading mac address from EEPROM */
662 if (smsc75xx_read_eeprom(dev
, EEPROM_MAC_OFFSET
, ETH_ALEN
,
663 dev
->net
->dev_addr
) == 0) {
664 if (is_valid_ether_addr(dev
->net
->dev_addr
)) {
665 /* eeprom values are valid so use them */
666 netif_dbg(dev
, ifup
, dev
->net
,
667 "MAC address read from EEPROM");
672 /* no eeprom, or eeprom values are invalid. generate random MAC */
673 random_ether_addr(dev
->net
->dev_addr
);
674 netif_dbg(dev
, ifup
, dev
->net
, "MAC address set to random_ether_addr");
677 static int smsc75xx_set_mac_address(struct usbnet
*dev
)
679 u32 addr_lo
= dev
->net
->dev_addr
[0] | dev
->net
->dev_addr
[1] << 8 |
680 dev
->net
->dev_addr
[2] << 16 | dev
->net
->dev_addr
[3] << 24;
681 u32 addr_hi
= dev
->net
->dev_addr
[4] | dev
->net
->dev_addr
[5] << 8;
683 int ret
= smsc75xx_write_reg(dev
, RX_ADDRH
, addr_hi
);
684 check_warn_return(ret
, "Failed to write RX_ADDRH: %d", ret
);
686 ret
= smsc75xx_write_reg(dev
, RX_ADDRL
, addr_lo
);
687 check_warn_return(ret
, "Failed to write RX_ADDRL: %d", ret
);
689 addr_hi
|= ADDR_FILTX_FB_VALID
;
690 ret
= smsc75xx_write_reg(dev
, ADDR_FILTX
, addr_hi
);
691 check_warn_return(ret
, "Failed to write ADDR_FILTX: %d", ret
);
693 ret
= smsc75xx_write_reg(dev
, ADDR_FILTX
+ 4, addr_lo
);
694 check_warn_return(ret
, "Failed to write ADDR_FILTX+4: %d", ret
);
699 static int smsc75xx_phy_initialize(struct usbnet
*dev
)
701 int bmcr
, timeout
= 0;
703 /* Initialize MII structure */
704 dev
->mii
.dev
= dev
->net
;
705 dev
->mii
.mdio_read
= smsc75xx_mdio_read
;
706 dev
->mii
.mdio_write
= smsc75xx_mdio_write
;
707 dev
->mii
.phy_id_mask
= 0x1f;
708 dev
->mii
.reg_num_mask
= 0x1f;
709 dev
->mii
.phy_id
= SMSC75XX_INTERNAL_PHY_ID
;
711 /* reset phy and wait for reset to complete */
712 smsc75xx_mdio_write(dev
->net
, dev
->mii
.phy_id
, MII_BMCR
, BMCR_RESET
);
716 bmcr
= smsc75xx_mdio_read(dev
->net
, dev
->mii
.phy_id
, MII_BMCR
);
717 check_warn_return(bmcr
, "Error reading MII_BMCR");
719 } while ((bmcr
& MII_BMCR
) && (timeout
< 100));
721 if (timeout
>= 100) {
722 netdev_warn(dev
->net
, "timeout on PHY Reset");
726 smsc75xx_mdio_write(dev
->net
, dev
->mii
.phy_id
, MII_ADVERTISE
,
727 ADVERTISE_ALL
| ADVERTISE_CSMA
| ADVERTISE_PAUSE_CAP
|
728 ADVERTISE_PAUSE_ASYM
);
731 smsc75xx_mdio_read(dev
->net
, dev
->mii
.phy_id
, PHY_INT_SRC
);
732 check_warn_return(bmcr
, "Error reading PHY_INT_SRC");
734 smsc75xx_mdio_write(dev
->net
, dev
->mii
.phy_id
, PHY_INT_MASK
,
735 PHY_INT_MASK_DEFAULT
);
736 mii_nway_restart(&dev
->mii
);
738 netif_dbg(dev
, ifup
, dev
->net
, "phy initialised successfully");
742 static int smsc75xx_set_rx_max_frame_length(struct usbnet
*dev
, int size
)
748 ret
= smsc75xx_read_reg(dev
, MAC_RX
, &buf
);
749 check_warn_return(ret
, "Failed to read MAC_RX: %d", ret
);
751 rxenabled
= ((buf
& MAC_RX_RXEN
) != 0);
755 ret
= smsc75xx_write_reg(dev
, MAC_RX
, buf
);
756 check_warn_return(ret
, "Failed to write MAC_RX: %d", ret
);
759 /* add 4 to size for FCS */
760 buf
&= ~MAC_RX_MAX_SIZE
;
761 buf
|= (((size
+ 4) << MAC_RX_MAX_SIZE_SHIFT
) & MAC_RX_MAX_SIZE
);
763 ret
= smsc75xx_write_reg(dev
, MAC_RX
, buf
);
764 check_warn_return(ret
, "Failed to write MAC_RX: %d", ret
);
768 ret
= smsc75xx_write_reg(dev
, MAC_RX
, buf
);
769 check_warn_return(ret
, "Failed to write MAC_RX: %d", ret
);
775 static int smsc75xx_change_mtu(struct net_device
*netdev
, int new_mtu
)
777 struct usbnet
*dev
= netdev_priv(netdev
);
779 int ret
= smsc75xx_set_rx_max_frame_length(dev
, new_mtu
);
780 check_warn_return(ret
, "Failed to set mac rx frame length");
782 return usbnet_change_mtu(netdev
, new_mtu
);
785 static int smsc75xx_reset(struct usbnet
*dev
)
787 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
789 int ret
= 0, timeout
;
791 netif_dbg(dev
, ifup
, dev
->net
, "entering smsc75xx_reset");
793 ret
= smsc75xx_read_reg(dev
, HW_CFG
, &buf
);
794 check_warn_return(ret
, "Failed to read HW_CFG: %d", ret
);
798 ret
= smsc75xx_write_reg(dev
, HW_CFG
, buf
);
799 check_warn_return(ret
, "Failed to write HW_CFG: %d", ret
);
804 ret
= smsc75xx_read_reg(dev
, HW_CFG
, &buf
);
805 check_warn_return(ret
, "Failed to read HW_CFG: %d", ret
);
807 } while ((buf
& HW_CFG_LRST
) && (timeout
< 100));
809 if (timeout
>= 100) {
810 netdev_warn(dev
->net
, "timeout on completion of Lite Reset");
814 netif_dbg(dev
, ifup
, dev
->net
, "Lite reset complete, resetting PHY");
816 ret
= smsc75xx_read_reg(dev
, PMT_CTL
, &buf
);
817 check_warn_return(ret
, "Failed to read PMT_CTL: %d", ret
);
819 buf
|= PMT_CTL_PHY_RST
;
821 ret
= smsc75xx_write_reg(dev
, PMT_CTL
, buf
);
822 check_warn_return(ret
, "Failed to write PMT_CTL: %d", ret
);
827 ret
= smsc75xx_read_reg(dev
, PMT_CTL
, &buf
);
828 check_warn_return(ret
, "Failed to read PMT_CTL: %d", ret
);
830 } while ((buf
& PMT_CTL_PHY_RST
) && (timeout
< 100));
832 if (timeout
>= 100) {
833 netdev_warn(dev
->net
, "timeout waiting for PHY Reset");
837 netif_dbg(dev
, ifup
, dev
->net
, "PHY reset complete");
839 smsc75xx_init_mac_address(dev
);
841 ret
= smsc75xx_set_mac_address(dev
);
842 check_warn_return(ret
, "Failed to set mac address");
844 netif_dbg(dev
, ifup
, dev
->net
, "MAC Address: %pM", dev
->net
->dev_addr
);
846 ret
= smsc75xx_read_reg(dev
, HW_CFG
, &buf
);
847 check_warn_return(ret
, "Failed to read HW_CFG: %d", ret
);
849 netif_dbg(dev
, ifup
, dev
->net
, "Read Value from HW_CFG : 0x%08x", buf
);
853 ret
= smsc75xx_write_reg(dev
, HW_CFG
, buf
);
854 check_warn_return(ret
, "Failed to write HW_CFG: %d", ret
);
856 ret
= smsc75xx_read_reg(dev
, HW_CFG
, &buf
);
857 check_warn_return(ret
, "Failed to read HW_CFG: %d", ret
);
859 netif_dbg(dev
, ifup
, dev
->net
, "Read Value from HW_CFG after "
860 "writing HW_CFG_BIR: 0x%08x", buf
);
864 dev
->rx_urb_size
= MAX_SINGLE_PACKET_SIZE
;
865 } else if (dev
->udev
->speed
== USB_SPEED_HIGH
) {
866 buf
= DEFAULT_HS_BURST_CAP_SIZE
/ HS_USB_PKT_SIZE
;
867 dev
->rx_urb_size
= DEFAULT_HS_BURST_CAP_SIZE
;
869 buf
= DEFAULT_FS_BURST_CAP_SIZE
/ FS_USB_PKT_SIZE
;
870 dev
->rx_urb_size
= DEFAULT_FS_BURST_CAP_SIZE
;
873 netif_dbg(dev
, ifup
, dev
->net
, "rx_urb_size=%ld",
874 (ulong
)dev
->rx_urb_size
);
876 ret
= smsc75xx_write_reg(dev
, BURST_CAP
, buf
);
877 check_warn_return(ret
, "Failed to write BURST_CAP: %d", ret
);
879 ret
= smsc75xx_read_reg(dev
, BURST_CAP
, &buf
);
880 check_warn_return(ret
, "Failed to read BURST_CAP: %d", ret
);
882 netif_dbg(dev
, ifup
, dev
->net
,
883 "Read Value from BURST_CAP after writing: 0x%08x", buf
);
885 ret
= smsc75xx_write_reg(dev
, BULK_IN_DLY
, DEFAULT_BULK_IN_DELAY
);
886 check_warn_return(ret
, "Failed to write BULK_IN_DLY: %d", ret
);
888 ret
= smsc75xx_read_reg(dev
, BULK_IN_DLY
, &buf
);
889 check_warn_return(ret
, "Failed to read BULK_IN_DLY: %d", ret
);
891 netif_dbg(dev
, ifup
, dev
->net
,
892 "Read Value from BULK_IN_DLY after writing: 0x%08x", buf
);
895 ret
= smsc75xx_read_reg(dev
, HW_CFG
, &buf
);
896 check_warn_return(ret
, "Failed to read HW_CFG: %d", ret
);
898 netif_dbg(dev
, ifup
, dev
->net
, "HW_CFG: 0x%08x", buf
);
900 buf
|= (HW_CFG_MEF
| HW_CFG_BCE
);
902 ret
= smsc75xx_write_reg(dev
, HW_CFG
, buf
);
903 check_warn_return(ret
, "Failed to write HW_CFG: %d", ret
);
905 ret
= smsc75xx_read_reg(dev
, HW_CFG
, &buf
);
906 check_warn_return(ret
, "Failed to read HW_CFG: %d", ret
);
908 netif_dbg(dev
, ifup
, dev
->net
, "HW_CFG: 0x%08x", buf
);
912 buf
= (MAX_RX_FIFO_SIZE
- 512) / 512;
913 ret
= smsc75xx_write_reg(dev
, FCT_RX_FIFO_END
, buf
);
914 check_warn_return(ret
, "Failed to write FCT_RX_FIFO_END: %d", ret
);
916 netif_dbg(dev
, ifup
, dev
->net
, "FCT_RX_FIFO_END set to 0x%08x", buf
);
918 buf
= (MAX_TX_FIFO_SIZE
- 512) / 512;
919 ret
= smsc75xx_write_reg(dev
, FCT_TX_FIFO_END
, buf
);
920 check_warn_return(ret
, "Failed to write FCT_TX_FIFO_END: %d", ret
);
922 netif_dbg(dev
, ifup
, dev
->net
, "FCT_TX_FIFO_END set to 0x%08x", buf
);
924 ret
= smsc75xx_write_reg(dev
, INT_STS
, INT_STS_CLEAR_ALL
);
925 check_warn_return(ret
, "Failed to write INT_STS: %d", ret
);
927 ret
= smsc75xx_read_reg(dev
, ID_REV
, &buf
);
928 check_warn_return(ret
, "Failed to read ID_REV: %d", ret
);
930 netif_dbg(dev
, ifup
, dev
->net
, "ID_REV = 0x%08x", buf
);
932 /* Configure GPIO pins as LED outputs */
933 ret
= smsc75xx_read_reg(dev
, LED_GPIO_CFG
, &buf
);
934 check_warn_return(ret
, "Failed to read LED_GPIO_CFG: %d", ret
);
936 buf
&= ~(LED_GPIO_CFG_LED2_FUN_SEL
| LED_GPIO_CFG_LED10_FUN_SEL
);
937 buf
|= LED_GPIO_CFG_LEDGPIO_EN
| LED_GPIO_CFG_LED2_FUN_SEL
;
939 ret
= smsc75xx_write_reg(dev
, LED_GPIO_CFG
, buf
);
940 check_warn_return(ret
, "Failed to write LED_GPIO_CFG: %d", ret
);
942 ret
= smsc75xx_write_reg(dev
, FLOW
, 0);
943 check_warn_return(ret
, "Failed to write FLOW: %d", ret
);
945 ret
= smsc75xx_write_reg(dev
, FCT_FLOW
, 0);
946 check_warn_return(ret
, "Failed to write FCT_FLOW: %d", ret
);
948 /* Don't need rfe_ctl_lock during initialisation */
949 ret
= smsc75xx_read_reg(dev
, RFE_CTL
, &pdata
->rfe_ctl
);
950 check_warn_return(ret
, "Failed to read RFE_CTL: %d", ret
);
952 pdata
->rfe_ctl
|= RFE_CTL_AB
| RFE_CTL_DPF
;
954 ret
= smsc75xx_write_reg(dev
, RFE_CTL
, pdata
->rfe_ctl
);
955 check_warn_return(ret
, "Failed to write RFE_CTL: %d", ret
);
957 ret
= smsc75xx_read_reg(dev
, RFE_CTL
, &pdata
->rfe_ctl
);
958 check_warn_return(ret
, "Failed to read RFE_CTL: %d", ret
);
960 netif_dbg(dev
, ifup
, dev
->net
, "RFE_CTL set to 0x%08x", pdata
->rfe_ctl
);
962 /* Enable or disable checksum offload engines */
963 ethtool_op_set_tx_hw_csum(dev
->net
, DEFAULT_TX_CSUM_ENABLE
);
964 ret
= smsc75xx_set_rx_csum_offload(dev
);
965 check_warn_return(ret
, "Failed to set rx csum offload: %d", ret
);
967 smsc75xx_ethtool_set_tso(dev
->net
, DEFAULT_TSO_ENABLE
);
969 smsc75xx_set_multicast(dev
->net
);
971 ret
= smsc75xx_phy_initialize(dev
);
972 check_warn_return(ret
, "Failed to initialize PHY: %d", ret
);
974 ret
= smsc75xx_read_reg(dev
, INT_EP_CTL
, &buf
);
975 check_warn_return(ret
, "Failed to read INT_EP_CTL: %d", ret
);
977 /* enable PHY interrupts */
978 buf
|= INT_ENP_PHY_INT
;
980 ret
= smsc75xx_write_reg(dev
, INT_EP_CTL
, buf
);
981 check_warn_return(ret
, "Failed to write INT_EP_CTL: %d", ret
);
983 ret
= smsc75xx_read_reg(dev
, MAC_TX
, &buf
);
984 check_warn_return(ret
, "Failed to read MAC_TX: %d", ret
);
988 ret
= smsc75xx_write_reg(dev
, MAC_TX
, buf
);
989 check_warn_return(ret
, "Failed to write MAC_TX: %d", ret
);
991 netif_dbg(dev
, ifup
, dev
->net
, "MAC_TX set to 0x%08x", buf
);
993 ret
= smsc75xx_read_reg(dev
, FCT_TX_CTL
, &buf
);
994 check_warn_return(ret
, "Failed to read FCT_TX_CTL: %d", ret
);
996 buf
|= FCT_TX_CTL_EN
;
998 ret
= smsc75xx_write_reg(dev
, FCT_TX_CTL
, buf
);
999 check_warn_return(ret
, "Failed to write FCT_TX_CTL: %d", ret
);
1001 netif_dbg(dev
, ifup
, dev
->net
, "FCT_TX_CTL set to 0x%08x", buf
);
1003 ret
= smsc75xx_set_rx_max_frame_length(dev
, 1514);
1004 check_warn_return(ret
, "Failed to set max rx frame length");
1006 ret
= smsc75xx_read_reg(dev
, MAC_RX
, &buf
);
1007 check_warn_return(ret
, "Failed to read MAC_RX: %d", ret
);
1011 ret
= smsc75xx_write_reg(dev
, MAC_RX
, buf
);
1012 check_warn_return(ret
, "Failed to write MAC_RX: %d", ret
);
1014 netif_dbg(dev
, ifup
, dev
->net
, "MAC_RX set to 0x%08x", buf
);
1016 ret
= smsc75xx_read_reg(dev
, FCT_RX_CTL
, &buf
);
1017 check_warn_return(ret
, "Failed to read FCT_RX_CTL: %d", ret
);
1019 buf
|= FCT_RX_CTL_EN
;
1021 ret
= smsc75xx_write_reg(dev
, FCT_RX_CTL
, buf
);
1022 check_warn_return(ret
, "Failed to write FCT_RX_CTL: %d", ret
);
1024 netif_dbg(dev
, ifup
, dev
->net
, "FCT_RX_CTL set to 0x%08x", buf
);
1026 netif_dbg(dev
, ifup
, dev
->net
, "smsc75xx_reset, return 0");
1030 static const struct net_device_ops smsc75xx_netdev_ops
= {
1031 .ndo_open
= usbnet_open
,
1032 .ndo_stop
= usbnet_stop
,
1033 .ndo_start_xmit
= usbnet_start_xmit
,
1034 .ndo_tx_timeout
= usbnet_tx_timeout
,
1035 .ndo_change_mtu
= smsc75xx_change_mtu
,
1036 .ndo_set_mac_address
= eth_mac_addr
,
1037 .ndo_validate_addr
= eth_validate_addr
,
1038 .ndo_do_ioctl
= smsc75xx_ioctl
,
1039 .ndo_set_multicast_list
= smsc75xx_set_multicast
,
1042 static int smsc75xx_bind(struct usbnet
*dev
, struct usb_interface
*intf
)
1044 struct smsc75xx_priv
*pdata
= NULL
;
1047 printk(KERN_INFO SMSC_CHIPNAME
" v" SMSC_DRIVER_VERSION
"\n");
1049 ret
= usbnet_get_endpoints(dev
, intf
);
1050 check_warn_return(ret
, "usbnet_get_endpoints failed: %d", ret
);
1052 dev
->data
[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv
),
1055 pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
1057 netdev_warn(dev
->net
, "Unable to allocate smsc75xx_priv");
1063 spin_lock_init(&pdata
->rfe_ctl_lock
);
1064 mutex_init(&pdata
->dataport_mutex
);
1066 INIT_WORK(&pdata
->set_multicast
, smsc75xx_deferred_multicast_write
);
1068 pdata
->use_rx_csum
= DEFAULT_RX_CSUM_ENABLE
;
1070 /* We have to advertise SG otherwise TSO cannot be enabled */
1071 dev
->net
->features
|= NETIF_F_SG
;
1073 /* Init all registers */
1074 ret
= smsc75xx_reset(dev
);
1076 dev
->net
->netdev_ops
= &smsc75xx_netdev_ops
;
1077 dev
->net
->ethtool_ops
= &smsc75xx_ethtool_ops
;
1078 dev
->net
->flags
|= IFF_MULTICAST
;
1079 dev
->net
->hard_header_len
+= SMSC75XX_TX_OVERHEAD
;
1083 static void smsc75xx_unbind(struct usbnet
*dev
, struct usb_interface
*intf
)
1085 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
1087 netif_dbg(dev
, ifdown
, dev
->net
, "free pdata");
1094 static void smsc75xx_rx_csum_offload(struct sk_buff
*skb
, u32 rx_cmd_a
,
1097 if (unlikely(rx_cmd_a
& RX_CMD_A_LCSM
)) {
1098 skb
->ip_summed
= CHECKSUM_NONE
;
1100 skb
->csum
= ntohs((u16
)(rx_cmd_b
>> RX_CMD_B_CSUM_SHIFT
));
1101 skb
->ip_summed
= CHECKSUM_COMPLETE
;
1105 static int smsc75xx_rx_fixup(struct usbnet
*dev
, struct sk_buff
*skb
)
1107 struct smsc75xx_priv
*pdata
= (struct smsc75xx_priv
*)(dev
->data
[0]);
1109 while (skb
->len
> 0) {
1110 u32 rx_cmd_a
, rx_cmd_b
, align_count
, size
;
1111 struct sk_buff
*ax_skb
;
1112 unsigned char *packet
;
1114 memcpy(&rx_cmd_a
, skb
->data
, sizeof(rx_cmd_a
));
1115 le32_to_cpus(&rx_cmd_a
);
1118 memcpy(&rx_cmd_b
, skb
->data
, sizeof(rx_cmd_b
));
1119 le32_to_cpus(&rx_cmd_b
);
1120 skb_pull(skb
, 4 + NET_IP_ALIGN
);
1124 /* get the packet length */
1125 size
= (rx_cmd_a
& RX_CMD_A_LEN
) - NET_IP_ALIGN
;
1126 align_count
= (4 - ((size
+ NET_IP_ALIGN
) % 4)) % 4;
1128 if (unlikely(rx_cmd_a
& RX_CMD_A_RED
)) {
1129 netif_dbg(dev
, rx_err
, dev
->net
,
1130 "Error rx_cmd_a=0x%08x", rx_cmd_a
);
1131 dev
->net
->stats
.rx_errors
++;
1132 dev
->net
->stats
.rx_dropped
++;
1134 if (rx_cmd_a
& RX_CMD_A_FCS
)
1135 dev
->net
->stats
.rx_crc_errors
++;
1136 else if (rx_cmd_a
& (RX_CMD_A_LONG
| RX_CMD_A_RUNT
))
1137 dev
->net
->stats
.rx_frame_errors
++;
1139 /* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */
1140 if (unlikely(size
> (ETH_FRAME_LEN
+ 12))) {
1141 netif_dbg(dev
, rx_err
, dev
->net
,
1142 "size err rx_cmd_a=0x%08x", rx_cmd_a
);
1146 /* last frame in this batch */
1147 if (skb
->len
== size
) {
1148 if (pdata
->use_rx_csum
)
1149 smsc75xx_rx_csum_offload(skb
, rx_cmd_a
,
1152 skb
->ip_summed
= CHECKSUM_NONE
;
1154 skb_trim(skb
, skb
->len
- 4); /* remove fcs */
1155 skb
->truesize
= size
+ sizeof(struct sk_buff
);
1160 ax_skb
= skb_clone(skb
, GFP_ATOMIC
);
1161 if (unlikely(!ax_skb
)) {
1162 netdev_warn(dev
->net
, "Error allocating skb");
1167 ax_skb
->data
= packet
;
1168 skb_set_tail_pointer(ax_skb
, size
);
1170 if (pdata
->use_rx_csum
)
1171 smsc75xx_rx_csum_offload(ax_skb
, rx_cmd_a
,
1174 ax_skb
->ip_summed
= CHECKSUM_NONE
;
1176 skb_trim(ax_skb
, ax_skb
->len
- 4); /* remove fcs */
1177 ax_skb
->truesize
= size
+ sizeof(struct sk_buff
);
1179 usbnet_skb_return(dev
, ax_skb
);
1182 skb_pull(skb
, size
);
1184 /* padding bytes before the next frame starts */
1186 skb_pull(skb
, align_count
);
1189 if (unlikely(skb
->len
< 0)) {
1190 netdev_warn(dev
->net
, "invalid rx length<0 %d", skb
->len
);
1197 static struct sk_buff
*smsc75xx_tx_fixup(struct usbnet
*dev
,
1198 struct sk_buff
*skb
, gfp_t flags
)
1200 u32 tx_cmd_a
, tx_cmd_b
;
1204 if (skb_headroom(skb
) < SMSC75XX_TX_OVERHEAD
) {
1205 struct sk_buff
*skb2
=
1206 skb_copy_expand(skb
, SMSC75XX_TX_OVERHEAD
, 0, flags
);
1207 dev_kfree_skb_any(skb
);
1213 tx_cmd_a
= (u32
)(skb
->len
& TX_CMD_A_LEN
) | TX_CMD_A_FCS
;
1215 if (skb
->ip_summed
== CHECKSUM_PARTIAL
)
1216 tx_cmd_a
|= TX_CMD_A_IPE
| TX_CMD_A_TPE
;
1218 if (skb_is_gso(skb
)) {
1219 u16 mss
= max(skb_shinfo(skb
)->gso_size
, TX_MSS_MIN
);
1220 tx_cmd_b
= (mss
<< TX_CMD_B_MSS_SHIFT
) & TX_CMD_B_MSS
;
1222 tx_cmd_a
|= TX_CMD_A_LSO
;
1228 cpu_to_le32s(&tx_cmd_b
);
1229 memcpy(skb
->data
, &tx_cmd_b
, 4);
1232 cpu_to_le32s(&tx_cmd_a
);
1233 memcpy(skb
->data
, &tx_cmd_a
, 4);
1238 static const struct driver_info smsc75xx_info
= {
1239 .description
= "smsc75xx USB 2.0 Gigabit Ethernet",
1240 .bind
= smsc75xx_bind
,
1241 .unbind
= smsc75xx_unbind
,
1242 .link_reset
= smsc75xx_link_reset
,
1243 .reset
= smsc75xx_reset
,
1244 .rx_fixup
= smsc75xx_rx_fixup
,
1245 .tx_fixup
= smsc75xx_tx_fixup
,
1246 .status
= smsc75xx_status
,
1247 .flags
= FLAG_ETHER
| FLAG_SEND_ZLP
,
1250 static const struct usb_device_id products
[] = {
1252 /* SMSC7500 USB Gigabit Ethernet Device */
1253 USB_DEVICE(USB_VENDOR_ID_SMSC
, USB_PRODUCT_ID_LAN7500
),
1254 .driver_info
= (unsigned long) &smsc75xx_info
,
1257 /* SMSC7500 USB Gigabit Ethernet Device */
1258 USB_DEVICE(USB_VENDOR_ID_SMSC
, USB_PRODUCT_ID_LAN7505
),
1259 .driver_info
= (unsigned long) &smsc75xx_info
,
1263 MODULE_DEVICE_TABLE(usb
, products
);
1265 static struct usb_driver smsc75xx_driver
= {
1266 .name
= SMSC_CHIPNAME
,
1267 .id_table
= products
,
1268 .probe
= usbnet_probe
,
1269 .suspend
= usbnet_suspend
,
1270 .resume
= usbnet_resume
,
1271 .disconnect
= usbnet_disconnect
,
1274 static int __init
smsc75xx_init(void)
1276 return usb_register(&smsc75xx_driver
);
1278 module_init(smsc75xx_init
);
1280 static void __exit
smsc75xx_exit(void)
1282 usb_deregister(&smsc75xx_driver
);
1284 module_exit(smsc75xx_exit
);
1286 MODULE_AUTHOR("Nancy Lin");
1287 MODULE_AUTHOR("Steve Glendinning <steve.glendinning@smsc.com>");
1288 MODULE_DESCRIPTION("SMSC75XX USB 2.0 Gigabit Ethernet Devices");
1289 MODULE_LICENSE("GPL");