iPXE
Functions | Variables
forcedeth.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/crypto.h>
#include <ipxe/pci.h>
#include <ipxe/timer.h>
#include <mii.h>
#include "forcedeth.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static void pci_push (void *ioaddr)
 
static int reg_delay (struct forcedeth_private *priv, int offset, u32 mask, u32 target, int delay, int delaymax, const char *msg)
 
static int mii_rw (struct forcedeth_private *priv, int addr, int miireg, int value)
 
static void nv_txrx_gate (struct forcedeth_private *priv, int gate)
 
static void nv_mac_reset (struct forcedeth_private *priv)
 
static void nv_init_tx_ring (struct forcedeth_private *priv)
 
static void nv_alloc_rx (struct forcedeth_private *priv)
 nv_alloc_rx - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in use by the hardware More...
 
static void nv_init_rx_ring (struct forcedeth_private *priv)
 
static int nv_init_rings (struct forcedeth_private *priv)
 nv_init_rings - Allocate and intialize descriptor rings More...
 
static void nv_free_rxtx_resources (struct forcedeth_private *priv)
 
static void nv_txrx_reset (struct forcedeth_private *priv)
 
static void nv_disable_hw_interrupts (struct forcedeth_private *priv)
 
static void nv_enable_hw_interrupts (struct forcedeth_private *priv)
 
static void nv_start_rx (struct forcedeth_private *priv)
 
static void nv_stop_rx (struct forcedeth_private *priv)
 
static void nv_start_tx (struct forcedeth_private *priv)
 
static void nv_stop_tx (struct forcedeth_private *priv)
 
static void nv_update_pause (struct forcedeth_private *priv, u32 pause_flags)
 
static int nv_update_linkspeed (struct forcedeth_private *priv)
 
static int forcedeth_open (struct net_device *netdev)
 open - Called when a network interface is made active More...
 
static int forcedeth_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 transmit - Transmit a packet More...
 
static void nv_process_tx_packets (struct net_device *netdev)
 nv_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_complete() More...
 
static void nv_process_rx_packets (struct net_device *netdev)
 nv_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 forcedeth_link_status (struct net_device *netdev)
 check_link - Check for link status change More...
 
static void forcedeth_poll (struct net_device *netdev)
 poll - Poll for received packets More...
 
static void forcedeth_close (struct net_device *netdev)
 close - Disable network interface More...
 
static void forcedeth_irq (struct net_device *netdev, int action)
 irq - enable or disable interrupts More...
 
static int nv_setup_mac_addr (struct forcedeth_private *priv)
 
static int nv_mgmt_acquire_sema (struct forcedeth_private *priv)
 
static void nv_mgmt_release_sema (struct forcedeth_private *priv)
 
static int nv_mgmt_get_version (struct forcedeth_private *priv)
 
static int phy_reset (struct forcedeth_private *priv, u32 bmcr_setup)
 
static int phy_init (struct forcedeth_private *priv)
 
static int nv_setup_phy (struct forcedeth_private *priv)
 nv_setup_phy - Find PHY and initialize it More...
 
static int forcedeth_map_regs (struct forcedeth_private *priv)
 forcedeth_map_regs - Find a suitable BAR for the NIC and map the registers in memory More...
 
static int forcedeth_probe (struct pci_device *pdev)
 probe - Initial configuration of NIC More...
 
static void nv_restore_phy (struct forcedeth_private *priv)
 
static void forcedeth_remove (struct pci_device *pdev)
 remove - Device Removal Routine More...
 

Variables

static struct net_device_operations forcedeth_operations
 
static struct pci_device_id forcedeth_nics []
 
struct pci_driver forcedeth_driver __pci_driver
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ pci_push()

static void pci_push ( void *  ioaddr)
inlinestatic

Definition at line 62 of file forcedeth.c.

63 {
64  /* force out pending posted writes */
65  wmb();
66  readl ( ioaddr );
67 }
wmb()
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static unsigned long ioaddr
Definition: davicom.c:129

References ioaddr, readl(), and wmb().

Referenced by forcedeth_open(), forcedeth_transmit(), nv_disable_hw_interrupts(), nv_mac_reset(), nv_start_rx(), nv_start_tx(), nv_txrx_reset(), nv_update_linkspeed(), and reg_delay().

◆ reg_delay()

static int reg_delay ( struct forcedeth_private priv,
int  offset,
u32  mask,
u32  target,
int  delay,
int  delaymax,
const char *  msg 
)
static

Definition at line 70 of file forcedeth.c.

72 {
73  void *ioaddr = priv->mmio_addr;
74 
75  pci_push ( ioaddr );
76  do {
77  udelay ( delay );
78  delaymax -= delay;
79  if ( delaymax < 0 ) {
80  if ( msg )
81  DBG ( "%s\n", msg );
82  return 1;
83  }
84  } while ( ( readl ( ioaddr + offset ) & mask ) != target );
85 
86  return 0;
87 }
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: message.c:61
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static unsigned long ioaddr
Definition: davicom.c:129
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tlan_private * priv
Definition: tlan.c:224
uint16_t delay
Forward delay.
Definition: stp.h:40
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, delay, ioaddr, msg(), offset, pci_push(), priv, readl(), and udelay().

Referenced by forcedeth_open(), mii_rw(), nv_stop_rx(), and nv_stop_tx().

◆ mii_rw()

static int mii_rw ( struct forcedeth_private priv,
int  addr,
int  miireg,
int  value 
)
static

Definition at line 91 of file forcedeth.c.

92 {
93  void *ioaddr = priv->mmio_addr;
94  u32 reg;
95  int retval;
96 
98 
100  if ( reg & NVREG_MIICTL_INUSE ) {
103  }
104 
105  reg = ( addr << NVREG_MIICTL_ADDRSHIFT ) | miireg;
106  if ( value != MII_READ ) {
109  }
111 
114  DBG ( "mii_rw of reg %d at PHY %d timed out.\n",
115  miireg, addr );
116  retval = -1;
117  } else if ( value != MII_READ ) {
118  /* it was a write operation - fewer failures are detectable */
119  DBG ( "mii_rw wrote 0x%x to reg %d at PHY %d\n",
120  value, miireg, addr );
121  retval = 0;
122  } else if ( readl ( ioaddr + NvRegMIIStatus ) & NVREG_MIISTAT_ERROR ) {
123  DBG ( "mii_rw of reg %d at PHY %d failed.\n",
124  miireg, addr );
125  retval = -1;
126  } else {
128  DBG ( "mii_rw read from reg %d at PHY %d: 0x%x.\n",
129  miireg, addr, retval );
130  }
131 
132  return retval;
133 }
#define MII_READ
Definition: forcedeth.h:296
static unsigned int unsigned int reg
Definition: myson.h:162
#define NVREG_MIISTAT_MASK_RW
Definition: forcedeth.h:489
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static int reg_delay(struct forcedeth_private *priv, int offset, u32 mask, u32 target, int delay, int delaymax, const char *msg)
Definition: forcedeth.c:70
#define NV_MIIBUSY_DELAY
Definition: forcedeth.h:289
static unsigned long ioaddr
Definition: davicom.c:129
#define NVREG_MIICTL_ADDRSHIFT
Definition: forcedeth.h:506
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define NV_MIIPHY_DELAY
Definition: forcedeth.h:290
#define NVREG_MIICTL_INUSE
Definition: forcedeth.h:504
unsigned long retval
Definition: xen.h:45
static struct tlan_private * priv
Definition: tlan.c:224
u32 addr
Definition: sky2.h:8
#define NV_MIIPHY_DELAYMAX
Definition: forcedeth.h:291
#define NVREG_MIICTL_WRITE
Definition: forcedeth.h:505
#define NVREG_MIISTAT_ERROR
Definition: forcedeth.h:487
#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

References addr, DBG, ioaddr, MII_READ, NULL, NV_MIIBUSY_DELAY, NV_MIIPHY_DELAY, NV_MIIPHY_DELAYMAX, NVREG_MIICTL_ADDRSHIFT, NVREG_MIICTL_INUSE, NVREG_MIICTL_WRITE, NVREG_MIISTAT_ERROR, NVREG_MIISTAT_MASK_RW, NvRegMIIControl, NvRegMIIData, NvRegMIIStatus, priv, readl(), reg, reg_delay(), retval, udelay(), value, and writel().

Referenced by forcedeth_open(), nv_restore_phy(), nv_setup_phy(), nv_update_linkspeed(), phy_init(), and phy_reset().

◆ nv_txrx_gate()

static void nv_txrx_gate ( struct forcedeth_private priv,
int  gate 
)
static

Definition at line 136 of file forcedeth.c.

