iPXE
smsc75xx.c File Reference

SMSC LAN75xx USB Ethernet driver. More...

#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/ethernet.h>
#include <ipxe/usb.h>
#include <ipxe/usbnet.h>
#include <ipxe/profile.h>
#include "smsc75xx.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int smsc75xx_dump_statistics (struct smscusb_device *smscusb)
 Dump statistics (for debugging)
static int smsc75xx_reset (struct smscusb_device *smscusb)
 Reset device.
static void smsc75xx_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete bulk IN transfer.
static int smsc75xx_out_transmit (struct smscusb_device *smscusb, struct io_buffer *iobuf)
 Transmit packet.
static int smsc75xx_open (struct net_device *netdev)
 Open network device.
static void smsc75xx_close (struct net_device *netdev)
 Close network device.
int smsc75xx_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet.
void smsc75xx_poll (struct net_device *netdev)
 Poll for completed and received packets.
static int smsc75xx_probe (struct usb_function *func, struct usb_configuration_descriptor *config)
 Probe device.
static void smsc75xx_remove (struct usb_function *func)
 Remove device.

Variables

static struct profiler smsc75xx_in_profiler __profiler
 Bulk IN completion profiler.
struct usb_endpoint_driver_operations smsc75xx_in_operations
 Bulk IN endpoint operations.
static struct net_device_operations smsc75xx_operations
 SMSC75xx network device operations.
static struct usb_device_id smsc75xx_ids []
 SMSC75xx device IDs.
struct usb_driver smsc75xx_driver __usb_driver
 SMSC LAN75xx driver.

Detailed Description

SMSC LAN75xx USB Ethernet driver.

Definition in file smsc75xx.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ smsc75xx_dump_statistics()

int smsc75xx_dump_statistics ( struct smscusb_device * smscusb)

Dump statistics (for debugging)

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 64 of file smsc75xx.c.

64 {
65 struct smsc75xx_statistics stats;
66 int rc;
67
68 /* Do nothing unless debugging is enabled */
69 if ( ! DBG_LOG )
70 return 0;
71
72 /* Get statistics */
73 if ( ( rc = smscusb_get_statistics ( smscusb, 0, &stats,
74 sizeof ( stats ) ) ) != 0 ) {
75 DBGC ( smscusb, "SMSC75XX %p could not get statistics: "
76 "%s\n", smscusb, strerror ( rc ) );
77 return rc;
78 }
79
80 /* Dump statistics */
81 DBGC ( smscusb, "SMSC75XX %p RXE fcs %d aln %d frg %d jab %d und %d "
82 "ovr %d drp %d\n", smscusb, le32_to_cpu ( stats.rx.err.fcs ),
83 le32_to_cpu ( stats.rx.err.alignment ),
84 le32_to_cpu ( stats.rx.err.fragment ),
85 le32_to_cpu ( stats.rx.err.jabber ),
86 le32_to_cpu ( stats.rx.err.undersize ),
87 le32_to_cpu ( stats.rx.err.oversize ),
88 le32_to_cpu ( stats.rx.err.dropped ) );
89 DBGC ( smscusb, "SMSC75XX %p RXB ucast %d bcast %d mcast %d\n",
90 smscusb, le32_to_cpu ( stats.rx.byte.unicast ),
91 le32_to_cpu ( stats.rx.byte.broadcast ),
92 le32_to_cpu ( stats.rx.byte.multicast ) );
93 DBGC ( smscusb, "SMSC75XX %p RXF ucast %d bcast %d mcast %d pause "
94 "%d\n", smscusb, le32_to_cpu ( stats.rx.frame.unicast ),
95 le32_to_cpu ( stats.rx.frame.broadcast ),
96 le32_to_cpu ( stats.rx.frame.multicast ),
97 le32_to_cpu ( stats.rx.frame.pause ) );
98 DBGC ( smscusb, "SMSC75XX %p TXE fcs %d def %d car %d cnt %d sgl %d "
99 "mul %d exc %d lat %d\n", smscusb,
100 le32_to_cpu ( stats.tx.err.fcs ),
101 le32_to_cpu ( stats.tx.err.deferral ),
102 le32_to_cpu ( stats.tx.err.carrier ),
103 le32_to_cpu ( stats.tx.err.count ),
104 le32_to_cpu ( stats.tx.err.single ),
105 le32_to_cpu ( stats.tx.err.multiple ),
106 le32_to_cpu ( stats.tx.err.excessive ),
107 le32_to_cpu ( stats.tx.err.late ) );
108 DBGC ( smscusb, "SMSC75XX %p TXB ucast %d bcast %d mcast %d\n",
109 smscusb, le32_to_cpu ( stats.tx.byte.unicast ),
110 le32_to_cpu ( stats.tx.byte.broadcast ),
111 le32_to_cpu ( stats.tx.byte.multicast ) );
112 DBGC ( smscusb, "SMSC75XX %p TXF ucast %d bcast %d mcast %d pause "
113 "%d\n", smscusb, le32_to_cpu ( stats.tx.frame.unicast ),
114 le32_to_cpu ( stats.tx.frame.broadcast ),
115 le32_to_cpu ( stats.tx.frame.multicast ),
116 le32_to_cpu ( stats.tx.frame.pause ) );
117
118 return 0;
119}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBGC(...)
Definition compiler.h:505
#define DBG_LOG
Definition compiler.h:317
#define le32_to_cpu(value)
Definition byteswap.h:114
static int smscusb_get_statistics(struct smscusb_device *smscusb, unsigned int index, void *data, size_t len)
Get statistics.
Definition smscusb.h:223
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
Statistics.
Definition smsc75xx.h:196

