iPXE
Functions | Variables
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)
 
int smsc75xx_dump_statistics (struct smscusb_device *smscusb)
 Dump statistics (for debugging) More...
 
static int smsc75xx_reset (struct smscusb_device *smscusb)
 Reset device. More...
 
static void smsc75xx_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete bulk IN transfer. More...
 
static int smsc75xx_out_transmit (struct smscusb_device *smscusb, struct io_buffer *iobuf)
 Transmit packet. More...
 
static int smsc75xx_open (struct net_device *netdev)
 Open network device. More...
 
static void smsc75xx_close (struct net_device *netdev)
 Close network device. More...
 
int smsc75xx_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
void smsc75xx_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static int smsc75xx_probe (struct usb_function *func, struct usb_configuration_descriptor *config)
 Probe device. More...
 
static void smsc75xx_remove (struct usb_function *func)
 Remove device. More...
 

Variables

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

Detailed Description

SMSC LAN75xx USB Ethernet driver.

Definition in file smsc75xx.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ 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 63 of file smsc75xx.c.

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

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()

static int smsc75xx_reset ( struct smscusb_device smscusb)
static

Reset device.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 133 of file smsc75xx.c.

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

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()

static 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 176 of file smsc75xx.c.

177  {
178  struct smscusb_device *smscusb =
179  container_of ( ep, struct smscusb_device, usbnet.in );
180  struct net_device *netdev = smscusb->netdev;
181  struct smsc75xx_rx_header *header;
182 
183  /* Profile completions */
184  profile_start ( &smsc75xx_in_profiler );
185 
186  /* Ignore packets cancelled when the endpoint closes */
187  if ( ! ep->open ) {
188  free_iob ( iobuf );
189  return;
190  }
191 
192  /* Record USB errors against the network device */
193  if ( rc != 0 ) {
194  DBGC ( smscusb, "SMSC75XX %p bulk IN failed: %s\n",
195  smscusb, strerror ( rc ) );
196  goto err;
197  }
198 
199  /* Sanity check */
200  if ( iob_len ( iobuf ) < ( sizeof ( *header ) ) ) {
201  DBGC ( smscusb, "SMSC75XX %p underlength bulk IN\n",
202  smscusb );
203  DBGC_HDA ( smscusb, 0, iobuf->data, iob_len ( iobuf ) );
204  rc = -EINVAL;
205  goto err;
206  }
207 
208  /* Strip header */
209  header = iobuf->data;
210  iob_pull ( iobuf, sizeof ( *header ) );
211 
212  /* Check for errors */
213  if ( header->command & cpu_to_le32 ( SMSC75XX_RX_RED ) ) {
214  DBGC ( smscusb, "SMSC75XX %p receive error (%08x):\n",
215  smscusb, le32_to_cpu ( header->command ) );
216  DBGC_HDA ( smscusb, 0, iobuf->data, iob_len ( iobuf ) );
217  rc = -EIO;
218  goto err;
219  }
220 
221  /* Hand off to network stack */
222  netdev_rx ( netdev, iob_disown ( iobuf ) );
223 
224  profile_stop ( &smsc75xx_in_profiler );
225  return;
226 
227  err:
228  /* Hand off to network stack */
229  netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
230 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
#define le32_to_cpu(value)
Definition: byteswap.h:113
Receive packet header.
Definition: smsc75xx.h:85
#define SMSC75XX_RX_RED
Receive error detected.
Definition: smsc75xx.h:97
An SMSC USB device.
Definition: smscusb.h:147
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define DBGC(...)
Definition: compiler.h:505
int open
Endpoint is open.
Definition: usb.h:404
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:212
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define DBGC_HDA(...)
Definition: compiler.h:506
static struct net_device * netdev
Definition: gdbudp.c:52
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
#define cpu_to_le32(value)
Definition: byteswap.h:107
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
A network device.
Definition: netdevice.h:352
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
void * data
Start of data.
Definition: iobuf.h:48
#define EIO
Input/output error.
Definition: errno.h:433
struct ena_aq_header header
Header.
Definition: ena.h:12
struct net_device * netdev
Network device.
Definition: smscusb.h:153

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()

static 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 244 of file smsc75xx.c.

245  {
246  struct smsc75xx_tx_header *header;
247  size_t len = iob_len ( iobuf );
248  int rc;
249 
250  /* Profile transmissions */
251  profile_start ( &smsc75xx_out_profiler );
252 
253  /* Prepend header */
254  if ( ( rc = iob_ensure_headroom ( iobuf, sizeof ( *header ) ) ) != 0 )
255  return rc;
256  header = iob_push ( iobuf, sizeof ( *header ) );
257  header->command = cpu_to_le32 ( SMSC75XX_TX_FCS | len );
258  header->tag = 0;
259  header->mss = 0;
260 
261  /* Enqueue I/O buffer */
262  if ( ( rc = usb_stream ( &smscusb->usbnet.out, iobuf, 0 ) ) != 0 )
263  return rc;
264 
265  profile_stop ( &smsc75xx_out_profiler );
266  return 0;
267 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_push(iobuf, len)
Definition: iobuf.h:84
Transmit packet header.
Definition: smsc75xx.h:100
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
Definition: usb.c:545
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:31
#define SMSC75XX_TX_FCS
Insert frame checksum and pad.
Definition: smsc75xx.h:110
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
#define cpu_to_le32(value)
Definition: byteswap.h:107
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
uint32_t len
Length.
Definition: ena.h:14
struct ena_aq_header header
Header.
Definition: ena.h:12
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
Definition: iobuf.c:228

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()

static int smsc75xx_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 282 of file smsc75xx.c.

282  {
283  struct smscusb_device *smscusb = netdev->priv;
284  int rc;
285 
286  /* Clear stored interrupt status */
287  smscusb->int_sts = 0;
288 
289  /* Configure bulk IN empty response */
290  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_HW_CFG,
291  SMSC75XX_HW_CFG_BIR ) ) != 0 )
292  goto err_hw_cfg;
293 
294  /* Open USB network device */
295  if ( ( rc = usbnet_open ( &smscusb->usbnet ) ) != 0 ) {
296  DBGC ( smscusb, "SMSC75XX %p could not open: %s\n",
297  smscusb, strerror ( rc ) );
298  goto err_open;
299  }
300 
301  /* Configure interrupt endpoint */
302  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_INT_EP_CTL,
304  SMSC75XX_INT_EP_CTL_PHY_EN ) ) ) != 0 )
305  goto err_int_ep_ctl;
306 
307  /* Configure bulk IN delay */
308  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_BULK_IN_DLY,
309  SMSC75XX_BULK_IN_DLY_SET ( 0 ) ) ) != 0 )
310  goto err_bulk_in_dly;
311 
312  /* Configure receive filters */
313  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_RFE_CTL,
316  SMSC75XX_RFE_CTL_AU ) ) ) != 0 )
317  goto err_rfe_ctl;
318 
319  /* Configure receive FIFO */
320  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_FCT_RX_CTL,
322  SMSC75XX_FCT_RX_CTL_BAD ) ) ) != 0 )
323  goto err_fct_rx_ctl;
324 
325  /* Configure transmit FIFO */
326  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_FCT_TX_CTL,
327  SMSC75XX_FCT_TX_CTL_EN ) ) != 0 )
328  goto err_fct_tx_ctl;
329 
330  /* Configure receive datapath */
331  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_MAC_RX,
334  SMSC75XX_MAC_RX_EN ) ) ) != 0 )
335  goto err_mac_rx;
336 
337  /* Configure transmit datapath */
338  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_MAC_TX,
339  SMSC75XX_MAC_TX_EN ) ) != 0 )
340  goto err_mac_tx;
341 
342  /* Set MAC address */
343  if ( ( rc = smscusb_set_address ( smscusb,
344  SMSC75XX_RX_ADDR_BASE ) ) != 0 )
345  goto err_set_address;
346 
347  /* Set MAC address perfect filter */
348  if ( ( rc = smscusb_set_filter ( smscusb,
349  SMSC75XX_ADDR_FILT_BASE ) ) != 0 )
350  goto err_set_filter;
351 
352  /* Enable PHY interrupts and update link status */
353  if ( ( rc = smscusb_mii_open ( smscusb, SMSC75XX_MII_PHY_INTR_MASK,
355  SMSC75XX_PHY_INTR_LINK_DOWN ) ) ) != 0)
356  goto err_mii_open;
357 
358  return 0;
359 
360  err_mii_open:
361  err_set_filter:
362  err_set_address:
363  err_mac_tx:
364  err_mac_rx:
365  err_fct_tx_ctl:
366  err_fct_rx_ctl:
367  err_rfe_ctl:
368  err_bulk_in_dly:
369  err_int_ep_ctl:
370  usbnet_close ( &smscusb->usbnet );
371  err_open:
372  err_hw_cfg:
373  smsc75xx_reset ( smscusb );
374  return rc;
375 }
int smscusb_set_address(struct smscusb_device *smscusb, unsigned int addr_base)
Set receive address.
Definition: smscusb.c:686
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define SMSC75XX_RFE_CTL
Receive filtering engine control register.
Definition: smsc75xx.h:37
#define SMSC75XX_FCT_RX_CTL_BAD
Store bad frames.
Definition: smsc75xx.h:45
#define SMSC75XX_MAC_RX_MAX_SIZE_DEFAULT
Definition: smsc75xx.h:54
An SMSC USB device.
Definition: smscusb.h:147
#define SMSC75XX_BULK_IN_DLY
Bulk IN delay register.
Definition: smsc75xx.h:30
static int smsc75xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: smsc75xx.c:133
#define DBGC(...)
Definition: compiler.h:505
#define SMSC75XX_PHY_INTR_ANEG_DONE
PHY interrupt: auto-negotiation complete.
Definition: smsc75xx.h:76
#define SMSC75XX_MAC_RX_EN
RX enable.
Definition: smsc75xx.h:57
#define SMSC75XX_MAC_RX
MAC receive register.
Definition: smsc75xx.h:52
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition: smscusb.h:182
#define SMSC75XX_FCT_RX_CTL_EN
FCT RX enable.
Definition: smsc75xx.h:44
#define SMSC75XX_FCT_TX_CTL
FIFO controller TX FIFO control register.
Definition: smsc75xx.h:48
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:655
#define SMSC75XX_RFE_CTL_AB
Accept broadcast.
Definition: smsc75xx.h:38
#define SMSC75XX_INT_EP_CTL_PHY_EN
PHY interrupt.
Definition: smsc75xx.h:27
#define SMSC75XX_INT_EP_CTL_RDFO_EN
RX FIFO overflow.
Definition: smsc75xx.h:26
int smscusb_set_filter(struct smscusb_device *smscusb, unsigned int filt_base)
Set receive filter.
Definition: smscusb.c:718
uint32_t int_sts
Interrupt status.
Definition: smscusb.h:165
#define SMSC75XX_RFE_CTL_AM
Accept multicast.
Definition: smsc75xx.h:39
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
#define SMSC75XX_RFE_CTL_AU
Accept unicast.
Definition: smsc75xx.h:40
void * priv
Driver private data.
Definition: netdevice.h:431
#define SMSC75XX_PHY_INTR_LINK_DOWN
PHY interrupt: link down.
Definition: smsc75xx.h:79
static struct net_device * netdev
Definition: gdbudp.c:52
#define SMSC75XX_FCT_TX_CTL_EN
FCT TX enable.
Definition: smsc75xx.h:49
#define SMSC75XX_MAC_TX
MAC transmit register.
Definition: smsc75xx.h:60
#define SMSC75XX_BULK_IN_DLY_SET(ticks)
Delay / 16.7ns.
Definition: smsc75xx.h:31
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define SMSC75XX_MII_PHY_INTR_MASK
PHY interrupt mask MII register.
Definition: smsc75xx.h:73
#define SMSC75XX_HW_CFG
Hardware configuration register.
Definition: smsc75xx.h:20
#define SMSC75XX_MAC_TX_EN
TX enable.
Definition: smsc75xx.h:61
#define SMSC75XX_HW_CFG_BIR
Bulk IN use NAK.
Definition: smsc75xx.h:21
#define SMSC75XX_INT_EP_CTL
Interrupt endpoint control register.
Definition: smsc75xx.h:25
#define SMSC75XX_ADDR_FILT_BASE
MAC address perfect filter register base.
Definition: smsc75xx.h:82
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
#define SMSC75XX_FCT_RX_CTL
FIFO controller RX FIFO control register.
Definition: smsc75xx.h:43
#define SMSC75XX_MAC_RX_FCS
FCS stripping.
Definition: smsc75xx.h:56
#define SMSC75XX_RX_ADDR_BASE
MAC receive address register base.
Definition: smsc75xx.h:64
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition: usbnet.c:54

