iPXE
Functions | Variables
pcnet32.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <byteswap.h>
#include <errno.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/io.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/netdevice.h>
#include <ipxe/pci.h>
#include <ipxe/timer.h>
#include <mii.h>
#include "pcnet32.h"

Go to the source code of this file.

Functions

 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 More...
 
static int pcnet32_setup_rx_resources (struct pcnet32_private *priv)
 pcnet32_setup_rx_resources - allocate Rx resources (Descriptors) More...
 
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) More...
 
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 More...
 
static void pcnet32_setup_init_block (struct pcnet32_private *priv)
 pcnet32_setup_init_block - setup the NICs initialization block More...
 
static void pcnet32_setup_probe_phy (struct pcnet32_private *priv)
 pcnet32_setup_probe_phy - go through all PHYs and see which one is present More...
 
static int pcnet32_setup_mac_addr (struct pcnet32_private *priv)
 pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses More...
 
static void pcnet32_setup_if_duplex (struct pcnet32_private *priv)
 pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode More...
 
static void pcnet32_hw_start (struct pcnet32_private *priv)
 pcnet32_hw_start - Starts up the NIC More...
 
static int pcnet32_open (struct net_device *netdev)
 open - Called when a network interface is made active More...
 
static int pcnet32_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 transmit - Transmit a packet More...
 
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() More...
 
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 More...
 
static void pcnet32_poll (struct net_device *netdev)
 poll - Poll for received packets More...
 
static void pcnet32_close (struct net_device *netdev)
 close - Disable network interface More...
 
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 More...
 
static int pcnet32_probe (struct pci_device *pdev)
 probe - Initial configuration of NIC More...
 
static void pcnet32_remove (struct pci_device *pdev)
 remove - Device Removal Routine More...
 

Variables

static struct pcnet32_access pcnet32_wio
 
static struct pcnet32_access pcnet32_dwio
 
static struct net_device_operations pcnet32_operations
 
static struct pci_device_id pcnet32_nics []
 
struct pci_driver pcnet32_driver __pci_driver
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ pcnet32_wio_read_csr()

static u16 pcnet32_wio_read_csr ( unsigned long  addr,
int  index 
)
static

Definition at line 42 of file pcnet32.c.