References smsc75xx_rx_error_statistics::alignment, smsc75xx_byte_statistics::broadcast, smsc75xx_frame_statistics::broadcast, smsc75xx_rx_statistics::byte, smsc75xx_tx_statistics::byte, smsc75xx_tx_error_statistics::carrier, smsc75xx_tx_error_statistics::count, DBG_LOG, DBGC, smsc75xx_tx_error_statistics::deferral, smsc75xx_rx_error_statistics::dropped, smsc75xx_rx_statistics::err, smsc75xx_tx_statistics::err, smsc75xx_tx_error_statistics::excessive, smsc75xx_rx_error_statistics::fcs, smsc75xx_tx_error_statistics::fcs, smsc75xx_rx_error_statistics::fragment, smsc75xx_rx_statistics::frame, smsc75xx_tx_statistics::frame, smsc75xx_rx_error_statistics::jabber, smsc75xx_tx_error_statistics::late, le32_to_cpu, smsc75xx_byte_statistics::multicast, smsc75xx_frame_statistics::multicast, smsc75xx_tx_error_statistics::multiple, smsc75xx_rx_error_statistics::oversize, smsc75xx_frame_statistics::pause, rc, smsc75xx_statistics::rx, smsc75xx_tx_error_statistics::single, smscusb_get_statistics(), strerror(), smsc75xx_statistics::tx, smsc75xx_rx_error_statistics::undersize, smsc75xx_byte_statistics::unicast, and smsc75xx_frame_statistics::unicast.

Referenced by lan78xx_close(), and smsc75xx_close().

◆ smsc75xx_reset()

int smsc75xx_reset ( struct smscusb_device * smscusb)
static

Reset device.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 134 of file smsc75xx.c.

