iPXE
smsc75xx.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 FILE_SECBOOT ( PERMITTED );
26 
27 #include <string.h>
28 #include <unistd.h>
29 #include <errno.h>
30 #include <byteswap.h>
31 #include <ipxe/ethernet.h>
32 #include <ipxe/usb.h>
33 #include <ipxe/usbnet.h>
34 #include <ipxe/profile.h>
35 #include "smsc75xx.h"
36 
37 /** @file
38  *
39  * SMSC LAN75xx USB Ethernet driver
40  *
41  */
42 
43 /** Bulk IN completion profiler */
44 static struct profiler smsc75xx_in_profiler __profiler =
45  { .name = "smsc75xx.in" };
46 
47 /** Bulk OUT profiler */
48 static struct profiler smsc75xx_out_profiler __profiler =
49  { .name = "smsc75xx.out" };
50 
51 /******************************************************************************
52  *
53  * Statistics (for debugging)
54  *
55  ******************************************************************************
56  */
57 
58 /**
59  * Dump statistics (for debugging)
60  *
61  * @v smscusb SMSC USB device
62  * @ret rc Return status code
63  */
64 int smsc75xx_dump_statistics ( struct smscusb_device *smscusb ) {
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 }
120 
121 /******************************************************************************
122  *
123  * Device reset
124  *
125  ******************************************************************************
126  */
127 
128 /**
129  * Reset device
130  *
131  * @v smscusb SMSC USB device
132  * @ret rc Return status code
133  */
134 static int smsc75xx_reset ( struct smscusb_device *smscusb ) {
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 }
162 
163 /******************************************************************************
164  *
165  * Endpoint operations
166  *
167  ******************************************************************************
168  */
169 
170 /**
171  * Complete bulk IN transfer
172  *
173  * @v ep USB endpoint
174  * @v iobuf I/O buffer
175  * @v rc Completion status code
176  */
177 static void smsc75xx_in_complete ( struct usb_endpoint *ep,
178  struct io_buffer *iobuf, int rc ) {
179  struct smscusb_device *smscusb =
180  container_of ( ep, struct smscusb_device, usbnet.in );
181  struct net_device *netdev = smscusb->netdev;
182  struct smsc75xx_rx_header *header;
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 }
232 
233 /** Bulk IN endpoint operations */
236 };
237 
238 /**
239  * Transmit packet
240  *
241  * @v smscusb SMSC USB device
242  * @v iobuf I/O buffer
243  * @ret rc Return status code
244  */
245 static int smsc75xx_out_transmit ( struct smscusb_device *smscusb,
246  struct io_buffer *iobuf ) {
247  struct smsc75xx_tx_header *header;
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 }
269 
270 /******************************************************************************
271  *
272  * Network device interface
273  *
274  ******************************************************************************
275  */
276 
277 /**
278  * Open network device
279  *
280  * @v netdev Network device
281  * @ret rc Return status code
282  */
283 static int smsc75xx_open ( struct net_device *netdev ) {
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 */
354  if ( ( rc = smscusb_mii_open ( smscusb, SMSC75XX_MII_PHY_INTR_MASK,
356  SMSC75XX_PHY_INTR_LINK_DOWN ) ) ) != 0)
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 }
377 
378 /**
379  * Close network device
380  *
381  * @v netdev Network device
382  */
383 static void smsc75xx_close ( struct net_device *netdev ) {
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 }
396 
397 /**
398  * Transmit packet
399  *
400  * @v netdev Network device
401  * @v iobuf I/O buffer
402  * @ret rc Return status code
403  */
404 int smsc75xx_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
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 }
414 
415 /**
416  * Poll for completed and received packets
417  *
418  * @v netdev Network device
419  */
420 void smsc75xx_poll ( struct net_device *netdev ) {
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 )
430  netdev_rx_err ( netdev, NULL, rc );
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 )
460  netdev_rx_err ( netdev, NULL, rc );
461  smscusb->int_sts = 0;
462 }
463 
464 /** SMSC75xx network device operations */
466  .open = smsc75xx_open,
467  .close = smsc75xx_close,
468  .transmit = smsc75xx_transmit,
469  .poll = smsc75xx_poll,
470 };
471 
472 /******************************************************************************
473  *
474  * USB interface
475  *
476  ******************************************************************************
477  */
478 
479 /**
480  * Probe device
481  *
482  * @v func USB function
483  * @v config Configuration descriptor
484  * @ret rc Return status code
485  */
486 static int smsc75xx_probe ( struct usb_function *func,
487  struct usb_configuration_descriptor *config ) {
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 );
505  usb_refill_init ( &smscusb->usbnet.in, 0, SMSC75XX_IN_MTU,
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 
529  usb_func_set_drvdata ( func, netdev );
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 }
542 
543 /**
544  * Remove device
545  *
546  * @v func USB function
547  */
548 static void smsc75xx_remove ( struct usb_function *func ) {
549  struct net_device *netdev = usb_func_get_drvdata ( func );
550 
553  netdev_put ( netdev );
554 }
555 
556 /** SMSC75xx device IDs */
557 static struct usb_device_id smsc75xx_ids[] = {
558  {
559  .name = "smsc7500",
560  .vendor = 0x0424,
561  .product = 0x7500,
562  },
563  {
564  .name = "smsc7505",
565  .vendor = 0x0424,
566  .product = 0x7505,
567  },
568 };
569 
570 /** SMSC LAN75xx driver */
571 struct usb_driver smsc75xx_driver __usb_driver = {
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 };
int smscusb_set_address(struct smscusb_device *smscusb, unsigned int addr_base)
Set receive address.
Definition: smscusb.c:687
#define iob_pull(iobuf, len)
Definition: iobuf.h:107
uint32_t pause
Pause frames.
Definition: smsc75xx.h:132
A USB driver.
Definition: usb.h:1407
#define EINVAL
Invalid argument.
Definition: errno.h:429
#define SMSC75XX_IN_MAX_FILL
Bulk IN maximum fill level.
Definition: smsc75xx.h:210
#define SMSC75XX_MII_PHY_INTR_SOURCE
PHY interrupt source MII register.
Definition: smsc75xx.h:71
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define SMSC75XX_E2P_BASE
EEPROM register base.
Definition: smsc75xx.h:35
A USB device ID.
Definition: usb.h:1361
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
Definition: usb.h:496
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:587
#define SMSC75XX_RFE_CTL
Receive filtering engine control register.
Definition: smsc75xx.h:38
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition: usb.h:718
uint32_t oversize
Oversize frame errors.
Definition: smsc75xx.h:150
const char * name
Name.
Definition: usb.h:676
#define le32_to_cpu(value)
Definition: byteswap.h:114
int(* open)(struct net_device *netdev)
Open network device.
Definition: netdevice.h:223
const char * name
Name.
Definition: usb.h:1363
Receive packet header.
Definition: smsc75xx.h:86
static struct profiler smsc75xx_in_profiler __profiler
Bulk IN completion profiler.
Definition: smsc75xx.c:44
uint32_t undersize
Undersize frame errors.
Definition: smsc75xx.h:148
Error codes.
#define SMSC75XX_FCT_RX_CTL_BAD
Store bad frames.
Definition: smsc75xx.h:46
#define SMSC75XX_RX_RED
Receive error detected.
Definition: smsc75xx.h:98
static void smsc75xx_close(struct net_device *netdev)
Close network device.
Definition: smsc75xx.c:383
#define iob_push(iobuf, len)
Definition: iobuf.h:89
#define SMSC75XX_MAC_RX_MAX_SIZE_DEFAULT
Definition: smsc75xx.h:55
An SMSC USB device.
Definition: smscusb.h:148
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:153
#define SMSC75XX_BULK_IN_DLY
Bulk IN delay register.
Definition: smsc75xx.h:31
static int smsc75xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: smsc75xx.c:134
struct smsc75xx_tx_error_statistics err
Error statistics.
Definition: smsc75xx.h:188
Transmit packet header.
Definition: smsc75xx.h:101
#define SMSC75XX_INT_STS
Interrupt status register.
Definition: smsc75xx.h:16
uint32_t count
Bad byte count.
Definition: smsc75xx.h:174
uint32_t carrier
Carrier errors.
Definition: smsc75xx.h:172
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:260
#define SMSC75XX_INT_STS_RDFO_INT
RX FIFO overflow.
Definition: smsc75xx.h:17
#define DBGC(...)
Definition: compiler.h:505
uint32_t unicast
Unicast frames.
Definition: smsc75xx.h:126
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
Definition: usb.c:546
uint32_t jabber
Jabber errors.
Definition: smsc75xx.h:146
int smsc75xx_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: smsc75xx.c:404
#define SMSC75XX_IN_MTU
Bulk IN buffer size.
Definition: smsc75xx.h:213
#define SMSC75XX_PHY_INTR_ANEG_DONE
PHY interrupt: auto-negotiation complete.
Definition: smsc75xx.h:77
#define SMSC75XX_MAC_RX_EN
RX enable.
Definition: smsc75xx.h:58
#define SMSC75XX_MAC_RX
MAC receive register.
Definition: smsc75xx.h:53
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition: smscusb.h:183
A data structure for storing profiling information.
Definition: profile.h:27
#define SMSC75XX_FCT_RX_CTL_EN
FCT RX enable.
Definition: smsc75xx.h:45
struct usb_endpoint_driver_operations smsc75xx_in_operations
Bulk IN endpoint operations.
Definition: smsc75xx.c:234
int open
Endpoint is open.
Definition: usb.h:419
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:174
#define SMSC75XX_FCT_TX_CTL
FIFO controller TX FIFO control register.
Definition: smsc75xx.h:49
static void smsc75xx_remove(struct usb_function *func)
Remove device.
Definition: smsc75xx.c:548
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:281
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
#define SMSC75XX_RFE_CTL_AB
Accept broadcast.
Definition: smsc75xx.h:39
#define SMSC75XX_INT_EP_CTL_PHY_EN
PHY interrupt.
Definition: smsc75xx.h:28
Statistics.
Definition: smsc75xx.h:196
uint32_t multicast
Multicast frames.
Definition: smsc75xx.h:130
static int smsc75xx_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition: smsc75xx.c:486
#define SMSC75XX_INT_EP_CTL_RDFO_EN
RX FIFO overflow.
Definition: smsc75xx.h:27
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:32
uint32_t fcs
FCS errors.
Definition: smsc75xx.h:140
int smscusb_set_filter(struct smscusb_device *smscusb, unsigned int filt_base)
Set receive filter.
Definition: smscusb.c:719
uint32_t multicast
Multicast byte count.
Definition: smsc75xx.h:120
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:519
uint32_t unicast
Unicast byte count.
Definition: smsc75xx.h:116
uint32_t int_sts
Interrupt status.
Definition: smscusb.h:166
#define ENOMEM
Not enough space.
Definition: errno.h:535
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:217
A USB endpoint.
Definition: usb.h:404
const char * name
Name.
Definition: profile.h:29
#define SMSC75XX_RFE_CTL_AM
Accept multicast.
Definition: smsc75xx.h:40
#define SMSC75XX_TX_FCS
Insert frame checksum and pad.
Definition: smsc75xx.h:111
uint32_t dropped
Dropped frame errors.
Definition: smsc75xx.h:152
struct usb_driver smsc75xx_driver __usb_driver
SMSC LAN75xx driver.
Definition: smsc75xx.c:571
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:156
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:576
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:36
uint32_t deferral
Excess deferral errors.
Definition: smsc75xx.h:170
Ethernet protocol.
#define SMSC75XX_RFE_CTL_AU
Accept unicast.
Definition: smsc75xx.h:41
void * priv
Driver private data.
Definition: netdevice.h:432
#define DBGC_HDA(...)
Definition: compiler.h:506
struct smsc75xx_frame_statistics frame
Frame count statistics.
Definition: smsc75xx.h:192
#define SMSC75XX_HW_CFG_LRST
Soft lite reset.
Definition: smsc75xx.h:23
int smsc75xx_dump_statistics(struct smscusb_device *smscusb)
Dump statistics (for debugging)
Definition: smsc75xx.c:64
ring len
Length.
Definition: dwmac.h:231
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
#define SMSC75XX_PHY_INTR_LINK_DOWN
PHY interrupt: link down.
Definition: smsc75xx.h:80
static struct net_device * netdev
Definition: gdbudp.c:52
void smsc75xx_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: smsc75xx.c:420
#define SMSC75XX_FCT_TX_CTL_EN
FCT TX enable.
Definition: smsc75xx.h:50
static int smscusb_readl(struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
Read register.
Definition: smscusb.h:204
SMSC LAN75xx USB Ethernet driver.
static int smsc75xx_out_transmit(struct smscusb_device *smscusb, struct io_buffer *iobuf)
Transmit packet.
Definition: smsc75xx.c:245
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition: usb.h:707
static int smsc75xx_open(struct net_device *netdev)
Open network device.
Definition: smsc75xx.c:283
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:161
#define SMSC75XX_MAC_TX
MAC transmit register.
Definition: smsc75xx.h:61
Profiling.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:942
struct smsc75xx_byte_statistics byte
Byte count statistics.
Definition: smsc75xx.h:160
#define SMSC75XX_MII_BASE
MII register base.
Definition: smsc75xx.h:68
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition: usbnet.c:152
#define cpu_to_le32(value)
Definition: byteswap.h:108
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
Definition: usb.h:1072
#define SMSC75XX_BULK_IN_DLY_SET(ticks)
Delay / 16.7ns.
Definition: smsc75xx.h:32
FILE_SECBOOT(PERMITTED)
int smscusb_eeprom_fetch_mac(struct smscusb_device *smscusb, unsigned int e2p_base)
Fetch MAC address from EEPROM.
Definition: smscusb.c:216
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define SMSC75XX_MII_PHY_INTR_MASK
PHY interrupt mask MII register.
Definition: smsc75xx.h:74
uint32_t late
Late collisions.
Definition: smsc75xx.h:182
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:760
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:160
#define SMSC75XX_HW_CFG
Hardware configuration register.
Definition: smsc75xx.h:21
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition: usb.h:1389
A network device.
Definition: netdevice.h:353
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:30
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:532
Normal driver.
Definition: usb.h:1453
#define SMSC75XX_RESET_MAX_WAIT_MS
Maximum time to wait for reset (in milliseconds)
Definition: smsc75xx.h:204
uint32_t broadcast
Broadcast frames.
Definition: smsc75xx.h:128
struct smsc75xx_tx_statistics tx
Transmit statistics.
Definition: smsc75xx.h:200
unsigned int uint32_t
Definition: stdint.h:12
Network device operations.
Definition: netdevice.h:214
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:549
struct device * dev
Underlying hardware device.
Definition: netdevice.h:365
struct smsc75xx_rx_statistics rx
Receive statistics.
Definition: smsc75xx.h:198
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:79
USB network devices.
A USB configuration descriptor.
Definition: usb.h:210
struct smsc75xx_frame_statistics frame
Frame count statistics.
Definition: smsc75xx.h:162
#define ENOBUFS
No buffer space available.
Definition: errno.h:499
#define DBGC2(...)
Definition: compiler.h:522
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:595
Universal Serial Bus (USB)
#define SMSC75XX_MAC_TX_EN
TX enable.
Definition: smsc75xx.h:62
void * data
Start of data.
Definition: iobuf.h:53
uint32_t alignment
Alignment errors.
Definition: smsc75xx.h:142
int smscusb_mii_check_link(struct smscusb_device *smscusb)
Check link status.
Definition: smscusb.c:614
uint32_t excessive
Excession collisions.
Definition: smsc75xx.h:180
#define EIO
Input/output error.
Definition: errno.h:434
#define SMSC75XX_HW_CFG_BIR
Bulk IN use NAK.
Definition: smsc75xx.h:22
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:265
struct smsc75xx_byte_statistics byte
Byte count statistics.
Definition: smsc75xx.h:190
uint32_t single
Single collisions.
Definition: smsc75xx.h:176
struct ena_llq_option header
Header locations.
Definition: ena.h:16
static struct net_device_operations smsc75xx_operations
SMSC75xx network device operations.
Definition: smsc75xx.c:465
#define SMSC75XX_INT_EP_CTL
Interrupt endpoint control register.
Definition: smsc75xx.h:26
uint32_t broadcast
Broadcast byte count.
Definition: smsc75xx.h:118
uint32_t fragment
Fragment errors.
Definition: smsc75xx.h:144
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition: usbnet.c:278
struct usb_bus * bus
USB bus.
Definition: smscusb.h:152
#define SMSC75XX_ADDR_FILT_BASE
MAC address perfect filter register base.
Definition: smsc75xx.h:83
struct net_device * netdev
Network device.
Definition: smscusb.h:154
uint32_t fcs
FCS errors.
Definition: smsc75xx.h:168
static int smscusb_get_statistics(struct smscusb_device *smscusb, unsigned int index, void *data, size_t len)
Get statistics.
Definition: smscusb.h:226
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:128
USB endpoint driver operations.
Definition: usb.h:489
struct device dev
Generic device.
Definition: usb.h:682
A USB function.
Definition: usb.h:674
#define SMSC75XX_INT_STS_PHY_INT
PHY interrupt.
Definition: smsc75xx.h:18
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
Definition: iobuf.c:235
uint32_t multiple
Multiple collisions.
Definition: smsc75xx.h:178
#define DBG_LOG
Definition: compiler.h:317
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
#define SMSC75XX_FCT_RX_CTL
FIFO controller RX FIFO control register.
Definition: smsc75xx.h:44
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:670
#define SMSC75XX_MAC_RX_FCS
FCS stripping.
Definition: smsc75xx.h:57
String functions.
struct smsc75xx_rx_error_statistics err
Error statistics.
Definition: smsc75xx.h:158
struct usb_device_id * ids
USB ID table.
Definition: usb.h:1409
#define SMSC75XX_RX_ADDR_BASE
MAC receive address register base.
Definition: smsc75xx.h:65
static struct usb_device_id smsc75xx_ids[]
SMSC75xx device IDs.
Definition: smsc75xx.c:557
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:38
static void smsc75xx_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
Definition: smsc75xx.c:177
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition: usbnet.c:55