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