134 {
135 uint32_t hw_cfg;
136 unsigned int i;
137 int rc;
138
139 /* Reset device */
140 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_HW_CFG,
141 SMSC75XX_HW_CFG_LRST ) ) != 0 )
142 return rc;
143
144 /* Wait for reset to complete */
145 for ( i = 0 ; i < SMSC75XX_RESET_MAX_WAIT_MS ; i++ ) {
146
147 /* Check if reset has completed */
148 if ( ( rc = smscusb_readl ( smscusb, SMSC75XX_HW_CFG,
149 &hw_cfg ) ) != 0 )
150 return rc;
151 if ( ! ( hw_cfg & SMSC75XX_HW_CFG_LRST ) )
152 return 0;
153
154 /* Delay */
155 mdelay ( 1 );
156 }
157
158 DBGC ( smscusb, "SMSC75XX %p timed out waiting for reset\n",
159 smscusb );
160 return -ETIMEDOUT;
161}
unsigned int uint32_t
Definition stdint.h:12
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define SMSC75XX_HW_CFG
Hardware configuration register.
Definition smsc75xx.h:21
#define SMSC75XX_RESET_MAX_WAIT_MS
Maximum time to wait for reset (in milliseconds)
Definition smsc75xx.h:204
#define SMSC75XX_HW_CFG_LRST
Soft lite reset.
Definition smsc75xx.h:23
static int smscusb_readl(struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
Read register.
Definition smscusb.h:201
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition smscusb.h:180
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79

References DBGC, ETIMEDOUT, mdelay(), rc, SMSC75XX_HW_CFG, SMSC75XX_HW_CFG_LRST, SMSC75XX_RESET_MAX_WAIT_MS, smscusb_readl(), and smscusb_writel().

Referenced by smsc75xx_close(), smsc75xx_open(), and smsc75xx_probe().

◆ smsc75xx_in_complete()

void smsc75xx_in_complete ( struct usb_endpoint * ep,
struct io_buffer * iobuf,
int rc )
static

Complete bulk IN transfer.

Parameters
epUSB endpoint
iobufI/O buffer
rcCompletion status code

Definition at line 177 of file smsc75xx.c.

178 {
179 struct smscusb_device *smscusb =
180 container_of ( ep, struct smscusb_device, usbnet.in );
181 struct net_device *netdev = smscusb->netdev;
183
184 /* Profile completions */
185 profile_start ( &smsc75xx_in_profiler );
186
187 /* Ignore packets cancelled when the endpoint closes */
188 if ( ! ep->open ) {
189 free_iob ( iobuf );
190 return;
191 }
192
193 /* Record USB errors against the network device */
194 if ( rc != 0 ) {
195 DBGC ( smscusb, "SMSC75XX %p bulk IN failed: %s\n",
196 smscusb, strerror ( rc ) );
197 goto err;
198 }
199
200 /* Sanity check */
201 if ( iob_len ( iobuf ) < ( sizeof ( *header ) ) ) {
202 DBGC ( smscusb, "SMSC75XX %p underlength bulk IN\n",
203 smscusb );
204 DBGC_HDA ( smscusb, 0, iobuf->data, iob_len ( iobuf ) );
205 rc = -EINVAL;
206 goto err;
207 }
208
209 /* Strip header */
210 header = iobuf->data;
211 iob_pull ( iobuf, sizeof ( *header ) );
212
213 /* Check for errors */
214 if ( header->command & cpu_to_le32 ( SMSC75XX_RX_RED ) ) {
215 DBGC ( smscusb, "SMSC75XX %p receive error (%08x):\n",
216 smscusb, le32_to_cpu ( header->command ) );
217 DBGC_HDA ( smscusb, 0, iobuf->data, iob_len ( iobuf ) );
218 rc = -EIO;
219 goto err;
220 }
221
222 /* Hand off to network stack */
223 netdev_rx ( netdev, iob_disown ( iobuf ) );
224
225 profile_stop ( &smsc75xx_in_profiler );
226 return;
227
228 err:
229 /* Hand off to network stack */
230 netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
231}
struct ena_llq_option header
Header locations.
Definition ena.h:5
static struct net_device * netdev
Definition gdbudp.c:53
#define DBGC_HDA(...)
Definition compiler.h:506
#define EINVAL
Invalid argument.
Definition errno.h:429
#define EIO
Input/output error.
Definition errno.h:434
#define cpu_to_le32(value)
Definition byteswap.h:108
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition profile.h:174
static void profile_start(struct profiler *profiler)
Start profiling.
Definition profile.h:161
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition iobuf.h:217
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
#define iob_pull(iobuf, len)
Definition iobuf.h:107
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition netdevice.c:587
#define SMSC75XX_RX_RED
Receive error detected.
Definition smsc75xx.h:98
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
void * data
Start of data.
Definition iobuf.h:53
A network device.
Definition netdevice.h:353
Receive packet header.
Definition smsc75xx.h:86
An SMSC USB device.
Definition smscusb.h:145
struct net_device * netdev
Network device.
Definition smscusb.h:151
struct usbnet_device usbnet
USB network device.
Definition smscusb.h:153
int open
Endpoint is open.
Definition usb.h:419
struct usb_endpoint in
Bulk IN endpoint.
Definition usbnet.h:30

References container_of, cpu_to_le32, io_buffer::data, DBGC, DBGC_HDA, EINVAL, EIO, free_iob(), header, usbnet_device::in, iob_disown, iob_len(), iob_pull, le32_to_cpu, netdev, smscusb_device::netdev, netdev_rx(), netdev_rx_err(), usb_endpoint::open, profile_start(), profile_stop(), rc, SMSC75XX_RX_RED, strerror(), and smscusb_device::usbnet.

◆ smsc75xx_out_transmit()

int smsc75xx_out_transmit ( struct smscusb_device * smscusb,
struct io_buffer * iobuf )
static

Transmit packet.

Parameters
smscusbSMSC USB device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 245 of file smsc75xx.c.

246 {
248 size_t len = iob_len ( iobuf );
249 int rc;
250
251 /* Profile transmissions */
252 profile_start ( &smsc75xx_out_profiler );
253
254 /* Prepend header */
255 if ( ( rc = iob_ensure_headroom ( iobuf, sizeof ( *header ) ) ) != 0 )
256 return rc;
257 header = iob_push ( iobuf, sizeof ( *header ) );
258 header->command = cpu_to_le32 ( SMSC75XX_TX_FCS | len );
259 header->tag = 0;
260 header->mss = 0;
261
262 /* Enqueue I/O buffer */
263 if ( ( rc = usb_stream ( &smscusb->usbnet.out, iobuf, 0 ) ) != 0 )
264 return rc;
265
266 profile_stop ( &smsc75xx_out_profiler );
267 return 0;
268}
ring len
Length.
Definition dwmac.h:226
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
Definition iobuf.c:235
#define iob_push(iobuf, len)
Definition iobuf.h:89
#define SMSC75XX_TX_FCS
Insert frame checksum and pad.
Definition smsc75xx.h:111
Transmit packet header.
Definition smsc75xx.h:101
struct usb_endpoint out
Bulk OUT endpoint.
Definition usbnet.h:32
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
Definition usb.c:546

References cpu_to_le32, header, iob_ensure_headroom(), iob_len(), iob_push, len, usbnet_device::out, profile_start(), profile_stop(), rc, SMSC75XX_TX_FCS, usb_stream(), and smscusb_device::usbnet.

Referenced by smsc75xx_transmit().

◆ smsc75xx_open()

int smsc75xx_open ( struct net_device * netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 283 of file smsc75xx.c.

283 {
284 struct smscusb_device *smscusb = netdev->priv;
285 int rc;
286
287 /* Clear stored interrupt status */
288 smscusb->int_sts = 0;
289
290 /* Configure bulk IN empty response */
291 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_HW_CFG,
292 SMSC75XX_HW_CFG_BIR ) ) != 0 )
293 goto err_hw_cfg;
294
295 /* Open USB network device */
296 if ( ( rc = usbnet_open ( &smscusb->usbnet ) ) != 0 ) {
297 DBGC ( smscusb, "SMSC75XX %p could not open: %s\n",
298 smscusb, strerror ( rc ) );
299 goto err_open;
300 }
301
302 /* Configure interrupt endpoint */
303 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_INT_EP_CTL,
305 SMSC75XX_INT_EP_CTL_PHY_EN ) ) ) != 0 )
306 goto err_int_ep_ctl;
307
308 /* Configure bulk IN delay */
309 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_BULK_IN_DLY,
310 SMSC75XX_BULK_IN_DLY_SET ( 0 ) ) ) != 0 )
311 goto err_bulk_in_dly;
312
313 /* Configure receive filters */
314 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_RFE_CTL,
317 SMSC75XX_RFE_CTL_AU ) ) ) != 0 )
318 goto err_rfe_ctl;
319
320 /* Configure receive FIFO */
321 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_FCT_RX_CTL,
323 SMSC75XX_FCT_RX_CTL_BAD ) ) ) != 0 )
324 goto err_fct_rx_ctl;
325
326 /* Configure transmit FIFO */
327 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_FCT_TX_CTL,
328 SMSC75XX_FCT_TX_CTL_EN ) ) != 0 )
329 goto err_fct_tx_ctl;
330
331 /* Configure receive datapath */
332 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_MAC_RX,
335 SMSC75XX_MAC_RX_EN ) ) ) != 0 )
336 goto err_mac_rx;
337
338 /* Configure transmit datapath */
339 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_MAC_TX,
340 SMSC75XX_MAC_TX_EN ) ) != 0 )
341 goto err_mac_tx;
342
343 /* Set MAC address */
344 if ( ( rc = smscusb_set_address ( smscusb,
345 SMSC75XX_RX_ADDR_BASE ) ) != 0 )
346 goto err_set_address;
347
348 /* Set MAC address perfect filter */
349 if ( ( rc = smscusb_set_filter ( smscusb,
350 SMSC75XX_ADDR_FILT_BASE ) ) != 0 )
351 goto err_set_filter;
352
353 /* Enable PHY interrupts and update link status */
357 goto err_mii_open;
358
359 return 0;
360
361 err_mii_open:
362 err_set_filter:
363 err_set_address:
364 err_mac_tx:
365 err_mac_rx:
366 err_fct_tx_ctl:
367 err_fct_rx_ctl:
368 err_rfe_ctl:
369 err_bulk_in_dly:
370 err_int_ep_ctl:
371 usbnet_close ( &smscusb->usbnet );
372 err_open:
373 err_hw_cfg:
374 smsc75xx_reset ( smscusb );
375 return rc;
376}
static int smsc75xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition smsc75xx.c:134
#define SMSC75XX_MAC_RX_EN
RX enable.
Definition smsc75xx.h:58
#define SMSC75XX_RFE_CTL_AM
Accept multicast.
Definition smsc75xx.h:40
#define SMSC75XX_PHY_INTR_ANEG_DONE
PHY interrupt: auto-negotiation complete.
Definition smsc75xx.h:77
#define SMSC75XX_MAC_RX_MAX_SIZE_DEFAULT
Definition smsc75xx.h:55
#define SMSC75XX_FCT_RX_CTL_BAD
Store bad frames.
Definition smsc75xx.h:46
#define SMSC75XX_RFE_CTL_AB
Accept broadcast.
Definition smsc75xx.h:39
#define SMSC75XX_RFE_CTL_AU
Accept unicast.
Definition smsc75xx.h:41
#define SMSC75XX_FCT_TX_CTL
FIFO controller TX FIFO control register.
Definition smsc75xx.h:49
#define SMSC75XX_MII_PHY_INTR_MASK
PHY interrupt mask MII register.
Definition smsc75xx.h:74
#define SMSC75XX_ADDR_FILT_BASE
MAC address perfect filter register base.
Definition smsc75xx.h:83
#define SMSC75XX_MAC_TX_EN
TX enable.
Definition smsc75xx.h:62
#define SMSC75XX_MAC_TX
MAC transmit register.
Definition smsc75xx.h:61
#define SMSC75XX_FCT_RX_CTL
FIFO controller RX FIFO control register.
Definition smsc75xx.h:44
#define SMSC75XX_INT_EP_CTL_PHY_EN
PHY interrupt.
Definition smsc75xx.h:28
#define SMSC75XX_RX_ADDR_BASE
MAC receive address register base.
Definition smsc75xx.h:65
#define SMSC75XX_RFE_CTL
Receive filtering engine control register.
Definition smsc75xx.h:38
#define SMSC75XX_HW_CFG_BIR
Bulk IN use NAK.
Definition smsc75xx.h:22
#define SMSC75XX_PHY_INTR_LINK_DOWN
PHY interrupt: link down.
Definition smsc75xx.h:80
#define SMSC75XX_MAC_RX_FCS
FCS stripping.
Definition smsc75xx.h:57
#define SMSC75XX_FCT_RX_CTL_EN
FCT RX enable.
Definition smsc75xx.h:45
#define SMSC75XX_INT_EP_CTL_RDFO_EN
RX FIFO overflow.
Definition smsc75xx.h:27
#define SMSC75XX_INT_EP_CTL
Interrupt endpoint control register.
Definition smsc75xx.h:26
#define SMSC75XX_FCT_TX_CTL_EN
FCT TX enable.
Definition smsc75xx.h:50
#define SMSC75XX_MAC_RX
MAC receive register.
Definition smsc75xx.h:53
#define SMSC75XX_BULK_IN_DLY_SET(ticks)
Delay / 16.7ns.
Definition smsc75xx.h:32
#define SMSC75XX_BULK_IN_DLY
Bulk IN delay register.
Definition smsc75xx.h:31
int smscusb_set_address(struct smscusb_device *smscusb, unsigned int addr_base)
Set receive address.
Definition smscusb.c:687
int smscusb_set_filter(struct smscusb_device *smscusb, unsigned int filt_base)
Set receive filter.
Definition smscusb.c:719
int smscusb_mii_open(struct smscusb_device *smscusb, unsigned int phy_mask, unsigned int intrs)
Enable PHY interrupts and update link status.
Definition smscusb.c:656
uint32_t int_sts
Interrupt status.
Definition smscusb.h:163
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition usbnet.c:55
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition usbnet.c:128