43 {
45  return inw ( addr + PCNET32_WIO_RDP );
46 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
u32 addr
Definition: sky2.h:8
#define PCNET32_WIO_RDP
Definition: pcnet32.h:53
#define PCNET32_WIO_RAP
Definition: pcnet32.h:54
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, inw(), outw, PCNET32_WIO_RAP, and PCNET32_WIO_RDP.

Referenced by pcnet32_set_ops().

◆ pcnet32_wio_write_csr()

static void pcnet32_wio_write_csr ( unsigned long  addr,
int  index,
u16  val 
)
static

Definition at line 48 of file pcnet32.c.

49 {
52 }
#define outw(data, io_addr)
Definition: io.h:319
u32 addr
Definition: sky2.h:8
#define PCNET32_WIO_RDP
Definition: pcnet32.h:53
void __asmcall int val
Definition: setjmp.h:28
#define PCNET32_WIO_RAP
Definition: pcnet32.h:54
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, outw, PCNET32_WIO_RAP, PCNET32_WIO_RDP, and val.

◆ pcnet32_wio_read_bcr()

static u16 pcnet32_wio_read_bcr ( unsigned long  addr,
int  index 
)
static

Definition at line 54 of file pcnet32.c.

55 {
57  return inw ( addr + PCNET32_WIO_BDP );
58 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
#define PCNET32_WIO_BDP
Definition: pcnet32.h:56
u32 addr
Definition: sky2.h:8
#define PCNET32_WIO_RAP
Definition: pcnet32.h:54
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, inw(), outw, PCNET32_WIO_BDP, and PCNET32_WIO_RAP.

◆ pcnet32_wio_write_bcr()

static void pcnet32_wio_write_bcr ( unsigned long  addr,
int  index,
u16  val 
)
static

Definition at line 60 of file pcnet32.c.

61 {
64 }
#define outw(data, io_addr)
Definition: io.h:319
#define PCNET32_WIO_BDP
Definition: pcnet32.h:56
u32 addr
Definition: sky2.h:8
void __asmcall int val
Definition: setjmp.h:28
#define PCNET32_WIO_RAP
Definition: pcnet32.h:54
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, outw, PCNET32_WIO_BDP, PCNET32_WIO_RAP, and val.

◆ pcnet32_wio_read_rap()

static u16 pcnet32_wio_read_rap ( unsigned long  addr)
static

Definition at line 66 of file pcnet32.c.

67 {
68  return inw ( addr + PCNET32_WIO_RAP );
69 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
u32 addr
Definition: sky2.h:8
#define PCNET32_WIO_RAP
Definition: pcnet32.h:54

References addr, inw(), and PCNET32_WIO_RAP.

◆ pcnet32_wio_write_rap()

static void pcnet32_wio_write_rap ( unsigned long  addr,
u16  val 
)
static

Definition at line 71 of file pcnet32.c.

72 {
74 }
#define outw(data, io_addr)
Definition: io.h:319
u32 addr
Definition: sky2.h:8
void __asmcall int val
Definition: setjmp.h:28
#define PCNET32_WIO_RAP
Definition: pcnet32.h:54

References addr, outw, PCNET32_WIO_RAP, and val.

◆ pcnet32_wio_reset()

static void pcnet32_wio_reset ( unsigned long  addr)
static

Definition at line 76 of file pcnet32.c.

77 {
79 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define PCNET32_WIO_RESET
Definition: pcnet32.h:55
u32 addr
Definition: sky2.h:8

References addr, inw(), and PCNET32_WIO_RESET.

Referenced by pcnet32_close(), pcnet32_probe(), and pcnet32_remove().

◆ pcnet32_wio_check()

static int pcnet32_wio_check ( unsigned long  addr)
static

Definition at line 81 of file pcnet32.c.

82 {
83  outw ( 88, addr + PCNET32_WIO_RAP );
84  return ( inw ( addr + PCNET32_WIO_RAP ) == 88 );
85 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
u32 addr
Definition: sky2.h:8
#define PCNET32_WIO_RAP
Definition: pcnet32.h:54

References addr, inw(), outw, and PCNET32_WIO_RAP.

Referenced by pcnet32_set_ops().

◆ pcnet32_dwio_read_csr()

static u16 pcnet32_dwio_read_csr ( unsigned long  addr,
int  index 
)
static

Definition at line 97 of file pcnet32.c.

98 {
100  return ( inl ( addr + PCNET32_DWIO_RDP ) & 0xffff );
101 }
#define PCNET32_DWIO_RAP
Definition: pcnet32.h:59
#define outl(data, io_addr)
Definition: io.h:329
u32 addr
Definition: sky2.h:8
#define PCNET32_DWIO_RDP
Definition: pcnet32.h:58
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, inl(), outl, PCNET32_DWIO_RAP, and PCNET32_DWIO_RDP.

Referenced by pcnet32_set_ops().

◆ pcnet32_dwio_write_csr()

static void pcnet32_dwio_write_csr ( unsigned long  addr,
int  index,
u16  val 
)
static

Definition at line 103 of file pcnet32.c.

104 {
106  outl ( val, addr + PCNET32_DWIO_RDP );
107 }
#define PCNET32_DWIO_RAP
Definition: pcnet32.h:59
#define outl(data, io_addr)
Definition: io.h:329
u32 addr
Definition: sky2.h:8
void __asmcall int val
Definition: setjmp.h:28
#define PCNET32_DWIO_RDP
Definition: pcnet32.h:58
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, outl, PCNET32_DWIO_RAP, PCNET32_DWIO_RDP, and val.

◆ pcnet32_dwio_read_bcr()

static u16 pcnet32_dwio_read_bcr ( unsigned long  addr,
int  index 
)
static

Definition at line 109 of file pcnet32.c.

110 {
112  return ( inl ( addr + PCNET32_DWIO_BDP ) & 0xffff );
113 }
#define PCNET32_DWIO_RAP
Definition: pcnet32.h:59
#define PCNET32_DWIO_BDP
Definition: pcnet32.h:61
#define outl(data, io_addr)
Definition: io.h:329
u32 addr
Definition: sky2.h:8
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, inl(), outl, PCNET32_DWIO_BDP, and PCNET32_DWIO_RAP.

◆ pcnet32_dwio_write_bcr()

static void pcnet32_dwio_write_bcr ( unsigned long  addr,
int  index,
u16  val 
)
static

Definition at line 115 of file pcnet32.c.

116 {
118  outl ( val, addr + PCNET32_DWIO_BDP );
119 }
#define PCNET32_DWIO_RAP
Definition: pcnet32.h:59
#define PCNET32_DWIO_BDP
Definition: pcnet32.h:61
#define outl(data, io_addr)
Definition: io.h:329
u32 addr
Definition: sky2.h:8
void __asmcall int val
Definition: setjmp.h:28
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References addr, index, outl, PCNET32_DWIO_BDP, PCNET32_DWIO_RAP, and val.

◆ pcnet32_dwio_read_rap()

static u16 pcnet32_dwio_read_rap ( unsigned long  addr)
static

Definition at line 121 of file pcnet32.c.

122 {
123  return ( inl ( addr + PCNET32_DWIO_RAP ) & 0xffff );
124 }
#define PCNET32_DWIO_RAP
Definition: pcnet32.h:59
u32 addr
Definition: sky2.h:8
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.

References addr, inl(), and PCNET32_DWIO_RAP.

◆ pcnet32_dwio_write_rap()

static void pcnet32_dwio_write_rap ( unsigned long  addr,
u16  val 
)
static

Definition at line 126 of file pcnet32.c.

127 {
128  outl ( val, addr + PCNET32_DWIO_RAP );
129 }
#define PCNET32_DWIO_RAP
Definition: pcnet32.h:59
#define outl(data, io_addr)
Definition: io.h:329
u32 addr
Definition: sky2.h:8
void __asmcall int val
Definition: setjmp.h:28

References addr, outl, PCNET32_DWIO_RAP, and val.

◆ pcnet32_dwio_reset()

static void pcnet32_dwio_reset ( unsigned long  addr)
static

Definition at line 131 of file pcnet32.c.

132 {
134 }
#define PCNET32_DWIO_RESET
Definition: pcnet32.h:60
u32 addr
Definition: sky2.h:8
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.

References addr, inl(), and PCNET32_DWIO_RESET.

Referenced by pcnet32_set_ops().

◆ pcnet32_dwio_check()

static int pcnet32_dwio_check ( unsigned long  addr)
static

Definition at line 136 of file pcnet32.c.

137 {
138  outl ( 88, addr + PCNET32_DWIO_RAP );
139  return ( ( inl ( addr + PCNET32_DWIO_RAP ) & 0xffff ) == 88 );
140 }
#define PCNET32_DWIO_RAP
Definition: pcnet32.h:59
#define outl(data, io_addr)
Definition: io.h:329
u32 addr
Definition: sky2.h:8
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.

References addr, inl(), outl, and PCNET32_DWIO_RAP.

Referenced by pcnet32_set_ops().

◆ pcnet32_mdio_read()

static int pcnet32_mdio_read ( struct net_device netdev,
int  phy,
int  reg 
)
static

Definition at line 154 of file pcnet32.c.

155 {
156  struct pcnet32_private *priv = netdev->priv;
157  unsigned long ioaddr = priv->pci_dev->ioaddr;
158  u16 val_out;
159 
160  if ( ! priv->mii )
161  return 0;
162 
163  /* First, select PHY chip and the register we want to read */
164  priv->a->write_bcr ( ioaddr, 33,
165  ( ( phy & 0x1f ) << 5 ) | ( reg & 0x1f ) );
166 
167  /* Read the selected register's value */
168  val_out = priv->a->read_bcr ( ioaddr, 34 );
169 
170  return val_out;
171 }
uint16_t u16
Definition: stdint.h:21
static unsigned int unsigned int reg
Definition: myson.h:162
static unsigned long ioaddr
Definition: davicom.c:129
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static struct tlan_private * priv
Definition: tlan.c:224

References ioaddr, netdev, priv, net_device::priv, and reg.

Referenced by pcnet32_setup_probe_phy().

◆ pcnet32_mdio_write()

static void __unused pcnet32_mdio_write ( struct net_device netdev,
int  phy,
int  reg,
int  val 
)
static

Definition at line 174 of file pcnet32.c.

175 {
176  struct pcnet32_private *priv = netdev->priv;
177  unsigned long ioaddr = priv->pci_dev->ioaddr;
178 
179  if ( ! priv->mii )
180  return;
181 
182  /* First, select PHY chip and the register we want to write to */
183  priv->a->write_bcr ( ioaddr, 33,
184  ( ( phy & 0x1f ) << 5 ) | ( reg & 0x1f ) );
185 
186  /* Write val to the selected register */
187  priv->a->write_bcr ( ioaddr, 34, val );
188 }
static unsigned int unsigned int reg
Definition: myson.h:162
static unsigned long ioaddr
Definition: davicom.c:129
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
void __asmcall int val
Definition: setjmp.h:28
static struct tlan_private * priv
Definition: tlan.c:224

References ioaddr, netdev, priv, net_device::priv, reg, and val.

◆ pcnet32_refill_rx_ring()

static void pcnet32_refill_rx_ring ( struct pcnet32_private priv)
static

pcnet32_refill_rx_ring - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in use by the hardware

Parameters
privDriver private structure

Definition at line 198 of file pcnet32.c.

199 {
200  struct pcnet32_rx_desc *rx_curr_desc;
201  u16 status;
202  int i;
203 
204  DBGP ( "pcnet32_refill_rx_ring\n" );
205 
206  for ( i = 0; i < RX_RING_SIZE; i++ ) {
207  rx_curr_desc = priv->rx_base + i;
208 
209  status = le16_to_cpu ( rx_curr_desc->status );
210 
211  /* Don't touch descriptors owned by the hardware */
212  if ( status & DescOwn )
213  continue;
214 
215  /* Descriptors with iobufs still need to be processed */
216  if ( priv->rx_iobuf[i] != NULL )
217  continue;
218 
219  /* If alloc_iob fails, try again later (next poll) */
220  if ( ! ( priv->rx_iobuf[i] = alloc_iob ( PKT_BUF_SIZE ) ) ) {
221  DBG ( "Refill rx ring failed\n" );
222  break;
223  }
224 
225  rx_curr_desc->base =
226  cpu_to_le32 ( virt_to_bus ( priv->rx_iobuf[i]->data ) );
227  rx_curr_desc->buf_length = cpu_to_le16 ( -PKT_BUF_SIZE );
228  rx_curr_desc->msg_length = rx_curr_desc->reserved = 0;
229 
230  /* Owner changes after the other status fields are set */
231  wmb();
232  rx_curr_desc->status = cpu_to_le16 ( DescOwn );
233  }
234 
235 }
uint16_t u16
Definition: stdint.h:21
wmb()
#define PKT_BUF_SIZE
Definition: pcnet32.h:46
s16 buf_length
Definition: pcnet32.h:93
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129
uint8_t status
Status.
Definition: ena.h:16
u32 msg_length
Definition: pcnet32.h:95
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define le16_to_cpu(value)
Definition: byteswap.h:112
#define RX_RING_SIZE
Definition: 3c515.c:87
static struct tlan_private * priv
Definition: tlan.c:224
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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, status, pcnet32_rx_desc::status, virt_to_bus(), and wmb().

Referenced by pcnet32_process_rx_packets(), and pcnet32_setup_rx_resources().

◆ pcnet32_setup_rx_resources()

static int pcnet32_setup_rx_resources ( struct pcnet32_private priv)
static

pcnet32_setup_rx_resources - allocate Rx resources (Descriptors)

Parameters
privDriver private structure
Return values
rcReturns 0 on success, negative on failure

Definition at line 245 of file pcnet32.c.

246 {
247  DBGP ( "pcnet32_setup_rx_resources\n" );
248 
250 
251  DBG ( "priv->rx_base = %#08lx\n", virt_to_bus ( priv->rx_base ) );
252 
253  if ( ! priv->rx_base ) {
254  return -ENOMEM;
255  }
256 
257  memset ( priv->rx_base, 0, RX_RING_BYTES );
258 
260 
261  priv->rx_curr = 0;
262 
263  return 0;
264 }
#define RX_RING_BYTES
Definition: eepro100.h:22
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define RX_RING_ALIGN
Definition: 3c90x.h:268
#define DBGP(...)
Definition: compiler.h:532
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 ...
Definition: pcnet32.c:198
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
void * memset(void *dest, int character, size_t len) __nonnull

References DBG, DBGP, ENOMEM, malloc_phys(), memset(), pcnet32_refill_rx_ring(), priv, RX_RING_ALIGN, RX_RING_BYTES, and virt_to_bus().

Referenced by pcnet32_open().

◆ pcnet32_free_rx_resources()

static void pcnet32_free_rx_resources ( struct pcnet32_private priv)
static

Definition at line 267 of file pcnet32.c.

268 {
269  int i;
270 
271  DBGP ( "pcnet32_free_rx_resources\n" );
272 
273  free_phys ( priv->rx_base, RX_RING_BYTES );
274 
275  for ( i = 0; i < RX_RING_SIZE; i++ ) {
276  free_iob ( priv->rx_iobuf[i] );
277  priv->rx_iobuf[i] = NULL;
278  }
279 }
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define RX_RING_BYTES
Definition: eepro100.h:22
#define DBGP(...)
Definition: compiler.h:532
#define RX_RING_SIZE
Definition: 3c515.c:87
static struct tlan_private * priv
Definition: tlan.c:224
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References DBGP, free_iob(), free_phys(), NULL, priv, RX_RING_BYTES, and RX_RING_SIZE.

Referenced by pcnet32_close().

◆ pcnet32_setup_tx_resources()

static int pcnet32_setup_tx_resources ( struct pcnet32_private priv)
static

pcnet32_setup_tx_resources - allocate Tx resources (Descriptors)

Parameters
privDriver private structure
Return values
rcReturns 0 on success, negative on failure

Definition at line 289 of file pcnet32.c.

290 {
291  DBGP ( "pcnet32_setup_tx_resources\n" );
292 
294 
295  if ( ! priv->tx_base ) {
296  return -ENOMEM;
297  }
298 
299  memset ( priv->tx_base, 0, TX_RING_BYTES );
300 
301  DBG ( "priv->tx_base = %#08lx\n", virt_to_bus ( priv->tx_base ) );
302 
303  priv->tx_curr = 0;
304  priv->tx_fill_ctr = 0;
305  priv->tx_tail = 0;
306 
307  return 0;
308 }
#define TX_RING_BYTES
Definition: eepro100.h:23
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
#define TX_RING_ALIGN
Definition: 3c90x.h:267
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
void * memset(void *dest, int character, size_t len) __nonnull

References DBG, DBGP, ENOMEM, malloc_phys(), memset(), priv, TX_RING_ALIGN, TX_RING_BYTES, and virt_to_bus().

Referenced by pcnet32_open().

◆ pcnet32_free_tx_resources()

static void pcnet32_free_tx_resources ( struct pcnet32_private priv)
static

Definition at line 311 of file pcnet32.c.

312 {
313  DBGP ( "pcnet32_free_tx_resources\n" );
314 
315  free_phys ( priv->tx_base, TX_RING_BYTES );
316 }
#define TX_RING_BYTES
Definition: eepro100.h:23
#define DBGP(...)
Definition: compiler.h:532
static struct tlan_private * priv
Definition: tlan.c:224
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77

References DBGP, free_phys(), priv, and TX_RING_BYTES.

Referenced by pcnet32_close(), and pcnet32_open().

◆ pcnet32_chip_detect()

static int pcnet32_chip_detect ( struct pcnet32_private priv)
static

Definition at line 319 of file pcnet32.c.

320 {
321  int fdx, mii, fset;
322  int media;
323  int rc;
324  unsigned long ioaddr;
325  struct pcnet32_access *a;
326  int chip_version;
327  char *chipname;
328 
329  ioaddr = priv->pci_dev->ioaddr;
330  a = priv->a;
331 
332  chip_version = a->read_csr ( ioaddr, 88 )
333  | ( a->read_csr ( ioaddr, 89 ) << 16 );
334 
335  rc = -ENODEV;
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  /* 970 gives the wrong chip id back */
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;
359  mii = 1;
360  fset = 1;
361  break;
362  case 0x2624:
363  chipname = "PCnet/FAST+ 79C972";
364  fdx = 1;
365  mii = 1;
366  fset = 1;
367  break;
368  case 0x2625:
369  chipname = "PCnet/FAST III 79C973";
370  fdx = 1;
371  mii = 1;
372  break;
373  case 0x2626:
374  chipname = "PCnet/Home 79C978";
375  fdx = 1;
376  /*
377  * This is based on specs published at www.amd.com. This section
378  * assumes that a NIC with a 79C978 wants to go into 1Mb HomePNA
379  * mode. The 79C978 can also go into standard ethernet, and
380  * there probably should be some sort of module option to select
381  * the mode by which the card should operate
382  */
383  /* switch to home wiring mode */
384  media = a->read_bcr(ioaddr, 49);
385 
386  DBG ( "media reset to %#x.\n", media );
387  a->write_bcr(ioaddr, 49, media);
388  break;
389  case 0x2627:
390  chipname = "PCnet/FAST III 79C975";
391  fdx = 1;
392  mii = 1;
393  break;
394  case 0x2628:
395  chipname = "PCnet/PRO 79C976";
396  fdx = 1;
397  mii = 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  * On selected chips turn on the BCR18:NOUFLO bit. This stops transmit
409  * starting until the packet is loaded. Strike one for reliability, lose
410  * one for latency - although on PCI this isn't a big loss. Older chips
411  * have FIFO's smaller than a packet, so you can't do this.
412  * Turn on BCR18:BurstRdEn and BCR18:BurstWrEn.
413  */
414  if (fset) {
415  a->write_bcr ( ioaddr, 18,
416  ( a->read_bcr ( ioaddr, 18 ) | 0x0860 ) );
417  a->write_csr ( ioaddr, 80, 0x0c00 );
418  }
419 
420  priv->full_duplex = fdx;
421  priv->mii = mii;
422 
423  return 0;
424 
425 err_unsupported:
426  return rc;
427 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static struct mii_phy mii
uint32_t a
Definition: md4.c:28
static unsigned long ioaddr
Definition: davicom.c:129
#define ENODEV
No such device.
Definition: errno.h:509
static struct tlan_private * priv
Definition: tlan.c:224
static char media[]
Definition: sundance.c:85
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References a, DBG, ENODEV, ioaddr, media, mii, priv, and rc.

Referenced by pcnet32_probe().

◆ pcnet32_set_ops()

static int pcnet32_set_ops ( struct pcnet32_private priv)
static

pcnet32_set_ops - Determines the ops used to access the registers

Parameters
privDriver private structure
Return values
rcReturns 0 on success, negative on failure

Definition at line 437 of file pcnet32.c.

438 {
439  int rc;
440  unsigned long ioaddr;
441 
442  ioaddr = priv->pci_dev->ioaddr;
443 
444  /* Check if CSR0 has its default value and perform a write / read
445  in the RAP register to see if it works. Based on these results
446  determine what mode the NIC is in (WIO / DWIO)
447  */
448  rc = -ENODEV;
449 
450  if ( pcnet32_wio_read_csr ( ioaddr, 0 ) == 4 &&
451  pcnet32_wio_check ( ioaddr ) ) {
452  priv->a = &pcnet32_wio;
453  } else {
455  if ( pcnet32_dwio_read_csr ( ioaddr, 0 ) == 4 &&
456  pcnet32_dwio_check ( ioaddr ) ) {
457  priv->a = &pcnet32_dwio;
458  } else {
459  goto err_unsupported;
460  }
461  }
462 
463  return 0;
464 
465 err_unsupported:
466  return rc;
467 }
static struct pcnet32_access pcnet32_dwio
Definition: pcnet32.c:143
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static u16 pcnet32_wio_read_csr(unsigned long addr, int index)
Definition: pcnet32.c:42
static u16 pcnet32_dwio_read_csr(unsigned long addr, int index)
Definition: pcnet32.c:97
static unsigned long ioaddr
Definition: davicom.c:129
static int pcnet32_dwio_check(unsigned long addr)
Definition: pcnet32.c:136
static struct pcnet32_access pcnet32_wio
Definition: pcnet32.c:87
#define ENODEV
No such device.
Definition: errno.h:509
static struct tlan_private * priv
Definition: tlan.c:224
static void pcnet32_dwio_reset(unsigned long addr)
Definition: pcnet32.c:131
static int pcnet32_wio_check(unsigned long addr)
Definition: pcnet32.c:81

References ENODEV, ioaddr, pcnet32_dwio, pcnet32_dwio_check(), pcnet32_dwio_read_csr(), pcnet32_dwio_reset(), pcnet32_wio, pcnet32_wio_check(), pcnet32_wio_read_csr(), priv, and rc.

Referenced by pcnet32_probe().

◆ pcnet32_setup_init_block()

static void pcnet32_setup_init_block ( struct pcnet32_private priv)
static

pcnet32_setup_init_block - setup the NICs initialization block

Parameters
privDriver private structure
Return values
rcReturns 0 on success, negative on failure

Definition at line 477 of file pcnet32.c.

478 {
479  int i;
480 
481  /* Configure the network port based on what we've established so far */
482  priv->init_block.mode =
483  cpu_to_le16 ( ( priv->options & PCNET32_PORT_PORTSEL ) << 7 );
484 
485  /* Setup RLEN and TLEN fields */
486  priv->init_block.tlen_rlen =
488  ( PCNET32_LOG_TX_BUFFERS << 12 ) );
489 
490  /* Fill in physical address */
491  for ( i = 0; i < ETH_ALEN; i++)
492  priv->init_block.phys_addr[i] = priv->netdev->hw_addr[i];
493 
494  /* No multicasting scheme, accept everything */
495  priv->init_block.filter[0] = 0xffffffff;
496  priv->init_block.filter[1] = 0xffffffff;
497 
498  priv->init_block.rx_ring =
499  cpu_to_le32 ( virt_to_bus ( priv->rx_base ) );
500  priv->init_block.tx_ring =
501  cpu_to_le32 ( virt_to_bus ( priv->tx_base ) );
502 
503  /* Make sure all changes are visible */
504  wmb();
505 }
wmb()
#define PCNET32_LOG_RX_BUFFERS
Definition: pcnet32.h:31
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define PCNET32_LOG_TX_BUFFERS
Definition: pcnet32.h:30
#define ETH_ALEN
Definition: if_ether.h:8
#define PCNET32_PORT_PORTSEL
Definition: pcnet32.h:68
static struct tlan_private * priv
Definition: tlan.c:224
#define cpu_to_le16(value)
Definition: byteswap.h:106

References cpu_to_le16, cpu_to_le32, ETH_ALEN, PCNET32_LOG_RX_BUFFERS, PCNET32_LOG_TX_BUFFERS, PCNET32_PORT_PORTSEL, priv, virt_to_bus(), and wmb().

Referenced by pcnet32_open().

◆ pcnet32_setup_probe_phy()

static void pcnet32_setup_probe_phy ( struct pcnet32_private priv)
static

pcnet32_setup_probe_phy - go through all PHYs and see which one is present

Parameters
privDriver private structure

Definition at line 513 of file pcnet32.c.

514 {
515  unsigned long ioaddr = priv->pci_dev->ioaddr;
516  unsigned int phycount = 0;
517  int phy_id;
518  int i;
519 
520  if ( priv->mii ) {
521  phy_id = ( ( priv->a->read_bcr ( ioaddr, 33 ) ) >> 5 ) & 0x1f;
522  for ( i = 0; i < PCNET32_MAX_PHYS; i++ ) {
523  unsigned short id1, id2;
524  id1 = pcnet32_mdio_read ( priv->netdev, i, MII_PHYSID1 );
525  if ( id1 == 0xffff )
526  continue;
527  id2 = pcnet32_mdio_read ( priv->netdev, i, MII_PHYSID2 );
528  if ( id2 == 0xffff )
529  continue;
530  if ( i == 31 && ( ( priv->chip_version + 1 ) & 0xfffe ) == 0x2624 )
531  continue;
532 
533  phycount++;
534  phy_id = i;
535  }
536  priv->a->write_bcr ( ioaddr, 33, phy_id << 5 );
537  if ( phycount > 1 )
538  priv->options |= PCNET32_PORT_MII;
539  }
540 }
static int pcnet32_mdio_read(struct net_device *netdev, int phy, int reg)
Definition: pcnet32.c:154
#define PCNET32_MAX_PHYS
Definition: pcnet32.h:77
static unsigned long ioaddr
Definition: davicom.c:129
#define PCNET32_PORT_MII
Definition: pcnet32.h:66
static struct tlan_private * priv
Definition: tlan.c:224
#define MII_PHYSID2
Definition: atl1e.h:874
#define MII_PHYSID1
Definition: atl1e.h:873

References ioaddr, MII_PHYSID1, MII_PHYSID2, PCNET32_MAX_PHYS, pcnet32_mdio_read(), PCNET32_PORT_MII, and priv.

Referenced by pcnet32_probe().

◆ pcnet32_setup_mac_addr()

static int pcnet32_setup_mac_addr ( struct pcnet32_private priv)
static

pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses

Parameters
privDriver private structure

Definition at line 549 of file pcnet32.c.

550 {
551  int i;
552  u8 promaddr[ETH_ALEN];
553  unsigned long ioaddr = priv->pci_dev->ioaddr;
554 
555  /* In most chips, after a chip reset, the ethernet address is read from
556  * the station address PROM at the base address and programmed into the
557  * "Physical Address Registers" CSR12-14.
558  * As a precautionary measure, we read the PROM values and complain if
559  * they disagree with the CSRs. If they miscompare, and the PROM addr
560  * is valid, then the PROM addr is used.
561  */
562  for ( i = 0; i < 3; i++ ) {
563  unsigned int val;
564  val = priv->a->read_csr ( ioaddr, i + 12 ) & 0x0ffff;
565  /* There may be endianness issues here. */
566  priv->netdev->hw_addr[2 * i] = val & 0x0ff;
567  priv->netdev->hw_addr[2 * i + 1] = ( val >> 8 ) & 0x0ff;
568  }
569 
570  for ( i = 0; i < ETH_ALEN; i++ )
571  promaddr[i] = inb ( ioaddr + i );
572 
573  if ( memcmp ( promaddr, priv->netdev->hw_addr, ETH_ALEN ) ||
574  ! is_valid_ether_addr ( priv->netdev->hw_addr ) ) {
575  if ( is_valid_ether_addr ( promaddr ) ) {
576  DBG ( "CSR address is invalid, using PROM addr\n" );
577  memcpy ( priv->netdev->hw_addr, promaddr, ETH_ALEN );
578  }
579  }
580 
581  /* If ethernet address is not valid, return error */
582  if ( ! is_valid_ether_addr ( priv->netdev->hw_addr ) )
583  return -EADDRNOTAVAIL;
584 
585  return 0;
586 }
static unsigned long ioaddr
Definition: davicom.c:129
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
#define ETH_ALEN
Definition: if_ether.h:8
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
void __asmcall int val
Definition: setjmp.h:28
#define EADDRNOTAVAIL
Address not available.
Definition: errno.h:308
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
uint8_t u8
Definition: stdint.h:19

References DBG, EADDRNOTAVAIL, ETH_ALEN, inb(), ioaddr, is_valid_ether_addr(), memcmp(), memcpy(), priv, and val.

Referenced by pcnet32_probe().

◆ pcnet32_setup_if_duplex()

static void pcnet32_setup_if_duplex ( struct pcnet32_private priv)
static

pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode

Parameters
privDriver private structure

Definition at line 594 of file pcnet32.c.

595 {
596  unsigned long ioaddr = priv->pci_dev->ioaddr;
597  u16 val;
598 
599  /* Set/Reset autoselect bit */
600  val = priv->a->read_bcr ( ioaddr, 2 ) & ~2;
601  if ( priv->options & PCNET32_PORT_ASEL )
602  val |= 2;
603  priv->a->write_bcr ( ioaddr, 2, val );
604 
605  /* Handle full duplex setting */
606  if ( priv->full_duplex ) {
607  val = priv->a->read_bcr ( ioaddr, 9 ) & ~3;
608  if ( priv->options & PCNET32_PORT_FD ) {
609  val |= 1;
610  if ( priv->options == ( PCNET32_PORT_FD | PCNET32_PORT_AUI ) )
611  val |= 2;
612  } else if ( priv->options & PCNET32_PORT_ASEL ) {
613  /* Workaround of xSeries 250, on for 79C975 only */
614  if ( priv->chip_version == 0x2627 )
615  val |= 3;
616  }
617  priv->a->write_bcr ( ioaddr, 9, val );
618  }
619 
620  /* Set/Reset GPSI bit in test register */
621  val = priv->a->read_csr ( ioaddr, 124 ) & ~0x10;
622  if ( ( priv->options & PCNET32_PORT_PORTSEL ) == PCNET32_PORT_GPSI )
623  val |= 0x10;
624  priv->a->write_bcr ( ioaddr, 124, val );
625 
626  /* Allied Telesyn AT are 100Mbit only and do not negotiate */
627  u16 subsys_vend_id, subsys_dev_id;
628  pci_read_config_word ( priv->pci_dev,
630  &subsys_vend_id );
631  pci_read_config_word ( priv->pci_dev,
633  &subsys_dev_id );
634  if ( subsys_vend_id == PCI_VENDOR_ID_AT &&
635  ( ( subsys_dev_id == PCI_SUBDEVICE_ID_AT_2700FX ) ||
636  ( subsys_dev_id == PCI_SUBDEVICE_ID_AT_2701FX ) ) ) {
638  }
639 
640  if ( priv->mii && ! ( priv->options & PCNET32_PORT_ASEL ) ) {
641  /* Disable Auto Negotiation, set 10Mbps, HD */
642  val = priv->a->read_bcr ( ioaddr, 32 ) & ~0x38;
643  if ( priv->options & PCNET32_PORT_FD )
644  val |= 0x10;
645  if ( priv->options & PCNET32_PORT_100 )
646  val |= 0x08;
647  priv->a->write_bcr ( ioaddr, 32, val );
648  } else if ( priv->options & PCNET32_PORT_ASEL ) {
649  /* 79C970 chips do not have the BCR32 register */
650  if ( ( priv->chip_version != 0x2420 ) &&
651  ( priv->chip_version != 0x2621 ) ) {
652  /* Enable Auto Negotiation, setup, disable FD */
653  val = priv->a->read_bcr ( ioaddr, 32 ) & ~0x98;
654  val |= 0x20;
655  priv->a->write_bcr ( ioaddr, 32, val );
656  }
657  }
658 }
uint16_t u16
Definition: stdint.h:21
#define PCI_SUBDEVICE_ID_AT_2701FX
Definition: pcnet32.h:88
#define PCNET32_PORT_AUI
Definition: pcnet32.h:63
#define PCNET32_PORT_100
Definition: pcnet32.h:70
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.
Definition: pci.h:78
static unsigned long ioaddr
Definition: davicom.c:129
#define PCNET32_PORT_ASEL
Definition: pcnet32.h:69
#define PCI_VENDOR_ID_AT
Definition: pcnet32.h:80
#define PCNET32_PORT_FD
Definition: pcnet32.h:71
void __asmcall int val
Definition: setjmp.h:28
#define PCNET32_PORT_PORTSEL
Definition: pcnet32.h:68
static struct tlan_private * priv
Definition: tlan.c:224
#define PCI_SUBDEVICE_ID_AT_2700FX
Definition: pcnet32.h:84
#define PCI_SUBSYSTEM_VENDOR_ID
PCI subsystem vendor ID.
Definition: pci.h:75
#define PCNET32_PORT_GPSI
Definition: pcnet32.h:65

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, and val.

Referenced by pcnet32_open().

◆ pcnet32_hw_start()

static void pcnet32_hw_start ( struct pcnet32_private priv)
static

pcnet32_hw_start - Starts up the NIC

Parameters
privDriver private structure

Definition at line 666 of file pcnet32.c.

667 {
668  unsigned long ioaddr = priv->pci_dev->ioaddr;
669  int i;
670 
671  /* Begin initialization procedure */
672  priv->a->write_csr ( ioaddr, 0, Init );
673 
674  /* Wait for the initialization to be done */
675  i = 0;
676  while ( i++ < 100 )
677  if ( priv->a->read_csr ( ioaddr, 0 ) & InitDone )
678  break;
679 
680  /* Start the chip */
681  priv->a->write_csr ( ioaddr, 0, Strt );
682 }
Definition: pcnet32.h:168
static unsigned long ioaddr
Definition: davicom.c:129
Definition: pcnet32.h:167
static struct tlan_private * priv
Definition: tlan.c:224

References Init, InitDone, ioaddr, priv, and Strt.

Referenced by pcnet32_open().

◆ pcnet32_open()

static int pcnet32_open ( struct net_device netdev)
static

open - Called when a network interface is made active

Parameters
netdevNetwork device
Return values
rcReturn status code, 0 on success, negative value on failure

Definition at line 691 of file pcnet32.c.

692 {
693  struct pcnet32_private *priv = netdev->priv;
694  unsigned long ioaddr = priv->pci_dev->ioaddr;
695  int rc;
696  u16 val;
697 
698  /* Setup TX and RX descriptors */
699  if ( ( rc = pcnet32_setup_tx_resources ( priv ) ) != 0 ) {
700  DBG ( "Error setting up TX resources\n" );
701  goto err_setup_tx;
702  }
703 
704  if ( ( rc = pcnet32_setup_rx_resources ( priv ) ) != 0 ) {
705  DBG ( "Error setting up RX resources\n" );
706  goto err_setup_rx;
707  }
708 
709  /* Reset the chip */
710  priv->a->reset ( ioaddr );
711 
712  /* Switch pcnet32 to 32bit mode */
713  priv->a->write_bcr ( ioaddr, 20, PCNET32_SWSTYLE_PCNET32 );
714 
715  /* Setup the interface and duplex mode */
717 
718  /* Disable interrupts */
719  val = priv->a->read_csr ( ioaddr, 3 );
721  priv->a->write_csr ( ioaddr, 3, val );
722 
723  /* Setup initialization block */
725 
726  /* Fill in the address of the initialization block */
727  priv->a->write_csr ( ioaddr, 1,
728  ( virt_to_bus ( &priv->init_block ) ) & 0xffff );
729  priv->a->write_csr ( ioaddr, 2,
730  ( virt_to_bus ( &priv->init_block ) ) >> 16 );
731 
732  /* Enable Auto-Pad, disable interrupts */
733  priv->a->write_csr ( ioaddr, 4, 0x0915 );
734 
736 
737  return 0;
738 
739 err_setup_rx:
741 err_setup_tx:
742  priv->a->reset( priv->pci_dev->ioaddr );
743  return rc;
744 }
uint16_t u16
Definition: stdint.h:21
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int pcnet32_setup_rx_resources(struct pcnet32_private *priv)
pcnet32_setup_rx_resources - allocate Rx resources (Descriptors)
Definition: pcnet32.c:245
static unsigned long ioaddr
Definition: davicom.c:129
static void pcnet32_free_tx_resources(struct pcnet32_private *priv)
Definition: pcnet32.c:311
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static int pcnet32_setup_tx_resources(struct pcnet32_private *priv)
pcnet32_setup_tx_resources - allocate Tx resources (Descriptors)
Definition: pcnet32.c:289
static void pcnet32_hw_start(struct pcnet32_private *priv)
pcnet32_hw_start - Starts up the NIC
Definition: pcnet32.c:666
static void pcnet32_setup_if_duplex(struct pcnet32_private *priv)
pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode
Definition: pcnet32.c:594
void __asmcall int val
Definition: setjmp.h:28
static struct tlan_private * priv
Definition: tlan.c:224
static void pcnet32_setup_init_block(struct pcnet32_private *priv)
pcnet32_setup_init_block - setup the NICs initialization block
Definition: pcnet32.c:477
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define PCNET32_SWSTYLE_PCNET32
Definition: pcnet32.h:75

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, net_device::priv, rc, RxIntMask, TxIntMask, val, and virt_to_bus().

◆ pcnet32_transmit()

static int pcnet32_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)
static

transmit - Transmit a packet

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturns 0 on success, negative on failure

Definition at line 755 of file pcnet32.c.

756 {
757  struct pcnet32_private *priv = netdev->priv;
758  unsigned long ioaddr = priv->pci_dev->ioaddr;
759  uint32_t tx_len = iob_len ( iobuf );
760  struct pcnet32_tx_desc *tx_curr_desc;
761 
762  DBGP ( "pcnet32_transmit\n" );
763 
764  if ( priv->tx_fill_ctr == TX_RING_SIZE ) {
765  DBG ( "Tx overflow\n" );
766  return -ENOTSUP;
767  }
768 
769  priv->tx_iobuf[priv->tx_curr] = iobuf;
770 
771  tx_curr_desc = priv->tx_base + priv->tx_curr;
772 
773  /* Configure current descriptor to transmit packet */
774  tx_curr_desc->length = cpu_to_le16 ( -tx_len );
775  tx_curr_desc->misc = 0x00000000;
776  tx_curr_desc->base = cpu_to_le32 ( virt_to_bus ( iobuf->data ) );
777 
778  /* Owner changes after the other status fields are set */
779  wmb();
780  tx_curr_desc->status =
782 
783  /* Trigger an immediate send poll */
784  priv->a->write_csr ( ioaddr, 0,
785  ( priv->irq_enabled ? IntEnable : 0 ) | TxDemand );
786 
787  /* Point to the next free descriptor */
788  priv->tx_curr = ( priv->tx_curr + 1 ) % TX_RING_SIZE;
789 
790  /* Increment number of tx descriptors in use */
791  priv->tx_fill_ctr++;
792 
793  return 0;
794 }
wmb()
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static unsigned long ioaddr
Definition: davicom.c:129
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define cpu_to_le32(value)
Definition: byteswap.h:107
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
unsigned int uint32_t
Definition: stdint.h:12
static struct tlan_private * priv
Definition: tlan.c:224
void * data
Start of data.
Definition: iobuf.h:48
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define TX_RING_SIZE
Definition: 3c515.c:86

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, net_device::priv, StartOfPacket, pcnet32_tx_desc::status, TX_RING_SIZE, TxDemand, virt_to_bus(), and wmb().

◆ pcnet32_process_tx_packets()

static 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
netdevNetwork device

Definition at line 803 of file pcnet32.c.

804 {
805  struct pcnet32_private *priv = netdev->priv;
806  struct pcnet32_tx_desc *tx_curr_desc;
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 
813  u16 status = le16_to_cpu ( tx_curr_desc->status );
814 
815  DBG ( "Before OWN bit check, status: %#08x\n", status );
816 
817  /* Skip this descriptor if hardware still owns it */
818  if ( status & DescOwn )
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 );
825  DBG ( "tx_curr_desc = %#08lx\n", virt_to_bus ( tx_curr_desc ) );
826 
827  /* This packet is ready for completion */
828  netdev_tx_complete ( netdev, priv->tx_iobuf[priv->tx_tail]);
829 
830  /* Clear the descriptor */
831  memset ( tx_curr_desc, 0, sizeof(*tx_curr_desc) );
832 
833  /* Reduce the number of tx descriptors in use */
834  priv->tx_fill_ctr--;
835 
836  /* Go to next available descriptor */
837  priv->tx_tail = ( priv->tx_tail + 1 ) % TX_RING_SIZE;
838  }
839 }
uint16_t u16
Definition: stdint.h:21
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:752
uint8_t status
Status.
Definition: ena.h:16
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define le16_to_cpu(value)
Definition: byteswap.h:112
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define TX_RING_SIZE
Definition: 3c515.c:86
void * memset(void *dest, int character, size_t len) __nonnull

References DBG, DBGP, DescOwn, le16_to_cpu, memset(), netdev, netdev_tx_complete(), priv, net_device::priv, status, pcnet32_tx_desc::status, TX_RING_SIZE, and virt_to_bus().

Referenced by pcnet32_poll().

◆ pcnet32_process_rx_packets()

static 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
netdevNetwork device

Definition at line 849 of file pcnet32.c.

850 {
851  struct pcnet32_private *priv = netdev->priv;
852  struct pcnet32_rx_desc *rx_curr_desc;
853  u16 status;
854  u32 len;
855  int i;
856 
857  DBGP ( "pcnet32_process_rx_packets\n" );
858 
859  for ( i = 0; i < RX_RING_SIZE; i++ ) {
860  rx_curr_desc = priv->rx_base + priv->rx_curr;
861 
862  status = le16_to_cpu ( rx_curr_desc->status );
863  rmb();
864 
865  DBG ( "Before OWN bit check, status: %#08x\n", status );
866 
867  /* Skip this descriptor if hardware still owns it */
868  if ( status & DescOwn )
869  break;
870 
871  /* We own the descriptor, but it has not been refilled yet */
872  if ( priv->rx_iobuf[priv->rx_curr] == NULL )
873  break;
874 
875  DBG ( "Received packet.\n" );
876  DBG ( "priv->rx_curr = %d\n", priv->rx_curr );
877  DBG ( "rx_len = %d\n",
878  ( le32_to_cpu ( rx_curr_desc->msg_length ) & 0xfff ) - 4 );
879  DBG ( "rx_curr_desc = %#08lx\n",
880  virt_to_bus ( rx_curr_desc ) );
881 
882  /* Check ERR bit */
883  if ( status & 0x4000 ) {
884  netdev_rx_err ( netdev, priv->rx_iobuf[priv->rx_curr],
885  -EINVAL );
886  DBG ( "Corrupted packet received!\n");
887  } else {
888  /* Adjust size of the iobuf to reflect received data */
889  len = ( le32_to_cpu ( rx_curr_desc->msg_length ) & 0xfff ) - 4;
890  iob_put ( priv->rx_iobuf[priv->rx_curr], len );
891 
892  /* Add this packet to the receive queue */
893  netdev_rx ( netdev, priv->rx_iobuf[priv->rx_curr] );
894  }
895 
896  /* Invalidate iobuf and descriptor */
897  priv->rx_iobuf[priv->rx_curr] = NULL;
898  memset ( rx_curr_desc, 0, sizeof(*rx_curr_desc) );
899 
900  /* Point to the next free descriptor */
901  priv->rx_curr = ( priv->rx_curr + 1 ) % RX_RING_SIZE;
902  }
903 
904  /* Allocate new iobufs where needed */
906 }
uint16_t u16
Definition: stdint.h:21
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define iob_put(iobuf, len)
Definition: iobuf.h:120
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
#define le32_to_cpu(value)
Definition: byteswap.h:113
uint8_t status
Status.
Definition: ena.h:16
u32 msg_length
Definition: pcnet32.h:95
#define rmb()
Definition: io.h:484
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define le16_to_cpu(value)
Definition: byteswap.h:112
#define RX_RING_SIZE
Definition: 3c515.c:87
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
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 ...
Definition: pcnet32.c:198
uint32_t len
Length.
Definition: ena.h:14
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint32_t u32
Definition: stdint.h:23
void * memset(void *dest, int character, size_t len) __nonnull

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, net_device::priv, rmb, RX_RING_SIZE, status, pcnet32_rx_desc::status, and virt_to_bus().

Referenced by pcnet32_poll().

◆ pcnet32_poll()

static void pcnet32_poll ( struct net_device netdev)
static

poll - Poll for received packets

Parameters
netdevNetwork device

Definition at line 914 of file pcnet32.c.

915 {
916  struct pcnet32_private *priv = netdev->priv;
917  unsigned long ioaddr = priv->pci_dev->ioaddr;
918  u16 status;
919 
920  DBGP ( "pcnet32_poll\n" );
921 
922  status = priv->a->read_csr ( ioaddr, 0 );
923 
924  /* Clear interrupts */
925  priv->a->write_csr ( ioaddr, 0, status );
926 
927  DBG ( "pcnet32_poll: mask = %#04x, status = %#04x\n",
928  priv->a->read_csr ( ioaddr, 3 ), status );
929 
930  /* Return when RINT or TINT are not set */
931  if ( ( status & 0x0500 ) == 0x0000 )
932  return;
933 
934  /* Process transmitted packets */
936 
937  /* Process received packets */
939 }
uint16_t u16
Definition: stdint.h:21
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_t...
Definition: pcnet32.c:803
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 ne...
Definition: pcnet32.c:849
uint8_t status
Status.
Definition: ena.h:16
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, DBGP, ioaddr, netdev, pcnet32_process_rx_packets(), pcnet32_process_tx_packets(), priv, net_device::priv, and status.

◆ pcnet32_close()

static void pcnet32_close ( struct net_device netdev)
static

close - Disable network interface

Parameters
netdevnetwork interface device structure

Definition at line 947 of file pcnet32.c.

948 {
949  struct pcnet32_private *priv = netdev->priv;
950  unsigned long ioaddr = priv->pci_dev->ioaddr;
951 
952  DBGP ( "pcnet32_close\n" );
953 
954  /* Reset the chip */
956 
957  /* Stop the PCNET32 - it occasionally polls memory if we don't */
958  priv->a->write_csr ( ioaddr, 0, Stop );
959 
960  /* Switch back to 16bit mode to avoid problems with dumb
961  * DOS packet driver after a warm reboot */
962  priv->a->write_bcr ( ioaddr, 20, PCNET32_SWSTYLE_LANCE );
963 
966 }
static void pcnet32_wio_reset(unsigned long addr)
Definition: pcnet32.c:76
static unsigned long ioaddr
Definition: davicom.c:129
static void pcnet32_free_tx_resources(struct pcnet32_private *priv)
Definition: pcnet32.c:311
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define PCNET32_SWSTYLE_LANCE
Definition: pcnet32.h:73
static struct tlan_private * priv
Definition: tlan.c:224
Definition: pcnet32.h:166
static void pcnet32_free_rx_resources(struct pcnet32_private *priv)
Definition: pcnet32.c:267

References DBGP, ioaddr, netdev, pcnet32_free_rx_resources(), pcnet32_free_tx_resources(), PCNET32_SWSTYLE_LANCE, pcnet32_wio_reset(), priv, net_device::priv, and Stop.

◆ pcnet32_irq_enable()

static void pcnet32_irq_enable ( struct pcnet32_private priv)
static

Definition at line 968 of file pcnet32.c.

969 {
970  unsigned long ioaddr = priv->pci_dev->ioaddr;
971  u16 val;
972 
973  DBGP ( "pcnet32_irq_enable\n" );
974 
975  /* Enable TINT and RINT masks */
976  val = priv->a->read_csr ( ioaddr, 3 );
977  val &= ~( RxIntMask | TxIntMask );
978  priv->a->write_csr ( ioaddr, 3, val );
979 
980  /* Enable interrupts */
981  priv->a->write_csr ( ioaddr, 0, IntEnable );
982 
983  priv->irq_enabled = 1;
984 }
uint16_t u16
Definition: stdint.h:21
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void __asmcall int val
Definition: setjmp.h:28
static struct tlan_private * priv
Definition: tlan.c:224

References DBGP, IntEnable, ioaddr, priv, RxIntMask, TxIntMask, and val.

Referenced by pcnet32_irq().

◆ pcnet32_irq_disable()

static void pcnet32_irq_disable ( struct pcnet32_private priv)
static

Definition at line 986 of file pcnet32.c.

987 {
988  unsigned long ioaddr = priv->pci_dev->ioaddr;
989 
990  DBGP ( "pcnet32_irq_disable\n" );
991 
992  priv->a->write_csr ( ioaddr, 0, 0x0000 );
993 
994  priv->irq_enabled = 0;
995 }
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
static struct tlan_private * priv
Definition: tlan.c:224

References DBGP, ioaddr, and priv.

Referenced by pcnet32_irq().

◆ pcnet32_irq()

static void pcnet32_irq ( struct net_device netdev,
int  action 
)
static

irq - enable or disable interrupts

Parameters
netdevnetwork adapter
actionrequested interrupt action

Definition at line 1004 of file pcnet32.c.

1005 {
1006  struct pcnet32_private *priv = netdev->priv;
1007 
1008  DBGP ( "pcnet32_irq\n" );
1009 
1010  switch ( action ) {
1011  case 0:
1013  break;
1014  default:
1016  break;
1017  }
1018 }
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static struct tlan_private * priv
Definition: tlan.c:224
static void pcnet32_irq_disable(struct pcnet32_private *priv)
Definition: pcnet32.c:986
static void pcnet32_irq_enable(struct pcnet32_private *priv)
Definition: pcnet32.c:968

References DBGP, netdev, pcnet32_irq_disable(), pcnet32_irq_enable(), priv, and net_device::priv.

◆ pcnet32_probe()

static int pcnet32_probe ( struct pci_device pdev)
static

probe - Initial configuration of NIC

Parameters
pdevPCI device
entPCI IDs
Return values
rcReturn status code

Definition at line 1037 of file pcnet32.c.

1038 {
1039  struct net_device *netdev;
1040  struct pcnet32_private *priv;
1041  unsigned long ioaddr;
1042  int rc;
1043 
1044  DBGP ( "pcnet32_probe\n" );
1045 
1046  DBG ( "Found %s, vendor = %#04x, device = %#04x\n",
1047  pdev->id->name, pdev->id->vendor, pdev->id->device );
1048 
1049  /* Allocate our private data */
1050  netdev = alloc_etherdev ( sizeof ( *priv ) );
1051  if ( ! netdev ) {
1052  rc = -ENOMEM;
1053  goto err_alloc_etherdev;
1054  }
1055 
1056  /* Link our operations to the netdev struct */
1058 
1059  /* Link the PCI device to the netdev struct */
1060  pci_set_drvdata ( pdev, netdev );
1061  netdev->dev = &pdev->dev;
1062 
1063  /* Get a reference to our private data */
1064  priv = netdev->priv;
1065 
1066  /* We'll need these set up for the rest of the routines */
1067  priv->pci_dev = pdev;
1068  priv->netdev = netdev;
1069 
1070  ioaddr = pdev->ioaddr;
1071 
1072  /* Only use irqs under UNDI */
1073  priv->irq_enabled = 0;
1074 
1075  /* Reset the chip */
1077 
1078  if ( ( rc = pcnet32_set_ops ( priv ) ) != 0 ) {
1079  DBG ( "Setting driver operations failed\n");
1080  goto err_set_ops;
1081  }
1082 
1083  if ( ( rc = pcnet32_chip_detect ( priv ) ) != 0 ) {
1084  DBG ( "pcnet32_chip_detect failed\n" );
1085  goto err_chip_detect;
1086  }
1087 
1088  /* Enter bus mastering mode */
1089  adjust_pci_device ( pdev );
1090 
1091  /* Verify and get MAC address */
1092  if ( ( rc = pcnet32_setup_mac_addr ( priv ) ) != 0 ) {
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,
1098  eth_ntoa ( netdev->hw_addr ) );
1099 
1100  priv->options = PCNET32_PORT_ASEL;
1101 
1102  /* Detect special T1/E1 WAN card by checking for MAC address */
1103  if ( netdev->hw_addr[0] == 0x00 &&
1104  netdev->hw_addr[1] == 0xE0 &&
1105  netdev->hw_addr[2] == 0x75 )
1106  priv->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI;
1107 
1108  /* Probe the PHY so we can check link state and speed */
1110 
1111  if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
1112  DBG ( "Error registering netdev\n" );
1113  goto err_register;
1114  }
1115 
1116  netdev_link_up ( netdev );
1117 
1118  return 0;
1119 
1120 err_register:
1121  netdev_put ( netdev );
1122 err_chip_detect:
1123 err_set_ops:
1124 err_alloc_etherdev:
1125 err_mac_addr:
1126  return rc;
1127 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void pcnet32_wio_reset(unsigned long addr)
Definition: pcnet32.c:76
static int pcnet32_setup_mac_addr(struct pcnet32_private *priv)
pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses
Definition: pcnet32.c:549
unsigned long ioaddr
I/O address.
Definition: pci.h:221
static int pcnet32_set_ops(struct pcnet32_private *priv)
pcnet32_set_ops - Determines the ops used to access the registers
Definition: pcnet32.c:437
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:154
struct device dev
Generic device.
Definition: pci.h:208
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
#define ENOMEM
Not enough space.
Definition: errno.h:534
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:774
static struct net_device * netdev
Definition: gdbudp.c:52
static int pcnet32_chip_detect(struct pcnet32_private *priv)
Definition: pcnet32.c:319
#define PCNET32_PORT_ASEL
Definition: pcnet32.h:69
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A network device.
Definition: netdevice.h:352
#define PCNET32_PORT_FD
Definition: pcnet32.h:71
const char * name
Name.
Definition: pci.h:172
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
uint16_t vendor
PCI vendor ID.
Definition: pci.h:174
uint16_t device
PCI device ID.
Definition: pci.h:176
static struct tlan_private * priv
Definition: tlan.c:224
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
struct pci_device_id * id
Driver device ID.
Definition: pci.h:243
#define PCNET32_PORT_GPSI
Definition: pcnet32.h:65
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static void pcnet32_setup_probe_phy(struct pcnet32_private *priv)
pcnet32_setup_probe_phy - go through all PHYs and see which one is present
Definition: pcnet32.c:513
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
static struct net_device_operations pcnet32_operations
Definition: pcnet32.c:1020

References adjust_pci_device(), alloc_etherdev(), DBG, DBGP, pci_device::dev, net_device::dev, pci_device_id::device, ENOMEM, eth_ntoa(), net_device::hw_addr, 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, net_device::priv, rc, register_netdev(), and pci_device_id::vendor.

◆ pcnet32_remove()

static void pcnet32_remove ( struct pci_device pdev)
static

remove - Device Removal Routine

Parameters
pdevPCI device information struct

Definition at line 1135 of file pcnet32.c.

1136 {
1137  struct net_device *netdev = pci_get_drvdata ( pdev );
1138  unsigned long ioaddr = pdev->ioaddr;
1139 
1140  DBGP ( "pcnet32_remove\n" );
1141 
1142  /* Reset the chip */
1144 
1146  netdev_nullify ( netdev );
1147  netdev_put ( netdev );
1148 }
static void pcnet32_wio_reset(unsigned long addr)
Definition: pcnet32.c:76
unsigned long ioaddr
I/O address.
Definition: pci.h:221
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:369

References DBGP, ioaddr, pci_device::ioaddr, netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), pcnet32_wio_reset(), and unregister_netdev().

Variable Documentation

◆ pcnet32_wio

struct pcnet32_access pcnet32_wio
static
Initial value:
= {
.read_csr = pcnet32_wio_read_csr,
.write_csr = pcnet32_wio_write_csr,
.read_bcr = pcnet32_wio_read_bcr,
.write_bcr = pcnet32_wio_write_bcr,
.read_rap = pcnet32_wio_read_rap,
.write_rap = pcnet32_wio_write_rap,
}
static u16 pcnet32_wio_read_bcr(unsigned long addr, int index)
Definition: pcnet32.c:54
static void pcnet32_wio_reset(unsigned long addr)
Definition: pcnet32.c:76
static u16 pcnet32_wio_read_rap(unsigned long addr)
Definition: pcnet32.c:66
static u16 pcnet32_wio_read_csr(unsigned long addr, int index)
Definition: pcnet32.c:42
static void pcnet32_wio_write_rap(unsigned long addr, u16 val)
Definition: pcnet32.c:71
static void pcnet32_wio_write_bcr(unsigned long addr, int index, u16 val)
Definition: pcnet32.c:60
static void pcnet32_wio_write_csr(unsigned long addr, int index, u16 val)
Definition: pcnet32.c:48

Definition at line 87 of file pcnet32.c.

Referenced by pcnet32_set_ops().

◆ pcnet32_dwio

struct pcnet32_access pcnet32_dwio
static
Initial value:
= {
.read_csr = pcnet32_dwio_read_csr,
.write_csr = pcnet32_dwio_write_csr,
.read_bcr = pcnet32_dwio_read_bcr,
.write_bcr = pcnet32_dwio_write_bcr,
.read_rap = pcnet32_dwio_read_rap,
.write_rap = pcnet32_dwio_write_rap,
}
static u16 pcnet32_dwio_read_csr(unsigned long addr, int index)
Definition: pcnet32.c:97
static void pcnet32_dwio_write_rap(unsigned long addr, u16 val)
Definition: pcnet32.c:126
static u16 pcnet32_dwio_read_rap(unsigned long addr)
Definition: pcnet32.c:121
static void pcnet32_dwio_reset(unsigned long addr)
Definition: pcnet32.c:131
static void pcnet32_dwio_write_csr(unsigned long addr, int index, u16 val)
Definition: pcnet32.c:103
static u16 pcnet32_dwio_read_bcr(unsigned long addr, int index)
Definition: pcnet32.c:109
static void pcnet32_dwio_write_bcr(unsigned long addr, int index, u16 val)
Definition: pcnet32.c:115

Definition at line 143 of file pcnet32.c.

Referenced by pcnet32_set_ops().

◆ pcnet32_operations

struct net_device_operations pcnet32_operations
static
Initial value:
= {
.open = pcnet32_open,
.transmit = pcnet32_transmit,
.poll = pcnet32_poll,
.close = pcnet32_close,
.irq = pcnet32_irq,
}
static void pcnet32_close(struct net_device *netdev)
close - Disable network interface
Definition: pcnet32.c:947
static void pcnet32_poll(struct net_device *netdev)
poll - Poll for received packets
Definition: pcnet32.c:914
static void pcnet32_irq(struct net_device *netdev, int action)
irq - enable or disable interrupts
Definition: pcnet32.c:1004
static int pcnet32_open(struct net_device *netdev)
open - Called when a network interface is made active
Definition: pcnet32.c:691
static int pcnet32_transmit(struct net_device *netdev, struct io_buffer *iobuf)
transmit - Transmit a packet
Definition: pcnet32.c:755

Definition at line 1020 of file pcnet32.c.

Referenced by pcnet32_probe().

◆ pcnet32_nics

struct pci_device_id pcnet32_nics[]
static
Initial value:
= {
PCI_ROM(0x1022, 0x2000, "pcnet32", "AMD PCnet/PCI", 0),
PCI_ROM(0x1022, 0x2001, "amdhomepna", "AMD PCnet/HomePNA", 0),
PCI_ROM(0x1022, 0x2625, "pcnetfastiii", "AMD PCNet FAST III", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:303

Definition at line 1150 of file pcnet32.c.

◆ __pci_driver

struct pci_driver pcnet32_driver __pci_driver
Initial value:
= {
.ids = pcnet32_nics,
.id_count = ARRAY_SIZE ( pcnet32_nics ),
.probe = pcnet32_probe,
.remove = pcnet32_remove,
}
static void pcnet32_remove(struct pci_device *pdev)
remove - Device Removal Routine
Definition: pcnet32.c:1135
static int pcnet32_probe(struct pci_device *pdev)
probe - Initial configuration of NIC
Definition: pcnet32.c:1037
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
static struct pci_device_id pcnet32_nics[]
Definition: pcnet32.c:1150

Definition at line 1156 of file pcnet32.c.