iPXE
myri10ge.c
Go to the documentation of this file.
1/************************************************* -*- linux-c -*-
2 * Myricom 10Gb Network Interface Card Software
3 * Copyright 2009, Myricom, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU 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
20FILE_LICENCE ( GPL2_ONLY );
21
22/*
23 * Author: Glenn Brown <glenn@myri.com>
24 */
25
26/*
27 * General Theory of Operation
28 *
29 * This is a minimal Myricom 10 gigabit Ethernet driver for network
30 * boot.
31 *
32 * Initialization
33 *
34 * myri10ge_pci_probe() is called by iPXE during initialization.
35 * Minimal NIC initialization is performed to minimize resources
36 * consumed when the driver is resident but unused.
37 *
38 * Network Boot
39 *
40 * myri10ge_net_open() is called by iPXE before attempting to network
41 * boot from the card. Packet buffers are allocated and the NIC
42 * interface is initialized.
43 *
44 * Transmit
45 *
46 * myri10ge_net_transmit() enqueues frames for transmission by writing
47 * discriptors to the NIC's tx ring. For simplicity and to avoid
48 * copies, we always have the NIC DMA up the packet. The sent I/O
49 * buffer is released once the NIC signals myri10ge_interrupt_handler()
50 * that the send has completed.
51 *
52 * Receive
53 *
54 * Receives are posted to the NIC's receive ring. The NIC fills a
55 * DMAable receive_completion ring with completion notifications.
56 * myri10ge_net_poll() polls for these receive notifications, posts
57 * replacement receive buffers to the NIC, and passes received frames
58 * to netdev_rx().
59 *
60 * NonVolatile Storage
61 *
62 * This driver supports NonVolatile Storage (nvs) in the NIC EEPROM.
63 * If the last EEPROM block is not otherwise filled, we tell
64 * iPXE it may store NonVolatile Options (nvo) there.
65 */
66
67/*
68 * Debugging levels:
69 * - DBG() is for any errors, i.e. failed alloc_iob(), malloc_phys(),
70 * TX overflow, corrupted packets, ...
71 * - DBG2() is for successful events, like packet received,
72 * packet transmitted, and other general notifications.
73 * - DBGP() prints the name of each called function on entry
74 */
75
76#include <stdint.h>
77#include <string.h>
78#include <byteswap.h>
79#include <errno.h>
80#include <ipxe/ethernet.h>
81#include <ipxe/if_ether.h>
82#include <ipxe/iobuf.h>
83#include <ipxe/malloc.h>
84#include <ipxe/netdevice.h>
85#include <ipxe/nvo.h>
86#include <ipxe/nvs.h>
87#include <ipxe/pci.h>
88#include <ipxe/timer.h>
89
90#include "myri10ge_mcp.h"
91
92/****************************************************************
93 * Forward declarations
94 ****************************************************************/
95
96/* PCI driver entry points */
97
98static int myri10ge_pci_probe ( struct pci_device* );
99static void myri10ge_pci_remove ( struct pci_device* );
100
101/* Network device operations */
102
103static void myri10ge_net_close ( struct net_device* );
104static void myri10ge_net_irq ( struct net_device*, int enable );
105static int myri10ge_net_open ( struct net_device* );
106static void myri10ge_net_poll ( struct net_device* );
107static int myri10ge_net_transmit ( struct net_device*, struct io_buffer* );
108
109/****************************************************************
110 * Constants
111 ****************************************************************/
112
113/* Maximum ring indices, used to wrap ring indices. These must be 2**N-1. */
114
115#define MYRI10GE_TRANSMIT_WRAP 1U
116#define MYRI10GE_RECEIVE_WRAP 7U
117#define MYRI10GE_RECEIVE_COMPLETION_WRAP 31U
118
119/****************************************************************
120 * Driver internal data types.
121 ****************************************************************/
122
123/* Structure holding all DMA buffers for a NIC, which we will
124 allocated as contiguous read/write DMAable memory when the NIC is
125 initialized. */
126
128{
129 /* The NIC DMAs receive completion notifications into this ring */
130
132
133 /* Interrupt details are DMAd here before interrupting. */
134
136
137 /* NIC command completion status is DMAd here. */
138
140};
141
143{
144 /* Interrupt support */
145
146 uint32 *irq_claim; /* in NIC SRAM */
147 uint32 *irq_deassert; /* in NIC SRAM */
148
149 /* DMA buffers. */
150
152
153 /*
154 * Transmit state.
155 *
156 * The counts here are uint32 for easy comparison with
157 * priv->dma->irq_data.send_done_count and with each other.
158 */
159
165
166 /*
167 * Receive state.
168 */
169
172 unsigned int receives_posted;
173 unsigned int receives_done;
175
176 /* Address for writing commands to the firmware.
177 BEWARE: the value must be written 32 bits at a time. */
178
180
181 /*
182 * Nonvolatile Storage for configuration options.
183 */
184
187 unsigned int nvo_registered;
188
189 /* Cached PCI capability locations. */
190
192};
193
194/****************************************************************
195 * Driver internal functions.
196 ****************************************************************/
197
198/* Print ring status when debugging. Use this only after a printed
199 value changes. */
200
201#define DBG2_RINGS( priv ) \
202 DBG2 ( "tx %x/%x rx %x/%x in %s() \n", \
203 ( priv ) ->transmits_done, ( priv ) -> transmits_posted, \
204 ( priv ) ->receives_done, ( priv ) -> receives_posted, \
205 __FUNCTION__ )
206
207/*
208 * Return a pointer to the driver private data for a network device.
209 *
210 * @v netdev Network device created by this driver.
211 * @ret priv The corresponding driver private data.
212 */
213static inline struct myri10ge_private *myri10ge_priv ( struct net_device *nd )
214{
215 /* Our private data always follows the network device in memory,
216 since we use alloc_netdev() to allocate the storage. */
217
218 return ( struct myri10ge_private * ) ( nd + 1 );
219}
220
221/*
222 * Convert a Myri10ge driver private data pointer to a netdev pointer.
223 *
224 * @v p Myri10ge device private data.
225 * @ret r The corresponding network device.
226 */
227static inline struct net_device *myri10ge_netdev ( struct myri10ge_private *p )
228{
229 return ( ( struct net_device * ) p ) - 1;
230}
231
232/*
233 * Convert a network device pointer to a PCI device pointer.
234 *
235 * @v netdev A Network Device.
236 * @ret r The corresponding PCI device.
237 */
238static inline struct pci_device *myri10ge_pcidev ( struct net_device *netdev )
239{
240 return container_of (netdev->dev, struct pci_device, dev);
241}
242
243/*
244 * Pass a receive buffer to the NIC to be filled.
245 *
246 * @v priv The network device to receive the buffer.
247 * @v iob The I/O buffer to fill.
248 *
249 * Receive buffers are filled in FIFO order.
250 */
252 struct io_buffer *iob )
253{
254 unsigned int receives_posted;
256
257 /* Record the posted I/O buffer, to be passed to netdev_rx() on
258 receive. */
259
260 receives_posted = priv->receives_posted;
261 priv->receive_iob[receives_posted & MYRI10GE_RECEIVE_WRAP] = iob;
262
263 /* Post the receive. */
264
265 request = &priv->receive_post_ring[receives_posted
266 & priv->receive_post_ring_wrap];
267 request->addr_high = 0;
268 wmb();
269 request->addr_low = htonl ( virt_to_bus ( iob->data ) );
270 priv->receives_posted = ++receives_posted;
271}
272
273/*
274 * Execute a command on the NIC.
275 *
276 * @v priv NIC to perform the command.
277 * @v cmd The command to perform.
278 * @v data I/O copy buffer for parameters/results
279 * @ret rc 0 on success, else an error code.
280 */
282 uint32 cmd,
283 uint32 data[3] )
284{
285 int i;
288 unsigned int slept_ms;
289 volatile mcp_cmd_response_t *response;
290
291 DBGP ( "myri10ge_command ( ,%d, ) \n", cmd );
292 command = priv->command;
293 response = &priv->dma->command_response;
294
295 /* Mark the command as incomplete. */
296
297 response->result = 0xFFFFFFFF;
298
299 /* Pass the command to the NIC. */
300
301 command->cmd = htonl ( cmd );
302 command->data0 = htonl ( data[0] );
303 command->data1 = htonl ( data[1] );
304 command->data2 = htonl ( data[2] );
305 command->response_addr.high = 0;
306 command->response_addr.low
307 = htonl ( virt_to_bus ( &priv->dma->command_response ) );
308 for ( i=0; i<9; i++ )
309 command->pad[i] = 0;
310 wmb();
311 command->pad[9] = 0;
312
313 /* Wait up to 2 seconds for a response. */
314
315 for ( slept_ms=0; slept_ms<2000; slept_ms++ ) {
316 result = response->result;
317 if ( result == 0 ) {
318 data[0] = ntohl ( response->data );
319 return 0;
320 } else if ( result != 0xFFFFFFFF ) {
321 DBG ( "cmd%d:0x%x\n",
322 cmd,
323 ntohl ( response->result ) );
324 return -EIO;
325 }
326 udelay ( 1000 );
327 rmb();
328 }
329 DBG ( "cmd%d:timed out\n", cmd );
330 return -ETIMEDOUT;
331}
332
333/*
334 * Handle any pending interrupt.
335 *
336 * @v netdev Device being polled for interrupts.
337 *
338 * This is called periodically to let the driver check for interrupts.
339 */
341{
342 struct myri10ge_private *priv;
343 mcp_irq_data_t *irq_data;
344 uint8 valid;
345
347 irq_data = &priv->dma->irq_data;
348
349 /* Return if there was no interrupt. */
350
351 rmb();
352 valid = irq_data->valid;
353 if ( !valid )
354 return;
355 DBG2 ( "irq " );
356
357 /* Tell the NIC to deassert the interrupt and clear
358 irq_data->valid.*/
359
360 *priv->irq_deassert = 0; /* any value is OK. */
361 mb();
362
363 /* Handle any new receives. */
364
365 if ( valid & 1 ) {
366
367 /* Pass the receive interrupt token back to the NIC. */
368
369 DBG2 ( "rx " );
370 *priv->irq_claim = htonl ( 3 );
371 wmb();
372 }
373
374 /* Handle any sent packet by freeing its I/O buffer, now that
375 we know it has been DMAd. */
376
377 if ( valid & 2 ) {
378 unsigned int nic_done_count;
379
380 DBG2 ( "snt " );
381 nic_done_count = ntohl ( priv->dma->irq_data.send_done_count );
382 while ( priv->transmits_done != nic_done_count ) {
383 struct io_buffer *iob;
384
385 iob = priv->transmit_iob [priv->transmits_done
387 DBG2 ( "%p ", iob );
388 netdev_tx_complete ( netdev, iob );
389 ++priv->transmits_done;
390 }
391 }
392
393 /* Record any statistics update. */
394
395 if ( irq_data->stats_updated ) {
396
397 /* Update the link status. */
398
399 DBG2 ( "stats " );
400 if ( ntohl ( irq_data->link_up ) == MXGEFW_LINK_UP )
402 else
404
405 /* Ignore all error counters from the NIC. */
406 }
407
408 /* Wait for the interrupt to be deasserted, as indicated by
409 irq_data->valid, which is set by the NIC after the deassert. */
410
411 DBG2 ( "wait " );
412 do {
413 mb();
414 } while ( irq_data->valid );
415
416 /* Claim the interrupt to enable future interrupt generation. */
417
418 DBG2 ( "claim\n" );
419 * ( priv->irq_claim + 1 ) = htonl ( 3 );
420 mb();
421}
422
423/* Constants for reading the STRING_SPECS via the Myricom
424 Vendor Specific PCI configuration space capability. */
425
426#define VS_EEPROM_READ_ADDR ( vs + 0x04 )
427#define VS_EEPROM_READ_DATA ( vs + 0x08 )
428#define VS_EEPROM_WRITE ( vs + 0x0C )
429#define VS_ADDR ( vs + 0x18 )
430#define VS_DATA ( vs + 0x14 )
431#define VS_MODE ( vs + 0x10 )
432#define VS_MODE_READ32 0x3
433#define VS_MODE_LOCATE 0x8
434#define VS_LOCATE_STRING_SPECS 0x3
435#define VS_MODE_EEPROM_STREAM_WRITE 0xB
436
437/*
438 * Read MAC address from its 'string specs' via the vendor-specific
439 * capability. (This capability allows NIC SRAM and ROM to be read
440 * before it is mapped.)
441 *
442 * @v pci The device.
443 * @v vs Offset of the PCI Vendor-Specific Capability.
444 * @v mac Buffer to store the MAC address.
445 * @ret rc Returns 0 on success, else an error code.
446 */
448 unsigned int vs,
450{
451 char string_specs[256];
452 char *ptr, *limit;
453 char *to = string_specs;
454 uint32 addr;
455 uint32 len;
456 int mac_set = 0;
457
458 /* Locate the String specs in LANai SRAM. */
459
464 DBG2 ( "ss@%x,%x\n", addr, len );
465
466 /* Copy in the string specs. Use 32-bit reads for performance. */
467
468 if ( len > sizeof ( string_specs ) || ( len & 3 ) ) {
469 pci_write_config_byte ( pci, VS_MODE, 0 );
470 DBG ( "SS too big\n" );
471 return -ENOTSUP;
472 }
473
475 while ( len >= 4 ) {
476 uint32 tmp;
477
480 tmp = ntohl ( tmp );
481 memcpy ( to, &tmp, 4 );
482 to += 4;
483 addr += 4;
484 len -= 4;
485 }
486 pci_write_config_byte ( pci, VS_MODE, 0 );
487
488 /* Parse the string specs. */
489
490 DBG2 ( "STRING_SPECS:\n" );
491 ptr = string_specs;
492 limit = string_specs + sizeof ( string_specs );
493 while ( *ptr != '\0' && ptr < limit ) {
494 DBG2 ( "%s\n", ptr );
495 if ( memcmp ( ptr, "MAC=", 4 ) == 0 ) {
496 unsigned int i;
497
498 ptr += 4;
499 for ( i=0; i<6; i++ ) {
500 if ( ( ptr + 2 ) > limit ) {
501 DBG ( "bad MAC addr\n" );
502 return -ENOTSUP;
503 }
504 mac[i] = strtoul ( ptr, &ptr, 16 );
505 ptr += 1;
506 }
507 mac_set = 1;
508 }
509 else
510 while ( ptr < limit && *ptr++ );
511 }
512
513 /* Verify we parsed all we need. */
514
515 if ( !mac_set ) {
516 DBG ( "no MAC addr\n" );
517 return -ENOTSUP;
518 }
519
520 DBG2 ( "MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
521 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
522
523 return 0;
524}
525
526/****************************************************************
527 * NonVolatile Storage support
528 ****************************************************************/
529
530/*
531 * Fill a buffer with data read from nonvolatile storage.
532 *
533 * @v nvs The NonVolatile Storage device to be read.
534 * @v addr The first NonVolatile Storage address to be read.
535 * @v _buf Pointer to the data buffer to be filled.
536 * @v len The number of bytes to copy.
537 * @ret rc 0 on success, else nonzero.
538 */
539static int myri10ge_nvs_read ( struct nvs_device *nvs,
540 unsigned int addr,
541 void *_buf,
542 size_t len )
543{
544 struct myri10ge_private *priv =
546 struct pci_device *pci = myri10ge_pcidev ( myri10ge_netdev ( priv ) );
547 unsigned int vs = priv->pci_cap_vs;
548 unsigned char *buf = (unsigned char *) _buf;
549 unsigned int data;
550 unsigned int i, j;
551
552 DBGP ( "myri10ge_nvs_read\n" );
553
554 /* Issue the first read address. */
555
559 addr++;
560
561 /* Issue all the reads, and harvest the results every 4th issue. */
562
563 for ( i=0; i<len; ++i,addr++ ) {
564
565 /* Issue the next read address, updating only the
566 bytes that need updating. We always update the
567 LSB, which triggers the read. */
568
569 if ( ( addr & 0xff ) == 0 ) {
570 if ( ( addr & 0xffff ) == 0 ) {
573 addr >> 16 );
574 }
577 addr >> 8 );
578 }
580
581 /* If 4 data bytes are available, read them with a single read. */
582
583 if ( ( i & 3 ) == 3 ) {
586 &data );
587 for ( j=0; j<4; j++ ) {
588 buf[i-j] = data;
589 data >>= 8;
590 }
591 }
592 }
593
594 /* Harvest any remaining results. */
595
596 if ( ( i & 3 ) != 0 ) {
598 for ( j=1; j<=(i&3); j++ ) {
599 buf[i-j] = data;
600 data >>= 8;
601 }
602 }
603
604 DBGP_HDA ( addr - len, _buf, len );
605 return 0;
606}
607
608/*
609 * Write a buffer into nonvolatile storage.
610 *
611 * @v nvs The NonVolatile Storage device to be written.
612 * @v address The NonVolatile Storage address to be written.
613 * @v _buf Pointer to the data to be written.
614 * @v len Length of the buffer to be written.
615 * @ret rc 0 on success, else nonzero.
616 */
617static int myri10ge_nvs_write ( struct nvs_device *nvs,
618 unsigned int addr,
619 const void *_buf,
620 size_t len )
621{
622 struct myri10ge_private *priv =
624 struct pci_device *pci = myri10ge_pcidev ( myri10ge_netdev ( priv ) );
625 unsigned int vs = priv->pci_cap_vs;
626 const unsigned char *buf = (const unsigned char *)_buf;
627 unsigned int i;
628 uint8 verify;
629
630 DBGP ( "nvs_write " );
631 DBGP_HDA ( addr, _buf, len );
632
633 /* Start erase of the NonVolatile Options block. */
634
635 DBGP ( "erasing " );
636 pci_write_config_dword ( pci, VS_EEPROM_WRITE, ( addr << 8 ) | 0xff );
637
638 /* Wait for erase to complete. */
639
640 DBGP ( "waiting " );
642 while ( verify != 0xff ) {
645 }
646
647 /* Write the data one byte at a time. */
648
649 DBGP ( "writing " );
652 for (i=0; i<len; i++, addr++)
653 pci_write_config_byte ( pci, VS_DATA, buf[i] );
654 pci_write_config_dword ( pci, VS_ADDR, 0xffffffff );
655 pci_write_config_byte ( pci, VS_MODE, 0 );
656
657 DBGP ( "done\n" );
658 return 0;
659}
660
661/*
662 * Initialize NonVolatile storage support for a device.
663 *
664 * @v priv Device private data for the device.
665 * @ret rc 0 on success, else an error code.
666 */
667
669{
670 int rc;
671 struct myri10ge_eeprom_header
672 {
673 uint8 __jump[8];
674 uint32 eeprom_len;
675 uint32 eeprom_segment_len;
676 uint32 mcp1_offset;
677 uint32 mcp2_offset;
679 } hdr;
680 uint32 mcp2_len;
681 unsigned int nvo_fragment_pos;
682
683 DBGP ( "myri10ge_nv_init\n" );
684
685 /* Read the EEPROM header, and byteswap the fields we will use.
686 This is safe even though priv->nvs is not yet initialized. */
687
688 rc = myri10ge_nvs_read ( &priv->nvs, 0, &hdr, sizeof ( hdr ) );
689 if ( rc ) {
690 DBG ( "EEPROM header unreadable\n" );
691 return rc;
692 }
693 hdr.eeprom_len = ntohl ( hdr.eeprom_len );
694 hdr.eeprom_segment_len = ntohl ( hdr.eeprom_segment_len );
695 hdr.mcp2_offset = ntohl ( hdr.mcp2_offset );
696 hdr.version = ntohl ( hdr.version );
697 DBG2 ( "eelen:%xh seglen:%xh mcp2@%xh ver%d\n", hdr.eeprom_len,
698 hdr.eeprom_segment_len, hdr.mcp2_offset, hdr.version );
699
700 /* If the firmware does not support EEPROM writes, simply return. */
701
702 if ( hdr.version < 1 ) {
703 DBG ( "No EEPROM write support\n" );
704 return 0;
705 }
706
707 /* Read the length of MCP2. */
708
709 rc = myri10ge_nvs_read ( &priv->nvs, hdr.mcp2_offset, &mcp2_len, 4 );
710 mcp2_len = ntohl ( mcp2_len );
711 DBG2 ( "mcp2len:%xh\n", mcp2_len );
712
713 /* Determine the position of the NonVolatile Options fragment and
714 simply return if it overlaps other data. */
715
716 nvo_fragment_pos = hdr.eeprom_len - hdr.eeprom_segment_len;
717 if ( hdr.mcp2_offset + mcp2_len > nvo_fragment_pos ) {
718 DBG ( "EEPROM full\n" );
719 return 0;
720 }
721
722 /* Initialize NonVolatile Storage state. */
723
724 priv->nvs.word_len_log2 = 0;
725 priv->nvs.size = hdr.eeprom_len;
726 priv->nvs.block_size = hdr.eeprom_segment_len;
727 priv->nvs.read = myri10ge_nvs_read;
728 priv->nvs.write = myri10ge_nvs_write;
729
730 /* Register the NonVolatile Options storage. */
731
732 nvo_init ( &priv->nvo,
733 &priv->nvs,
734 nvo_fragment_pos, 0x200,
735 NULL,
736 & myri10ge_netdev (priv) -> refcnt );
737 rc = register_nvo ( &priv->nvo,
739 if ( rc ) {
740 DBG ("register_nvo failed");
741 return rc;
742 }
743
744 priv->nvo_registered = 1;
745 DBG2 ( "NVO supported\n" );
746 return 0;
747}
748
749void
751{
752 /* Simply return if nonvolatile access is not supported. */
753
754 if ( 0 == priv->nvo_registered )
755 return;
756
757 unregister_nvo ( &priv->nvo );
758}
759
760/****************************************************************
761 * iPXE PCI Device Driver API functions
762 ****************************************************************/
763
764/*
765 * Initialize the PCI device.
766 *
767 * @v pci The device's associated pci_device structure.
768 * @v id The PCI device + vendor id.
769 * @ret rc Returns zero if successfully initialized.
770 *
771 * This function is called very early on, while iPXE is initializing.
772 * This is a iPXE PCI Device Driver API function.
773 */
774static int myri10ge_pci_probe ( struct pci_device *pci )
775{
776 static struct net_device_operations myri10ge_operations = {
777 .open = myri10ge_net_open,
778 .close = myri10ge_net_close,
779 .transmit = myri10ge_net_transmit,
780 .poll = myri10ge_net_poll,
781 .irq = myri10ge_net_irq
782 };
783
784 const char *dbg;
785 int rc;
786 struct net_device *netdev;
787 struct myri10ge_private *priv;
788
789 DBGP ( "myri10ge_pci_probe: " );
790
791 netdev = alloc_etherdev ( sizeof ( *priv ) );
792 if ( !netdev ) {
793 rc = -ENOMEM;
794 dbg = "alloc_etherdev";
795 goto abort_with_nothing;
796 }
797
798 netdev_init ( netdev, &myri10ge_operations );
800
801 pci_set_drvdata ( pci, netdev );
802 netdev->dev = &pci->dev;
803
804 /* Make sure interrupts are disabled. */
805
807
808 /* Find the PCI Vendor-Specific capability. */
809
810 priv->pci_cap_vs = pci_find_capability ( pci , PCI_CAP_ID_VNDR );
811 if ( 0 == priv->pci_cap_vs ) {
812 rc = -ENOTSUP;
813 dbg = "no_vs";
814 goto abort_with_netdev_init;
815 }
816
817 /* Read the NIC HW address. */
818
820 priv->pci_cap_vs,
821 netdev->hw_addr );
822 if ( rc ) {
823 dbg = "mac_from_ss";
824 goto abort_with_netdev_init;
825 }
826 DBGP ( "mac " );
827
828 /* Enable bus master, etc. */
829
830 adjust_pci_device ( pci );
831 DBGP ( "pci " );
832
833 /* Register the initialized network device. */
834
836 if ( rc ) {
837 dbg = "register_netdev";
838 goto abort_with_netdev_init;
839 }
840
841 /* Initialize NonVolatile Storage support. */
842
844 if ( rc ) {
845 dbg = "myri10ge_nv_init";
846 goto abort_with_registered_netdev;
847 }
848
849 DBGP ( "done\n" );
850
851 return 0;
852
853abort_with_registered_netdev:
855abort_with_netdev_init:
857 netdev_put ( netdev );
858abort_with_nothing:
859 DBG ( "%s:%s\n", dbg, strerror ( rc ) );
860 return rc;
861}
862
863/*
864 * Remove a device from the PCI device list.
865 *
866 * @v pci PCI device to remove.
867 *
868 * This is a PCI Device Driver API function.
869 */
870static void myri10ge_pci_remove ( struct pci_device *pci )
871{
872 struct net_device *netdev;
873
874 DBGP ( "myri10ge_pci_remove\n" );
875 netdev = pci_get_drvdata ( pci );
876
880 netdev_put ( netdev );
881}
882
883/****************************************************************
884 * iPXE Network Device Driver Operations
885 ****************************************************************/
886
887/*
888 * Close a network device.
889 *
890 * @v netdev Device to close.
891 *
892 * This is a iPXE Network Device Driver API function.
893 */
894static void myri10ge_net_close ( struct net_device *netdev )
895{
896 struct myri10ge_private *priv;
897 uint32 data[3];
898
899 DBGP ( "myri10ge_net_close\n" );
901
902 /* disable interrupts */
903
905
906 /* Reset the NIC interface, so we won't get any more events from
907 the NIC. */
908
910
911 /* Free receive buffers that were never filled. */
912
913 while ( priv->receives_done != priv->receives_posted ) {
914 free_iob ( priv->receive_iob[priv->receives_done
916 ++priv->receives_done;
917 }
918
919 /* Release DMAable memory. */
920
921 free_phys ( priv->dma, sizeof ( *priv->dma ) );
922
923 /* Erase all state from the open. */
924
925 memset ( priv, 0, sizeof ( *priv ) );
926
927 DBG2_RINGS ( priv );
928}
929
930/*
931 * Enable or disable IRQ masking.
932 *
933 * @v netdev Device to control.
934 * @v enable Zero to mask off IRQ, non-zero to enable IRQ.
935 *
936 * This is a iPXE Network Driver API function.
937 */
938static void myri10ge_net_irq ( struct net_device *netdev, int enable )
939{
940 struct pci_device *pci_dev;
941 uint16 val;
942
943 DBGP ( "myri10ge_net_irq\n" );
944 pci_dev = ( struct pci_device * ) netdev->dev;
945
946 /* Adjust the Interrupt Disable bit in the Command register of the
947 PCI Device. */
948
949 pci_read_config_word ( pci_dev, PCI_COMMAND, &val );
950 if ( enable )
952 else
955}
956
957/*
958 * Opens a network device.
959 *
960 * @v netdev Device to be opened.
961 * @ret rc Non-zero if failed to open.
962 *
963 * This enables tx and rx on the device.
964 * This is a iPXE Network Device Driver API function.
965 */
966static int myri10ge_net_open ( struct net_device *netdev )
967{
968 const char *dbg; /* printed upon error return */
969 int rc;
970 struct io_buffer *iob;
971 struct myri10ge_private *priv;
972 uint32 data[3];
973 struct pci_device *pci_dev;
974 void *membase;
975
976 DBGP ( "myri10ge_net_open\n" );
978 pci_dev = ( struct pci_device * ) netdev->dev;
979 membase = phys_to_virt ( pci_dev->membase );
980
981 /* Compute address for passing commands to the firmware. */
982
983 priv->command = membase + MXGEFW_ETH_CMD;
984
985 /* Ensure interrupts are disabled. */
986
988
989 /* Allocate cleared DMAable buffers. */
990
991 priv->dma = malloc_phys ( sizeof ( *priv->dma ) , 128 );
992 if ( !priv->dma ) {
993 rc = -ENOMEM;
994 dbg = "DMA";
995 goto abort_with_nothing;
996 }
997 memset ( priv->dma, 0, sizeof ( *priv->dma ) );
998
999 /* Simplify following code. */
1000
1001#define TRY( prefix, base, suffix ) do { \
1002 rc = myri10ge_command ( priv, \
1003 MXGEFW_ \
1004 ## prefix \
1005 ## base \
1006 ## suffix, \
1007 data ); \
1008 if ( rc ) { \
1009 dbg = #base; \
1010 goto abort_with_dma; \
1011 } \
1012 } while ( 0 )
1013
1014 /* Send a reset command to the card to see if it is alive,
1015 and to reset its queue state. */
1016
1017 TRY ( CMD_, RESET , );
1018
1019 /* Set the interrupt queue size. */
1020
1021 data[0] = ( (uint32_t)( sizeof ( priv->dma->receive_completion ) )
1023 TRY ( CMD_SET_ , INTRQ_SIZE , );
1024
1025 /* Set the interrupt queue DMA address. */
1026
1027 data[0] = virt_to_bus ( &priv->dma->receive_completion );
1028 data[1] = 0;
1029 TRY ( CMD_SET_, INTRQ_DMA, );
1030
1031 /* Get the NIC interrupt claim address. */
1032
1033 TRY ( CMD_GET_, IRQ_ACK, _OFFSET );
1034 priv->irq_claim = membase + data[0];
1035
1036 /* Get the NIC interrupt assert address. */
1037
1038 TRY ( CMD_GET_, IRQ_DEASSERT, _OFFSET );
1039 priv->irq_deassert = membase + data[0];
1040
1041 /* Disable interrupt coalescing, which is inappropriate for the
1042 minimal buffering we provide. */
1043
1044 TRY ( CMD_GET_, INTR_COAL, _DELAY_OFFSET );
1045 * ( ( uint32 * ) ( membase + data[0] ) ) = 0;
1046
1047 /* Set the NIC mac address. */
1048
1049 data[0] = ( netdev->ll_addr[0] << 24
1050 | netdev->ll_addr[1] << 16
1051 | netdev->ll_addr[2] << 8
1052 | netdev->ll_addr[3] );
1053 data[1] = ( ( netdev->ll_addr[4] << 8 )
1054 | netdev->ll_addr[5] );
1055 TRY ( SET_ , MAC_ADDRESS , );
1056
1057 /* Enable multicast receives, because some iPXE clients don't work
1058 without multicast. . */
1059
1060 TRY ( ENABLE_ , ALLMULTI , );
1061
1062 /* Disable Ethernet flow control, so the NIC cannot deadlock the
1063 network under any circumstances. */
1064
1065 TRY ( DISABLE_ , FLOW , _CONTROL );
1066
1067 /* Compute transmit ring sizes. */
1068
1069 data[0] = 0; /* slice 0 */
1070 TRY ( CMD_GET_, SEND_RING, _SIZE );
1071 priv->transmit_ring_wrap
1072 = data[0] / sizeof ( mcp_kreq_ether_send_t ) - 1;
1073 if ( priv->transmit_ring_wrap
1074 & ( priv->transmit_ring_wrap + 1 ) ) {
1075 rc = -EPROTO;
1076 dbg = "TX_RING";
1077 goto abort_with_dma;
1078 }
1079
1080 /* Compute receive ring sizes. */
1081
1082 data[0] = 0; /* slice 0 */
1083 TRY ( CMD_GET_ , RX_RING , _SIZE );
1084 priv->receive_post_ring_wrap = data[0] / sizeof ( mcp_dma_addr_t ) - 1;
1085 if ( priv->receive_post_ring_wrap
1086 & ( priv->receive_post_ring_wrap + 1 ) ) {
1087 rc = -EPROTO;
1088 dbg = "RX_RING";
1089 goto abort_with_dma;
1090 }
1091
1092 /* Get NIC transmit ring address. */
1093
1094 data[0] = 0; /* slice 0. */
1095 TRY ( CMD_GET_, SEND, _OFFSET );
1096 priv->transmit_ring = membase + data[0];
1097
1098 /* Get the NIC receive ring address. */
1099
1100 data[0] = 0; /* slice 0. */
1101 TRY ( CMD_GET_, SMALL_RX, _OFFSET );
1102 priv->receive_post_ring = membase + data[0];
1103
1104 /* Set the Nic MTU. */
1105
1106 data[0] = ETH_FRAME_LEN;
1107 TRY ( CMD_SET_, MTU, );
1108
1109 /* Tell the NIC our buffer sizes. ( We use only small buffers, so we
1110 set both buffer sizes to the same value, which will force all
1111 received frames to use small buffers. ) */
1112
1114 TRY ( CMD_SET_, SMALL_BUFFER, _SIZE );
1116 TRY ( CMD_SET_, BIG_BUFFER, _SIZE );
1117
1118 /* Tell firmware where to DMA IRQ data */
1119
1120 data[0] = virt_to_bus ( &priv->dma->irq_data );
1121 data[1] = 0;
1122 data[2] = sizeof ( priv->dma->irq_data );
1123 TRY ( CMD_SET_, STATS_DMA_V2, );
1124
1125 /* Post receives. */
1126
1127 while ( priv->receives_posted <= MYRI10GE_RECEIVE_WRAP ) {
1128
1129 /* Reserve 2 extra bytes at the start of packets, since
1130 the firmware always skips the first 2 bytes of the buffer
1131 so TCP headers will be aligned. */
1132
1134 if ( !iob ) {
1135 rc = -ENOMEM;
1136 dbg = "alloc_iob";
1137 goto abort_with_receives_posted;
1138 }
1139 iob_reserve ( iob, MXGEFW_PAD );
1140 myri10ge_post_receive ( priv, iob );
1141 }
1142
1143 /* Bring up the link. */
1144
1145 TRY ( CMD_, ETHERNET_UP, );
1146
1147 DBG2_RINGS ( priv );
1148 return 0;
1149
1150abort_with_receives_posted:
1151 while ( priv->receives_posted-- )
1152 free_iob ( priv->receive_iob[priv->receives_posted] );
1153abort_with_dma:
1154 /* Because the link is not up, we don't have to reset the NIC here. */
1155 free_phys ( priv->dma, sizeof ( *priv->dma ) );
1156abort_with_nothing:
1157 /* Erase all signs of the failed open. */
1158 memset ( priv, 0, sizeof ( *priv ) );
1159 DBG ( "%s: %s\n", dbg, strerror ( rc ) );
1160 return ( rc );
1161}
1162
1163/*
1164 * This function allows a driver to process events during operation.
1165 *
1166 * @v netdev Device being polled.
1167 *
1168 * This is called periodically by iPXE to let the driver check the status of
1169 * transmitted packets and to allow the driver to check for received packets.
1170 * This is a iPXE Network Device Driver API function.
1171 */
1172static void myri10ge_net_poll ( struct net_device *netdev )
1173{
1174 struct io_buffer *iob;
1175 struct io_buffer *replacement;
1176 struct myri10ge_dma_buffers *dma;
1177 struct myri10ge_private *priv;
1178 unsigned int length;
1179 unsigned int orig_receives_posted;
1180
1181 DBGP ( "myri10ge_net_poll\n" );
1183 dma = priv->dma;
1184
1185 /* Process any pending interrupt. */
1186
1188
1189 /* Pass up received frames, but limit ourselves to receives posted
1190 before this function was called, so we cannot livelock if
1191 receives are arriving faster than we process them. */
1192
1193 orig_receives_posted = priv->receives_posted;
1194 while ( priv->receives_done != orig_receives_posted ) {
1195
1196 /* Stop if there is no pending receive. */
1197
1198 length = ntohs ( dma->receive_completion
1199 [priv->receives_done
1201 .length );
1202 if ( length == 0 )
1203 break;
1204
1205 /* Allocate a replacement buffer. If none is available,
1206 stop passing up packets until a buffer is available.
1207
1208 Reserve 2 extra bytes at the start of packets, since
1209 the firmware always skips the first 2 bytes of the buffer
1210 so TCP headers will be aligned. */
1211
1213 if ( !replacement ) {
1214 DBG ( "NO RX BUF\n" );
1215 break;
1216 }
1218
1219 /* Pass up the received frame. */
1220
1221 iob = priv->receive_iob[priv->receives_done
1223 iob_put ( iob, length );
1224 netdev_rx ( netdev, iob );
1225
1226 /* We have consumed the packet, so clear the receive
1227 notification. */
1228
1229 dma->receive_completion [priv->receives_done
1231 .length = 0;
1232 wmb();
1233
1234 /* Replace the passed-up I/O buffer. */
1235
1237 ++priv->receives_done;
1238 DBG2_RINGS ( priv );
1239 }
1240}
1241
1242/*
1243 * This transmits a packet.
1244 *
1245 * @v netdev Device to transmit from.
1246 * @v iobuf Data to transmit.
1247 * @ret rc Non-zero if failed to transmit.
1248 *
1249 * This is a iPXE Network Driver API function.
1250 */
1252 struct io_buffer *iobuf )
1253{
1255 size_t len;
1256 struct myri10ge_private *priv;
1258
1259 DBGP ( "myri10ge_net_transmit\n" );
1261
1262 /* Confirm space in the send ring. */
1263
1264 transmits_posted = priv->transmits_posted;
1265 if ( transmits_posted - priv->transmits_done
1267 DBG ( "TX ring full\n" );
1268 return -ENOBUFS;
1269 }
1270
1271 DBG2 ( "TX %p+%zd ", iobuf->data, iob_len ( iobuf ) );
1272 DBG2_HD ( iobuf->data, 14 );
1273
1274 /* Record the packet being transmitted, so we can later report
1275 send completion. */
1276
1277 priv->transmit_iob[transmits_posted & MYRI10GE_TRANSMIT_WRAP] = iobuf;
1278
1279 /* Copy and pad undersized frames, because the NIC does not pad,
1280 and we would rather copy small frames than do a gather. */
1281
1282 len = iob_len ( iobuf );
1283 if ( len < ETH_ZLEN ) {
1284 iob_pad ( iobuf, ETH_ZLEN );
1285 len = ETH_ZLEN;
1286 }
1287
1288 /* Enqueue the packet by writing a descriptor to the NIC.
1289 This is a bit tricky because the HW requires 32-bit writes,
1290 but the structure has smaller fields. */
1291
1292 kreq = &priv->transmit_ring[transmits_posted
1293 & priv->transmit_ring_wrap];
1294 kreq->addr_high = 0;
1295 kreq->addr_low = htonl ( virt_to_bus ( iobuf->data ) );
1296 ( ( uint32 * ) kreq ) [2] = htonl (
1297 0x0000 << 16 /* pseudo_header_offset */
1298 | ( len & 0xFFFF ) /* length */
1299 );
1300 wmb();
1301 ( ( uint32 * ) kreq ) [3] = htonl (
1302 0x00 << 24 /* pad */
1303 | 0x01 << 16 /* rdma_count */
1304 | 0x00 << 8 /* cksum_offset */
1307 | MXGEFW_FLAGS_NO_TSO ) /* flags */
1308 );
1309 wmb();
1310
1311 /* Mark the slot as consumed and return. */
1312
1313 priv->transmits_posted = ++transmits_posted;
1314 DBG2_RINGS ( priv );
1315 return 0;
1316}
1317
1318static struct pci_device_id myri10ge_nics[] = {
1319 /* Each of these macros must be a single line to satisfy a script. */
1320 PCI_ROM ( 0x14c1, 0x0008, "myri10ge", "Myricom 10Gb Ethernet Adapter", 0 ) ,
1321};
1322
1323struct pci_driver myri10ge_driver __pci_driver = {
1324 .ids = myri10ge_nics,
1325 .id_count = ( sizeof ( myri10ge_nics ) / sizeof ( myri10ge_nics[0] ) ) ,
1328};
1329
1330/*
1331 * Local variables:
1332 * c-basic-offset: 8
1333 * c-indent-level: 8
1334 * tab-width: 8
1335 * End:
1336 */
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct golan_inbox_hdr hdr
Message header.
Definition CIB_PRM.h:0
struct golan_eqe_cmd cmd
Definition CIB_PRM.h:1
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
uint16_t result
Definition hyperv.h:33
unsigned int uint32_t
Definition stdint.h:12
u32 version
Driver version.
Definition ath9k_hw.c:1985
ring len
Length.
Definition dwmac.h:226
uint32_t addr
Buffer address.
Definition dwmac.h:9
const char * replacement
Definition editstring.h:54
uint8_t data[48]
Additional event data.
Definition ena.h:11
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
Error codes.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
Ethernet protocol.
static struct net_device * netdev
Definition gdbudp.c:53
#define DBG2_HD(...)
Definition compiler.h:517
#define DBGP(...)
Definition compiler.h:532
#define DBG2(...)
Definition compiler.h:515
#define DBGP_HDA(...)
Definition compiler.h:533
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define EPROTO
Protocol error.
Definition errno.h:625
#define ENOMEM
Not enough space.
Definition errno.h:535
#define EIO
Input/output error.
Definition errno.h:434
#define ENOTSUP
Operation not supported.
Definition errno.h:590
#define ENOBUFS
No buffer space available.
Definition errno.h:499
u8 request[0]
List of IEs requested.
Definition ieee80211.h:2
#define ETH_ZLEN
Definition if_ether.h:11
#define ETH_FRAME_LEN
Definition if_ether.h:12
#define ETH_ALEN
Definition if_ether.h:9
#define ntohl(value)
Definition byteswap.h:135
#define htonl(value)
Definition byteswap.h:134
#define ntohs(value)
Definition byteswap.h:137
#define rmb()
Definition io.h:545
void mb(void)
Memory barrier.
#define wmb()
Definition io.h:546
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
iPXE timers
void __asmcall int val
Definition setjmp.h:12
uint8_t uint8
Definition stdint.h:29
uint16_t uint16
Definition stdint.h:31
uint32_t uint32
Definition stdint.h:33
String functions.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
Definition iobpad.c:50
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition iobuf.c:131
I/O buffers.
#define iob_put(iobuf, len)
Definition iobuf.h:125
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
#define iob_reserve(iobuf, len)
Definition iobuf.h:72
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
uint16_t limit
Limit.
Definition librm.h:1
unsigned long tmp
Definition linux_pci.h:65
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723
Dynamic memory allocation.
static void myri10ge_net_poll(struct net_device *)
Definition myri10ge.c:1172
static int myri10ge_nvs_write(struct nvs_device *nvs, unsigned int addr, const void *_buf, size_t len)
Definition myri10ge.c:617
#define VS_EEPROM_READ_DATA
Definition myri10ge.c:427
static struct pci_device * myri10ge_pcidev(struct net_device *netdev)
Definition myri10ge.c:238
static void myri10ge_net_irq(struct net_device *, int enable)
Definition myri10ge.c:938
static int myri10ge_nv_init(struct myri10ge_private *priv)
Definition myri10ge.c:668
void myri10ge_nv_fini(struct myri10ge_private *priv)
Definition myri10ge.c:750
static int myri10ge_net_transmit(struct net_device *, struct io_buffer *)
Definition myri10ge.c:1251
static int mac_address_from_string_specs(struct pci_device *pci, unsigned int vs, uint8 mac[ETH_ALEN])
Definition myri10ge.c:447
#define VS_DATA
Definition myri10ge.c:430
#define MYRI10GE_RECEIVE_COMPLETION_WRAP
Definition myri10ge.c:117
static struct myri10ge_private * myri10ge_priv(struct net_device *nd)
Definition myri10ge.c:213
static void myri10ge_pci_remove(struct pci_device *)
Definition myri10ge.c:870
static void myri10ge_net_close(struct net_device *)
Definition myri10ge.c:894
static void myri10ge_interrupt_handler(struct net_device *netdev)
Definition myri10ge.c:340
#define MYRI10GE_RECEIVE_WRAP
Definition myri10ge.c:116
#define VS_EEPROM_WRITE
Definition myri10ge.c:428
#define DBG2_RINGS(priv)
Definition myri10ge.c:201
#define MYRI10GE_TRANSMIT_WRAP
Definition myri10ge.c:115
#define TRY(prefix, base, suffix)
static int myri10ge_pci_probe(struct pci_device *)
Definition myri10ge.c:774
static int myri10ge_command(struct myri10ge_private *priv, uint32 cmd, uint32 data[3])
Definition myri10ge.c:281
#define VS_MODE_READ32
Definition myri10ge.c:432
static int myri10ge_nvs_read(struct nvs_device *nvs, unsigned int addr, void *_buf, size_t len)
Definition myri10ge.c:539
static struct net_device * myri10ge_netdev(struct myri10ge_private *p)
Definition myri10ge.c:227
#define VS_EEPROM_READ_ADDR
Definition myri10ge.c:426
#define VS_LOCATE_STRING_SPECS
Definition myri10ge.c:434
#define VS_ADDR
Definition myri10ge.c:429
static struct pci_device_id myri10ge_nics[]
Definition myri10ge.c:1318
#define VS_MODE
Definition myri10ge.c:431
#define VS_MODE_EEPROM_STREAM_WRITE
Definition myri10ge.c:435
static void myri10ge_post_receive(struct myri10ge_private *priv, struct io_buffer *iob)
Definition myri10ge.c:251
#define VS_MODE_LOCATE
Definition myri10ge.c:433
static int myri10ge_net_open(struct net_device *)
Definition myri10ge.c:966
#define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK
#define MXGEFW_LINK_UP
#define MXGEFW_FLAGS_FIRST
struct mcp_slot mcp_slot_t
#define MXGEFW_ETH_CMD
#define MXGEFW_FLAGS_NO_TSO
struct mcp_dma_addr mcp_dma_addr_t
struct mcp_irq_data mcp_irq_data_t
struct mcp_kreq_ether_recv mcp_kreq_ether_recv_t
struct mcp_kreq_ether_send mcp_kreq_ether_send_t
struct mcp_cmd mcp_cmd_t
struct mcp_cmd_response mcp_cmd_response_t
#define MXGEFW_PAD
@ MXGEFW_CMD_RESET
#define MXGEFW_FLAGS_SMALL
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition netdevice.c:231
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
Network device management.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:789
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:519
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition netdevice.h:587
void nvo_init(struct nvo_block *nvo, struct nvs_device *nvs, size_t address, size_t len, int(*resize)(struct nvo_block *nvo, size_t len), struct refcnt *refcnt)
Initialise non-volatile stored options.
Definition nvo.c:274
void unregister_nvo(struct nvo_block *nvo)
Unregister non-volatile stored options.
Definition nvo.c:325
int register_nvo(struct nvo_block *nvo, struct settings *parent)
Register non-volatile stored options.
Definition nvo.c:294
Non-volatile stored options.
Non-volatile storage.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
PCI bus.
#define PCI_CAP_ID_VNDR
Vendor-specific.
Definition pci.h:97
#define __pci_driver
Declare a PCI driver.
Definition pci.h:278
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308
#define PCI_COMMAND_INTX_DISABLE
Interrupt disable.
Definition pci.h:33
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376
#define PCI_COMMAND
PCI command.
Definition pci.h:26
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition pciextra.c:39
@ RESET
Definition sis900.h:46
u16 length
Definition sky2.h:1
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition string.c:485
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
A command-line command.
Definition command.h:10
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53
uint8_t stats_updated
uint32_t link_up
mcp_slot_t receive_completion[1+MYRI10GE_RECEIVE_COMPLETION_WRAP]
Definition myri10ge.c:131
mcp_irq_data_t irq_data
Definition myri10ge.c:135
mcp_cmd_response_t command_response
Definition myri10ge.c:139
uint32 * irq_claim
Definition myri10ge.c:146
unsigned int receives_done
Definition myri10ge.c:173
uint32 transmits_done
Definition myri10ge.c:163
struct io_buffer * receive_iob[1+MYRI10GE_RECEIVE_WRAP]
Definition myri10ge.c:174
unsigned int receives_posted
Definition myri10ge.c:172
struct myri10ge_dma_buffers * dma
Definition myri10ge.c:151
struct nvs_device nvs
Definition myri10ge.c:185
struct io_buffer * transmit_iob[1+MYRI10GE_TRANSMIT_WRAP]
Definition myri10ge.c:164
mcp_kreq_ether_send_t * transmit_ring
Definition myri10ge.c:160
unsigned int nvo_registered
Definition myri10ge.c:187
uint32 * irq_deassert
Definition myri10ge.c:147
uint32 transmit_ring_wrap
Definition myri10ge.c:161
unsigned int receive_post_ring_wrap
Definition myri10ge.c:171
struct nvo_block nvo
Definition myri10ge.c:186
uint32 transmits_posted
Definition myri10ge.c:162
mcp_cmd_t * command
Definition myri10ge.c:179
mcp_kreq_ether_recv_t * receive_post_ring
Definition myri10ge.c:170
Network device operations.
Definition netdevice.h:214
A network device.
Definition netdevice.h:353
A block of non-volatile stored options.
Definition nvo.h:23
A non-volatile storage device.
Definition nvs.h:16
A PCI device ID list entry.
Definition pci.h:175
A PCI device.
Definition pci.h:211
unsigned long membase
Memory base.
Definition pci.h:220
struct device dev
Generic device.
Definition pci.h:213
A PCI driver.
Definition pci.h:252
int(* probe)(struct pci_device *pci)
Probe device.
Definition pci.h:265
A reference counter.
Definition refcnt.h:27
@ MAC_ADDRESS
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61
static struct tlan_private * priv
Definition tlan.c:225
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40