References DBGC, smscusb_device::int_sts, netdev, rc, SMSC75XX_ADDR_FILT_BASE, SMSC75XX_BULK_IN_DLY, SMSC75XX_BULK_IN_DLY_SET, SMSC75XX_FCT_RX_CTL, SMSC75XX_FCT_RX_CTL_BAD, SMSC75XX_FCT_RX_CTL_EN, SMSC75XX_FCT_TX_CTL, SMSC75XX_FCT_TX_CTL_EN, SMSC75XX_HW_CFG, SMSC75XX_HW_CFG_BIR, SMSC75XX_INT_EP_CTL, SMSC75XX_INT_EP_CTL_PHY_EN, SMSC75XX_INT_EP_CTL_RDFO_EN, SMSC75XX_MAC_RX, SMSC75XX_MAC_RX_EN, SMSC75XX_MAC_RX_FCS, SMSC75XX_MAC_RX_MAX_SIZE_DEFAULT, SMSC75XX_MAC_TX, SMSC75XX_MAC_TX_EN, SMSC75XX_MII_PHY_INTR_MASK, SMSC75XX_PHY_INTR_ANEG_DONE, SMSC75XX_PHY_INTR_LINK_DOWN, smsc75xx_reset(), SMSC75XX_RFE_CTL, SMSC75XX_RFE_CTL_AB, SMSC75XX_RFE_CTL_AM, SMSC75XX_RFE_CTL_AU, SMSC75XX_RX_ADDR_BASE, smscusb_mii_open(), smscusb_set_address(), smscusb_set_filter(), smscusb_writel(), strerror(), smscusb_device::usbnet, usbnet_close(), and usbnet_open().