137 {
138  void *ioaddr = priv->mmio_addr;
139  u32 powerstate;
140 
141  if ( ! priv->mac_in_use &&
142  ( priv->driver_data & DEV_HAS_POWER_CNTRL ) ) {
143  powerstate = readl ( ioaddr + NvRegPowerState2 );
144  if ( gate )
145  powerstate |= NVREG_POWERSTATE2_GATE_CLOCKS;
146  else
147  powerstate &= ~NVREG_POWERSTATE2_GATE_CLOCKS;
148  writel ( powerstate, ioaddr + NvRegPowerState2 );
149  }
150 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static unsigned long ioaddr
Definition: davicom.c:129
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define DEV_HAS_POWER_CNTRL
Definition: forcedeth.h:182
static struct tlan_private * priv
Definition: tlan.c:224
#define NVREG_POWERSTATE2_GATE_CLOCKS
Definition: forcedeth.h:579
uint32_t u32
Definition: stdint.h:23

References DEV_HAS_POWER_CNTRL, ioaddr, NVREG_POWERSTATE2_GATE_CLOCKS, NvRegPowerState2, priv, readl(), and writel().

Referenced by forcedeth_close(), and forcedeth_open().

◆ nv_mac_reset()

static void nv_mac_reset ( struct forcedeth_private priv)
static

Definition at line 153 of file forcedeth.c.

154 {
155  void *ioaddr = priv->mmio_addr;
156  u32 temp1, temp2, temp3;
157 
160  pci_push ( ioaddr );
161 
162  /* save registers since they will be cleared on reset */
163  temp1 = readl ( ioaddr + NvRegMacAddrA );
164  temp2 = readl ( ioaddr + NvRegMacAddrB );
165  temp3 = readl ( ioaddr + NvRegTransmitPoll );
166 
168  pci_push ( ioaddr );
170  writel ( 0, ioaddr + NvRegMacReset );
171  pci_push ( ioaddr );
173 
174  /* restore saved registers */
175  writel ( temp1, ioaddr + NvRegMacAddrA );
176  writel ( temp2, ioaddr + NvRegMacAddrB );
177  writel ( temp3, ioaddr + NvRegTransmitPoll );
178 
181  pci_push ( ioaddr );
182 }
#define NVREG_TXRXCTL_RESET
Definition: forcedeth.h:470
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define NV_MAC_RESET_DELAY
Definition: forcedeth.h:292
#define NVREG_TXRXCTL_DESC_1
Definition: forcedeth.h:472
static unsigned long ioaddr
Definition: davicom.c:129
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define NVREG_TXRXCTL_BIT2
Definition: forcedeth.h:468
static struct tlan_private * priv
Definition: tlan.c:224
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62
#define NVREG_MAC_RESET_ASSERT
Definition: forcedeth.h:376
uint32_t u32
Definition: stdint.h:23

References ioaddr, NV_MAC_RESET_DELAY, NVREG_MAC_RESET_ASSERT, NVREG_TXRXCTL_BIT2, NVREG_TXRXCTL_DESC_1, NVREG_TXRXCTL_RESET, NvRegMacAddrA, NvRegMacAddrB, NvRegMacReset, NvRegTransmitPoll, NvRegTxRxControl, pci_push(), priv, readl(), udelay(), and writel().

Referenced by forcedeth_open().

◆ nv_init_tx_ring()

static void nv_init_tx_ring ( struct forcedeth_private priv)
static

Definition at line 185 of file forcedeth.c.

186 {
187  int i;
188 
189  for ( i = 0; i < TX_RING_SIZE; i++ ) {
190  priv->tx_ring[i].flaglen = 0;
191  priv->tx_ring[i].buf = 0;
192  priv->tx_iobuf[i] = NULL;
193  }
194 
195  priv->tx_fill_ctr = 0;
196  priv->tx_curr = 0;
197  priv->tx_tail = 0;
198 }
static struct tlan_private * priv
Definition: tlan.c:224
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define TX_RING_SIZE
Definition: 3c515.c:86

References NULL, priv, and TX_RING_SIZE.

Referenced by nv_init_rings().

◆ nv_alloc_rx()

static void nv_alloc_rx ( struct forcedeth_private priv)
static

nv_alloc_rx - 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 207 of file forcedeth.c.

208 {
209  struct ring_desc *rx_curr_desc;
210  int i;
211  u32 status;
212 
213  DBGP ( "nv_alloc_rx\n" );
214 
215  for ( i = 0; i < RX_RING_SIZE; i++ ) {
216  rx_curr_desc = priv->rx_ring + i;
217  status = le32_to_cpu ( rx_curr_desc->flaglen );
218 
219  /* Don't touch the descriptors owned by the hardware */
220  if ( status & NV_RX_AVAIL )
221  continue;
222 
223  /* Descriptors with iobufs still need to be processed */
224  if ( priv->rx_iobuf[i] != NULL )
225  continue;
226 
227  /* If alloc_iob fails, try again later (next poll) */
228  if ( ! ( priv->rx_iobuf[i] = alloc_iob ( RX_BUF_SZ ) ) ) {
229  DBG ( "Refill rx_ring failed, size %d\n", RX_BUF_SZ );
230  break;
231  }
232 
233  rx_curr_desc->buf =
234  cpu_to_le32 ( virt_to_bus ( priv->rx_iobuf[i]->data ) );
235  wmb();
236  rx_curr_desc->flaglen =
238  }
239 }
wmb()
#define RX_BUF_SZ
Definition: forcedeth.h:67
#define le32_to_cpu(value)
Definition: byteswap.h:113
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.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
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define RX_RING_SIZE
Definition: 3c515.c:87
uint8_t status
Status.
Definition: ena.h:16
#define NV_RX_AVAIL
Definition: forcedeth.h:247
static struct tlan_private * priv
Definition: tlan.c:224
u32 buf
Definition: forcedeth.h:40
#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
u32 flaglen
Definition: forcedeth.h:41

References alloc_iob(), ring_desc::buf, cpu_to_le32, DBG, DBGP, ring_desc::flaglen, le32_to_cpu, NULL, NV_RX_AVAIL, priv, RX_BUF_SZ, RX_RING_SIZE, status, virt_to_bus(), and wmb().

Referenced by nv_init_rings(), and nv_process_rx_packets().

◆ nv_init_rx_ring()

static void nv_init_rx_ring ( struct forcedeth_private priv)
static

Definition at line 242 of file forcedeth.c.

243 {
244  int i;
245 
246  for ( i = 0; i < RX_RING_SIZE; i++ ) {
247  priv->rx_ring[i].flaglen = 0;
248  priv->rx_ring[i].buf = 0;
249  priv->rx_iobuf[i] = NULL;
250  }
251 
252  priv->rx_curr = 0;
253 }
#define RX_RING_SIZE
Definition: 3c515.c:87
static struct tlan_private * priv
Definition: tlan.c:224
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References NULL, priv, and RX_RING_SIZE.

Referenced by nv_init_rings().

◆ nv_init_rings()

static int nv_init_rings ( struct forcedeth_private priv)
static

nv_init_rings - Allocate and intialize descriptor rings

Parameters
privDriver private structure
Return values
rcReturn status code

Definition at line 263 of file forcedeth.c.

264 {
265  void *ioaddr = priv->mmio_addr;
266  int rc = -ENOMEM;
267 
268  /* Allocate ring for both TX and RX */
269  priv->rx_ring =
270  malloc_phys ( sizeof(struct ring_desc) * RXTX_RING_SIZE, 32 );
271  if ( ! priv->rx_ring )
272  goto err_malloc;
273  priv->tx_ring = &priv->rx_ring[RX_RING_SIZE];
274 
275  /* Initialize rings */
276  nv_init_tx_ring ( priv );
277  nv_init_rx_ring ( priv );
278 
279  /* Allocate iobufs for RX */
280  nv_alloc_rx ( priv );
281 
282  /* Give hw rings */
283  writel ( cpu_to_le32 ( virt_to_bus ( priv->rx_ring ) ),
285  writel ( cpu_to_le32 ( virt_to_bus ( priv->tx_ring ) ),
287 
288  DBG ( "RX ring at phys addr: %#08lx\n",
289  virt_to_bus ( priv->rx_ring ) );
290  DBG ( "TX ring at phys addr: %#08lx\n",
291  virt_to_bus ( priv->tx_ring ) );
292 
293  writel ( ( ( RX_RING_SIZE - 1 ) << NVREG_RINGSZ_RXSHIFT ) +
294  ( ( TX_RING_SIZE - 1 ) << NVREG_RINGSZ_TXSHIFT ),
296 
297  return 0;
298 
299 err_malloc:
300  DBG ( "Could not allocate descriptor rings\n");
301  return rc;
302 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define RXTX_RING_SIZE
Definition: forcedeth.h:57
static void nv_init_tx_ring(struct forcedeth_private *priv)
Definition: forcedeth.c:185
static void nv_alloc_rx(struct forcedeth_private *priv)
nv_alloc_rx - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in use by the ...
Definition: forcedeth.c:207
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 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
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define RX_RING_SIZE
Definition: 3c515.c:87
static void nv_init_rx_ring(struct forcedeth_private *priv)
Definition: forcedeth.c:242
#define NVREG_RINGSZ_RXSHIFT
Definition: forcedeth.h:450
#define NVREG_RINGSZ_TXSHIFT
Definition: forcedeth.h:449
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

References cpu_to_le32, DBG, ENOMEM, ioaddr, malloc_phys(), nv_alloc_rx(), nv_init_rx_ring(), nv_init_tx_ring(), NVREG_RINGSZ_RXSHIFT, NVREG_RINGSZ_TXSHIFT, NvRegRingSizes, NvRegRxRingPhysAddr, NvRegTxRingPhysAddr, priv, rc, RX_RING_SIZE, RXTX_RING_SIZE, TX_RING_SIZE, virt_to_bus(), and writel().

Referenced by forcedeth_open().

◆ nv_free_rxtx_resources()

static void nv_free_rxtx_resources ( struct forcedeth_private priv)
static

Definition at line 305 of file forcedeth.c.

306 {
307  int i;
308 
309  DBGP ( "nv_free_rxtx_resources\n" );
310 
311  free_phys ( priv->rx_ring, sizeof(struct ring_desc) * RXTX_RING_SIZE );
312 
313  for ( i = 0; i < RX_RING_SIZE; i++ ) {
314  free_iob ( priv->rx_iobuf[i] );
315  priv->rx_iobuf[i] = NULL;
316  }
317 }
#define RXTX_RING_SIZE
Definition: forcedeth.h:57
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#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_SIZE, and RXTX_RING_SIZE.

Referenced by forcedeth_close().

◆ nv_txrx_reset()

static void nv_txrx_reset ( struct forcedeth_private priv)
static

Definition at line 320 of file forcedeth.c.

321 {
322  void *ioaddr = priv->mmio_addr;
323 
326  pci_push ( ioaddr );
330  pci_push ( ioaddr );
331 }
#define NVREG_TXRXCTL_RESET
Definition: forcedeth.h:470
#define NVREG_TXRXCTL_DESC_1
Definition: forcedeth.h:472
static unsigned long ioaddr
Definition: davicom.c:129
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define NV_TXRX_RESET_DELAY
Definition: forcedeth.h:278
#define NVREG_TXRXCTL_BIT2
Definition: forcedeth.h:468
static struct tlan_private * priv
Definition: tlan.c:224
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62

References ioaddr, NV_TXRX_RESET_DELAY, NVREG_TXRXCTL_BIT2, NVREG_TXRXCTL_DESC_1, NVREG_TXRXCTL_RESET, NvRegTxRxControl, pci_push(), priv, udelay(), and writel().

Referenced by forcedeth_close(), and forcedeth_open().

◆ nv_disable_hw_interrupts()

static void nv_disable_hw_interrupts ( struct forcedeth_private priv)
static

Definition at line 334 of file forcedeth.c.

335 {
336  void *ioaddr = priv->mmio_addr;
337 
338  writel ( 0, ioaddr + NvRegIrqMask );
339  pci_push ( ioaddr );
340 }
static unsigned long ioaddr
Definition: davicom.c:129
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct tlan_private * priv
Definition: tlan.c:224
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62

References ioaddr, NvRegIrqMask, pci_push(), priv, and writel().

Referenced by forcedeth_close(), forcedeth_irq(), and forcedeth_open().

◆ nv_enable_hw_interrupts()

static void nv_enable_hw_interrupts ( struct forcedeth_private priv)
static

Definition at line 343 of file forcedeth.c.

344 {
345  void *ioaddr = priv->mmio_addr;
346 
348 }
static unsigned long ioaddr
Definition: davicom.c:129
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define NVREG_IRQMASK_THROUGHPUT
Definition: forcedeth.h:350
static struct tlan_private * priv
Definition: tlan.c:224

References ioaddr, NVREG_IRQMASK_THROUGHPUT, NvRegIrqMask, priv, and writel().

Referenced by forcedeth_irq().

◆ nv_start_rx()

static void nv_start_rx ( struct forcedeth_private priv)
static

Definition at line 351 of file forcedeth.c.

352 {
353  void *ioaddr = priv->mmio_addr;
354  u32 rx_ctrl = readl ( ioaddr + NvRegReceiverControl );
355 
356  DBGP ( "nv_start_rx\n" );
357  /* Already running? Stop it. */
358  if ( ( readl ( ioaddr + NvRegReceiverControl ) & NVREG_RCVCTL_START ) && !priv->mac_in_use ) {
359  rx_ctrl &= ~NVREG_RCVCTL_START;
360  writel ( rx_ctrl, ioaddr + NvRegReceiverControl );
361  pci_push ( ioaddr );
362  }
363  writel ( priv->linkspeed, ioaddr + NvRegLinkSpeed );
364  pci_push ( ioaddr );
365  rx_ctrl |= NVREG_RCVCTL_START;
366  if ( priv->mac_in_use )
367  rx_ctrl &= ~NVREG_RCVCTL_RX_PATH_EN;
368  writel ( rx_ctrl, ioaddr + NvRegReceiverControl );
369  DBG ( "nv_start_rx to duplex %d, speed 0x%08x.\n",
370  priv->duplex, priv->linkspeed);
371  pci_push ( ioaddr );
372 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
u32 duplex
Definition: tlan.c:214
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define NVREG_RCVCTL_START
Definition: forcedeth.h:406
#define NVREG_RCVCTL_RX_PATH_EN
Definition: forcedeth.h:407
static struct tlan_private * priv
Definition: tlan.c:224
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint32_t u32
Definition: stdint.h:23

References DBG, DBGP, tlan_private::duplex, ioaddr, NVREG_RCVCTL_RX_PATH_EN, NVREG_RCVCTL_START, NvRegLinkSpeed, NvRegReceiverControl, pci_push(), priv, readl(), and writel().

Referenced by forcedeth_open(), and nv_update_linkspeed().

◆ nv_stop_rx()

static void nv_stop_rx ( struct forcedeth_private priv)
static

Definition at line 375 of file forcedeth.c.

376 {
377  void *ioaddr = priv->mmio_addr;
378  u32 rx_ctrl = readl ( ioaddr + NvRegReceiverControl );
379 
380  DBGP ( "nv_stop_rx\n" );
381  if ( ! priv->mac_in_use )
382  rx_ctrl &= ~NVREG_RCVCTL_START;
383  else
384  rx_ctrl |= NVREG_RCVCTL_RX_PATH_EN;
385  writel ( rx_ctrl, ioaddr + NvRegReceiverControl );
388  "nv_stop_rx: ReceiverStatus remained busy");
389 
391  if ( ! priv->mac_in_use )
392  writel ( 0, priv + NvRegLinkSpeed );
393 }
#define NV_RXSTOP_DELAY2
Definition: forcedeth.h:284
#define NVREG_RCVSTAT_BUSY
Definition: forcedeth.h:409
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static int reg_delay(struct forcedeth_private *priv, int offset, u32 mask, u32 target, int delay, int delaymax, const char *msg)
Definition: forcedeth.c:70
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define NVREG_RCVCTL_START
Definition: forcedeth.h:406
#define NVREG_RCVCTL_RX_PATH_EN
Definition: forcedeth.h:407
#define NV_RXSTOP_DELAY1
Definition: forcedeth.h:282
static struct tlan_private * priv
Definition: tlan.c:224
#define NV_RXSTOP_DELAY1MAX
Definition: forcedeth.h:283
uint32_t u32
Definition: stdint.h:23

References DBGP, ioaddr, NV_RXSTOP_DELAY1, NV_RXSTOP_DELAY1MAX, NV_RXSTOP_DELAY2, NVREG_RCVCTL_RX_PATH_EN, NVREG_RCVCTL_START, NVREG_RCVSTAT_BUSY, NvRegLinkSpeed, NvRegReceiverControl, NvRegReceiverStatus, priv, readl(), reg_delay(), udelay(), and writel().

Referenced by forcedeth_close(), and nv_update_linkspeed().

◆ nv_start_tx()

static void nv_start_tx ( struct forcedeth_private priv)
static

Definition at line 396 of file forcedeth.c.

397 {
398  void *ioaddr = priv->mmio_addr;
399  u32 tx_ctrl = readl ( ioaddr + NvRegTransmitterControl );
400 
401  DBGP ( "nv_start_tx\n" );
402  tx_ctrl |= NVREG_XMITCTL_START;
403  if ( priv->mac_in_use )
404  tx_ctrl &= ~NVREG_XMITCTL_TX_PATH_EN;
405  writel ( tx_ctrl, ioaddr + NvRegTransmitterControl );
406  pci_push ( ioaddr );
407 }
#define NVREG_XMITCTL_START
Definition: forcedeth.h:378
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define NVREG_XMITCTL_TX_PATH_EN
Definition: forcedeth.h:388
static struct tlan_private * priv
Definition: tlan.c:224
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62
uint32_t u32
Definition: stdint.h:23

References DBGP, ioaddr, NVREG_XMITCTL_START, NVREG_XMITCTL_TX_PATH_EN, NvRegTransmitterControl, pci_push(), priv, readl(), and writel().

Referenced by forcedeth_open(), and nv_update_linkspeed().

◆ nv_stop_tx()

static void nv_stop_tx ( struct forcedeth_private priv)
static

Definition at line 410 of file forcedeth.c.

411 {
412  void *ioaddr = priv->mmio_addr;
413  u32 tx_ctrl = readl ( ioaddr + NvRegTransmitterControl );
414 
415  DBGP ( "nv_stop_tx");
416 
417  if ( ! priv->mac_in_use )
418  tx_ctrl &= ~NVREG_XMITCTL_START;
419  else
420  tx_ctrl |= NVREG_XMITCTL_TX_PATH_EN;
421  writel ( tx_ctrl, ioaddr + NvRegTransmitterControl );
424  "nv_stop_tx: TransmitterStatus remained busy");
425 
427  if ( ! priv->mac_in_use )
431 }
#define NVREG_XMITCTL_START
Definition: forcedeth.h:378
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static int reg_delay(struct forcedeth_private *priv, int offset, u32 mask, u32 target, int delay, int delaymax, const char *msg)
Definition: forcedeth.c:70
#define NVREG_TRANSMITPOLL_MAC_ADDR_REV
Definition: forcedeth.h:452
#define NV_TXSTOP_DELAY1
Definition: forcedeth.h:279
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define NVREG_XMITCTL_TX_PATH_EN
Definition: forcedeth.h:388
#define NV_TXSTOP_DELAY2
Definition: forcedeth.h:281
#define NVREG_XMITSTAT_BUSY
Definition: forcedeth.h:393
#define NV_TXSTOP_DELAY1MAX
Definition: forcedeth.h:280
static struct tlan_private * priv
Definition: tlan.c:224
uint32_t u32
Definition: stdint.h:23

References DBGP, ioaddr, NV_TXSTOP_DELAY1, NV_TXSTOP_DELAY1MAX, NV_TXSTOP_DELAY2, NVREG_TRANSMITPOLL_MAC_ADDR_REV, NVREG_XMITCTL_START, NVREG_XMITCTL_TX_PATH_EN, NVREG_XMITSTAT_BUSY, NvRegTransmitPoll, NvRegTransmitterControl, NvRegTransmitterStatus, priv, readl(), reg_delay(), udelay(), and writel().

Referenced by forcedeth_close(), and nv_update_linkspeed().

◆ nv_update_pause()

static void nv_update_pause ( struct forcedeth_private priv,
u32  pause_flags 
)
static

Definition at line 435 of file forcedeth.c.

436 {
437  void *ioaddr = priv->mmio_addr;
438 
439  priv->pause_flags &= ~ ( NV_PAUSEFRAME_TX_ENABLE |
441 
442  if ( priv->pause_flags & NV_PAUSEFRAME_RX_CAPABLE ) {
444  if ( pause_flags & NV_PAUSEFRAME_RX_ENABLE ) {
446  priv->pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
447  } else {
449  }
450  }
451  if ( priv->pause_flags & NV_PAUSEFRAME_TX_CAPABLE ) {
452  u32 regmisc = readl ( ioaddr + NvRegMisc1 ) & ~NVREG_MISC1_PAUSE_TX;
453  if ( pause_flags & NV_PAUSEFRAME_TX_ENABLE ) {
454  u32 pause_enable = NVREG_TX_PAUSEFRAME_ENABLE_V1;
455  if ( priv->driver_data & DEV_HAS_PAUSEFRAME_TX_V2 )
456  pause_enable = NVREG_TX_PAUSEFRAME_ENABLE_V2;
457  if ( priv->driver_data & DEV_HAS_PAUSEFRAME_TX_V3 ) {
458  pause_enable = NVREG_TX_PAUSEFRAME_ENABLE_V3;
459  /* limit the number of tx pause frames to a default of 8 */
463  }
464  writel ( pause_enable, ioaddr + NvRegTxPauseFrame );
465  writel ( regmisc | NVREG_MISC1_PAUSE_TX, ioaddr + NvRegMisc1 );
466  priv->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
467  } else {
469  writel ( regmisc, ioaddr + NvRegMisc1 );
470  }
471  }
472 }
#define NVREG_TX_PAUSEFRAME_ENABLE_V1
Definition: forcedeth.h:481
#define DEV_HAS_PAUSEFRAME_TX_V3
Definition: forcedeth.h:192
#define NV_PAUSEFRAME_TX_ENABLE
Definition: forcedeth.h:147
#define NVREG_PFF_PAUSE_RX
Definition: forcedeth.h:396
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define NVREG_TX_PAUSEFRAMELIMIT_ENABLE
Definition: forcedeth.h:485
#define NVREG_TX_PAUSEFRAME_ENABLE_V2
Definition: forcedeth.h:482
#define DEV_HAS_PAUSEFRAME_TX_V2
Definition: forcedeth.h:191
static unsigned long ioaddr
Definition: davicom.c:129
#define NVREG_MISC1_PAUSE_TX
Definition: forcedeth.h:371
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define NV_PAUSEFRAME_TX_CAPABLE
Definition: forcedeth.h:145
#define NV_PAUSEFRAME_RX_ENABLE
Definition: forcedeth.h:146
#define NVREG_TX_PAUSEFRAME_ENABLE_V3
Definition: forcedeth.h:483
#define NV_PAUSEFRAME_RX_CAPABLE
Definition: forcedeth.h:144
static struct tlan_private * priv
Definition: tlan.c:224
#define NVREG_TX_PAUSEFRAME_DISABLE
Definition: forcedeth.h:480
uint32_t u32
Definition: stdint.h:23

References DEV_HAS_PAUSEFRAME_TX_V2, DEV_HAS_PAUSEFRAME_TX_V3, ioaddr, NV_PAUSEFRAME_RX_CAPABLE, NV_PAUSEFRAME_RX_ENABLE, NV_PAUSEFRAME_TX_CAPABLE, NV_PAUSEFRAME_TX_ENABLE, NVREG_MISC1_PAUSE_TX, NVREG_PFF_PAUSE_RX, NVREG_TX_PAUSEFRAME_DISABLE, NVREG_TX_PAUSEFRAME_ENABLE_V1, NVREG_TX_PAUSEFRAME_ENABLE_V2, NVREG_TX_PAUSEFRAME_ENABLE_V3, NVREG_TX_PAUSEFRAMELIMIT_ENABLE, NvRegMisc1, NvRegPacketFilterFlags, NvRegTxPauseFrame, NvRegTxPauseFrameLimit, priv, readl(), and writel().

Referenced by nv_update_linkspeed().

◆ nv_update_linkspeed()

static int nv_update_linkspeed ( struct forcedeth_private priv)
static

Definition at line 475 of file forcedeth.c.

476 {
477  void *ioaddr = priv->mmio_addr;
478  int adv = 0;
479  int lpa = 0;
480  int adv_lpa, adv_pause, lpa_pause;
481  u32 newls = priv->linkspeed;
482  int newdup = priv->duplex;
483  int mii_status;
484  int retval = 0;
485  u32 control_1000, status_1000, phyreg, pause_flags, txreg;
486  u32 txrxFlags = 0;
487  u32 phy_exp;
488 
489  /* BMSR_LSTATUS is latched, read it twice:
490  * we want the current value.
491  */
492  mii_rw ( priv, priv->phyaddr, MII_BMSR, MII_READ );
493  mii_status = mii_rw ( priv, priv->phyaddr, MII_BMSR, MII_READ );
494 
495  if ( ! ( mii_status & BMSR_LSTATUS ) ) {
496  DBG ( "No link detected by phy - falling back to 10HD.\n" );
498  newdup = 0;
499  retval = 0;
500  goto set_speed;
501  }
502 
503  /* check auto negotiation is complete */
504  if ( ! ( mii_status & BMSR_ANEGCOMPLETE ) ) {
505  /* still in autonegotiation - configure nic for 10 MBit HD and wait. */
507  newdup = 0;
508  retval = 0;
509  DBG ( "autoneg not completed - falling back to 10HD.\n" );
510  goto set_speed;
511  }
512 
513  adv = mii_rw ( priv, priv->phyaddr, MII_ADVERTISE, MII_READ );
514  lpa = mii_rw ( priv, priv->phyaddr, MII_LPA, MII_READ );
515  DBG ( "nv_update_linkspeed: PHY advertises 0x%04x, lpa 0x%04x.\n", adv, lpa );
516 
517  retval = 1;
518  if ( priv->gigabit == PHY_GIGABIT ) {
519  control_1000 = mii_rw ( priv, priv->phyaddr, MII_CTRL1000, MII_READ);
520  status_1000 = mii_rw ( priv, priv->phyaddr, MII_STAT1000, MII_READ);
521 
522  if ( ( control_1000 & ADVERTISE_1000FULL ) &&
523  ( status_1000 & LPA_1000FULL ) ) {
524  DBG ( "nv_update_linkspeed: GBit ethernet detected.\n" );
526  newdup = 1;
527  goto set_speed;
528  }
529  }
530 
531  /* FIXME: handle parallel detection properly */
532  adv_lpa = lpa & adv;
533  if ( adv_lpa & LPA_100FULL ) {
535  newdup = 1;
536  } else if ( adv_lpa & LPA_100HALF ) {
538  newdup = 0;
539  } else if ( adv_lpa & LPA_10FULL ) {
541  newdup = 1;
542  } else if ( adv_lpa & LPA_10HALF ) {
544  newdup = 0;
545  } else {
546  DBG ( "bad ability %04x - falling back to 10HD.\n", adv_lpa);
548  newdup = 0;
549  }
550 
551 set_speed:
552  if ( priv->duplex == newdup && priv->linkspeed == newls )
553  return retval;
554 
555  DBG ( "changing link setting from %d/%d to %d/%d.\n",
556  priv->linkspeed, priv->duplex, newls, newdup);
557 
558  priv->duplex = newdup;
559  priv->linkspeed = newls;
560 
561  /* The transmitter and receiver must be restarted for safe update */
563  txrxFlags |= NV_RESTART_TX;
564  nv_stop_tx ( priv );
565  }
567  txrxFlags |= NV_RESTART_RX;
568  nv_stop_rx ( priv );
569  }
570 
571  if ( priv->gigabit == PHY_GIGABIT ) {
572  phyreg = readl ( ioaddr + NvRegSlotTime );
573  phyreg &= ~(0x3FF00);
574  if ( ( ( priv->linkspeed & 0xFFF ) == NVREG_LINKSPEED_10 ) ||
575  ( ( priv->linkspeed & 0xFFF ) == NVREG_LINKSPEED_100) )
576  phyreg |= NVREG_SLOTTIME_10_100_FULL;
577  else if ( ( priv->linkspeed & 0xFFF ) == NVREG_LINKSPEED_1000 )
578  phyreg |= NVREG_SLOTTIME_1000_FULL;
579  writel( phyreg, priv + NvRegSlotTime );
580  }
581 
582  phyreg = readl ( ioaddr + NvRegPhyInterface );
583  phyreg &= ~( PHY_HALF | PHY_100 | PHY_1000 );
584  if ( priv->duplex == 0 )
585  phyreg |= PHY_HALF;
586  if ( ( priv->linkspeed & NVREG_LINKSPEED_MASK ) == NVREG_LINKSPEED_100 )
587  phyreg |= PHY_100;
588  else if ( ( priv->linkspeed & NVREG_LINKSPEED_MASK ) == NVREG_LINKSPEED_1000 )
589  phyreg |= PHY_1000;
590  writel ( phyreg, ioaddr + NvRegPhyInterface );
591 
592  phy_exp = mii_rw ( priv, priv->phyaddr, MII_EXPANSION, MII_READ ) & EXPANSION_NWAY; /* autoneg capable */
593  if ( phyreg & PHY_RGMII ) {
594  if ( ( priv->linkspeed & NVREG_LINKSPEED_MASK ) == NVREG_LINKSPEED_1000 ) {
596  } else {
597  if ( !phy_exp && !priv->duplex && ( priv->driver_data & DEV_HAS_COLLISION_FIX ) ) {
598  if ( ( priv->linkspeed & NVREG_LINKSPEED_MASK ) == NVREG_LINKSPEED_10 )
600  else
602  } else {
604  }
605  }
606  } else {
607  if ( !phy_exp && !priv->duplex && ( priv->driver_data & DEV_HAS_COLLISION_FIX ) )
609  else
611  }
612  writel ( txreg, ioaddr + NvRegTxDeferral );
613 
615  writel ( txreg, ioaddr + NvRegTxWatermark );
616 
618  pci_push ( ioaddr );
619  writel ( priv->linkspeed, priv + NvRegLinkSpeed);
620  pci_push ( ioaddr );
621 
622  pause_flags = 0;
623  /* setup pause frame */
624  if ( priv->duplex != 0 ) {
625  if ( priv->pause_flags & NV_PAUSEFRAME_AUTONEG ) {
626  adv_pause = adv & ( ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM );
627  lpa_pause = lpa & ( LPA_PAUSE_CAP | LPA_PAUSE_ASYM );
628 
629  switch ( adv_pause ) {
630  case ADVERTISE_PAUSE_CAP:
631  if ( lpa_pause & LPA_PAUSE_CAP ) {
632  pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
633  if ( priv->pause_flags & NV_PAUSEFRAME_TX_REQ )
634  pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
635  }
636  break;
638  if ( lpa_pause == ( LPA_PAUSE_CAP | LPA_PAUSE_ASYM ) )
639  {
640  pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
641  }
642  break;
644  if ( lpa_pause & LPA_PAUSE_CAP )
645  {
646  pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
647  if ( priv->pause_flags & NV_PAUSEFRAME_TX_REQ )
648  pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
649  }
650  if ( lpa_pause == LPA_PAUSE_ASYM )
651  {
652  pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
653  }
654  break;
655  }
656  } else {
657  pause_flags = priv->pause_flags;
658  }
659  }
660  nv_update_pause ( priv, pause_flags );
661 
662  if ( txrxFlags & NV_RESTART_TX )
663  nv_start_tx ( priv );
664  if ( txrxFlags & NV_RESTART_RX )
665  nv_start_rx ( priv );
666 
667  return retval;
668 }
#define MII_ADVERTISE
Definition: atl1e.h:875
#define LPA_PAUSE_CAP
Definition: mii.h:106
#define LPA_10HALF
Definition: mii.h:97
#define NVREG_LINKSPEED_10
Definition: forcedeth.h:455
#define NVREG_TX_WM_DESC1_DEFAULT
Definition: forcedeth.h:462
#define MII_LPA
Definition: atl1e.h:876
#define MII_READ
Definition: forcedeth.h:296
static void nv_stop_tx(struct forcedeth_private *priv)
Definition: forcedeth.c:410
#define NV_PAUSEFRAME_AUTONEG
Definition: forcedeth.h:150
#define NVREG_XMITCTL_START
Definition: forcedeth.h:378
#define ADVERTISE_1000FULL
Definition: mii.h:133
#define NV_PAUSEFRAME_TX_ENABLE
Definition: forcedeth.h:147
#define NVREG_TX_DEFERRAL_RGMII_STRETCH_100
Definition: forcedeth.h:424
#define NVREG_TX_DEFERRAL_MII_STRETCH
Definition: forcedeth.h:425
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define PHY_HALF
Definition: forcedeth.h:141
#define PHY_RGMII
Definition: forcedeth.h:439
#define EXPANSION_NWAY
Definition: mii.h:117
#define PHY_1000
Definition: forcedeth.h:140
#define NVREG_LINKSPEED_MASK
Definition: forcedeth.h:458
#define LPA_100HALF
Definition: mii.h:101
#define NVREG_SLOTTIME_1000_FULL
Definition: forcedeth.h:414
#define NVREG_LINKSPEED_1000
Definition: forcedeth.h:457
u32 duplex
Definition: tlan.c:214
#define NVREG_MISC1_FORCE
Definition: forcedeth.h:373
static void nv_start_tx(struct forcedeth_private *priv)
Definition: forcedeth.c:396
#define LPA_1000FULL
Definition: mii.h:139
static unsigned long ioaddr
Definition: davicom.c:129
#define LPA_100FULL
Definition: mii.h:103
#define DEV_HAS_COLLISION_FIX
Definition: forcedeth.h:189
#define NVREG_TX_DEFERRAL_DEFAULT
Definition: forcedeth.h:420
#define LPA_10FULL
Definition: mii.h:99
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define BMSR_ANEGCOMPLETE
Definition: mii.h:60
#define NVREG_RCVCTL_START
Definition: forcedeth.h:406
#define MII_CTRL1000
Definition: mii.h:24
#define NVREG_TX_DEFERRAL_RGMII_1000
Definition: forcedeth.h:422
#define NVREG_TX_DEFERRAL_RGMII_10_100
Definition: forcedeth.h:421
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
#define BMSR_LSTATUS
Definition: mii.h:57
#define LPA_PAUSE_ASYM
Definition: mii.h:107
#define NVREG_LINKSPEED_FORCE
Definition: forcedeth.h:454
#define NV_PAUSEFRAME_RX_ENABLE
Definition: forcedeth.h:146
#define NV_RESTART_TX
Definition: forcedeth.h:597
static void nv_stop_rx(struct forcedeth_private *priv)
Definition: forcedeth.c:375
#define NV_RESTART_RX
Definition: forcedeth.h:598
static int mii_rw(struct forcedeth_private *priv, int addr, int miireg, int value)
Definition: forcedeth.c:91
unsigned long retval
Definition: xen.h:45
#define MII_EXPANSION
Definition: atl1e.h:877
static void nv_update_pause(struct forcedeth_private *priv, u32 pause_flags)
Definition: forcedeth.c:435
#define NVREG_MISC1_HD
Definition: forcedeth.h:372
#define NVREG_TX_DEFERRAL_RGMII_STRETCH_10
Definition: forcedeth.h:423
#define NVREG_SLOTTIME_10_100_FULL
Definition: forcedeth.h:413
static struct tlan_private * priv
Definition: tlan.c:224
#define PHY_GIGABIT
Definition: forcedeth.h:134
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62
#define NV_PAUSEFRAME_TX_REQ
Definition: forcedeth.h:149
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
#define NVREG_LINKSPEED_100
Definition: forcedeth.h:456
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define MII_BMSR
Definition: atl1e.h:872
static void nv_start_rx(struct forcedeth_private *priv)
Definition: forcedeth.c:351
#define PHY_100
Definition: forcedeth.h:139
uint32_t u32
Definition: stdint.h:23
#define MII_STAT1000
Definition: mii.h:25

References ADVERTISE_1000FULL, ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, BMSR_ANEGCOMPLETE, BMSR_LSTATUS, DBG, DEV_HAS_COLLISION_FIX, tlan_private::duplex, EXPANSION_NWAY, ioaddr, LPA_1000FULL, LPA_100FULL, LPA_100HALF, LPA_10FULL, LPA_10HALF, LPA_PAUSE_ASYM, LPA_PAUSE_CAP, MII_ADVERTISE, MII_BMSR, MII_CTRL1000, MII_EXPANSION, MII_LPA, MII_READ, mii_rw(), MII_STAT1000, NV_PAUSEFRAME_AUTONEG, NV_PAUSEFRAME_RX_ENABLE, NV_PAUSEFRAME_TX_ENABLE, NV_PAUSEFRAME_TX_REQ, NV_RESTART_RX, NV_RESTART_TX, nv_start_rx(), nv_start_tx(), nv_stop_rx(), nv_stop_tx(), nv_update_pause(), NVREG_LINKSPEED_10, NVREG_LINKSPEED_100, NVREG_LINKSPEED_1000, NVREG_LINKSPEED_FORCE, NVREG_LINKSPEED_MASK, NVREG_MISC1_FORCE, NVREG_MISC1_HD, NVREG_RCVCTL_START, NVREG_SLOTTIME_1000_FULL, NVREG_SLOTTIME_10_100_FULL, NVREG_TX_DEFERRAL_DEFAULT, NVREG_TX_DEFERRAL_MII_STRETCH, NVREG_TX_DEFERRAL_RGMII_1000, NVREG_TX_DEFERRAL_RGMII_10_100, NVREG_TX_DEFERRAL_RGMII_STRETCH_10, NVREG_TX_DEFERRAL_RGMII_STRETCH_100, NVREG_TX_WM_DESC1_DEFAULT, NVREG_XMITCTL_START, NvRegLinkSpeed, NvRegMisc1, NvRegPhyInterface, NvRegReceiverControl, NvRegSlotTime, NvRegTransmitterControl, NvRegTxDeferral, NvRegTxWatermark, pci_push(), PHY_100, PHY_1000, PHY_GIGABIT, PHY_HALF, PHY_RGMII, priv, readl(), retval, and writel().

Referenced by forcedeth_link_status(), and forcedeth_open().

◆ forcedeth_open()

static int forcedeth_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 678 of file forcedeth.c.

679 {
680  struct forcedeth_private *priv = netdev->priv;
681  void *ioaddr = priv->mmio_addr;
682  int i;
683  int rc;
684  u32 low;
685 
686  DBGP ( "forcedeth_open\n" );
687 
688  /* Power up phy */
689  mii_rw ( priv, priv->phyaddr, MII_BMCR,
690  mii_rw ( priv, priv->phyaddr, MII_BMCR, MII_READ ) & ~BMCR_PDOWN );
691 
692  nv_txrx_gate ( priv, 0 );
693 
694  /* Erase previous misconfiguration */
695  if ( priv->driver_data & DEV_HAS_POWER_CNTRL )
696  nv_mac_reset ( priv );
697 
698  /* Clear multicast masks and addresses, enter promiscuous mode */
704 
707 
709 
710  writel ( 0, ioaddr + NvRegLinkSpeed );
713  nv_txrx_reset ( priv );
715 
716  /* Initialize descriptor rings */
717  if ( ( rc = nv_init_rings ( priv ) ) != 0 )
718  goto err_init_rings;
719 
720  writel ( priv->linkspeed, ioaddr + NvRegLinkSpeed );
723  writel ( 0 , ioaddr + NvRegVlanControl );
724  pci_push ( ioaddr );
729  "open: SetupReg5, Bit 31 remained off\n" );
730 
731  writel ( 0, ioaddr + NvRegMIIMask );
734 
739 
742 
743  /* Set up slot time */
744  low = ( random() & NVREG_SLOTTIME_MASK );
746 
749 
751 
753  writel ( ( priv->phyaddr << NVREG_ADAPTCTL_PHYSHIFT ) |
758 
759  i = readl ( ioaddr + NvRegPowerState );
760  if ( ( i & NVREG_POWERSTATE_POWEREDUP ) == 0 )
762 
763  pci_push ( ioaddr );
764  udelay ( 10 );
767 
771  pci_push ( ioaddr );
772 
775  priv->linkspeed = 0;
777  nv_start_rx ( priv );
778  nv_start_tx ( priv );
779 
780  return 0;
781 
782 err_init_rings:
783  return rc;
784 }
#define NVREG_TX_WM_DESC1_DEFAULT
Definition: forcedeth.h:462
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MII_READ
Definition: forcedeth.h:296
uint32_t low
Low 16 bits of address.
Definition: myson.h:19
#define RX_BUF_SZ
Definition: forcedeth.h:67
#define NVREG_ADAPTCTL_RUNNING
Definition: forcedeth.h:498
#define NVREG_ADAPTCTL_PHYSHIFT
Definition: forcedeth.h:499
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static int reg_delay(struct forcedeth_private *priv, int offset, u32 mask, u32 target, int delay, int delaymax, const char *msg)
Definition: forcedeth.c:70
#define NVREG_TRANSMITPOLL_MAC_ADDR_REV
Definition: forcedeth.h:452
#define NVREG_POWERSTATE_POWEREDUP
Definition: forcedeth.h:533
#define NVREG_MISC1_FORCE
Definition: forcedeth.h:373
#define NVREG_TXRXCTL_DESC_1
Definition: forcedeth.h:472
static void nv_start_tx(struct forcedeth_private *priv)
Definition: forcedeth.c:396
static unsigned long ioaddr
Definition: davicom.c:129
#define NVREG_POLL_DEFAULT_THROUGHPUT
Definition: forcedeth.h:364
#define DBGP(...)
Definition: compiler.h:532
#define NVREG_TX_DEFERRAL_DEFAULT
Definition: forcedeth.h:420
static void nv_txrx_reset(struct forcedeth_private *priv)
Definition: forcedeth.c:320
void * priv
Driver private data.
Definition: netdevice.h:431
#define NVREG_SLOTTIME_DEFAULT
Definition: forcedeth.h:416
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct net_device * netdev
Definition: gdbudp.c:52
#define NV_SETUP5_DELAY
Definition: forcedeth.h:285
#define DEV_HAS_POWER_CNTRL
Definition: forcedeth.h:182
#define NVREG_MCASTMASKB_NONE
Definition: forcedeth.h:436
static void nv_mac_reset(struct forcedeth_private *priv)
Definition: forcedeth.c:153
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition: random.c:31
#define NVREG_RX_DEFERRAL_DEFAULT
Definition: forcedeth.h:427
#define NVREG_MII_LINKCHANGE
Definition: forcedeth.h:492
#define MII_BMCR
Definition: atl1e.h:871
static int mii_rw(struct forcedeth_private *priv, int addr, int miireg, int value)
Definition: forcedeth.c:91
#define NVREG_MIIDELAY
Definition: forcedeth.h:502
#define NVREG_POWERSTATE_VALID
Definition: forcedeth.h:534
#define NV_SETUP5_DELAYMAX
Definition: forcedeth.h:286
#define BMCR_PDOWN
Definition: mii.h:48
static void nv_txrx_gate(struct forcedeth_private *priv, int gate)
Definition: forcedeth.c:136
#define NVREG_MISC1_HD
Definition: forcedeth.h:372
#define NVREG_MCASTMASKA_NONE
Definition: forcedeth.h:434
static struct tlan_private * priv
Definition: tlan.c:224
#define NVREG_UNKSETUP6_VAL
Definition: forcedeth.h:357
static int nv_update_linkspeed(struct forcedeth_private *priv)
Definition: forcedeth.c:475
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62
static void nv_disable_hw_interrupts(struct forcedeth_private *priv)
Definition: forcedeth.c:334
#define NVREG_ADAPTCTL_PHYVALID
Definition: forcedeth.h:497
static int nv_init_rings(struct forcedeth_private *priv)
nv_init_rings - Allocate and intialize descriptor rings
Definition: forcedeth.c:263
#define NVREG_MIISPEED_BIT8
Definition: forcedeth.h:501
#define NVREG_UNKSETUP5_BIT31
Definition: forcedeth.h:460
#define NVREG_TXRXCTL_BIT1
Definition: forcedeth.h:467
#define NVREG_MIISTAT_MASK_ALL
Definition: forcedeth.h:490
#define NVREG_PFF_PROMISC
Definition: forcedeth.h:398
static void nv_start_rx(struct forcedeth_private *priv)
Definition: forcedeth.c:351
#define NVREG_SLOTTIME_MASK
Definition: forcedeth.h:417
uint32_t u32
Definition: stdint.h:23
#define NVREG_IRQSTAT_MASK
Definition: forcedeth.h:338

References BMCR_PDOWN, DBGP, DEV_HAS_POWER_CNTRL, ioaddr, low, MII_BMCR, MII_READ, mii_rw(), netdev, nv_disable_hw_interrupts(), nv_init_rings(), nv_mac_reset(), NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX, nv_start_rx(), nv_start_tx(), nv_txrx_gate(), nv_txrx_reset(), nv_update_linkspeed(), NVREG_ADAPTCTL_PHYSHIFT, NVREG_ADAPTCTL_PHYVALID, NVREG_ADAPTCTL_RUNNING, NVREG_IRQSTAT_MASK, NVREG_MCASTMASKA_NONE, NVREG_MCASTMASKB_NONE, NVREG_MII_LINKCHANGE, NVREG_MIIDELAY, NVREG_MIISPEED_BIT8, NVREG_MIISTAT_MASK_ALL, NVREG_MISC1_FORCE, NVREG_MISC1_HD, NVREG_PFF_PROMISC, NVREG_POLL_DEFAULT_THROUGHPUT, NVREG_POWERSTATE_POWEREDUP, NVREG_POWERSTATE_VALID, NVREG_RX_DEFERRAL_DEFAULT, NVREG_SLOTTIME_DEFAULT, NVREG_SLOTTIME_MASK, NVREG_TRANSMITPOLL_MAC_ADDR_REV, NVREG_TX_DEFERRAL_DEFAULT, NVREG_TX_WM_DESC1_DEFAULT, NVREG_TXRXCTL_BIT1, NVREG_TXRXCTL_DESC_1, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP6_VAL, NvRegAdapterControl, NvRegIrqStatus, NvRegLinkSpeed, NvRegMIIMask, NvRegMIISpeed, NvRegMIIStatus, NvRegMisc1, NvRegMulticastAddrA, NvRegMulticastAddrB, NvRegMulticastMaskA, NvRegMulticastMaskB, NvRegOffloadConfig, NvRegPacketFilterFlags, NvRegPollingInterval, NvRegPowerState, NvRegReceiverControl, NvRegReceiverStatus, NvRegRxDeferral, NvRegSlotTime, NvRegTransmitPoll, NvRegTransmitterControl, NvRegTransmitterStatus, NvRegTxDeferral, NvRegTxRxControl, NvRegTxWatermark, NvRegUnknownSetupReg5, NvRegUnknownSetupReg6, NvRegVlanControl, pci_push(), priv, net_device::priv, random(), rc, readl(), reg_delay(), RX_BUF_SZ, udelay(), and writel().

◆ forcedeth_transmit()

static int forcedeth_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 795 of file forcedeth.c.

796 {
797  struct forcedeth_private *priv = netdev->priv;
798  void *ioaddr = priv->mmio_addr;
799  struct ring_desc *tx_curr_desc;
800  u32 size = iob_len ( iobuf );
801 
802  DBGP ( "forcedeth_transmit\n" );
803 
804  /* NOTE: Some NICs have a hw bug that causes them to malfunction
805  * when there are more than 16 outstanding TXs. Increasing the TX
806  * ring size might trigger this bug */
807  if ( priv->tx_fill_ctr == TX_RING_SIZE ) {
808  DBG ( "Tx overflow\n" );
809  return -ENOBUFS;
810  }
811 
812  /* Pad small packets to minimum length */
813  iob_pad ( iobuf, ETH_ZLEN );
814 
815  priv->tx_iobuf[priv->tx_curr] = iobuf;
816 
817  tx_curr_desc = priv->tx_ring + priv->tx_curr;
818 
819  /* Configure current descriptor to transmit packet
820  * ( NV_TX_VALID sets the ownership bit ) */
821  tx_curr_desc->buf =
822  cpu_to_le32 ( virt_to_bus ( iobuf->data ) );
823  wmb();
824  /* Since we don't do fragmentation offloading, we always have
825  * the last packet bit set */
826  tx_curr_desc->flaglen =
828 
829  DBG ( "forcedeth_transmit: flaglen = %#04x\n",
830  ( size - 1 ) | NV_TX_VALID | NV_TX_LASTPACKET );
831  DBG ( "forcedeth_transmit: tx_fill_ctr = %d\n",
832  priv->tx_fill_ctr );
833 
836  pci_push ( ioaddr );
837 
838  /* Point to the next free descriptor */
839  priv->tx_curr = ( priv->tx_curr + 1 ) % TX_RING_SIZE;
840 
841  /* Increment number of descriptors in use */
842  priv->tx_fill_ctr++;
843 
844  return 0;
845 }
wmb()
#define NVREG_TXRXCTL_DESC_1
Definition: forcedeth.h:472
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
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
#define NV_TX_VALID
Definition: forcedeth.h:214
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define NVREG_TXRXCTL_KICK
Definition: forcedeth.h:466
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define ETH_ZLEN
Definition: if_ether.h:10
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
static struct tlan_private * priv
Definition: tlan.c:224
void * data
Start of data.
Definition: iobuf.h:48
static void pci_push(void *ioaddr)
Definition: forcedeth.c:62
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
u32 buf
Definition: forcedeth.h:40
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
Definition: iobpad.c:49
uint32_t u32
Definition: stdint.h:23
#define NV_TX_LASTPACKET
Definition: forcedeth.h:205
#define TX_RING_SIZE
Definition: 3c515.c:86
u32 flaglen
Definition: forcedeth.h:41

References ring_desc::buf, cpu_to_le32, io_buffer::data, DBG, DBGP, ENOBUFS, ETH_ZLEN, ring_desc::flaglen, ioaddr, iob_len(), iob_pad(), netdev, NV_TX_LASTPACKET, NV_TX_VALID, NVREG_TXRXCTL_DESC_1, NVREG_TXRXCTL_KICK, NvRegTxRxControl, pci_push(), priv, net_device::priv, size, TX_RING_SIZE, virt_to_bus(), wmb(), and writel().

◆ nv_process_tx_packets()

static void nv_process_tx_packets ( struct net_device netdev)
static

nv_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_complete()

Parameters
netdevNetwork device

Definition at line 854 of file forcedeth.c.

855 {
856  struct forcedeth_private *priv = netdev->priv;
857  struct ring_desc *tx_curr_desc;
858  u32 flaglen;
859 
860  DBGP ( "nv_process_tx_packets\n" );
861 
862  while ( priv->tx_tail != priv->tx_curr ) {
863 
864  tx_curr_desc = priv->tx_ring + priv->tx_tail;
865  flaglen = le32_to_cpu ( tx_curr_desc->flaglen );
866  rmb();
867 
868  /* Skip this descriptor if hardware still owns it */
869  if ( flaglen & NV_TX_VALID )
870  break;
871 
872  DBG ( "Transmitted packet.\n" );
873  DBG ( "priv->tx_fill_ctr= %d\n", priv->tx_fill_ctr );
874  DBG ( "priv->tx_tail = %d\n", priv->tx_tail );
875  DBG ( "priv->tx_curr = %d\n", priv->tx_curr );
876  DBG ( "flaglen = %#04x\n", flaglen );
877 
878  /* This packet is ready for completion */
879  netdev_tx_complete ( netdev, priv->tx_iobuf[priv->tx_tail] );
880 
881  /* Clear the descriptor */
882  memset ( tx_curr_desc, 0, sizeof(*tx_curr_desc) );
883 
884  /* Reduce the number of tx descriptors in use */
885  priv->tx_fill_ctr--;
886 
887  /* Go to next available descriptor */
888  priv->tx_tail = ( priv->tx_tail + 1 ) % TX_RING_SIZE;
889  }
890 }
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:752
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define rmb()
Definition: io.h:484
#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 NV_TX_VALID
Definition: forcedeth.h:214
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint32_t u32
Definition: stdint.h:23
#define TX_RING_SIZE
Definition: 3c515.c:86
void * memset(void *dest, int character, size_t len) __nonnull
u32 flaglen
Definition: forcedeth.h:41

References DBG, DBGP, ring_desc::flaglen, le32_to_cpu, memset(), netdev, netdev_tx_complete(), NV_TX_VALID, priv, net_device::priv, rmb, and TX_RING_SIZE.

Referenced by forcedeth_poll().

◆ nv_process_rx_packets()

static void nv_process_rx_packets ( struct net_device netdev)
static

nv_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 900 of file forcedeth.c.

901 {
902  struct forcedeth_private *priv = netdev->priv;
903  struct io_buffer *curr_iob;
904  struct ring_desc *rx_curr_desc;
905  u32 flags, len;
906  int i;
907 
908  DBGP ( "nv_process_rx_packets\n" );
909 
910  for ( i = 0; i < RX_RING_SIZE; i++ ) {
911 
912  rx_curr_desc = priv->rx_ring + priv->rx_curr;
913  flags = le32_to_cpu ( rx_curr_desc->flaglen );
914  rmb();
915 
916  /* Skip this descriptor if hardware still owns it */
917  if ( flags & NV_RX_AVAIL )
918  break;
919 
920  /* We own the descriptor, but it has not been refilled yet */
921  curr_iob = priv->rx_iobuf[priv->rx_curr];
922  DBG ( "%p %p\n", curr_iob, priv->rx_iobuf[priv->rx_curr] );
923  if ( curr_iob == NULL )
924  break;
925 
926  DBG ( "Received packet.\n" );
927  DBG ( "priv->rx_curr = %d\n", priv->rx_curr );
928  DBG ( "flags = %#04x\n", flags );
929 
930  /* Check for errors */
931  if ( ( flags & NV_RX_DESCRIPTORVALID ) &&
932  ( flags & NV_RX_ERROR ) ) {
933  netdev_rx_err ( netdev, curr_iob, -EINVAL );
934  DBG ( " Corrupted packet received!\n" );
935  } else {
936  len = flags & LEN_MASK_V1;
937 
938  iob_put ( curr_iob, len );
939  netdev_rx ( netdev, curr_iob );
940  }
941 
942  /* Invalidate iobuf */
943  priv->rx_iobuf[priv->rx_curr] = NULL;
944 
945  /* Invalidate descriptor */
946  memset ( rx_curr_desc, 0, sizeof(*rx_curr_desc) );
947 
948  /* Point to the next free descriptor */
949  priv->rx_curr = ( priv->rx_curr + 1 ) % RX_RING_SIZE;
950  }
951 
952  nv_alloc_rx ( priv );
953 }
#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 LEN_MASK_V1
Definition: forcedeth.h:202
#define le32_to_cpu(value)
Definition: byteswap.h:113
static void nv_alloc_rx(struct forcedeth_private *priv)
nv_alloc_rx - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in use by the ...
Definition: forcedeth.c:207
#define NV_RX_ERROR
Definition: forcedeth.h:246
#define rmb()
Definition: io.h:484
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
uint8_t flags
Flags.
Definition: ena.h:18
#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
#define NV_RX_AVAIL
Definition: forcedeth.h:247
static struct tlan_private * priv
Definition: tlan.c:224
#define NV_RX_DESCRIPTORVALID
Definition: forcedeth.h:236
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint32_t len
Length.
Definition: ena.h:14
#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
u32 flaglen
Definition: forcedeth.h:41
A persistent I/O buffer.
Definition: iobuf.h:33

References DBG, DBGP, EINVAL, ring_desc::flaglen, flags, iob_put, le32_to_cpu, len, LEN_MASK_V1, memset(), netdev, netdev_rx(), netdev_rx_err(), NULL, nv_alloc_rx(), NV_RX_AVAIL, NV_RX_DESCRIPTORVALID, NV_RX_ERROR, priv, net_device::priv, rmb, and RX_RING_SIZE.

Referenced by forcedeth_poll().

◆ forcedeth_link_status()

static void forcedeth_link_status ( struct net_device netdev)
static

check_link - Check for link status change

Parameters
netdevNetwork device

Definition at line 961 of file forcedeth.c.

962 {
963  struct forcedeth_private *priv = netdev->priv;
964  void *ioaddr = priv->mmio_addr;
965 
966  /* Clear the MII link change status by reading the MIIStatus register */
969 
970  if ( nv_update_linkspeed ( priv ) == 1 )
972  else
974 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
static unsigned long ioaddr
Definition: davicom.c:129
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
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
#define NVREG_MIISTAT_LINKCHANGE
Definition: forcedeth.h:488
static struct tlan_private * priv
Definition: tlan.c:224
static int nv_update_linkspeed(struct forcedeth_private *priv)
Definition: forcedeth.c:475

References ioaddr, netdev, netdev_link_down(), netdev_link_up(), nv_update_linkspeed(), NVREG_MIISTAT_LINKCHANGE, NvRegMIIStatus, priv, net_device::priv, readl(), and writel().

Referenced by forcedeth_poll(), and forcedeth_probe().

◆ forcedeth_poll()

static void forcedeth_poll ( struct net_device netdev)
static

poll - Poll for received packets

Parameters
netdevNetwork device

Definition at line 982 of file forcedeth.c.

983 {
984  struct forcedeth_private *priv = netdev->priv;
985  void *ioaddr = priv->mmio_addr;
986  u32 status;
987 
988  DBGP ( "forcedeth_poll\n" );
989 
991 
992  /* Return when no interrupts have been triggered */
993  if ( ! status )
994  return;
995 
996  /* Clear interrupts */
998 
999  DBG ( "forcedeth_poll: status = %#04x\n", status );
1000 
1001  /* Link change interrupt occurred. Call always if link is down,
1002  * to give auto-neg a chance to finish */
1003  if ( ( status & NVREG_IRQ_LINK ) || ! ( netdev_link_ok ( netdev ) ) )
1005 
1006  /* Process transmitted packets */
1008 
1009  /* Process received packets */
1011 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define NVREG_IRQ_LINK
Definition: forcedeth.h:346
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:636
static struct net_device * netdev
Definition: gdbudp.c:52
uint8_t status
Status.
Definition: ena.h:16
static void forcedeth_link_status(struct net_device *netdev)
check_link - Check for link status change
Definition: forcedeth.c:961
static struct tlan_private * priv
Definition: tlan.c:224
static void nv_process_rx_packets(struct net_device *netdev)
nv_process_rx_packets - Checks for received packets, reports them to iPXE with netdev_rx() or netdev_...
Definition: forcedeth.c:900
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static void nv_process_tx_packets(struct net_device *netdev)
nv_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_com...
Definition: forcedeth.c:854
uint32_t u32
Definition: stdint.h:23
#define NVREG_IRQSTAT_MASK
Definition: forcedeth.h:338

References DBG, DBGP, forcedeth_link_status(), ioaddr, netdev, netdev_link_ok(), nv_process_rx_packets(), nv_process_tx_packets(), NVREG_IRQ_LINK, NVREG_IRQSTAT_MASK, NvRegIrqStatus, priv, net_device::priv, readl(), status, and writel().

◆ forcedeth_close()

static void forcedeth_close ( struct net_device netdev)
static

close - Disable network interface

Parameters
netdevnetwork interface device structure

Definition at line 1019 of file forcedeth.c.

1020 {
1021  struct forcedeth_private *priv = netdev->priv;
1022 
1023  DBGP ( "forcedeth_close\n" );
1024 
1025  nv_stop_rx ( priv );
1026  nv_stop_tx ( priv );
1027  nv_txrx_reset ( priv );
1028 
1029  /* Disable interrupts on the nic or we will lock up */
1031 
1033 
1034  nv_txrx_gate ( priv, 0 );
1035 
1036  /* FIXME: power down nic */
1037 }
static void nv_stop_tx(struct forcedeth_private *priv)
Definition: forcedeth.c:410
#define DBGP(...)
Definition: compiler.h:532
static void nv_txrx_reset(struct forcedeth_private *priv)
Definition: forcedeth.c:320
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static void nv_free_rxtx_resources(struct forcedeth_private *priv)
Definition: forcedeth.c:305
static void nv_stop_rx(struct forcedeth_private *priv)
Definition: forcedeth.c:375
static void nv_txrx_gate(struct forcedeth_private *priv, int gate)
Definition: forcedeth.c:136
static struct tlan_private * priv
Definition: tlan.c:224
static void nv_disable_hw_interrupts(struct forcedeth_private *priv)
Definition: forcedeth.c:334

References DBGP, netdev, nv_disable_hw_interrupts(), nv_free_rxtx_resources(), nv_stop_rx(), nv_stop_tx(), nv_txrx_gate(), nv_txrx_reset(), priv, and net_device::priv.

◆ forcedeth_irq()

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

irq - enable or disable interrupts

Parameters
netdevnetwork adapter
actionrequested interrupt action

Definition at line 1046 of file forcedeth.c.

1047 {
1048  struct forcedeth_private *priv = netdev->priv;
1049 
1050  DBGP ( "forcedeth_irq\n" );
1051 
1052  switch ( action ) {
1053  case 0:
1055  break;
1056  default:
1058  break;
1059  }
1060 }
#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 void nv_enable_hw_interrupts(struct forcedeth_private *priv)
Definition: forcedeth.c:343
static struct tlan_private * priv
Definition: tlan.c:224
static void nv_disable_hw_interrupts(struct forcedeth_private *priv)
Definition: forcedeth.c:334

References DBGP, netdev, nv_disable_hw_interrupts(), nv_enable_hw_interrupts(), priv, and net_device::priv.

◆ nv_setup_mac_addr()

static int nv_setup_mac_addr ( struct forcedeth_private priv)
static

Definition at line 1071 of file forcedeth.c.

1072 {
1073  struct net_device *dev = priv->netdev;
1074  void *ioaddr = priv->mmio_addr;
1075  u32 orig_mac[2];
1076  u32 txreg;
1077 
1078  orig_mac[0] = readl ( ioaddr + NvRegMacAddrA );
1079  orig_mac[1] = readl ( ioaddr + NvRegMacAddrB );
1080 
1081  txreg = readl ( ioaddr + NvRegTransmitPoll );
1082 
1083  if ( ( priv->driver_data & DEV_HAS_CORRECT_MACADDR ) ||
1084  ( txreg & NVREG_TRANSMITPOLL_MAC_ADDR_REV ) ) {
1085  /* mac address is already in correct order */
1086  dev->hw_addr[0] = ( orig_mac[0] >> 0 ) & 0xff;
1087  dev->hw_addr[1] = ( orig_mac[0] >> 8 ) & 0xff;
1088  dev->hw_addr[2] = ( orig_mac[0] >> 16 ) & 0xff;
1089  dev->hw_addr[3] = ( orig_mac[0] >> 24 ) & 0xff;
1090  dev->hw_addr[4] = ( orig_mac[1] >> 0 ) & 0xff;
1091  dev->hw_addr[5] = ( orig_mac[1] >> 8 ) & 0xff;
1092  } else {
1093  /* need to reverse mac address to correct order */
1094  dev->hw_addr[0] = ( orig_mac[1] >> 8 ) & 0xff;
1095  dev->hw_addr[1] = ( orig_mac[1] >> 0 ) & 0xff;
1096  dev->hw_addr[2] = ( orig_mac[0] >> 24 ) & 0xff;
1097  dev->hw_addr[3] = ( orig_mac[0] >> 16 ) & 0xff;
1098  dev->hw_addr[4] = ( orig_mac[0] >> 8 ) & 0xff;
1099  dev->hw_addr[5] = ( orig_mac[0] >> 0 ) & 0xff;
1100  }
1101 
1102  if ( ! is_valid_ether_addr ( dev->hw_addr ) )
1103  return -EADDRNOTAVAIL;
1104 
1105  DBG ( "MAC address is: %s\n", eth_ntoa ( dev->hw_addr ) );
1106 
1107  return 0;
1108 }
#define DEV_HAS_CORRECT_MACADDR
Definition: forcedeth.h:188
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define NVREG_TRANSMITPOLL_MAC_ADDR_REV
Definition: forcedeth.h:452
static unsigned long ioaddr
Definition: davicom.c:129
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A network device.
Definition: netdevice.h:352
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
#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
uint32_t u32
Definition: stdint.h:23

References DBG, net_device::dev, DEV_HAS_CORRECT_MACADDR, EADDRNOTAVAIL, eth_ntoa(), ioaddr, is_valid_ether_addr(), NVREG_TRANSMITPOLL_MAC_ADDR_REV, NvRegMacAddrA, NvRegMacAddrB, NvRegTransmitPoll, priv, and readl().

Referenced by forcedeth_probe().

◆ nv_mgmt_acquire_sema()

static int nv_mgmt_acquire_sema ( struct forcedeth_private priv)
static

Definition at line 1111 of file forcedeth.c.

1112 {
1113  void *ioaddr = priv->mmio_addr;
1114  int i;
1115  u32 tx_ctrl, mgmt_sema;
1116 
1117  for ( i = 0; i < 10; i++ ) {
1118  mgmt_sema = readl ( ioaddr + NvRegTransmitterControl ) &
1120  if ( mgmt_sema == NVREG_XMITCTL_MGMT_SEMA_FREE )
1121  break;
1122  mdelay ( 500 );
1123  }
1124 
1125  if ( mgmt_sema != NVREG_XMITCTL_MGMT_SEMA_FREE )
1126  return 0;
1127 
1128  for ( i = 0; i < 2; i++ ) {
1129  tx_ctrl = readl ( ioaddr + NvRegTransmitterControl );
1130  tx_ctrl |= NVREG_XMITCTL_HOST_SEMA_ACQ;
1131  writel ( tx_ctrl, ioaddr + NvRegTransmitterControl );
1132 
1133  /* verify that the semaphore was acquired */
1134  tx_ctrl = readl ( ioaddr + NvRegTransmitterControl );
1135  if ( ( ( tx_ctrl & NVREG_XMITCTL_HOST_SEMA_MASK ) ==
1137  ( ( tx_ctrl & NVREG_XMITCTL_MGMT_SEMA_MASK ) ==
1139  priv->mgmt_sema = 1;
1140  return 1;
1141  } else {
1142  udelay ( 50 );
1143  }
1144  }
1145 
1146  return 0;
1147 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static unsigned long ioaddr
Definition: davicom.c:129
#define NVREG_XMITCTL_MGMT_SEMA_MASK
Definition: forcedeth.h:383
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define NVREG_XMITCTL_HOST_SEMA_MASK
Definition: forcedeth.h:385
#define NVREG_XMITCTL_MGMT_SEMA_FREE
Definition: forcedeth.h:384
#define NVREG_XMITCTL_HOST_SEMA_ACQ
Definition: forcedeth.h:386
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static struct tlan_private * priv
Definition: tlan.c:224
uint32_t u32
Definition: stdint.h:23

References ioaddr, mdelay(), NVREG_XMITCTL_HOST_SEMA_ACQ, NVREG_XMITCTL_HOST_SEMA_MASK, NVREG_XMITCTL_MGMT_SEMA_FREE, NVREG_XMITCTL_MGMT_SEMA_MASK, NvRegTransmitterControl, priv, readl(), udelay(), and writel().

Referenced by nv_setup_phy().

◆ nv_mgmt_release_sema()

static void nv_mgmt_release_sema ( struct forcedeth_private priv)
static

Definition at line 1150 of file forcedeth.c.

1151 {
1152  void *ioaddr = priv->mmio_addr;
1153  u32 tx_ctrl;
1154 
1155  if ( priv->driver_data & DEV_HAS_MGMT_UNIT ) {
1156  if ( priv->mgmt_sema ) {
1157  tx_ctrl = readl (ioaddr + NvRegTransmitterControl );
1158  tx_ctrl &= ~NVREG_XMITCTL_HOST_SEMA_ACQ;
1159  writel ( tx_ctrl, ioaddr + NvRegTransmitterControl );
1160  }
1161  }
1162 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static unsigned long ioaddr
Definition: davicom.c:129
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define DEV_HAS_MGMT_UNIT
Definition: forcedeth.h:187
#define NVREG_XMITCTL_HOST_SEMA_ACQ
Definition: forcedeth.h:386
static struct tlan_private * priv
Definition: tlan.c:224
uint32_t u32
Definition: stdint.h:23

References DEV_HAS_MGMT_UNIT, ioaddr, NVREG_XMITCTL_HOST_SEMA_ACQ, NvRegTransmitterControl, priv, readl(), and writel().

Referenced by forcedeth_remove().

◆ nv_mgmt_get_version()

static int nv_mgmt_get_version ( struct forcedeth_private priv)
static

Definition at line 1165 of file forcedeth.c.

1166 {
1167  void *ioaddr = priv->mmio_addr;
1168  u32 data_ready = readl ( ioaddr + NvRegTransmitterControl );
1169  u32 data_ready2 = 0;
1170  unsigned long start;
1171  int ready = 0;
1172 
1175  writel ( data_ready ^ NVREG_XMITCTL_DATA_START,
1177  start = currticks();
1178 
1179  while ( currticks() > start + 5 * TICKS_PER_SEC ) {
1180  data_ready2 = readl ( ioaddr + NvRegTransmitterControl );
1181  if ( ( data_ready & NVREG_XMITCTL_DATA_READY ) !=
1182  ( data_ready2 & NVREG_XMITCTL_DATA_READY ) ) {
1183  ready = 1;
1184  break;
1185  }
1186  mdelay ( 1000 );
1187  }
1188 
1189  if ( ! ready || ( data_ready2 & NVREG_XMITCTL_DATA_ERROR ) )
1190  return 0;
1191 
1192  priv->mgmt_version =
1194 
1195  return 1;
1196 }
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
#define NVREG_XMITCTL_DATA_ERROR
Definition: forcedeth.h:391
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define NVREG_XMITCTL_DATA_READY
Definition: forcedeth.h:390
uint32_t start
Starting offset.
Definition: netvsc.h:12
static unsigned long ioaddr
Definition: davicom.c:129
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define NVREG_MGMTUNITVERSION
Definition: forcedeth.h:527
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static struct tlan_private * priv
Definition: tlan.c:224
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define NVREG_XMITCTL_DATA_START
Definition: forcedeth.h:389
uint32_t u32
Definition: stdint.h:23
#define NVREG_MGMTUNITGETVERSION
Definition: forcedeth.h:525

References currticks(), ioaddr, mdelay(), NVREG_MGMTUNITGETVERSION, NVREG_MGMTUNITVERSION, NVREG_XMITCTL_DATA_ERROR, NVREG_XMITCTL_DATA_READY, NVREG_XMITCTL_DATA_START, NvRegMgmtUnitGetVersion, NvRegMgmtUnitVersion, NvRegTransmitterControl, priv, readl(), start, TICKS_PER_SEC, and writel().

Referenced by nv_setup_phy().

◆ phy_reset()

static int phy_reset ( struct forcedeth_private priv,
u32  bmcr_setup 
)
static

Definition at line 1201 of file forcedeth.c.

1202 {
1203  u32 miicontrol;
1204  unsigned int tries = 0;
1205 
1206  miicontrol = BMCR_RESET | bmcr_setup;
1207  if ( mii_rw ( priv, priv->phyaddr, MII_BMCR, miicontrol ) ) {
1208  return -1;
1209  }
1210 
1211  mdelay ( 500 );
1212 
1213  /* must wait till reset is deasserted */
1214  while ( miicontrol & BMCR_RESET ) {
1215  mdelay ( 10 );
1216  miicontrol = mii_rw ( priv, priv->phyaddr, MII_BMCR, MII_READ );
1217  if ( tries++ > 100 )
1218  return -1;
1219  }
1220  return 0;
1221 }
#define MII_READ
Definition: forcedeth.h:296
#define MII_BMCR
Definition: atl1e.h:871
static int mii_rw(struct forcedeth_private *priv, int addr, int miireg, int value)
Definition: forcedeth.c:91
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static struct tlan_private * priv
Definition: tlan.c:224
#define BMCR_RESET
Definition: mii.h:52
uint32_t u32
Definition: stdint.h:23

References BMCR_RESET, mdelay(), MII_BMCR, MII_READ, mii_rw(), and priv.

Referenced by phy_init().

◆ phy_init()

static int phy_init ( struct forcedeth_private priv)
static

Definition at line 1224 of file forcedeth.c.

1225 {
1226  void *ioaddr = priv->mmio_addr;
1227  u32 phyinterface, phy_reserved, mii_status;
1228  u32 mii_control, mii_control_1000, reg;
1229 
1230  /* phy errata for E3016 phy */
1231  if ( priv->phy_model == PHY_MODEL_MARVELL_E3016 ) {
1232  reg = mii_rw ( priv, priv->phyaddr, MII_NCONFIG, MII_READ );
1234  if ( mii_rw ( priv, priv->phyaddr, MII_NCONFIG, reg ) ) {
1235  DBG ( "PHY write to errata reg failed.\n" );
1236  return PHY_ERROR;
1237  }
1238  }
1239 
1240  if ( priv->phy_oui == PHY_OUI_REALTEK ) {
1241  if ( priv->phy_model == PHY_MODEL_REALTEK_8211 &&
1242  priv->phy_rev == PHY_REV_REALTEK_8211B ) {
1243  if ( mii_rw ( priv, priv->phyaddr,
1245  DBG ( "PHY init failed.\n" );
1246  return PHY_ERROR;
1247  }
1248  if ( mii_rw ( priv, priv->phyaddr,
1250  DBG ( "PHY init failed.\n" );
1251  return PHY_ERROR;
1252  }
1253  if ( mii_rw ( priv, priv->phyaddr,
1255  DBG ( "PHY init failed.\n" );
1256  return PHY_ERROR;
1257  }
1258  if ( mii_rw ( priv, priv->phyaddr,
1260  DBG ( "PHY init failed.\n" );
1261  return PHY_ERROR;
1262  }
1263  if ( mii_rw ( priv, priv->phyaddr,
1265  DBG ( "PHY init failed.\n" );
1266  return PHY_ERROR;
1267  }
1268  if ( mii_rw ( priv, priv->phyaddr,
1270  DBG ( "PHY init failed.\n" );
1271  return PHY_ERROR;
1272  }
1273  if ( mii_rw ( priv, priv->phyaddr,
1275  DBG ( "PHY init failed.\n" );
1276  return PHY_ERROR;
1277  }
1278  }
1279 
1280  if ( priv->phy_model == PHY_MODEL_REALTEK_8211 &&
1281  priv->phy_rev == PHY_REV_REALTEK_8211C ) {
1282  u32 powerstate = readl ( ioaddr + NvRegPowerState2 );
1283 
1284  /* need to perform hw phy reset */
1285  powerstate |= NVREG_POWERSTATE2_PHY_RESET;
1286  writel ( powerstate , ioaddr + NvRegPowerState2 );
1287  mdelay ( 25 );
1288 
1289  powerstate &= ~NVREG_POWERSTATE2_PHY_RESET;
1290  writel ( powerstate , ioaddr + NvRegPowerState2 );
1291  mdelay ( 25 );
1292 
1293  reg = mii_rw ( priv, priv->phyaddr,
1296  if ( mii_rw ( priv, priv->phyaddr,
1297  PHY_REALTEK_INIT_REG6, reg ) ) {
1298  DBG ( "PHY init failed.\n" );
1299  return PHY_ERROR;
1300  }
1301  if ( mii_rw ( priv, priv->phyaddr,
1303  DBG ( "PHY init failed.\n" );
1304  return PHY_ERROR;
1305  }
1306 
1307  reg = mii_rw ( priv, priv->phyaddr,
1309  if ( ! ( reg & PHY_REALTEK_INIT11 ) ) {
1311  if ( mii_rw ( priv, priv->phyaddr,
1312  PHY_REALTEK_INIT_REG7, reg ) ) {
1313  DBG ( "PHY init failed.\n" );
1314  return PHY_ERROR;
1315  }
1316  }
1317  if ( mii_rw ( priv, priv->phyaddr,
1319  DBG ( "PHY init failed.\n" );
1320  return PHY_ERROR;
1321  }
1322  }
1323  if ( priv->phy_model == PHY_MODEL_REALTEK_8201 ) {
1324  if ( priv->driver_data & DEV_NEED_PHY_INIT_FIX ) {
1325  phy_reserved = mii_rw ( priv, priv->phyaddr,
1327  MII_READ );
1328  phy_reserved |= PHY_REALTEK_INIT7;
1329  if ( mii_rw ( priv, priv->phyaddr,
1331  phy_reserved ) ) {
1332  DBG ( "PHY init failed.\n" );
1333  return PHY_ERROR;
1334  }
1335  }
1336  }
1337  }
1338 
1339  /* set advertise register */
1340  reg = mii_rw ( priv, priv->phyaddr, MII_ADVERTISE, MII_READ );
1343  if ( mii_rw ( priv, priv->phyaddr, MII_ADVERTISE, reg ) ) {
1344  DBG ( "PHY init failed.\n" );
1345  return PHY_ERROR;
1346  }
1347 
1348  /* get phy interface type */
1349  phyinterface = readl ( ioaddr + NvRegPhyInterface );
1350 
1351  /* see if gigabit phy */
1352  mii_status = mii_rw ( priv, priv->phyaddr, MII_BMSR, MII_READ );
1353  if ( mii_status & PHY_GIGABIT ) {
1354  priv->gigabit = PHY_GIGABIT;
1355  mii_control_1000 =
1356  mii_rw ( priv, priv->phyaddr, MII_CTRL1000, MII_READ );
1357  mii_control_1000 &= ~ADVERTISE_1000HALF;
1358  if ( phyinterface & PHY_RGMII )
1359  mii_control_1000 |= ADVERTISE_1000FULL;
1360  else
1361  mii_control_1000 &= ~ADVERTISE_1000FULL;
1362 
1363  if ( mii_rw ( priv, priv->phyaddr, MII_CTRL1000, mii_control_1000)) {
1364  DBG ( "PHY init failed.\n" );
1365  return PHY_ERROR;
1366  }
1367  } else {
1368  priv->gigabit = 0;
1369  }
1370 
1371  mii_control = mii_rw ( priv, priv->phyaddr, MII_BMCR, MII_READ );
1372  mii_control |= BMCR_ANENABLE;
1373 
1374  if ( priv->phy_oui == PHY_OUI_REALTEK &&
1375  priv->phy_model == PHY_MODEL_REALTEK_8211 &&
1376  priv->phy_rev == PHY_REV_REALTEK_8211C ) {
1377  /* start autoneg since we already performed hw reset above */
1378  mii_control |= BMCR_ANRESTART;
1379  if ( mii_rw ( priv, priv->phyaddr, MII_BMCR, mii_control ) ) {
1380  DBG ( "PHY init failed.\n" );
1381  return PHY_ERROR;
1382  }
1383  } else {
1384  /* reset the phy
1385  * (certain phys need bmcr to be setup with reset )
1386  */
1387  if ( phy_reset ( priv, mii_control ) ) {
1388  DBG ( "PHY reset failed\n" );
1389  return PHY_ERROR;
1390  }
1391  }
1392 
1393  /* phy vendor specific configuration */
1394  if ( ( priv->phy_oui == PHY_OUI_CICADA ) && ( phyinterface & PHY_RGMII ) ) {
1395  phy_reserved = mii_rw ( priv, priv->phyaddr, MII_RESV1, MII_READ );
1396  phy_reserved &= ~( PHY_CICADA_INIT1 | PHY_CICADA_INIT2 );
1397  phy_reserved |= ( PHY_CICADA_INIT3 | PHY_CICADA_INIT4 );
1398  if ( mii_rw ( priv, priv->phyaddr, MII_RESV1, phy_reserved ) ) {
1399  DBG ( "PHY init failed.\n" );
1400  return PHY_ERROR;
1401  }
1402  phy_reserved = mii_rw ( priv, priv->phyaddr, MII_NCONFIG, MII_READ );
1403  phy_reserved |= PHY_CICADA_INIT5;
1404  if ( mii_rw ( priv, priv->phyaddr, MII_NCONFIG, phy_reserved ) ) {
1405  DBG ( "PHY init failed.\n" );
1406  return PHY_ERROR;
1407  }
1408  }
1409  if ( priv->phy_oui == PHY_OUI_CICADA ) {
1410  phy_reserved = mii_rw ( priv, priv->phyaddr, MII_SREVISION, MII_READ );
1411  phy_reserved |= PHY_CICADA_INIT6;
1412  if ( mii_rw ( priv, priv->phyaddr, MII_SREVISION, phy_reserved ) ) {
1413  DBG ( "PHY init failed.\n" );
1414  return PHY_ERROR;
1415  }
1416  }
1417  if ( priv->phy_oui == PHY_OUI_VITESSE ) {
1418  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG1,
1419  PHY_VITESSE_INIT1)) {
1420  DBG ( "PHY init failed.\n" );
1421  return PHY_ERROR;
1422  }
1423  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG2,
1424  PHY_VITESSE_INIT2)) {
1425  DBG ( "PHY init failed.\n" );
1426  return PHY_ERROR;
1427  }
1428  phy_reserved = mii_rw ( priv, priv->phyaddr,
1430  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG4,
1431  phy_reserved ) ) {
1432  DBG ( "PHY init failed.\n" );
1433  return PHY_ERROR;
1434  }
1435  phy_reserved = mii_rw ( priv, priv->phyaddr,
1437  phy_reserved &= ~PHY_VITESSE_INIT_MSK1;
1438  phy_reserved |= PHY_VITESSE_INIT3;
1439  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG3,
1440  phy_reserved ) ) {
1441  DBG ( "PHY init failed.\n" );
1442  return PHY_ERROR;
1443  }
1444  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG2,
1445  PHY_VITESSE_INIT4 ) ) {
1446  DBG ( "PHY init failed.\n" );
1447  return PHY_ERROR;
1448  }
1449  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG2,
1450  PHY_VITESSE_INIT5 ) ) {
1451  DBG ( "PHY init failed.\n" );
1452  return PHY_ERROR;
1453  }
1454  phy_reserved = mii_rw ( priv, priv->phyaddr,
1456  phy_reserved &= ~PHY_VITESSE_INIT_MSK1;
1457  phy_reserved |= PHY_VITESSE_INIT3;
1458  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG4,
1459  phy_reserved ) ) {
1460  DBG ( "PHY init failed.\n" );
1461  return PHY_ERROR;
1462  }
1463  phy_reserved = mii_rw ( priv, priv->phyaddr,
1465  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG3,
1466  phy_reserved ) ) {
1467  DBG ( "PHY init failed.\n" );
1468  return PHY_ERROR;
1469  }
1470  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG2,
1471  PHY_VITESSE_INIT6 ) ) {
1472  DBG ( "PHY init failed.\n" );
1473  return PHY_ERROR;
1474  }
1475  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG2,
1476  PHY_VITESSE_INIT7 ) ) {
1477  DBG ( "PHY init failed.\n" );
1478  return PHY_ERROR;
1479  }
1480  phy_reserved = mii_rw ( priv, priv->phyaddr,
1482  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG4,
1483  phy_reserved ) ) {
1484  DBG ( "PHY init failed.\n" );
1485  return PHY_ERROR;
1486  }
1487  phy_reserved = mii_rw ( priv, priv->phyaddr,
1489  phy_reserved &= ~PHY_VITESSE_INIT_MSK2;
1490  phy_reserved |= PHY_VITESSE_INIT8;
1491  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG3,
1492  phy_reserved ) ) {
1493  DBG ( "PHY init failed.\n" );
1494  return PHY_ERROR;
1495  }
1496  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG2,
1497  PHY_VITESSE_INIT9 ) ) {
1498  DBG ( "PHY init failed.\n" );
1499  return PHY_ERROR;
1500  }
1501  if ( mii_rw ( priv, priv->phyaddr, PHY_VITESSE_INIT_REG1,
1502  PHY_VITESSE_INIT10 ) ) {
1503  DBG ( "PHY init failed.\n" );
1504  return PHY_ERROR;
1505  }
1506  }
1507 
1508  if ( priv->phy_oui == PHY_OUI_REALTEK ) {
1509  if ( priv->phy_model == PHY_MODEL_REALTEK_8211 &&
1510  priv->phy_rev == PHY_REV_REALTEK_8211B ) {
1511  /* reset could have cleared these out, set them back */
1512  if ( mii_rw ( priv, priv->phyaddr,
1514  DBG ( "PHY init failed.\n" );
1515  return PHY_ERROR;
1516  }
1517  if ( mii_rw ( priv, priv->phyaddr,
1519  DBG ( "PHY init failed.\n" );
1520  return PHY_ERROR;
1521  }
1522  if ( mii_rw ( priv, priv->phyaddr,
1524  DBG ( "PHY init failed.\n" );
1525  return PHY_ERROR;
1526  }
1527  if ( mii_rw ( priv, priv->phyaddr,
1529  DBG ( "PHY init failed.\n" );
1530  return PHY_ERROR;
1531  }
1532  if ( mii_rw ( priv, priv->phyaddr,
1534  DBG ( "PHY init failed.\n" );
1535  return PHY_ERROR;
1536  }
1537  if ( mii_rw ( priv, priv->phyaddr,
1539  DBG ( "PHY init failed.\n" );
1540  return PHY_ERROR;
1541  }
1542  if ( mii_rw ( priv, priv->phyaddr,
1544  DBG ( "PHY init failed.\n" );
1545  return PHY_ERROR;
1546  }
1547  }
1548  if ( priv->phy_model == PHY_MODEL_REALTEK_8201 ) {
1549  if ( priv->driver_data & DEV_NEED_PHY_INIT_FIX ) {
1550  phy_reserved = mii_rw ( priv, priv->phyaddr,
1552  MII_READ );
1553  phy_reserved |= PHY_REALTEK_INIT7;
1554  if ( mii_rw ( priv, priv->phyaddr,
1556  phy_reserved ) ) {
1557  DBG ( "PHY init failed.\n" );
1558  return PHY_ERROR;
1559  }
1560  }
1561 
1562  if ( mii_rw ( priv, priv->phyaddr,
1564  PHY_REALTEK_INIT3 ) ) {
1565  DBG ( "PHY init failed.\n" );
1566  return PHY_ERROR;
1567  }
1568  phy_reserved = mii_rw ( priv, priv->phyaddr,
1570  MII_READ );
1571  phy_reserved &= ~PHY_REALTEK_INIT_MSK1;
1572  phy_reserved |= PHY_REALTEK_INIT3;
1573  if ( mii_rw ( priv, priv->phyaddr,
1575  phy_reserved ) ) {
1576  DBG ( "PHY init failed.\n" );
1577  return PHY_ERROR;
1578  }
1579  if ( mii_rw ( priv, priv->phyaddr,
1581  PHY_REALTEK_INIT1 ) ) {
1582  DBG ( "PHY init failed.\n" );
1583  return PHY_ERROR;
1584  }
1585  }
1586  }
1587 
1588  /* some phys clear out pause advertisement on reset, set it back */
1589  mii_rw ( priv, priv->phyaddr, MII_ADVERTISE, reg );
1590 
1591  /* restart auto negotiation, power down phy */
1592  mii_control = mii_rw ( priv, priv->phyaddr, MII_BMCR, MII_READ );
1593  mii_control |= ( BMCR_ANRESTART | BMCR_ANENABLE );
1594  if ( mii_rw ( priv, priv->phyaddr, MII_BMCR, mii_control ) ) {
1595  return PHY_ERROR;
1596  }
1597 
1598  return 0;
1599 }
#define PHY_VITESSE_INIT_REG3
Definition: forcedeth.h:100
#define MII_ADVERTISE
Definition: atl1e.h:875
#define PHY_REALTEK_INIT_REG7
Definition: forcedeth.h:120
#define MII_READ
Definition: forcedeth.h:296
#define ADVERTISE_1000FULL
Definition: mii.h:133
#define PHY_REALTEK_INIT11
Definition: forcedeth.h:131
#define PHY_REALTEK_INIT4
Definition: forcedeth.h:124
static unsigned int unsigned int reg
Definition: myson.h:162
#define PHY_REALTEK_INIT6
Definition: forcedeth.h:126
#define MII_SREVISION
Definition: atl1e.h:887
#define ADVERTISE_10FULL
Definition: mii.h:76
#define PHY_VITESSE_INIT3
Definition: forcedeth.h:106
#define PHY_VITESSE_INIT5
Definition: forcedeth.h:108
#define PHY_MODEL_REALTEK_8211
Definition: forcedeth.h:85
#define PHY_REALTEK_INIT9
Definition: forcedeth.h:129
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static int phy_reset(struct forcedeth_private *priv, u32 bmcr_setup)
Definition: forcedeth.c:1201
#define PHY_RGMII
Definition: forcedeth.h:439
#define BMCR_ANRESTART
Definition: mii.h:46
#define ADVERTISE_100FULL
Definition: mii.h:80
#define PHY_REALTEK_INIT3
Definition: forcedeth.h:123
#define PHY_VITESSE_INIT_REG4
Definition: forcedeth.h:101
#define PHY_REALTEK_INIT_MSK1
Definition: forcedeth.h:132
#define PHY_REV_REALTEK_8211B
Definition: forcedeth.h:87
#define DEV_NEED_PHY_INIT_FIX
Definition: forcedeth.h:196
#define PHY_MARVELL_E3016_INITMASK
Definition: forcedeth.h:91
#define PHY_CICADA_INIT4
Definition: forcedeth.h:95
#define PHY_REALTEK_INIT5
Definition: forcedeth.h:125
#define PHY_CICADA_INIT1
Definition: forcedeth.h:92
static unsigned long ioaddr
Definition: davicom.c:129
#define PHY_VITESSE_INIT1
Definition: forcedeth.h:104
#define PHY_ERROR
Definition: forcedeth.h:137
#define PHY_VITESSE_INIT_MSK2
Definition: forcedeth.h:103
#define PHY_VITESSE_INIT6
Definition: forcedeth.h:109
#define MII_RESV1
Definition: atl1e.h:888
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define PHY_CICADA_INIT6
Definition: forcedeth.h:97
#define MII_CTRL1000
Definition: mii.h:24
#define PHY_REALTEK_INIT_REG3
Definition: forcedeth.h:116
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
#define PHY_REALTEK_INIT_REG4
Definition: forcedeth.h:117
#define PHY_VITESSE_INIT7
Definition: forcedeth.h:110
#define PHY_VITESSE_INIT10
Definition: forcedeth.h:113
#define MII_BMCR
Definition: atl1e.h:871
#define PHY_REALTEK_INIT_REG1
Definition: forcedeth.h:114
static int mii_rw(struct forcedeth_private *priv, int addr, int miireg, int value)
Definition: forcedeth.c:91
#define PHY_VITESSE_INIT2
Definition: forcedeth.h:105
#define ADVERTISE_1000HALF
Definition: mii.h:134
#define PHY_CICADA_INIT2
Definition: forcedeth.h:93
#define PHY_REALTEK_INIT_REG6
Definition: forcedeth.h:119
#define PHY_OUI_CICADA
Definition: forcedeth.h:76
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define PHY_VITESSE_INIT_REG1
Definition: forcedeth.h:98
#define PHY_REV_REALTEK_8211C
Definition: forcedeth.h:88
#define PHY_MODEL_MARVELL_E3016
Definition: forcedeth.h:90
#define PHY_CICADA_INIT3
Definition: forcedeth.h:94
static struct tlan_private * priv
Definition: tlan.c:224
#define PHY_REALTEK_INIT7
Definition: forcedeth.h:127
#define PHY_GIGABIT
Definition: forcedeth.h:134
#define ADVERTISE_10HALF
Definition: mii.h:74
#define PHY_REALTEK_INIT_REG5
Definition: forcedeth.h:118
#define PHY_REALTEK_INIT_REG2
Definition: forcedeth.h:115
#define PHY_REALTEK_INIT1
Definition: forcedeth.h:121
#define PHY_VITESSE_INIT9
Definition: forcedeth.h:112
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
#define ADVERTISE_100HALF
Definition: mii.h:78
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define PHY_MODEL_REALTEK_8201
Definition: forcedeth.h:89
#define BMCR_ANENABLE
Definition: mii.h:49
#define NVREG_POWERSTATE2_PHY_RESET
Definition: forcedeth.h:578
#define MII_BMSR
Definition: atl1e.h:872
#define PHY_OUI_REALTEK
Definition: forcedeth.h:78
#define PHY_REALTEK_INIT10
Definition: forcedeth.h:130
#define PHY_VITESSE_INIT_REG2
Definition: forcedeth.h:99
#define PHY_VITESSE_INIT_MSK1
Definition: forcedeth.h:102
#define PHY_CICADA_INIT5
Definition: forcedeth.h:96
#define PHY_REALTEK_INIT2
Definition: forcedeth.h:122
#define MII_NCONFIG
Definition: atl1e.h:893
uint32_t u32
Definition: stdint.h:23
#define PHY_VITESSE_INIT8
Definition: forcedeth.h:111
#define PHY_VITESSE_INIT4
Definition: forcedeth.h:107
#define PHY_OUI_VITESSE
Definition: forcedeth.h:77

References ADVERTISE_1000FULL, ADVERTISE_1000HALF, ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, BMCR_ANENABLE, BMCR_ANRESTART, DBG, DEV_NEED_PHY_INIT_FIX, ioaddr, mdelay(), MII_ADVERTISE, MII_BMCR, MII_BMSR, MII_CTRL1000, MII_NCONFIG, MII_READ, MII_RESV1, mii_rw(), MII_SREVISION, NVREG_POWERSTATE2_PHY_RESET, NvRegPhyInterface, NvRegPowerState2, PHY_CICADA_INIT1, PHY_CICADA_INIT2, PHY_CICADA_INIT3, PHY_CICADA_INIT4, PHY_CICADA_INIT5, PHY_CICADA_INIT6, PHY_ERROR, PHY_GIGABIT, PHY_MARVELL_E3016_INITMASK, PHY_MODEL_MARVELL_E3016, PHY_MODEL_REALTEK_8201, PHY_MODEL_REALTEK_8211, PHY_OUI_CICADA, PHY_OUI_REALTEK, PHY_OUI_VITESSE, PHY_REALTEK_INIT1, PHY_REALTEK_INIT10, PHY_REALTEK_INIT11, PHY_REALTEK_INIT2, PHY_REALTEK_INIT3, PHY_REALTEK_INIT4, PHY_REALTEK_INIT5, PHY_REALTEK_INIT6, PHY_REALTEK_INIT7, PHY_REALTEK_INIT9, PHY_REALTEK_INIT_MSK1, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT_REG2, PHY_REALTEK_INIT_REG3, PHY_REALTEK_INIT_REG4, PHY_REALTEK_INIT_REG5, PHY_REALTEK_INIT_REG6, PHY_REALTEK_INIT_REG7, phy_reset(), PHY_REV_REALTEK_8211B, PHY_REV_REALTEK_8211C, PHY_RGMII, PHY_VITESSE_INIT1, PHY_VITESSE_INIT10, PHY_VITESSE_INIT2, PHY_VITESSE_INIT3, PHY_VITESSE_INIT4, PHY_VITESSE_INIT5, PHY_VITESSE_INIT6, PHY_VITESSE_INIT7, PHY_VITESSE_INIT8, PHY_VITESSE_INIT9, PHY_VITESSE_INIT_MSK1, PHY_VITESSE_INIT_MSK2, PHY_VITESSE_INIT_REG1, PHY_VITESSE_INIT_REG2, PHY_VITESSE_INIT_REG3, PHY_VITESSE_INIT_REG4, priv, readl(), reg, and writel().

Referenced by nv_setup_phy().

◆ nv_setup_phy()

static int nv_setup_phy ( struct forcedeth_private priv)
static

nv_setup_phy - Find PHY and initialize it

Parameters
privDriver private structure
Return values
rcReturn status code

Definition at line 1609 of file forcedeth.c.

1610 {
1611  void *ioaddr = priv->mmio_addr;
1612  u32 phystate_orig = 0, phystate;
1613  int phyinitialised = 0;
1614  u32 powerstate;
1615  int rc = 0;
1616  int i;
1617 
1618  if ( priv->driver_data & DEV_HAS_POWER_CNTRL ) {
1619  /* take phy and nic out of low power mode */
1620  powerstate = readl ( ioaddr + NvRegPowerState2 );
1621  powerstate &= ~NVREG_POWERSTATE2_POWERUP_MASK;
1622  if ( ( priv->driver_data & DEV_NEED_LOW_POWER_FIX ) &&
1623  ( ( priv->pci_dev->class & 0xff ) >= 0xA3 ) )
1624  powerstate |= NVREG_POWERSTATE2_POWERUP_REV_A3;
1625  writel ( powerstate, ioaddr + NvRegPowerState2 );
1626  }
1627 
1628 
1629  /* clear phy state and temporarily halt phy interrupts */
1630  writel ( 0, ioaddr + NvRegMIIMask );
1631  phystate = readl ( ioaddr + NvRegAdapterControl );
1632  if ( phystate & NVREG_ADAPTCTL_RUNNING ) {
1633  phystate_orig = 1;
1634  phystate &= ~NVREG_ADAPTCTL_RUNNING;
1635  writel ( phystate, ioaddr + NvRegAdapterControl );
1636  }
1638 
1639  if ( priv->driver_data & DEV_HAS_MGMT_UNIT ) {
1640  /* management unit running on the mac? */
1643  nv_mgmt_acquire_sema ( priv ) &&
1644  nv_mgmt_get_version ( priv ) ) {
1645  priv->mac_in_use = 1;
1646  if ( priv->mgmt_version > 0 ) {
1648  }
1649 
1650  DBG ( "mgmt unit is running. mac in use\n" );
1651 
1652  /* management unit setup the phy already? */
1653  if ( priv->mac_in_use &&
1656  /* phy is inited by mgmt unit */
1657  phyinitialised = 1;
1658  DBG ( "Phy already initialized by mgmt unit" );
1659  }
1660  }
1661  }
1662 
1663  /* find a suitable phy */
1664  for ( i = 1; i <= 32; i++ ) {
1665  int id1, id2;
1666  int phyaddr = i & 0x1f;
1667 
1668  id1 = mii_rw ( priv, phyaddr, MII_PHYSID1, MII_READ );
1669  if ( id1 < 0 || id1 == 0xffff )
1670  continue;
1671  id2 = mii_rw ( priv, phyaddr, MII_PHYSID2, MII_READ );
1672  if ( id2 < 0 || id2 == 0xffff )
1673  continue;
1674 
1675  priv->phy_model = id2 & PHYID2_MODEL_MASK;
1676  id1 = ( id1 & PHYID1_OUI_MASK ) << PHYID1_OUI_SHFT;
1677  id2 = ( id2 & PHYID2_OUI_MASK ) >> PHYID2_OUI_SHFT;
1678  DBG ( "Found PHY: %04x:%04x at address %d\n", id1, id2, phyaddr );
1679  priv->phyaddr = phyaddr;
1680  priv->phy_oui = id1 | id2;
1681 
1682  /* Realtek hardcoded phy id1 to all zeros on certain phys */
1683  if ( priv->phy_oui == PHY_OUI_REALTEK2 )
1684  priv->phy_oui = PHY_OUI_REALTEK;
1685  /* Setup phy revision for Realtek */
1686  if ( priv->phy_oui == PHY_OUI_REALTEK &&
1687  priv->phy_model == PHY_MODEL_REALTEK_8211 )
1688  priv->phy_rev = mii_rw ( priv, phyaddr, MII_RESV1,
1689  MII_READ ) & PHY_REV_MASK;
1690  break;
1691  }
1692  if ( i == 33 ) {
1693  DBG ( "Could not find a valid PHY.\n" );
1694  rc = -ENODEV;
1695  goto err_phy;
1696  }
1697 
1698  if ( ! phyinitialised ) {
1699  /* reset it */
1700  phy_init ( priv );
1701  } else {
1702  u32 mii_status = mii_rw ( priv, priv->phyaddr, MII_BMSR, MII_READ );
1703  if ( mii_status & PHY_GIGABIT ) {
1704  priv->gigabit = PHY_GIGABIT;
1705  }
1706  }
1707 
1708  return 0;
1709 
1710 err_phy:
1711  if ( phystate_orig )
1712  writel ( phystate | NVREG_ADAPTCTL_RUNNING,
1714  return rc;
1715 }
#define PHYID1_OUI_SHFT
Definition: forcedeth.h:81
#define NVREG_XMITCTL_MGMT_ST
Definition: forcedeth.h:379
#define PHY_REV_MASK
Definition: forcedeth.h:86
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MII_READ
Definition: forcedeth.h:296
#define PHY_OUI_REALTEK2
Definition: forcedeth.h:79
#define NVREG_ADAPTCTL_RUNNING
Definition: forcedeth.h:498
#define PHY_MODEL_REALTEK_8211
Definition: forcedeth.h:85
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static int phy_init(struct forcedeth_private *priv)
Definition: forcedeth.c:1224
static unsigned long ioaddr
Definition: davicom.c:129
#define MII_RESV1
Definition: atl1e.h:888
static int nv_mgmt_get_version(struct forcedeth_private *priv)
Definition: forcedeth.c:1165
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define NVREG_POWERSTATE2_POWERUP_MASK
Definition: forcedeth.h:576
#define DEV_HAS_POWER_CNTRL
Definition: forcedeth.h:182
#define PHYID2_MODEL_MASK
Definition: forcedeth.h:84
#define NVREG_POWERSTATE2_POWERUP_REV_A3
Definition: forcedeth.h:577
#define NVREG_XMITCTL_SYNC_MASK
Definition: forcedeth.h:380
#define DEV_NEED_LOW_POWER_FIX
Definition: forcedeth.h:197
#define DEV_HAS_MGMT_UNIT
Definition: forcedeth.h:187
#define ENODEV
No such device.
Definition: errno.h:509
#define PHYID1_OUI_MASK
Definition: forcedeth.h:80
static int nv_mgmt_acquire_sema(struct forcedeth_private *priv)
Definition: forcedeth.c:1111
static int mii_rw(struct forcedeth_private *priv, int addr, int miireg, int value)
Definition: forcedeth.c:91
#define PHYID2_OUI_SHFT
Definition: forcedeth.h:83
#define PHYID2_OUI_MASK
Definition: forcedeth.h:82
static struct tlan_private * priv
Definition: tlan.c:224
#define MII_PHYSID2
Definition: atl1e.h:874
#define PHY_GIGABIT
Definition: forcedeth.h:134
#define NVREG_XMITCTL_SYNC_PHY_INIT
Definition: forcedeth.h:382
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define MII_BMSR
Definition: atl1e.h:872
#define MII_PHYSID1
Definition: atl1e.h:873
#define PHY_OUI_REALTEK
Definition: forcedeth.h:78
#define NVREG_MGMTUNITCONTROL_INUSE
Definition: forcedeth.h:541
#define NVREG_MIISTAT_MASK_ALL
Definition: forcedeth.h:490
uint32_t u32
Definition: stdint.h:23

References DBG, DEV_HAS_MGMT_UNIT, DEV_HAS_POWER_CNTRL, DEV_NEED_LOW_POWER_FIX, ENODEV, ioaddr, MII_BMSR, MII_PHYSID1, MII_PHYSID2, MII_READ, MII_RESV1, mii_rw(), nv_mgmt_acquire_sema(), nv_mgmt_get_version(), NVREG_ADAPTCTL_RUNNING, NVREG_MGMTUNITCONTROL_INUSE, NVREG_MIISTAT_MASK_ALL, NVREG_POWERSTATE2_POWERUP_MASK, NVREG_POWERSTATE2_POWERUP_REV_A3, NVREG_XMITCTL_MGMT_ST, NVREG_XMITCTL_SYNC_MASK, NVREG_XMITCTL_SYNC_PHY_INIT, NvRegAdapterControl, NvRegMgmtUnitControl, NvRegMIIMask, NvRegMIIStatus, NvRegPowerState2, NvRegTransmitterControl, PHY_GIGABIT, phy_init(), PHY_MODEL_REALTEK_8211, PHY_OUI_REALTEK, PHY_OUI_REALTEK2, PHY_REV_MASK, PHYID1_OUI_MASK, PHYID1_OUI_SHFT, PHYID2_MODEL_MASK, PHYID2_OUI_MASK, PHYID2_OUI_SHFT, priv, rc, readl(), and writel().

Referenced by forcedeth_probe().

◆ forcedeth_map_regs()

static int forcedeth_map_regs ( struct forcedeth_private priv)
static

forcedeth_map_regs - Find a suitable BAR for the NIC and map the registers in memory

Parameters
privDriver private structure
Return values
rcReturn status code

Definition at line 1726 of file forcedeth.c.

1727 {
1728  void *ioaddr;
1729  uint32_t bar;
1730  unsigned long addr;
1731  u32 register_size;
1732  int reg;
1733  int rc;
1734 
1735  /* Set register size based on NIC */
1736  if ( priv->driver_data & ( DEV_HAS_VLAN | DEV_HAS_MSI_X |
1738  DEV_HAS_STATISTICS_V3 ) ) {
1739  register_size = NV_PCI_REGSZ_VER3;
1740  } else if ( priv->driver_data & DEV_HAS_STATISTICS_V1 ) {
1741  register_size = NV_PCI_REGSZ_VER2;
1742  } else {
1743  register_size = NV_PCI_REGSZ_VER1;
1744  }
1745 
1746  /* Find an appropriate region for all the registers */
1747  rc = -EINVAL;
1748  addr = 0;
1749  for ( reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4 ) {
1750  pci_read_config_dword ( priv->pci_dev, reg, &bar );
1751 
1752  if ( ( ! ( bar & PCI_BASE_ADDRESS_SPACE_IO ) ) &&
1753  ( pci_bar_size ( priv->pci_dev, reg ) >= register_size ) ){
1754  addr = pci_bar_start ( priv->pci_dev, reg );
1755  break;
1756  }
1757  }
1758 
1759  if ( reg > PCI_BASE_ADDRESS_5 ) {
1760  DBG ( "Couldn't find register window\n" );
1761  goto err_bar_sz;
1762  }
1763 
1764  rc = -ENOMEM;
1765  ioaddr = pci_ioremap ( priv->pci_dev, addr, register_size );
1766  if ( ! ioaddr ) {
1767  DBG ( "Cannot remap MMIO\n" );
1768  goto err_ioremap;
1769  }
1770 
1771  priv->mmio_addr = ioaddr;
1772 
1773  return 0;
1774 
1775 err_bar_sz:
1776 err_ioremap:
1777  return rc;
1778 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static unsigned int unsigned int reg
Definition: myson.h:162
#define PCI_BASE_ADDRESS_0
Definition: pci.h:62
#define PCI_BASE_ADDRESS_5
Definition: pci.h:67
#define NV_PCI_REGSZ_VER3
Definition: forcedeth.h:274
#define DEV_HAS_STATISTICS_V1
Definition: forcedeth.h:183
#define DEV_HAS_STATISTICS_V2
Definition: forcedeth.h:184
#define ENOMEM
Not enough space.
Definition: errno.h:534
static unsigned long ioaddr
Definition: davicom.c:129
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
#define DEV_HAS_POWER_CNTRL
Definition: forcedeth.h:182
#define DEV_HAS_MSI_X
Definition: forcedeth.h:181
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Find the size of a PCI BAR.
Definition: pciextra.c:92
unsigned int uint32_t
Definition: stdint.h:12
#define PCI_BASE_ADDRESS_SPACE_IO
I/O BAR.
Definition: pci.h:68
static struct tlan_private * priv
Definition: tlan.c:224
u32 addr
Definition: sky2.h:8
#define NV_PCI_REGSZ_VER2
Definition: forcedeth.h:273
#define DEV_HAS_VLAN
Definition: forcedeth.h:179
#define DEV_HAS_STATISTICS_V3
Definition: forcedeth.h:185
#define NV_PCI_REGSZ_VER1
Definition: forcedeth.h:272
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
uint32_t u32
Definition: stdint.h:23

References addr, DBG, DEV_HAS_MSI_X, DEV_HAS_POWER_CNTRL, DEV_HAS_STATISTICS_V1, DEV_HAS_STATISTICS_V2, DEV_HAS_STATISTICS_V3, DEV_HAS_VLAN, EINVAL, ENOMEM, ioaddr, NV_PCI_REGSZ_VER1, NV_PCI_REGSZ_VER2, NV_PCI_REGSZ_VER3, pci_bar_size(), pci_bar_start(), PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_5, PCI_BASE_ADDRESS_SPACE_IO, pci_ioremap(), pci_read_config_dword(), priv, rc, and reg.

Referenced by forcedeth_probe().

◆ forcedeth_probe()

static int forcedeth_probe ( struct pci_device pdev)
static

probe - Initial configuration of NIC

Parameters
pdevPCI device
entPCI IDs
Return values
rcReturn status code

Definition at line 1789 of file forcedeth.c.

1790 {
1791  struct net_device *netdev;
1792  struct forcedeth_private *priv;
1793  void *ioaddr;
1794  int rc;
1795 
1796  DBGP ( "forcedeth_probe\n" );
1797 
1798  DBG ( "Found %s, vendor = %#04x, device = %#04x\n",
1799  pdev->id->name, pdev->id->vendor, pdev->id->device );
1800 
1801  /* Allocate our private data */
1802  netdev = alloc_etherdev ( sizeof ( *priv ) );
1803  if ( ! netdev ) {
1804  rc = -ENOMEM;
1805  DBG ( "Failed to allocate net device\n" );
1806  goto err_alloc_etherdev;
1807  }
1808 
1809  /* Link our operations to the netdev struct */
1811 
1812  /* Link the PCI device to the netdev struct */
1813  pci_set_drvdata ( pdev, netdev );
1814  netdev->dev = &pdev->dev;
1815 
1816  /* Get a reference to our private data */
1817  priv = netdev->priv;
1818 
1819  /* We'll need these set up for the rest of the routines */
1820  priv->pci_dev = pdev;
1821  priv->netdev = netdev;
1822  priv->driver_data = pdev->id->driver_data;
1823 
1824  adjust_pci_device ( pdev );
1825 
1826  /* Use memory mapped I/O */
1827  if ( ( rc = forcedeth_map_regs ( priv ) ) != 0 )
1828  goto err_map_regs;
1829  ioaddr = priv->mmio_addr;
1830 
1831  /* Verify and get MAC address */
1832  if ( ( rc = nv_setup_mac_addr ( priv ) ) != 0 ) {
1833  DBG ( "Invalid MAC address detected\n" );
1834  goto err_mac_addr;
1835  }
1836 
1837  /* Disable WOL */
1838  writel ( 0, ioaddr + NvRegWakeUpFlags );
1839 
1840  if ( ( rc = nv_setup_phy ( priv ) ) != 0 )
1841  goto err_setup_phy;
1842 
1843  /* Set Pause Frame parameters */
1844  priv->pause_flags = NV_PAUSEFRAME_RX_CAPABLE |
1847  if ( ( priv->driver_data & DEV_HAS_PAUSEFRAME_TX_V1 ) ||
1848  ( priv->driver_data & DEV_HAS_PAUSEFRAME_TX_V2 ) ||
1849  ( priv->driver_data & DEV_HAS_PAUSEFRAME_TX_V3 ) ) {
1851  }
1852 
1853  if ( priv->pause_flags & NV_PAUSEFRAME_TX_CAPABLE )
1855 
1856  /* Set default link speed settings */
1858  priv->duplex = 0;
1859 
1860  if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
1861  DBG ( "Error registering netdev\n" );
1862  goto err_register_netdev;
1863  }
1864 
1866 
1867  return 0;
1868 
1869 err_register_netdev:
1870 err_setup_phy:
1871 err_mac_addr:
1872  iounmap ( priv->mmio_addr );
1873 err_map_regs:
1874  netdev_nullify ( netdev );
1875  netdev_put ( netdev );
1876 err_alloc_etherdev:
1877  return rc;
1878 }
static struct net_device_operations forcedeth_operations
Definition: forcedeth.c:1062
#define NVREG_LINKSPEED_10
Definition: forcedeth.h:455
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define NV_PAUSEFRAME_AUTONEG
Definition: forcedeth.h:150
#define DEV_HAS_PAUSEFRAME_TX_V3
Definition: forcedeth.h:192
unsigned long driver_data
Arbitrary driver data.
Definition: pci.h:178
static int nv_setup_phy(struct forcedeth_private *priv)
nv_setup_phy - Find PHY and initialize it
Definition: forcedeth.c:1609
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:154
struct device dev
Generic device.
Definition: pci.h:208
u32 duplex
Definition: tlan.c:214
#define DEV_HAS_PAUSEFRAME_TX_V2
Definition: forcedeth.h:191
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
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
static int nv_setup_mac_addr(struct forcedeth_private *priv)
Definition: forcedeth.c:1071
#define NV_PAUSEFRAME_TX_CAPABLE
Definition: forcedeth.h:145
#define NVREG_LINKSPEED_FORCE
Definition: forcedeth.h:454
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
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
static void forcedeth_link_status(struct net_device *netdev)
check_link - Check for link status change
Definition: forcedeth.c:961
uint16_t device
PCI device ID.
Definition: pci.h:176
#define NV_PAUSEFRAME_RX_REQ
Definition: forcedeth.h:148
#define NV_PAUSEFRAME_RX_CAPABLE
Definition: forcedeth.h:144
static struct tlan_private * priv
Definition: tlan.c:224
static int forcedeth_map_regs(struct forcedeth_private *priv)
forcedeth_map_regs - Find a suitable BAR for the NIC and map the registers in memory
Definition: forcedeth.c:1726
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
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define NV_PAUSEFRAME_TX_REQ
Definition: forcedeth.h:149
#define DEV_HAS_PAUSEFRAME_TX_V1
Definition: forcedeth.h:190
#define NVREG_TX_PAUSEFRAME_DISABLE
Definition: forcedeth.h:480
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References adjust_pci_device(), alloc_etherdev(), DBG, DBGP, pci_device::dev, net_device::dev, DEV_HAS_PAUSEFRAME_TX_V1, DEV_HAS_PAUSEFRAME_TX_V2, DEV_HAS_PAUSEFRAME_TX_V3, pci_device_id::device, pci_device_id::driver_data, tlan_private::duplex, ENOMEM, forcedeth_link_status(), forcedeth_map_regs(), forcedeth_operations, pci_device::id, ioaddr, iounmap(), pci_device_id::name, netdev, netdev_init(), netdev_nullify(), netdev_put(), NV_PAUSEFRAME_AUTONEG, NV_PAUSEFRAME_RX_CAPABLE, NV_PAUSEFRAME_RX_REQ, NV_PAUSEFRAME_TX_CAPABLE, NV_PAUSEFRAME_TX_REQ, nv_setup_mac_addr(), nv_setup_phy(), NVREG_LINKSPEED_10, NVREG_LINKSPEED_FORCE, NVREG_TX_PAUSEFRAME_DISABLE, NvRegTxPauseFrame, NvRegWakeUpFlags, pci_set_drvdata(), priv, net_device::priv, rc, register_netdev(), pci_device_id::vendor, and writel().

◆ nv_restore_phy()

static void nv_restore_phy ( struct forcedeth_private priv)
static

Definition at line 1881 of file forcedeth.c.

1882 {
1883  u16 phy_reserved, mii_control;
1884 
1885  if ( priv->phy_oui == PHY_OUI_REALTEK &&
1886  priv->phy_model == PHY_MODEL_REALTEK_8201 ) {
1887  mii_rw ( priv, priv->phyaddr, PHY_REALTEK_INIT_REG1,
1889  phy_reserved = mii_rw ( priv, priv->phyaddr,
1891  phy_reserved &= ~PHY_REALTEK_INIT_MSK1;
1892  phy_reserved |= PHY_REALTEK_INIT8;
1893  mii_rw ( priv, priv->phyaddr, PHY_REALTEK_INIT_REG2,
1894  phy_reserved );
1895  mii_rw ( priv, priv->phyaddr, PHY_REALTEK_INIT_REG1,
1897 
1898  /* restart auto negotiation */
1899  mii_control = mii_rw ( priv, priv->phyaddr, MII_BMCR, MII_READ );
1900  mii_control |= ( BMCR_ANRESTART | BMCR_ANENABLE );
1901  mii_rw ( priv, priv->phyaddr, MII_BMCR, mii_control );
1902  }
1903 }
uint16_t u16
Definition: stdint.h:21
#define MII_READ
Definition: forcedeth.h:296
#define BMCR_ANRESTART
Definition: mii.h:46
#define PHY_REALTEK_INIT3
Definition: forcedeth.h:123
#define PHY_REALTEK_INIT_MSK1
Definition: forcedeth.h:132
#define MII_BMCR
Definition: atl1e.h:871
#define PHY_REALTEK_INIT_REG1
Definition: forcedeth.h:114
static int mii_rw(struct forcedeth_private *priv, int addr, int miireg, int value)
Definition: forcedeth.c:91
#define PHY_REALTEK_INIT8
Definition: forcedeth.h:128
static struct tlan_private * priv
Definition: tlan.c:224
#define PHY_REALTEK_INIT_REG2
Definition: forcedeth.h:115
#define PHY_REALTEK_INIT1
Definition: forcedeth.h:121
#define PHY_MODEL_REALTEK_8201
Definition: forcedeth.h:89
#define BMCR_ANENABLE
Definition: mii.h:49
#define PHY_OUI_REALTEK
Definition: forcedeth.h:78

References BMCR_ANENABLE, BMCR_ANRESTART, MII_BMCR, MII_READ, mii_rw(), PHY_MODEL_REALTEK_8201, PHY_OUI_REALTEK, PHY_REALTEK_INIT1, PHY_REALTEK_INIT3, PHY_REALTEK_INIT8, PHY_REALTEK_INIT_MSK1, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT_REG2, and priv.

Referenced by forcedeth_remove().

◆ forcedeth_remove()

static void forcedeth_remove ( struct pci_device pdev)
static

remove - Device Removal Routine

Parameters
pdevPCI device information struct

Definition at line 1911 of file forcedeth.c.

1912 {
1913  struct net_device *netdev = pci_get_drvdata ( pdev );
1914  struct forcedeth_private *priv = netdev->priv;
1915 
1916  DBGP ( "forcedeth_remove\n" );
1917 
1919 
1920  nv_restore_phy ( priv );
1921 
1923 
1924  iounmap ( priv->mmio_addr );
1925 
1926  netdev_nullify ( netdev );
1927  netdev_put ( netdev );
1928 }
static void nv_mgmt_release_sema(struct forcedeth_private *priv)
Definition: forcedeth.c:1150
#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 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
static struct tlan_private * priv
Definition: tlan.c:224
void iounmap(volatile const void *io_addr)
Unmap I/O address.
static void nv_restore_phy(struct forcedeth_private *priv)
Definition: forcedeth.c:1881

References DBGP, iounmap(), netdev, netdev_nullify(), netdev_put(), nv_mgmt_release_sema(), nv_restore_phy(), pci_get_drvdata(), priv, net_device::priv, and unregister_netdev().

Variable Documentation

◆ forcedeth_operations

struct net_device_operations forcedeth_operations
static
Initial value:
= {
.open = forcedeth_open,
.transmit = forcedeth_transmit,
.poll = forcedeth_poll,
.close = forcedeth_close,
.irq = forcedeth_irq,
}
static void forcedeth_poll(struct net_device *netdev)
poll - Poll for received packets
Definition: forcedeth.c:982
static void forcedeth_irq(struct net_device *netdev, int action)
irq - enable or disable interrupts
Definition: forcedeth.c:1046
static int forcedeth_transmit(struct net_device *netdev, struct io_buffer *iobuf)
transmit - Transmit a packet
Definition: forcedeth.c:795
static int forcedeth_open(struct net_device *netdev)
open - Called when a network interface is made active
Definition: forcedeth.c:678
static void forcedeth_close(struct net_device *netdev)
close - Disable network interface
Definition: forcedeth.c:1019

Definition at line 1062 of file forcedeth.c.

Referenced by forcedeth_probe().

◆ forcedeth_nics

struct pci_device_id forcedeth_nics[]
static

Definition at line 1930 of file forcedeth.c.

◆ __pci_driver

struct pci_driver forcedeth_driver __pci_driver
Initial value:
= {
.id_count = ARRAY_SIZE(forcedeth_nics),
.probe = forcedeth_probe,
.remove = forcedeth_remove,
}
static struct pci_device_id forcedeth_nics[]
Definition: forcedeth.c:1930
static int forcedeth_probe(struct pci_device *pdev)
probe - Initial configuration of NIC
Definition: forcedeth.c:1789
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
static void forcedeth_remove(struct pci_device *pdev)
remove - Device Removal Routine
Definition: forcedeth.c:1911

Definition at line 1973 of file forcedeth.c.