iPXE
smsc95xx.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 
26 #include <string.h>
27 #include <unistd.h>
28 #include <errno.h>
29 #include <byteswap.h>
30 #include <ipxe/ethernet.h>
31 #include <ipxe/usb.h>
32 #include <ipxe/usbnet.h>
33 #include <ipxe/profile.h>
34 #include <ipxe/base16.h>
35 #include <ipxe/smbios.h>
36 #include "smsc95xx.h"
37 
38 /** @file
39  *
40  * SMSC LAN95xx USB Ethernet driver
41  *
42  */
43 
44 /** Bulk IN completion profiler */
45 static struct profiler smsc95xx_in_profiler __profiler =
46  { .name = "smsc95xx.in" };
47 
48 /** Bulk OUT profiler */
49 static struct profiler smsc95xx_out_profiler __profiler =
50  { .name = "smsc95xx.out" };
51 
52 /******************************************************************************
53  *
54  * MAC address
55  *
56  ******************************************************************************
57  */
58 
59 /**
60  * Construct MAC address for Honeywell VM3
61  *
62  * @v smscusb SMSC USB device
63  * @ret rc Return status code
64  */
65 static int smsc95xx_vm3_fetch_mac ( struct smscusb_device *smscusb ) {
66  struct net_device *netdev = smscusb->netdev;
67  const struct smbios_header *structure;
68  const struct smbios_system_information *system;
69  const char *manufacturer;
70  const char *product;
71  const char *mac;
72  int len;
73  int rc;
74 
75  /* Find system information */
77  if ( ! structure ) {
78  DBGC ( smscusb, "SMSC95XX %p could not find system "
79  "information\n", smscusb );
80  return -ENOENT;
81  }
82  system = container_of ( structure, struct smbios_system_information,
83  header );
84 
85  /* Fetch system manufacturer name */
86  manufacturer = smbios_string ( structure, system->manufacturer );
87  if ( ! manufacturer ) {
88  DBGC ( smscusb, "SMSC95XX %p could not read manufacturer "
89  "name\n", smscusb );
90  return -ENOENT;
91  }
92 
93  /* Fetch system product name */
94  product = smbios_string ( structure, system->product );
95  if ( ! product ) {
96  DBGC ( smscusb, "SMSC95XX %p could not read product name\n",
97  smscusb );
98  return -ENOENT;
99  }
100 
101  /* Ignore non-VM3 devices */
102  if ( ( strcmp ( manufacturer, "Honeywell" ) != 0 ) ||
103  ( strcmp ( product, "VM3" ) != 0 ) )
104  return -ENOTTY;
105 
106  /* Find OEM strings */
107  structure = smbios_structure ( SMBIOS_TYPE_OEM_STRINGS, 0 );
108  if ( ! structure ) {
109  DBGC ( smscusb, "SMSC95XX %p could not find OEM strings\n",
110  smscusb );
111  return -ENOENT;
112  }
113 
114  /* Fetch MAC address */
116  if ( ! mac ) {
117  DBGC ( smscusb, "SMSC95XX %p could not read OEM string\n",
118  smscusb );
119  return -ENOENT;
120  }
121 
122  /* Decode MAC address */
123  len = base16_decode ( mac, netdev->hw_addr, ETH_ALEN );
124  if ( len < 0 ) {
125  rc = len;
126  DBGC ( smscusb, "SMSC95XX %p invalid MAC address \"%s\"\n",
127  smscusb, mac );
128  return rc;
129  }
130 
131  DBGC ( smscusb, "SMSC95XX %p using VM3 MAC %s\n",
132  smscusb, eth_ntoa ( netdev->hw_addr ) );
133  return 0;
134 }
135 
136 /**
137  * Fetch MAC address
138  *
139  * @v smscusb SMSC USB device
140  * @ret rc Return status code
141  */
142 static int smsc95xx_fetch_mac ( struct smscusb_device *smscusb ) {
143  struct net_device *netdev = smscusb->netdev;
144  int rc;
145 
146  /* Read MAC address from EEPROM, if present */
147  if ( ( rc = smscusb_eeprom_fetch_mac ( smscusb,
148  SMSC95XX_E2P_BASE ) ) == 0 )
149  return 0;
150 
151  /* Read MAC address from device tree, if present */
152  if ( ( rc = smscusb_fdt_fetch_mac ( smscusb ) ) == 0 )
153  return 0;
154 
155  /* Construct MAC address for Honeywell VM3, if applicable */
156  if ( ( rc = smsc95xx_vm3_fetch_mac ( smscusb ) ) == 0 )
157  return 0;
158 
159  /* Otherwise, generate a random MAC address */
161  DBGC ( smscusb, "SMSC95XX %p using random MAC %s\n",
162  smscusb, eth_ntoa ( netdev->hw_addr ) );
163  return 0;
164 }
165 
166 /******************************************************************************
167  *
168  * Statistics (for debugging)
169  *
170  ******************************************************************************
171  */
172 
173 /**
174  * Dump statistics (for debugging)
175  *
176  * @v smscusb SMSC USB device
177  * @ret rc Return status code
178  */
179 static int smsc95xx_dump_statistics ( struct smscusb_device *smscusb ) {
180  struct smsc95xx_rx_statistics rx;
181  struct smsc95xx_tx_statistics tx;
182  int rc;
183 
184  /* Do nothing unless debugging is enabled */
185  if ( ! DBG_LOG )
186  return 0;
187 
188  /* Get RX statistics */
190  &rx, sizeof ( rx ) ) ) != 0 ) {
191  DBGC ( smscusb, "SMSC95XX %p could not get RX statistics: "
192  "%s\n", smscusb, strerror ( rc ) );
193  return rc;
194  }
195 
196  /* Get TX statistics */
198  &tx, sizeof ( tx ) ) ) != 0 ) {
199  DBGC ( smscusb, "SMSC95XX %p could not get TX statistics: "
200  "%s\n", smscusb, strerror ( rc ) );
201  return rc;
202  }
203 
204  /* Dump statistics */
205  DBGC ( smscusb, "SMSC95XX %p RX good %d bad %d crc %d und %d aln %d "
206  "ovr %d lat %d drp %d\n", smscusb, le32_to_cpu ( rx.good ),
207  le32_to_cpu ( rx.bad ), le32_to_cpu ( rx.crc ),
208  le32_to_cpu ( rx.undersize ), le32_to_cpu ( rx.alignment ),
209  le32_to_cpu ( rx.oversize ), le32_to_cpu ( rx.late ),
210  le32_to_cpu ( rx.dropped ) );
211  DBGC ( smscusb, "SMSC95XX %p TX good %d bad %d pau %d sgl %d mul %d "
212  "exc %d lat %d und %d def %d car %d\n", smscusb,
213  le32_to_cpu ( tx.good ), le32_to_cpu ( tx.bad ),
214  le32_to_cpu ( tx.pause ), le32_to_cpu ( tx.single ),
215  le32_to_cpu ( tx.multiple ), le32_to_cpu ( tx.excessive ),
216  le32_to_cpu ( tx.late ), le32_to_cpu ( tx.underrun ),
217  le32_to_cpu ( tx.deferred ), le32_to_cpu ( tx.carrier ) );
218 
219  return 0;
220 }
221 
222 /******************************************************************************
223  *
224  * Device reset
225  *
226  ******************************************************************************
227  */
228 
229 /**
230  * Reset device
231  *
232  * @v smscusb SMSC USB device
233  * @ret rc Return status code
234  */
235 static int smsc95xx_reset ( struct smscusb_device *smscusb ) {
236  uint32_t hw_cfg;
237  uint32_t led_gpio_cfg;
238  int rc;
239 
240  /* Reset device */
241  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_HW_CFG,
242  SMSC95XX_HW_CFG_LRST ) ) != 0 )
243  return rc;
244 
245  /* Wait for reset to complete */
247 
248  /* Check that reset has completed */
249  if ( ( rc = smscusb_readl ( smscusb, SMSC95XX_HW_CFG, &hw_cfg ) ) != 0 )
250  return rc;
251  if ( hw_cfg & SMSC95XX_HW_CFG_LRST ) {
252  DBGC ( smscusb, "SMSC95XX %p failed to reset\n", smscusb );
253  return -ETIMEDOUT;
254  }
255 
256  /* Configure LEDs */
257  led_gpio_cfg = ( SMSC95XX_LED_GPIO_CFG_GPCTL2_NSPD_LED |
260  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_LED_GPIO_CFG,
261  led_gpio_cfg ) ) != 0 ) {
262  DBGC ( smscusb, "SMSC95XX %p could not configure LEDs: %s\n",
263  smscusb, strerror ( rc ) );
264  /* Ignore error and continue */
265  }
266 
267  return 0;
268 }
269 
270 /******************************************************************************
271  *
272  * Endpoint operations
273  *
274  ******************************************************************************
275  */
276 
277 /**
278  * Complete bulk IN transfer
279  *
280  * @v ep USB endpoint
281  * @v iobuf I/O buffer
282  * @v rc Completion status code
283  */
284 static void smsc95xx_in_complete ( struct usb_endpoint *ep,
285  struct io_buffer *iobuf, int rc ) {
286  struct smscusb_device *smscusb =
287  container_of ( ep, struct smscusb_device, usbnet.in );
288  struct net_device *netdev = smscusb->netdev;
289  struct smsc95xx_rx_header *header;
290 
291  /* Profile completions */
292  profile_start ( &smsc95xx_in_profiler );
293 
294  /* Ignore packets cancelled when the endpoint closes */
295  if ( ! ep->open ) {
296  free_iob ( iobuf );
297  return;
298  }
299 
300  /* Record USB errors against the network device */
301  if ( rc != 0 ) {
302  DBGC ( smscusb, "SMSC95XX %p bulk IN failed: %s\n",
303  smscusb, strerror ( rc ) );
304  goto err;
305  }
306 
307  /* Sanity check */
308  if ( iob_len ( iobuf ) < ( sizeof ( *header ) + 4 /* CRC */ ) ) {
309  DBGC ( smscusb, "SMSC95XX %p underlength bulk IN\n",
310  smscusb );
311  DBGC_HDA ( smscusb, 0, iobuf->data, iob_len ( iobuf ) );
312  rc = -EINVAL;
313  goto err;
314  }
315 
316  /* Strip header and CRC */
317  header = iobuf->data;
318  iob_pull ( iobuf, sizeof ( *header ) );
319  iob_unput ( iobuf, 4 /* CRC */ );
320 
321  /* Check for errors */
322  if ( header->command & cpu_to_le32 ( SMSC95XX_RX_RUNT |
324  SMSC95XX_RX_CRC ) ) {
325  DBGC ( smscusb, "SMSC95XX %p receive error (%08x):\n",
326  smscusb, le32_to_cpu ( header->command ) );
327  DBGC_HDA ( smscusb, 0, iobuf->data, iob_len ( iobuf ) );
328  rc = -EIO;
329  goto err;
330  }
331 
332  /* Hand off to network stack */
333  netdev_rx ( netdev, iob_disown ( iobuf ) );
334 
335  profile_stop ( &smsc95xx_in_profiler );
336  return;
337 
338  err:
339  /* Hand off to network stack */
340  netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
341 }
342 
343 /** Bulk IN endpoint operations */
346 };
347 
348 /**
349  * Transmit packet
350  *
351  * @v smscusb SMSC USB device
352  * @v iobuf I/O buffer
353  * @ret rc Return status code
354  */
355 static int smsc95xx_out_transmit ( struct smscusb_device *smscusb,
356  struct io_buffer *iobuf ) {
357  struct smsc95xx_tx_header *header;
358  size_t len = iob_len ( iobuf );
359  int rc;
360 
361  /* Profile transmissions */
362  profile_start ( &smsc95xx_out_profiler );
363 
364  /* Prepend header */
365  if ( ( rc = iob_ensure_headroom ( iobuf, sizeof ( *header ) ) ) != 0 )
366  return rc;
367  header = iob_push ( iobuf, sizeof ( *header ) );
369  SMSC95XX_TX_LEN ( len ) );
370  header->len = cpu_to_le32 ( len );
371 
372  /* Enqueue I/O buffer */
373  if ( ( rc = usb_stream ( &smscusb->usbnet.out, iobuf, 0 ) ) != 0 )
374  return rc;
375 
376  profile_stop ( &smsc95xx_out_profiler );
377  return 0;
378 }
379 
380 /******************************************************************************
381  *
382  * Network device interface
383  *
384  ******************************************************************************
385  */
386 
387 /**
388  * Open network device
389  *
390  * @v netdev Network device
391  * @ret rc Return status code
392  */
393 static int smsc95xx_open ( struct net_device *netdev ) {
394  struct smscusb_device *smscusb = netdev->priv;
395  int rc;
396 
397  /* Clear stored interrupt status */
398  smscusb->int_sts = 0;
399 
400  /* Configure bulk IN empty response */
401  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_HW_CFG,
402  SMSC95XX_HW_CFG_BIR ) ) != 0 )
403  goto err_hw_cfg;
404 
405  /* Open USB network device */
406  if ( ( rc = usbnet_open ( &smscusb->usbnet ) ) != 0 ) {
407  DBGC ( smscusb, "SMSC95XX %p could not open: %s\n",
408  smscusb, strerror ( rc ) );
409  goto err_open;
410  }
411 
412  /* Configure interrupt endpoint */
413  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_INT_EP_CTL,
415  SMSC95XX_INT_EP_CTL_PHY_EN ) ) ) != 0 )
416  goto err_int_ep_ctl;
417 
418  /* Configure bulk IN delay */
419  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_BULK_IN_DLY,
420  SMSC95XX_BULK_IN_DLY_SET ( 0 ) ) ) != 0 )
421  goto err_bulk_in_dly;
422 
423  /* Configure MAC */
424  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_MAC_CR,
431  SMSC95XX_MAC_CR_RXEN ) ) ) != 0 )
432  goto err_mac_cr;
433 
434  /* Configure transmit datapath */
435  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_TX_CFG,
436  SMSC95XX_TX_CFG_ON ) ) != 0 )
437  goto err_tx_cfg;
438 
439  /* Set MAC address */
440  if ( ( rc = smscusb_set_address ( smscusb, SMSC95XX_ADDR_BASE ) ) != 0 )
441  goto err_set_address;
442 
443  /* Enable PHY interrupts and update link status */
444  if ( ( rc = smscusb_mii_open ( smscusb, SMSC95XX_MII_PHY_INTR_MASK,
446  SMSC95XX_PHY_INTR_LINK_DOWN ) ) ) != 0)
447  goto err_mii_open;
448 
449  return 0;
450 
451  err_mii_open:
452  err_set_address:
453  err_tx_cfg:
454  err_mac_cr:
455  err_bulk_in_dly:
456  err_int_ep_ctl:
457  usbnet_close ( &smscusb->usbnet );
458  err_open:
459  err_hw_cfg:
460  smsc95xx_reset ( smscusb );
461  return rc;
462 }
463 
464 /**
465  * Close network device
466  *
467  * @v netdev Network device
468  */
469 static void smsc95xx_close ( struct net_device *netdev ) {
470  struct smscusb_device *smscusb = netdev->priv;
471 
472  /* Close USB network device */
473  usbnet_close ( &smscusb->usbnet );
474 
475  /* Dump statistics (for debugging) */
476  smsc95xx_dump_statistics ( smscusb );
477 
478  /* Reset device */
479  smsc95xx_reset ( smscusb );
480 }
481 
482 /**
483  * Transmit packet
484  *
485  * @v netdev Network device
486  * @v iobuf I/O buffer
487  * @ret rc Return status code
488  */
489 static int smsc95xx_transmit ( struct net_device *netdev,
490  struct io_buffer *iobuf ) {
491  struct smscusb_device *smscusb = netdev->priv;
492  int rc;
493 
494  /* Transmit packet */
495  if ( ( rc = smsc95xx_out_transmit ( smscusb, iobuf ) ) != 0 )
496  return rc;
497 
498  return 0;
499 }
500 
501 /**
502  * Poll for completed and received packets
503  *
504  * @v netdev Network device
505  */
506 static void smsc95xx_poll ( struct net_device *netdev ) {
507  struct smscusb_device *smscusb = netdev->priv;
509  int rc;
510 
511  /* Poll USB bus */
512  usb_poll ( smscusb->bus );
513 
514  /* Refill endpoints */
515  if ( ( rc = usbnet_refill ( &smscusb->usbnet ) ) != 0 )
516  netdev_rx_err ( netdev, NULL, rc );
517 
518  /* Do nothing more unless there are interrupts to handle */
519  int_sts = smscusb->int_sts;
520  if ( ! int_sts )
521  return;
522 
523  /* Check link status if applicable */
525  smscusb_mii_check_link ( smscusb );
527  }
528 
529  /* Record RX FIFO overflow if applicable */
531  DBGC2 ( smscusb, "SMSC95XX %p RX FIFO overflowed\n",
532  smscusb );
535  }
536 
537  /* Check for unexpected interrupts */
538  if ( int_sts ) {
539  DBGC ( smscusb, "SMSC95XX %p unexpected interrupt %#08x\n",
540  smscusb, int_sts );
542  }
543 
544  /* Clear interrupts */
545  if ( ( rc = smscusb_writel ( smscusb, SMSC95XX_INT_STS,
546  smscusb->int_sts ) ) != 0 )
547  netdev_rx_err ( netdev, NULL, rc );
548  smscusb->int_sts = 0;
549 }
550 
551 /** SMSC95xx network device operations */
553  .open = smsc95xx_open,
554  .close = smsc95xx_close,
555  .transmit = smsc95xx_transmit,
556  .poll = smsc95xx_poll,
557 };
558 
559 /******************************************************************************
560  *
561  * USB interface
562  *
563  ******************************************************************************
564  */
565 
566 /**
567  * Probe device
568  *
569  * @v func USB function
570  * @v config Configuration descriptor
571  * @ret rc Return status code
572  */
573 static int smsc95xx_probe ( struct usb_function *func,
574  struct usb_configuration_descriptor *config ) {
575  struct net_device *netdev;
576  struct smscusb_device *smscusb;
577  int rc;
578 
579  /* Allocate and initialise structure */
580  netdev = alloc_etherdev ( sizeof ( *smscusb ) );
581  if ( ! netdev ) {
582  rc = -ENOMEM;
583  goto err_alloc;
584  }
586  netdev->dev = &func->dev;
587  smscusb = netdev->priv;
588  memset ( smscusb, 0, sizeof ( *smscusb ) );
589  smscusb_init ( smscusb, netdev, func, &smsc95xx_in_operations );
592  usb_refill_init ( &smscusb->usbnet.in,
593  ( sizeof ( struct smsc95xx_tx_header ) -
594  sizeof ( struct smsc95xx_rx_header ) ),
596  DBGC ( smscusb, "SMSC95XX %p on %s\n", smscusb, func->name );
597 
598  /* Describe USB network device */
599  if ( ( rc = usbnet_describe ( &smscusb->usbnet, config ) ) != 0 ) {
600  DBGC ( smscusb, "SMSC95XX %p could not describe: %s\n",
601  smscusb, strerror ( rc ) );
602  goto err_describe;
603  }
604 
605  /* Reset device */
606  if ( ( rc = smsc95xx_reset ( smscusb ) ) != 0 )
607  goto err_reset;
608 
609  /* Read MAC address */
610  if ( ( rc = smsc95xx_fetch_mac ( smscusb ) ) != 0 )
611  goto err_fetch_mac;
612 
613  /* Register network device */
614  if ( ( rc = register_netdev ( netdev ) ) != 0 )
615  goto err_register;
616 
617  usb_func_set_drvdata ( func, netdev );
618  return 0;
619 
621  err_register:
622  err_fetch_mac:
623  err_reset:
624  err_describe:
626  netdev_put ( netdev );
627  err_alloc:
628  return rc;
629 }
630 
631 /**
632  * Remove device
633  *
634  * @v func USB function
635  */
636 static void smsc95xx_remove ( struct usb_function *func ) {
637  struct net_device *netdev = usb_func_get_drvdata ( func );
638 
641  netdev_put ( netdev );
642 }
643 
644 /** SMSC95xx device IDs */
645 static struct usb_device_id smsc95xx_ids[] = {
646  {
647  .name = "smsc9500",
648  .vendor = 0x0424,
649  .product = 0x9500,
650  },
651  {
652  .name = "smsc9505",
653  .vendor = 0x0424,
654  .product = 0x9505,
655  },
656  {
657  .name = "smsc9500a",
658  .vendor = 0x0424,
659  .product = 0x9e00,
660  },
661  {
662  .name = "smsc9505a",
663  .vendor = 0x0424,
664  .product = 0x9e01,
665  },
666  {
667  .name = "smsc9514",
668  .vendor = 0x0424,
669  .product = 0xec00,
670  },
671  {
672  .name = "smsc9500-s",
673  .vendor = 0x0424,
674  .product = 0x9900,
675  },
676  {
677  .name = "smsc9505-s",
678  .vendor = 0x0424,
679  .product = 0x9901,
680  },
681  {
682  .name = "smsc9500a-s",
683  .vendor = 0x0424,
684  .product = 0x9902,
685  },
686  {
687  .name = "smsc9505a-s",
688  .vendor = 0x0424,
689  .product = 0x9903,
690  },
691  {
692  .name = "smsc9514-s",
693  .vendor = 0x0424,
694  .product = 0x9904,
695  },
696  {
697  .name = "smsc9500a-h",
698  .vendor = 0x0424,
699  .product = 0x9905,
700  },
701  {
702  .name = "smsc9505a-h",
703  .vendor = 0x0424,
704  .product = 0x9906,
705  },
706  {
707  .name = "smsc9500-2",
708  .vendor = 0x0424,
709  .product = 0x9907,
710  },
711  {
712  .name = "smsc9500a-2",
713  .vendor = 0x0424,
714  .product = 0x9908,
715  },
716  {
717  .name = "smsc9514-2",
718  .vendor = 0x0424,
719  .product = 0x9909,
720  },
721  {
722  .name = "smsc9530",
723  .vendor = 0x0424,
724  .product = 0x9530,
725  },
726  {
727  .name = "smsc9730",
728  .vendor = 0x0424,
729  .product = 0x9730,
730  },
731  {
732  .name = "smsc89530",
733  .vendor = 0x0424,
734  .product = 0x9e08,
735  },
736 };
737 
738 /** SMSC LAN95xx driver */
739 struct usb_driver smsc95xx_driver __usb_driver = {
740  .ids = smsc95xx_ids,
741  .id_count = ( sizeof ( smsc95xx_ids ) / sizeof ( smsc95xx_ids[0] ) ),
742  .class = USB_CLASS_ID ( 0xff, 0x00, 0xff ),
743  .score = USB_SCORE_NORMAL,
744  .probe = smsc95xx_probe,
745  .remove = smsc95xx_remove,
746 };
int smscusb_set_address(struct smscusb_device *smscusb, unsigned int addr_base)
Set receive address.
Definition: smscusb.c:686
Transmit packet header.
Definition: smsc95xx.h:96
#define iob_pull(iobuf, len)
Definition: iobuf.h:106
A USB driver.
Definition: usb.h:1406
#define SMSC95XX_INT_EP_CTL_RXDF_EN
RX FIFO overflow.
Definition: smsc95xx.h:45
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define SMSC95XX_VM3_OEM_STRING_MAC
Honeywell VM3 MAC address OEM string index.
Definition: smsc95xx.h:178
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int smsc95xx_open(struct net_device *netdev)
Open network device.
Definition: smsc95xx.c:393
A USB device ID.
Definition: usb.h:1360
static struct usb_device_id smsc95xx_ids[]
SMSC95xx device IDs.
Definition: smsc95xx.c:645
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
Definition: usb.h:495
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
Receive packet header.
Definition: smsc95xx.h:81
Receive statistics.
Definition: smsc95xx.h:113
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition: usb.h:717
const char * name
Name.
Definition: usb.h:675
#define SMSC95XX_PHY_INTR_LINK_DOWN
PHY interrupt: link down.
Definition: smsc95xx.h:78
static void smsc95xx_close(struct net_device *netdev)
Close network device.
Definition: smsc95xx.c:469
#define le32_to_cpu(value)
Definition: byteswap.h:113
int(* open)(struct net_device *netdev)
Open network device.
Definition: netdevice.h:222
const char * name
Name.
Definition: usb.h:1362
const char * smbios_string(const struct smbios_header *structure, unsigned int index)
Get indexed string within SMBIOS structure.
Definition: smbios.c:251
static int smsc95xx_out_transmit(struct smscusb_device *smscusb, struct io_buffer *iobuf)
Transmit packet.
Definition: smsc95xx.c:355
Error codes.
#define iob_push(iobuf, len)
Definition: iobuf.h:88
An SMSC USB device.
Definition: smscusb.h:147
#define SMSC95XX_ADDR_BASE
MAC address register base.
Definition: smsc95xx.h:63
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:152
Transmit statistics.
Definition: smsc95xx.h:136
#define SMSC95XX_RX_LATE
Late collision.
Definition: smsc95xx.h:90
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 SMSC95XX_HW_CFG
Hardware configuration register.
Definition: smsc95xx.h:24
#define DBGC(...)
Definition: compiler.h:505
#define SMSC95XX_INT_STS
Interrupt status register.
Definition: smsc95xx.h:15
const struct smbios_header * smbios_structure(unsigned int type, unsigned int instance)
Find specific structure type within SMBIOS.
Definition: smbios.c:182
#define ENOENT
No such file or directory.
Definition: errno.h:514
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
Definition: usb.c:545
#define SMSC95XX_LED_GPIO_CFG_GPCTL0_NFDX_LED
Full-duplex LED.
Definition: smsc95xx.h:37
#define SMSC95XX_TX_LAST
Last segment.
Definition: smsc95xx.h:107
static struct net_device_operations smsc95xx_operations
SMSC95xx network device operations.
Definition: smsc95xx.c:552
#define SMSC95XX_BULK_IN_DLY
Bulk IN delay register.
Definition: smsc95xx.h:49
#define SMSC95XX_LED_GPIO_CFG_GPCTL1_NLNKA_LED
Activity LED.
Definition: smsc95xx.h:34
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition: smscusb.h:182
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
A data structure for storing profiling information.
Definition: profile.h:26
#define SMSC95XX_HW_CFG_BIR
Bulk IN use NAK.
Definition: smsc95xx.h:25
int open
Endpoint is open.
Definition: usb.h:418
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:173
#define SMSC95XX_TX_LEN(len)
Buffer size.
Definition: smsc95xx.h:110
#define SMSC95XX_E2P_BASE
EEPROM register base.
Definition: smsc95xx.h:41
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
#define SMSC95XX_TX_CFG_ON
TX enable.
Definition: smsc95xx.h:21
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
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:31
#define SMSC95XX_MAC_CR_MCPAS
All multicast.
Definition: smsc95xx.h:56
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:518
static int smsc95xx_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition: smsc95xx.c:573
uint32_t int_sts
Interrupt status.
Definition: smscusb.h:165
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:216
A USB endpoint.
Definition: usb.h:403
#define SMSC95XX_PHY_INTR_ANEG_DONE
PHY interrupt: auto-negotiation complete.
Definition: smsc95xx.h:75
const char * name
Name.
Definition: profile.h:28
#define SMBIOS_TYPE_OEM_STRINGS
SMBIOS OEM strings structure type.
Definition: smbios.h:186
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
#define SMSC95XX_IN_MTU
Bulk IN buffer size.
Definition: smsc95xx.h:172
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:575
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
Ethernet protocol.
#define SMSC95XX_MAC_CR
MAC control register.
Definition: smsc95xx.h:53
void * priv
Driver private data.
Definition: netdevice.h:431
#define DBGC_HDA(...)
Definition: compiler.h:506
ring len
Length.
Definition: dwmac.h:231
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define SMSC95XX_INT_EP_CTL
Interrupt endpoint control register.
Definition: smsc95xx.h:44
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:616
static struct net_device * netdev
Definition: gdbudp.c:52
#define SMSC95XX_IN_MAX_FILL
Bulk IN maximum fill level.
Definition: smsc95xx.h:169
static int smscusb_readl(struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
Read register.
Definition: smscusb.h:203
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition: usb.h:706
static void smsc95xx_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: smsc95xx.c:506
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:160
Profiling.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
#define SMSC95XX_TX_CFG
Transmit configuration register.
Definition: smsc95xx.h:20
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition: usbnet.c:151
#define cpu_to_le32(value)
Definition: byteswap.h:107
static int smsc95xx_dump_statistics(struct smscusb_device *smscusb)
Dump statistics (for debugging)
Definition: smsc95xx.c:179
static int smsc95xx_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: smsc95xx.c:489
#define SMSC95XX_INT_STS_PHY_INT
PHY interrupt.
Definition: smsc95xx.h:17
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
Definition: usb.h:1071
#define iob_unput(iobuf, len)
Definition: iobuf.h:139
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
#define SMSC95XX_RX_STATISTICS
Receive statistics.
Definition: smsc95xx.h:133
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition: usb.h:1388
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:531
Normal driver.
Definition: usb.h:1452
#define SMSC95XX_INT_STS_RXDF_INT
RX FIFO overflow.
Definition: smsc95xx.h:16
#define SMSC95XX_MAC_CR_TXEN
TX enabled.
Definition: smsc95xx.h:59
static struct profiler smsc95xx_in_profiler __profiler
Bulk IN completion profiler.
Definition: smsc95xx.c:45
static int smsc95xx_vm3_fetch_mac(struct smscusb_device *smscusb)
Construct MAC address for Honeywell VM3.
Definition: smsc95xx.c:65
#define ETH_ALEN
Definition: if_ether.h:8
unsigned int uint32_t
Definition: stdint.h:12
#define SMSC95XX_HW_CFG_LRST
Soft lite reset.
Definition: smsc95xx.h:26
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:14
System Management BIOS.
#define SMSC95XX_INT_EP_CTL_PHY_EN
PHY interrupt.
Definition: smsc95xx.h:46
Network device operations.
Definition: netdevice.h:213
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static int smsc95xx_fetch_mac(struct smscusb_device *smscusb)
Fetch MAC address.
Definition: smsc95xx.c:142
static struct usb_endpoint_driver_operations smsc95xx_in_operations
Bulk IN endpoint operations.
Definition: smsc95xx.c:344
USB network devices.
A USB configuration descriptor.
Definition: usb.h:209
An SMBIOS structure header.
Definition: smbios.h:119
SMBIOS system information structure.
Definition: smbios.h:129
#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 strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
Universal Serial Bus (USB)
#define SMSC95XX_MAC_CR_PRMS
Promiscuous.
Definition: smsc95xx.h:57
SMSC LAN95xx USB Ethernet driver.
void * data
Start of data.
Definition: iobuf.h:52
int smscusb_mii_check_link(struct smscusb_device *smscusb)
Check link status.
Definition: smscusb.c:613
#define EIO
Input/output error.
Definition: errno.h:433
#define SMSC95XX_MAC_CR_FDPX
Full duplex.
Definition: smsc95xx.h:55
#define SMSC95XX_BULK_IN_DLY_SET(ticks)
Delay / 16.7ns.
Definition: smsc95xx.h:50
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
struct ena_llq_option header
Header locations.
Definition: ena.h:16
#define SMSC95XX_MAC_CR_PASSBAD
Pass bad frames.
Definition: smsc95xx.h:58
uint8_t product
Product string.
Definition: smbios.h:16
static int smsc95xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: smsc95xx.c:235
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition: usbnet.c:277
#define SMSC95XX_RX_CRC
CRC error.
Definition: smsc95xx.h:93
struct usb_bus * bus
USB bus.
Definition: smscusb.h:151
struct net_device * netdev
Network device.
Definition: smscusb.h:153
static int smscusb_get_statistics(struct smscusb_device *smscusb, unsigned int index, void *data, size_t len)
Get statistics.
Definition: smscusb.h:225
#define SMSC95XX_RX_RUNT
Runt frame.
Definition: smsc95xx.h:87
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
USB endpoint driver operations.
Definition: usb.h:488
struct device dev
Generic device.
Definition: usb.h:681
A USB function.
Definition: usb.h:673
#define SMSC95XX_MAC_CR_RXEN
RX enabled.
Definition: smsc95xx.h:60
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
Definition: iobuf.c:234
#define DBG_LOG
Definition: compiler.h:317
#define SMSC95XX_RESET_DELAY_US
Reset delay (in microseconds)
Definition: smsc95xx.h:163
#define SMSC95XX_TX_STATISTICS
Transmit statistics.
Definition: smsc95xx.h:160
#define SMSC95XX_MII_BASE
MII register base.
Definition: smsc95xx.h:66
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
int smscusb_fdt_fetch_mac(struct smscusb_device *smscusb)
Fetch MAC address from device tree.
Definition: smscusb.c:456
#define SMBIOS_TYPE_SYSTEM_INFORMATION
SMBIOS system information structure type.
Definition: smbios.h:147
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
struct usb_driver smsc95xx_driver __usb_driver
SMSC LAN95xx driver.
Definition: smsc95xx.c:739
String functions.
#define SMSC95XX_TX_FIRST
First segment.
Definition: smsc95xx.h:104
#define SMSC95XX_MII_PHY_INTR_MASK
PHY interrupt mask MII register.
Definition: smsc95xx.h:72
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define SMSC95XX_LED_GPIO_CFG
LED GPIO configuration register.
Definition: smsc95xx.h:29
void eth_random_addr(void *hw_addr)
Generate random Ethernet address.
Definition: ethernet.c:159
#define SMSC95XX_MAC_CR_RXALL
Receive all.
Definition: smsc95xx.h:54
static void smsc95xx_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
Definition: smsc95xx.c:284
#define SMSC95XX_MII_PHY_INTR_SOURCE
PHY interrupt source MII register.
Definition: smsc95xx.h:69
struct usb_device_id * ids
USB ID table.
Definition: usb.h:1408
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237
static void smsc95xx_remove(struct usb_function *func)
Remove device.
Definition: smsc95xx.c:636
uint8_t system[ETH_ALEN]
System identifier.
Definition: eth_slow.h:24
void * memset(void *dest, int character, size_t len) __nonnull
Base16 encoding.
A persistent I/O buffer.
Definition: iobuf.h:37
#define SMSC95XX_LED_GPIO_CFG_GPCTL2_NSPD_LED
Link speed LED.
Definition: smsc95xx.h:31
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition: usbnet.c:54