◆ smsc75xx_close()

void smsc75xx_close ( struct net_device * netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 383 of file smsc75xx.c.

383 {
384 struct smscusb_device *smscusb = netdev->priv;
385
386 /* Close USB network device */
387 usbnet_close ( &smscusb->usbnet );
388
389 /* Dump statistics (for debugging) */
390 if ( DBG_LOG )
391 smsc75xx_dump_statistics ( smscusb );
392
393 /* Reset device */
394 smsc75xx_reset ( smscusb );
395}
int smsc75xx_dump_statistics(struct smscusb_device *smscusb)
Dump statistics (for debugging)
Definition smsc75xx.c:64

References DBG_LOG, netdev, smsc75xx_dump_statistics(), smsc75xx_reset(), smscusb_device::usbnet, and usbnet_close().

◆ smsc75xx_transmit()

int smsc75xx_transmit ( struct net_device * netdev,
struct io_buffer * iobuf )

Transmit packet.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 404 of file smsc75xx.c.

404 {
405 struct smscusb_device *smscusb = netdev->priv;
406 int rc;
407
408 /* Transmit packet */
409 if ( ( rc = smsc75xx_out_transmit ( smscusb, iobuf ) ) != 0 )
410 return rc;
411
412 return 0;
413}
static int smsc75xx_out_transmit(struct smscusb_device *smscusb, struct io_buffer *iobuf)
Transmit packet.
Definition smsc75xx.c:245

References netdev, rc, and smsc75xx_out_transmit().

◆ smsc75xx_poll()

void smsc75xx_poll ( struct net_device * netdev)

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 420 of file smsc75xx.c.

420 {
421 struct smscusb_device *smscusb = netdev->priv;
423 int rc;
424
425 /* Poll USB bus */
426 usb_poll ( smscusb->bus );
427
428 /* Refill endpoints */
429 if ( ( rc = usbnet_refill ( &smscusb->usbnet ) ) != 0 )
431
432 /* Do nothing more unless there are interrupts to handle */
433 int_sts = smscusb->int_sts;
434 if ( ! int_sts )
435 return;
436
437 /* Check link status if applicable */
439 smscusb_mii_check_link ( smscusb );
441 }
442
443 /* Record RX FIFO overflow if applicable */
445 DBGC2 ( smscusb, "SMSC75XX %p RX FIFO overflowed\n", smscusb );
448 }
449
450 /* Check for unexpected interrupts */
451 if ( int_sts ) {
452 DBGC ( smscusb, "SMSC75XX %p unexpected interrupt %#08x\n",
453 smscusb, int_sts );
455 }
456
457 /* Clear interrupts */
458 if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_INT_STS,
459 smscusb->int_sts ) ) != 0 )
461 smscusb->int_sts = 0;
462}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
#define DBGC2(...)
Definition compiler.h:522
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define ENOTTY
Inappropriate I/O control operation.
Definition errno.h:595
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
Definition usb.h:1072
#define SMSC75XX_INT_STS_PHY_INT
PHY interrupt.
Definition smsc75xx.h:18
#define SMSC75XX_INT_STS_RDFO_INT
RX FIFO overflow.
Definition smsc75xx.h:17
#define SMSC75XX_INT_STS
Interrupt status register.
Definition smsc75xx.h:16
int smscusb_mii_check_link(struct smscusb_device *smscusb)
Check link status.
Definition smscusb.c:614
struct usb_bus * bus
USB bus.
Definition smscusb.h:149
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition usbnet.c:152

