|
| | FILE_LICENCE (GPL2_OR_LATER) |
| static u16 | pcnet32_wio_read_csr (unsigned long addr, int index) |
| static void | pcnet32_wio_write_csr (unsigned long addr, int index, u16 val) |
| static u16 | pcnet32_wio_read_bcr (unsigned long addr, int index) |
| static void | pcnet32_wio_write_bcr (unsigned long addr, int index, u16 val) |
| static u16 | pcnet32_wio_read_rap (unsigned long addr) |
| static void | pcnet32_wio_write_rap (unsigned long addr, u16 val) |
| static void | pcnet32_wio_reset (unsigned long addr) |
| static int | pcnet32_wio_check (unsigned long addr) |
| static u16 | pcnet32_dwio_read_csr (unsigned long addr, int index) |
| static void | pcnet32_dwio_write_csr (unsigned long addr, int index, u16 val) |
| static u16 | pcnet32_dwio_read_bcr (unsigned long addr, int index) |
| static void | pcnet32_dwio_write_bcr (unsigned long addr, int index, u16 val) |
| static u16 | pcnet32_dwio_read_rap (unsigned long addr) |
| static void | pcnet32_dwio_write_rap (unsigned long addr, u16 val) |
| static void | pcnet32_dwio_reset (unsigned long addr) |
| static int | pcnet32_dwio_check (unsigned long addr) |
| static int | pcnet32_mdio_read (struct net_device *netdev, int phy, int reg) |
| static void __unused | pcnet32_mdio_write (struct net_device *netdev, int phy, int reg, int val) |
| static void | pcnet32_refill_rx_ring (struct pcnet32_private *priv) |
| | pcnet32_refill_rx_ring - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in use by the hardware
|
| static int | pcnet32_setup_rx_resources (struct pcnet32_private *priv) |
| | pcnet32_setup_rx_resources - allocate Rx resources (Descriptors)
|
| static void | pcnet32_free_rx_resources (struct pcnet32_private *priv) |
| static int | pcnet32_setup_tx_resources (struct pcnet32_private *priv) |
| | pcnet32_setup_tx_resources - allocate Tx resources (Descriptors)
|
| static void | pcnet32_free_tx_resources (struct pcnet32_private *priv) |
| static int | pcnet32_chip_detect (struct pcnet32_private *priv) |
| static int | pcnet32_set_ops (struct pcnet32_private *priv) |
| | pcnet32_set_ops - Determines the ops used to access the registers
|
| static void | pcnet32_setup_init_block (struct pcnet32_private *priv) |
| | pcnet32_setup_init_block - setup the NICs initialization block
|
| static void | pcnet32_setup_probe_phy (struct pcnet32_private *priv) |
| | pcnet32_setup_probe_phy - go through all PHYs and see which one is present
|
| static int | pcnet32_setup_mac_addr (struct pcnet32_private *priv) |
| | pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses
|
| static void | pcnet32_setup_if_duplex (struct pcnet32_private *priv) |
| | pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode
|
| static void | pcnet32_hw_start (struct pcnet32_private *priv) |
| | pcnet32_hw_start - Starts up the NIC
|
| static int | pcnet32_open (struct net_device *netdev) |
| | open - Called when a network interface is made active
|
| static int | pcnet32_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
| | transmit - Transmit a packet
|
| static void | pcnet32_process_tx_packets (struct net_device *netdev) |
| | pcnet32_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_complete()
|
| static void | pcnet32_process_rx_packets (struct net_device *netdev) |
| | pcnet32_process_rx_packets - Checks for received packets, reports them to iPXE with netdev_rx() or netdev_rx_err() if there was an error receiving the packet
|
| static void | pcnet32_poll (struct net_device *netdev) |
| | poll - Poll for received packets
|
| static void | pcnet32_close (struct net_device *netdev) |
| | close - Disable network interface
|
| static void | pcnet32_irq_enable (struct pcnet32_private *priv) |
| static void | pcnet32_irq_disable (struct pcnet32_private *priv) |
| static void | pcnet32_irq (struct net_device *netdev, int action) |
| | irq - enable or disable interrupts
|
| static int | pcnet32_probe (struct pci_device *pdev) |
| | probe - Initial configuration of NIC
|
| static void | pcnet32_remove (struct pci_device *pdev) |
| | remove - Device Removal Routine
|
pcnet32_refill_rx_ring - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in use by the hardware
- Parameters
-
| priv | Driver private structure |
Definition at line 198 of file pcnet32.c.
199{
202 int i;
203
204 DBGP (
"pcnet32_refill_rx_ring\n" );
205
207 rx_curr_desc =
priv->rx_base + i;
208
210
211
213 continue;
214
215
217 continue;
218
219
221 DBG (
"Refill rx ring failed\n" );
222 break;
223 }
224
229
230
233 }
234
235}
#define NULL
NULL pointer (VOID *)
#define DBG(...)
Print a debugging message.
#define le16_to_cpu(value)
#define cpu_to_le32(value)
#define cpu_to_le16(value)
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
References alloc_iob(), pcnet32_rx_desc::base, pcnet32_rx_desc::buf_length, cpu_to_le16, cpu_to_le32, DBG, DBGP, DescOwn, le16_to_cpu, pcnet32_rx_desc::msg_length, NULL, PKT_BUF_SIZE, priv, pcnet32_rx_desc::reserved, RX_RING_SIZE, pcnet32_rx_desc::status, status, u16, virt_to_bus(), and wmb.
Referenced by pcnet32_process_rx_packets(), and pcnet32_setup_rx_resources().
Definition at line 319 of file pcnet32.c.
320{
326 int chip_version;
327 char *chipname;
328
331
334
336
337 DBG (
"PCnet chip version is 0x%X\n", chip_version );
338 if ( ( chip_version & 0xfff ) != 0x003 )
339 goto err_unsupported;
340
341 fdx =
mii = fset = 0;
342 chip_version = ( chip_version >> 12 ) & 0xffff;
343
344 switch (chip_version) {
345 case 0x2420:
346 chipname = "PCnet/PCI 79C970";
347 break;
348 case 0x2430:
349
350 chipname = "PCnet/PCI 79C970";
351 break;
352 case 0x2621:
353 chipname = "PCnet/PCI II 79C970A";
354 fdx = 1;
355 break;
356 case 0x2623:
357 chipname = "PCnet/FAST 79C971";
358 fdx = 1;
360 fset = 1;
361 break;
362 case 0x2624:
363 chipname = "PCnet/FAST+ 79C972";
364 fdx = 1;
366 fset = 1;
367 break;
368 case 0x2625:
369 chipname = "PCnet/FAST III 79C973";
370 fdx = 1;
372 break;
373 case 0x2626:
374 chipname = "PCnet/Home 79C978";
375 fdx = 1;
376
377
378
379
380
381
382
383
385
386 DBG (
"media reset to %#x.\n",
media );
388 break;
389 case 0x2627:
390 chipname = "PCnet/FAST III 79C975";
391 fdx = 1;
393 break;
394 case 0x2628:
395 chipname = "PCnet/PRO 79C976";
396 fdx = 1;
398 break;
399 default:
400 chipname = "UNKNOWN";
401 DBG (
"PCnet version %#x, no PCnet32 chip.\n", chip_version );
402 goto err_unsupported;
403 }
404
405 DBG (
"PCnet chipname %s\n", chipname );
406
407
408
409
410
411
412
413
414 if (fset) {
418 }
419
420 priv->full_duplex = fdx;
422
423 return 0;
424
425err_unsupported:
427}
struct arbelprm_rc_send_wqe rc
#define ENODEV
No such device.
static struct mii_phy mii
void(* write_csr)(unsigned long, int, u16)
u16(* read_csr)(unsigned long, int)
void(* write_bcr)(unsigned long, int, u16)
u16(* read_bcr)(unsigned long, int)
References DBG, ENODEV, ioaddr, media, mii, priv, rc, pcnet32_access::read_bcr, pcnet32_access::read_csr, pcnet32_access::write_bcr, and pcnet32_access::write_csr.
Referenced by pcnet32_probe().
pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses
- Parameters
-
| priv | Driver private structure |
Definition at line 549 of file pcnet32.c.
550{
551 int i;
554
555
556
557
558
559
560
561
562 for ( i = 0; i < 3; i++ ) {
565
566 priv->netdev->hw_addr[2 * i] =
val & 0x0ff;
567 priv->netdev->hw_addr[2 * i + 1] = (
val >> 8 ) & 0x0ff;
568 }
569
572
576 DBG (
"CSR address is invalid, using PROM addr\n" );
578 }
579 }
580
581
584
585 return 0;
586}
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
#define EADDRNOTAVAIL
Address not available.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
References DBG, EADDRNOTAVAIL, ETH_ALEN, inb, ioaddr, is_valid_ether_addr(), memcmp(), memcpy(), priv, u8, and val.
Referenced by pcnet32_probe().
pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode
- Parameters
-
| priv | Driver private structure |
Definition at line 594 of file pcnet32.c.
595{
598
599
604
605
606 if (
priv->full_duplex ) {
613
614 if (
priv->chip_version == 0x2627 )
616 }
618 }
619
620
625
626
627 u16 subsys_vend_id, subsys_dev_id;
630 &subsys_vend_id );
633 &subsys_dev_id );
638 }
639
641
649
650 if ( (
priv->chip_version != 0x2420 ) &&
651 (
priv->chip_version != 0x2621 ) ) {
652
656 }
657 }
658}
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
#define PCI_SUBSYSTEM_ID
PCI subsystem ID.
#define PCI_SUBSYSTEM_VENDOR_ID
PCI subsystem vendor ID.
#define PCI_SUBDEVICE_ID_AT_2701FX
#define PCNET32_PORT_ASEL
#define PCI_SUBDEVICE_ID_AT_2700FX
#define PCNET32_PORT_GPSI
References ioaddr, pci_read_config_word(), PCI_SUBDEVICE_ID_AT_2700FX, PCI_SUBDEVICE_ID_AT_2701FX, PCI_SUBSYSTEM_ID, PCI_SUBSYSTEM_VENDOR_ID, PCI_VENDOR_ID_AT, PCNET32_PORT_100, PCNET32_PORT_ASEL, PCNET32_PORT_AUI, PCNET32_PORT_FD, PCNET32_PORT_GPSI, PCNET32_PORT_PORTSEL, priv, u16, and val.
Referenced by pcnet32_open().
open - Called when a network interface is made active
- Parameters
-
- Return values
-
| rc | Return status code, 0 on success, negative value on failure |
Definition at line 691 of file pcnet32.c.
692{
697
698
700 DBG (
"Error setting up TX resources\n" );
701 goto err_setup_tx;
702 }
703
705 DBG (
"Error setting up RX resources\n" );
706 goto err_setup_rx;
707 }
708
709
711
712
714
715
717
718
722
723
725
726
731
732
734
736
737 return 0;
738
739err_setup_rx:
741err_setup_tx:
742 priv->a->reset(
priv->pci_dev->ioaddr );
744}
static int pcnet32_setup_rx_resources(struct pcnet32_private *priv)
pcnet32_setup_rx_resources - allocate Rx resources (Descriptors)
static void pcnet32_hw_start(struct pcnet32_private *priv)
pcnet32_hw_start - Starts up the NIC
static void pcnet32_free_tx_resources(struct pcnet32_private *priv)
static void pcnet32_setup_init_block(struct pcnet32_private *priv)
pcnet32_setup_init_block - setup the NICs initialization block
static int pcnet32_setup_tx_resources(struct pcnet32_private *priv)
pcnet32_setup_tx_resources - allocate Tx resources (Descriptors)
static void pcnet32_setup_if_duplex(struct pcnet32_private *priv)
pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode
#define PCNET32_SWSTYLE_PCNET32
References BablMask, DBG, InitDoneMask, ioaddr, MissFrameMask, netdev, pcnet32_free_tx_resources(), pcnet32_hw_start(), pcnet32_setup_if_duplex(), pcnet32_setup_init_block(), pcnet32_setup_rx_resources(), pcnet32_setup_tx_resources(), PCNET32_SWSTYLE_PCNET32, priv, rc, RxIntMask, TxIntMask, u16, val, and virt_to_bus().
transmit - Transmit a packet
- Parameters
-
| netdev | Network device |
| iobuf | I/O buffer |
- Return values
-
| rc | Returns 0 on success, negative on failure |
Definition at line 755 of file pcnet32.c.
756{
761
762 DBGP (
"pcnet32_transmit\n" );
763
765 DBG (
"Tx overflow\n" );
767 }
768
769 priv->tx_iobuf[
priv->tx_curr] = iobuf;
770
771 tx_curr_desc =
priv->tx_base +
priv->tx_curr;
772
773
775 tx_curr_desc->
misc = 0x00000000;
777
778
782
783
786
787
789
790
792
793 return 0;
794}
#define ENOTSUP
Operation not supported.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
void * data
Start of data.
References pcnet32_tx_desc::base, cpu_to_le16, cpu_to_le32, io_buffer::data, DBG, DBGP, DescOwn, EndOfPacket, ENOTSUP, IntEnable, ioaddr, iob_len(), pcnet32_tx_desc::length, pcnet32_tx_desc::misc, netdev, priv, StartOfPacket, pcnet32_tx_desc::status, TX_RING_SIZE, TxDemand, virt_to_bus(), and wmb.
| void pcnet32_process_tx_packets |
( |
struct net_device * | netdev | ) |
|
|
static |
pcnet32_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_complete()
- Parameters
-
Definition at line 803 of file pcnet32.c.
804{
807
808 DBGP (
"pcnet32_process_tx_packets\n" );
809
810 while (
priv->tx_tail !=
priv->tx_curr ) {
811 tx_curr_desc =
priv->tx_base +
priv->tx_tail;
812
814
815 DBG (
"Before OWN bit check, status: %#08x\n",
status );
816
817
819 break;
820
821 DBG (
"Transmitted packet.\n" );
822 DBG (
"priv->tx_fill_ctr= %d\n",
priv->tx_fill_ctr );
823 DBG (
"priv->tx_tail = %d\n",
priv->tx_tail );
824 DBG (
"priv->tx_curr = %d\n",
priv->tx_curr );
826
827
829
830
831 memset ( tx_curr_desc, 0,
sizeof(*tx_curr_desc) );
832
833
835
836
838 }
839}
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
References DBG, DBGP, DescOwn, le16_to_cpu, memset(), netdev, netdev_tx_complete(), priv, pcnet32_tx_desc::status, status, TX_RING_SIZE, u16, and virt_to_bus().
Referenced by pcnet32_poll().
| void pcnet32_process_rx_packets |
( |
struct net_device * | netdev | ) |
|
|
static |
pcnet32_process_rx_packets - Checks for received packets, reports them to iPXE with netdev_rx() or netdev_rx_err() if there was an error receiving the packet
- Parameters
-
Definition at line 849 of file pcnet32.c.
850{
855 int i;
856
857 DBGP (
"pcnet32_process_rx_packets\n" );
858
860 rx_curr_desc =
priv->rx_base +
priv->rx_curr;
861
864
865 DBG (
"Before OWN bit check, status: %#08x\n",
status );
866
867
869 break;
870
871
873 break;
874
875 DBG (
"Received packet.\n" );
876 DBG (
"priv->rx_curr = %d\n",
priv->rx_curr );
877 DBG (
"rx_len = %d\n",
879 DBG (
"rx_curr_desc = %#08lx\n",
881
882
886 DBG (
"Corrupted packet received!\n");
887 } else {
888
891
892
894 }
895
896
898 memset ( rx_curr_desc, 0,
sizeof(*rx_curr_desc) );
899
900
902 }
903
904
906}
#define EINVAL
Invalid argument.
#define le32_to_cpu(value)
#define iob_put(iobuf, len)
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
References DBG, DBGP, DescOwn, EINVAL, iob_put, le16_to_cpu, le32_to_cpu, len, memset(), pcnet32_rx_desc::msg_length, netdev, netdev_rx(), netdev_rx_err(), NULL, pcnet32_refill_rx_ring(), priv, rmb, RX_RING_SIZE, pcnet32_rx_desc::status, status, u16, u32, and virt_to_bus().
Referenced by pcnet32_poll().
probe - Initial configuration of NIC
- Parameters
-
| pdev | PCI device |
| ent | PCI IDs |
- Return values
-
Definition at line 1037 of file pcnet32.c.
1038{
1043
1044 DBGP (
"pcnet32_probe\n" );
1045
1046 DBG (
"Found %s, vendor = %#04x, device = %#04x\n",
1048
1049
1053 goto err_alloc_etherdev;
1054 }
1055
1056
1058
1059
1062
1063
1065
1066
1067 priv->pci_dev = pdev;
1069
1071
1072
1073 priv->irq_enabled = 0;
1074
1075
1077
1079 DBG (
"Setting driver operations failed\n");
1080 goto err_set_ops;
1081 }
1082
1084 DBG (
"pcnet32_chip_detect failed\n" );
1085 goto err_chip_detect;
1086 }
1087
1088
1090
1091
1093 DBG (
"Setting MAC address failed\n" );
1094 goto err_mac_addr;
1095 }
1096
1097 DBG (
"IO Addr 0x%lX, MAC Addr %s\n",
ioaddr,
1099
1101
1102
1103 if (
netdev->hw_addr[0] == 0x00 &&
1104 netdev->hw_addr[1] == 0xE0 &&
1105 netdev->hw_addr[2] == 0x75 )
1107
1108
1110
1112 DBG (
"Error registering netdev\n" );
1113 goto err_register;
1114 }
1115
1117
1118 return 0;
1119
1120err_register:
1122err_chip_detect:
1123err_set_ops:
1124err_alloc_etherdev:
1125err_mac_addr:
1127}
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
int register_netdev(struct net_device *netdev)
Register network device.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
static int pcnet32_set_ops(struct pcnet32_private *priv)
pcnet32_set_ops - Determines the ops used to access the registers
static struct net_device_operations pcnet32_operations
static void pcnet32_setup_probe_phy(struct pcnet32_private *priv)
pcnet32_setup_probe_phy - go through all PHYs and see which one is present
static int pcnet32_chip_detect(struct pcnet32_private *priv)
static int pcnet32_setup_mac_addr(struct pcnet32_private *priv)
pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses
uint16_t vendor
PCI vendor ID.
uint16_t device
PCI device ID.
unsigned long ioaddr
I/O address.
struct device dev
Generic device.
struct pci_device_id * id
Driver device ID.
References adjust_pci_device(), alloc_etherdev(), DBG, DBGP, pci_device::dev, pci_device_id::device, ENOMEM, eth_ntoa(), pci_device::id, ioaddr, pci_device::ioaddr, pci_device_id::name, netdev, netdev_init(), netdev_link_up(), netdev_put(), pci_set_drvdata(), pcnet32_chip_detect(), pcnet32_operations, PCNET32_PORT_ASEL, PCNET32_PORT_FD, PCNET32_PORT_GPSI, pcnet32_set_ops(), pcnet32_setup_mac_addr(), pcnet32_setup_probe_phy(), pcnet32_wio_reset(), priv, rc, register_netdev(), and pci_device_id::vendor.