References DBGC, smscusb_device::int_sts, netdev, net_device::priv, 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()

static void smsc75xx_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 382 of file smsc75xx.c.

382  {
383  struct smscusb_device *smscusb = netdev->priv;
384 
385  /* Close USB network device */
386  usbnet_close ( &smscusb->usbnet );
387 
388  /* Dump statistics (for debugging) */
389  if ( DBG_LOG )
390  smsc75xx_dump_statistics ( smscusb );
391 
392  /* Reset device */
393  smsc75xx_reset ( smscusb );
394 }
An SMSC USB device.
Definition: smscusb.h:147
static int smsc75xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: smsc75xx.c:133
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
void * priv
Driver private data.
Definition: netdevice.h:431
int smsc75xx_dump_statistics(struct smscusb_device *smscusb)
Dump statistics (for debugging)
Definition: smsc75xx.c:63
static struct net_device * netdev
Definition: gdbudp.c:52
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
#define DBG_LOG
Definition: compiler.h:317

References DBG_LOG, netdev, net_device::priv, 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 403 of file smsc75xx.c.

403  {
404  struct smscusb_device *smscusb = netdev->priv;
405  int rc;
406 
407  /* Transmit packet */
408  if ( ( rc = smsc75xx_out_transmit ( smscusb, iobuf ) ) != 0 )
409  return rc;
410 
411  return 0;
412 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
An SMSC USB device.
Definition: smscusb.h:147
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static int smsc75xx_out_transmit(struct smscusb_device *smscusb, struct io_buffer *iobuf)
Transmit packet.
Definition: smsc75xx.c:244

References netdev, net_device::priv, 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 419 of file smsc75xx.c.

419  {
420  struct smscusb_device *smscusb = netdev->priv;
422  int rc;
423 
424  /* Poll USB bus */
425  usb_poll ( smscusb->bus );
426 
427  /* Refill endpoints */
428  if ( ( rc = usbnet_refill ( &smscusb->usbnet ) ) != 0 )
429  netdev_rx_err ( netdev, NULL, rc );
430 
431  /* Do nothing more unless there are interrupts to handle */
432  int_sts = smscusb->int_sts;
433  if ( ! int_sts )
434  return;
435 
436  /* Check link status if applicable */
438  smscusb_mii_check_link ( smscusb );
440  }
441 
442  /* Record RX FIFO overflow if applicable */
444  DBGC2 ( smscusb, "SMSC75XX %p RX FIFO overflowed\n", smscusb );
447  }
448 
449  /* Check for unexpected interrupts */
450  if ( int_sts ) {
451  DBGC ( smscusb, "SMSC75XX %p unexpected interrupt %#08x\n",
452  smscusb, int_sts );
454  }
455 
456  /* Clear interrupts */
457  if ( ( rc = smscusb_writel ( smscusb, SMSC75XX_INT_STS,
458  smscusb->int_sts ) ) != 0 )
459  netdev_rx_err ( netdev, NULL, rc );
460  smscusb->int_sts = 0;
461 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
An SMSC USB device.
Definition: smscusb.h:147
#define SMSC75XX_INT_STS
Interrupt status register.
Definition: smsc75xx.h:15
#define SMSC75XX_INT_STS_RDFO_INT
RX FIFO overflow.
Definition: smsc75xx.h:16
#define DBGC(...)
Definition: compiler.h:505
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition: smscusb.h:182
uint32_t int_sts
Interrupt status.
Definition: smscusb.h:165
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition: usbnet.c:151
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
Definition: usb.h:1051
unsigned int uint32_t
Definition: stdint.h:12
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
int smscusb_mii_check_link(struct smscusb_device *smscusb)
Check link status.
Definition: smscusb.c:613
struct usb_bus * bus
USB bus.
Definition: smscusb.h:151
#define SMSC75XX_INT_STS_PHY_INT
PHY interrupt.
Definition: smsc75xx.h:17
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References smscusb_device::bus, DBGC, DBGC2, ENOBUFS, ENOTTY, smscusb_device::int_sts, netdev, netdev_rx_err(), NULL, net_device::priv, 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()