References smscusb_device::bus, DBGC, DBGC2, ENOBUFS, ENOTTY, smscusb_device::int_sts, netdev, netdev_rx_err(), NULL, rc, SMSC75XX_INT_STS, SMSC75XX_INT_STS_PHY_INT, SMSC75XX_INT_STS_RDFO_INT, smscusb_mii_check_link(), smscusb_writel(), usb_poll(), smscusb_device::usbnet, and usbnet_refill().

◆ smsc75xx_probe()

int smsc75xx_probe ( struct usb_function * func,
struct usb_configuration_descriptor * config )
static

Probe device.

Parameters
funcUSB function
configConfiguration descriptor
Return values
rcReturn status code

Definition at line 486 of file smsc75xx.c.

487 {
488 struct net_device *netdev;
489 struct smscusb_device *smscusb;
490 int rc;
491
492 /* Allocate and initialise structure */
493 netdev = alloc_etherdev ( sizeof ( *smscusb ) );
494 if ( ! netdev ) {
495 rc = -ENOMEM;
496 goto err_alloc;
497 }
499 netdev->dev = &func->dev;
500 smscusb = netdev->priv;
501 memset ( smscusb, 0, sizeof ( *smscusb ) );
502 smscusb_init ( smscusb, netdev, func, &smsc75xx_in_operations );
507 DBGC ( smscusb, "SMSC75XX %p on %s\n", smscusb, func->name );
508
509 /* Describe USB network device */
510 if ( ( rc = usbnet_describe ( &smscusb->usbnet, config ) ) != 0 ) {
511 DBGC ( smscusb, "SMSC75XX %p could not describe: %s\n",
512 smscusb, strerror ( rc ) );
513 goto err_describe;
514 }
515
516 /* Reset device */
517 if ( ( rc = smsc75xx_reset ( smscusb ) ) != 0 )
518 goto err_reset;
519
520 /* Read MAC address */
521 if ( ( rc = smscusb_eeprom_fetch_mac ( smscusb,
522 SMSC75XX_E2P_BASE ) ) != 0 )
523 goto err_fetch_mac;
524
525 /* Register network device */
526 if ( ( rc = register_netdev ( netdev ) ) != 0 )
527 goto err_register;
528
530 return 0;
531
533 err_register:
534 err_fetch_mac:
535 err_reset:
536 err_describe:
538 netdev_put ( netdev );
539 err_alloc:
540 return rc;
541}
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
#define ENOMEM
Not enough space.
Definition errno.h:535
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
Definition usb.h:617
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition usb.h:707
void * memset(void *dest, int character, size_t len) __nonnull
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:519
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
struct usb_endpoint_driver_operations smsc75xx_in_operations
Bulk IN endpoint operations.
Definition smsc75xx.c:234
static struct net_device_operations smsc75xx_operations
SMSC75xx network device operations.
Definition smsc75xx.c:465
#define SMSC75XX_MII_PHY_INTR_SOURCE
PHY interrupt source MII register.
Definition smsc75xx.h:71
#define SMSC75XX_MII_BASE
MII register base.
Definition smsc75xx.h:68
#define SMSC75XX_IN_MAX_FILL
Bulk IN maximum fill level.
Definition smsc75xx.h:210
#define SMSC75XX_IN_MTU
Bulk IN buffer size.
Definition smsc75xx.h:213
#define SMSC75XX_E2P_BASE
EEPROM register base.
Definition smsc75xx.h:35
int smscusb_eeprom_fetch_mac(struct smscusb_device *smscusb, unsigned int e2p_base)
Fetch MAC address from EEPROM.
Definition smscusb.c:216
static void smscusb_mii_init(struct smscusb_device *smscusb, unsigned int mii_base, unsigned int phy_source)
Initialise SMSC USB device MII interface.
Definition smscusb.h:278
static void smscusb_init(struct smscusb_device *smscusb, struct net_device *netdev, struct usb_function *func, struct usb_endpoint_driver_operations *in)
Initialise SMSC USB device.
Definition smscusb.h:257
struct device dev
Generic device.
Definition usb.h:682
const char * name
Name.
Definition usb.h:676
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition usbnet.c:278

References alloc_etherdev(), DBGC, usb_function::dev, ENOMEM, usbnet_device::in, memset(), usb_function::name, netdev, netdev_init(), netdev_nullify(), netdev_put(), rc, register_netdev(), SMSC75XX_E2P_BASE, SMSC75XX_IN_MAX_FILL, SMSC75XX_IN_MTU, smsc75xx_in_operations, SMSC75XX_MII_BASE, SMSC75XX_MII_PHY_INTR_SOURCE, smsc75xx_operations, smsc75xx_reset(), smscusb_eeprom_fetch_mac(), smscusb_init(), smscusb_mii_init(), strerror(), unregister_netdev(), usb_func_set_drvdata(), usb_refill_init(), smscusb_device::usbnet, and usbnet_describe().

◆ smsc75xx_remove()

void smsc75xx_remove ( struct usb_function * func)
static

Remove device.

Parameters
funcUSB function

Definition at line 548 of file smsc75xx.c.

548 {
549 struct net_device *netdev = usb_func_get_drvdata ( func );
550
553 netdev_put ( netdev );
554}
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition usb.h:718

References netdev, netdev_nullify(), netdev_put(), unregister_netdev(), and usb_func_get_drvdata().

Variable Documentation

◆ __profiler

struct profiler smsc75xx_out_profiler __profiler
static
Initial value:
=
{ .name = "smsc75xx.in" }