static 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 485 of file smsc75xx.c.

486  {
487  struct net_device *netdev;
488  struct smscusb_device *smscusb;
489  int rc;
490 
491  /* Allocate and initialise structure */
492  netdev = alloc_etherdev ( sizeof ( *smscusb ) );
493  if ( ! netdev ) {
494  rc = -ENOMEM;
495  goto err_alloc;
496  }
498  netdev->dev = &func->dev;
499  smscusb = netdev->priv;
500  memset ( smscusb, 0, sizeof ( *smscusb ) );
501  smscusb_init ( smscusb, netdev, func, &smsc75xx_in_operations );
504  usb_refill_init ( &smscusb->usbnet.in, 0, SMSC75XX_IN_MTU,
506  DBGC ( smscusb, "SMSC75XX %p on %s\n", smscusb, func->name );
507 
508  /* Describe USB network device */
509  if ( ( rc = usbnet_describe ( &smscusb->usbnet, config ) ) != 0 ) {
510  DBGC ( smscusb, "SMSC75XX %p could not describe: %s\n",
511  smscusb, strerror ( rc ) );
512  goto err_describe;
513  }
514 
515  /* Reset device */
516  if ( ( rc = smsc75xx_reset ( smscusb ) ) != 0 )
517  goto err_reset;
518 
519  /* Read MAC address */
520  if ( ( rc = smscusb_eeprom_fetch_mac ( smscusb,
521  SMSC75XX_E2P_BASE ) ) != 0 )
522  goto err_fetch_mac;
523 
524  /* Register network device */
525  if ( ( rc = register_netdev ( netdev ) ) != 0 )
526  goto err_register;
527 
528  usb_func_set_drvdata ( func, netdev );
529  return 0;
530 
532  err_register:
533  err_fetch_mac:
534  err_reset:
535  err_describe:
537  netdev_put ( netdev );
538  err_alloc:
539  return rc;
540 }
#define SMSC75XX_IN_MAX_FILL
Bulk IN maximum fill level.
Definition: smsc75xx.h:209
#define SMSC75XX_MII_PHY_INTR_SOURCE
PHY interrupt source MII register.
Definition: smsc75xx.h:70
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define SMSC75XX_E2P_BASE
EEPROM register base.
Definition: smsc75xx.h:34
const char * name
Name.
Definition: usb.h:661
An SMSC USB device.
Definition: smscusb.h:147
static int smsc75xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: smsc75xx.c:133
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:259
#define DBGC(...)
Definition: compiler.h:505
#define SMSC75XX_IN_MTU
Bulk IN buffer size.
Definition: smsc75xx.h:212
struct usb_endpoint_driver_operations smsc75xx_in_operations
Bulk IN endpoint operations.
Definition: smsc75xx.c:233
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:280
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
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:602
static struct net_device * netdev
Definition: gdbudp.c:52
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition: usb.h:692
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
#define SMSC75XX_MII_BASE
MII register base.
Definition: smsc75xx.h:67
int smscusb_eeprom_fetch_mac(struct smscusb_device *smscusb, unsigned int e2p_base)
Fetch MAC address from EEPROM.
Definition: smscusb.c:215
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
A network device.
Definition: netdevice.h:352
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
static struct net_device_operations smsc75xx_operations
SMSC75xx network device operations.
Definition: smsc75xx.c:464
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition: usbnet.c:277
struct device dev
Generic device.
Definition: usb.h:667
void * memset(void *dest, int character, size_t len) __nonnull

References alloc_etherdev(), DBGC, net_device::dev, usb_function::dev, ENOMEM, usbnet_device::in, memset(), usb_function::name, netdev, netdev_init(), netdev_nullify(), netdev_put(), net_device::priv, 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()

static void smsc75xx_remove ( struct usb_function func)
static

Remove device.

Parameters
funcUSB function

Definition at line 547 of file smsc75xx.c.

547  {
548  struct net_device *netdev = usb_func_get_drvdata ( func );
549 
552  netdev_put ( netdev );
553 }
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition: usb.h:703
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528

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 43 of file smsc75xx.c.

◆ 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:176

Bulk IN endpoint operations.

Definition at line 233 of file smsc75xx.c.

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,
}
static void smsc75xx_close(struct net_device *netdev)
Close network device.
Definition: smsc75xx.c:382
int smsc75xx_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: smsc75xx.c:403
void smsc75xx_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: smsc75xx.c:419
static int smsc75xx_open(struct net_device *netdev)
Open network device.
Definition: smsc75xx.c:282

SMSC75xx network device operations.

Definition at line 464 of file smsc75xx.c.

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 556 of file smsc75xx.c.

◆ __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,
}
static void smsc75xx_remove(struct usb_function *func)
Remove device.
Definition: smsc75xx.c:547
static int smsc75xx_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition: smsc75xx.c:485
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition: usb.h:1363
Normal driver.
Definition: usb.h:1427
static struct usb_device_id smsc75xx_ids[]
SMSC75xx device IDs.
Definition: smsc75xx.c:556

SMSC LAN75xx driver.

Definition at line 570 of file smsc75xx.c.