Bulk IN completion profiler.

Bulk OUT profiler.

Definition at line 44 of file smsc75xx.c.

45 { .name = "smsc75xx.in" };

◆ smsc75xx_in_operations

struct usb_endpoint_driver_operations smsc75xx_in_operations
Initial value:
= {
.complete = smsc75xx_in_complete,
}
static void smsc75xx_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
Definition smsc75xx.c:177

Bulk IN endpoint operations.

Definition at line 234 of file smsc75xx.c.

234 {
235 .complete = smsc75xx_in_complete,
236};

Referenced by lan78xx_probe(), and smsc75xx_probe().

◆ smsc75xx_operations

struct net_device_operations smsc75xx_operations
static
Initial value:
= {
.open = smsc75xx_open,
.close = smsc75xx_close,
.transmit = smsc75xx_transmit,
.poll = smsc75xx_poll,
}
void smsc75xx_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition smsc75xx.c:420
static void smsc75xx_close(struct net_device *netdev)
Close network device.
Definition smsc75xx.c:383
static int smsc75xx_open(struct net_device *netdev)
Open network device.
Definition smsc75xx.c:283
int smsc75xx_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition smsc75xx.c:404

SMSC75xx network device operations.

Definition at line 465 of file smsc75xx.c.

465 {
466 .open = smsc75xx_open,
467 .close = smsc75xx_close,
468 .transmit = smsc75xx_transmit,
469 .poll = smsc75xx_poll,
470};

Referenced by smsc75xx_probe().

◆ smsc75xx_ids

struct usb_device_id smsc75xx_ids[]
static
Initial value:
= {
{
.name = "smsc7500",
.vendor = 0x0424,
.product = 0x7500,
},
{
.name = "smsc7505",
.vendor = 0x0424,
.product = 0x7505,
},
}

SMSC75xx device IDs.

Definition at line 557 of file smsc75xx.c.

557 {
558 {
559 .name = "smsc7500",
560 .vendor = 0x0424,
561 .product = 0x7500,
562 },
563 {
564 .name = "smsc7505",
565 .vendor = 0x0424,
566 .product = 0x7505,
567 },
568};

◆ __usb_driver

struct usb_driver smsc75xx_driver __usb_driver
Initial value:
= {
.ids = smsc75xx_ids,
.id_count = ( sizeof ( smsc75xx_ids ) / sizeof ( smsc75xx_ids[0] ) ),
.class = USB_CLASS_ID ( 0xff, 0x00, 0xff ),
.score = USB_SCORE_NORMAL,
.probe = smsc75xx_probe,
.remove = smsc75xx_remove,
}
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition usb.h:1389
@ USB_SCORE_NORMAL
Normal driver.
Definition usb.h:1453
static void smsc75xx_remove(struct usb_function *func)
Remove device.
Definition smsc75xx.c:548
static int smsc75xx_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition smsc75xx.c:486
static struct usb_device_id smsc75xx_ids[]
SMSC75xx device IDs.
Definition smsc75xx.c:557

SMSC LAN75xx driver.

Definition at line 571 of file smsc75xx.c.

571 {
572 .ids = smsc75xx_ids,
573 .id_count = ( sizeof ( smsc75xx_ids ) / sizeof ( smsc75xx_ids[0] ) ),
574 .class = USB_CLASS_ID ( 0xff, 0x00, 0xff ),
575 .score = USB_SCORE_NORMAL,
576 .probe = smsc75xx_probe,
577 .remove = smsc75xx_remove,
578};