iPXE
Macros | Functions | Variables
eepro100.c File Reference
#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/spi_bit.h>
#include <ipxe/timer.h>
#include <ipxe/nvs.h>
#include <ipxe/threewire.h>
#include <ipxe/netdevice.h>
#include "eepro100.h"

Go to the source code of this file.

Macros

#define INTERRUPT_MASK   ( SCBMaskEarlyRx | SCBMaskFlowCtl )
 
#define RFD_STATUS
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static int ifec_pci_probe (struct pci_device *pci)
 
static void ifec_pci_remove (struct pci_device *pci)
 
static void ifec_net_close (struct net_device *netdev)
 
static void ifec_net_irq (struct net_device *netdev, int enable)
 
static int ifec_net_open (struct net_device *netdev)
 
static void ifec_net_poll (struct net_device *netdev)
 
static int ifec_net_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 
static int ifec_spi_read_bit (struct bit_basher *basher, unsigned int bit_id)
 
static void ifec_spi_write_bit (struct bit_basher *basher, unsigned int bit_id, unsigned long data)
 
static void ifec_init_eeprom (struct net_device *netdev)
 
static int ifec_mdio_read (struct net_device *netdev, int phy_id, int location)
 
static void ifec_mdio_setup (struct net_device *netdev, int options)
 
static int ifec_mdio_write (struct net_device *netdev, int phy_id, int location, int value)
 
static void ifec_reset (struct net_device *netdev)
 
static void ifec_free (struct net_device *netdev)
 
static void ifec_rfd_init (struct ifec_rfd *rfd, s16 command, u32 link)
 
static void ifec_reprime_ru (struct net_device *netdev)
 
static void ifec_check_ru_status (struct net_device *netdev, unsigned short intr_status)
 
static void ifec_rx_process (struct net_device *netdev)
 
static int ifec_get_rx_desc (struct net_device *netdev, int cur, int cmd, int link)
 
static void ifec_refill_rx_ring (struct net_device *netdev)
 
static int ifec_rx_setup (struct net_device *netdev)
 
static int ifec_scb_cmd (struct net_device *netdev, u32 ptr, u8 cmd)
 
static int ifec_scb_cmd_wait (struct net_device *netdev)
 
static void ifec_tx_process (struct net_device *netdev)
 
static int ifec_tx_setup (struct net_device *netdev)
 
void ifec_tx_wake (struct net_device *netdev)
 

Variables

static struct ifec_cfg ifec_cfg
 
static struct net_device_operations ifec_operations
 
static const uint16_t ifec_ee_bits []
 
static struct bit_basher_operations ifec_basher_ops
 
static struct pci_device_id ifec_nics []
 
struct pci_driver ifec_driver __pci_driver
 

Macro Definition Documentation

◆ INTERRUPT_MASK

#define INTERRUPT_MASK   ( SCBMaskEarlyRx | SCBMaskFlowCtl )

Definition at line 281 of file eepro100.c.

◆ RFD_STATUS

#define RFD_STATUS
Value:

Definition at line 786 of file eepro100.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ ifec_pci_probe()

static int ifec_pci_probe ( struct pci_device pci)
static

Definition at line 172 of file eepro100.c.

173 {
174  struct net_device *netdev;
175  struct ifec_private *priv;
176  int rc;
177 
178  DBGP ( "ifec_pci_probe: " );
179 
180  if ( pci->ioaddr == 0 )
181  return -EINVAL;
182 
183  netdev = alloc_etherdev ( sizeof(*priv) );
184  if ( !netdev )
185  return -ENOMEM;
186 
188  priv = netdev->priv;
189 
190  pci_set_drvdata ( pci, netdev );
191  netdev->dev = &pci->dev;
192 
193  /* enable bus master, etc */
194  adjust_pci_device( pci );
195 
196  DBGP ( "pci " );
197 
198  memset ( priv, 0, sizeof(*priv) );
199  priv->ioaddr = pci->ioaddr;
200 
201  ifec_reset ( netdev );
202  DBGP ( "reset " );
203 
205 
206  /* read MAC address */
207  nvs_read ( &priv->eeprom.nvs, EEPROM_ADDR_MAC_0, netdev->hw_addr,
208  ETH_ALEN );
209  /* read mdio_register */
210  nvs_read ( &priv->eeprom.nvs, EEPROM_ADDR_MDIO_REGISTER,
211  &priv->mdio_register, 2 );
212 
213  if ( ( rc = register_netdev ( netdev ) ) != 0 )
214  goto error;
215 
217 
218  DBGP ( "ints\n" );
219 
220  return 0;
221 
222 error:
223  ifec_reset ( netdev );
225  netdev_put ( netdev );
226 
227  return rc;
228 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEPROM_ADDR_MAC_0
Definition: eepro100.h:26
unsigned long ioaddr
I/O address.
Definition: pci.h:225
static void ifec_init_eeprom(struct net_device *netdev)
Definition: eepro100.c:541
struct arbelprm_completion_with_error error
Definition: arbel.h:12
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:240
struct device dev
Generic device.
Definition: pci.h:212
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:518
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:365
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define DBGP(...)
Definition: compiler.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:575
#define EEPROM_ADDR_MDIO_REGISTER
Definition: eepro100.h:27
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:788
static struct net_device * netdev
Definition: gdbudp.c:52
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
A network device.
Definition: netdevice.h:352
static void ifec_reset(struct net_device *netdev)
Definition: eepro100.c:666
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:531
#define ETH_ALEN
Definition: if_ether.h:8
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static struct tlan_private * priv
Definition: tlan.c:225
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
Definition: nvs.c:75
static struct net_device_operations ifec_operations
Definition: eepro100.c:152
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
void * memset(void *dest, int character, size_t len) __nonnull

References adjust_pci_device(), alloc_etherdev(), DBGP, pci_device::dev, net_device::dev, EEPROM_ADDR_MAC_0, EEPROM_ADDR_MDIO_REGISTER, EINVAL, ENOMEM, error, ETH_ALEN, net_device::hw_addr, ifec_init_eeprom(), ifec_operations, ifec_reset(), pci_device::ioaddr, memset(), netdev, netdev_init(), netdev_link_up(), netdev_nullify(), netdev_put(), nvs_read(), pci_set_drvdata(), priv, net_device::priv, rc, and register_netdev().

◆ ifec_pci_remove()

static void ifec_pci_remove ( struct pci_device pci)
static

Definition at line 237 of file eepro100.c.

238 {
239  struct net_device *netdev = pci_get_drvdata ( pci );
240 
241  DBGP ( "ifec_pci_remove\n" );
242 
244  ifec_reset ( netdev );
246  netdev_put ( netdev );
247 }
#define DBGP(...)
Definition: compiler.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:575
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 ifec_reset(struct net_device *netdev)
Definition: eepro100.c:666
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:531
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:375

References DBGP, ifec_reset(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), and unregister_netdev().

◆ ifec_net_close()

static void ifec_net_close ( struct net_device netdev)
static

Definition at line 258 of file eepro100.c.

259 {
260  struct ifec_private *priv = netdev->priv;
261  unsigned long ioaddr = priv->ioaddr;
262  unsigned short intr_status;
263 
264  DBGP ( "ifec_net_close\n" );
265 
266  /* disable interrupts */
267  ifec_net_irq ( netdev, 0 );
268 
269  /* Ack & clear ints */
270  intr_status = inw ( ioaddr + SCBStatus );
271  outw ( intr_status, ioaddr + SCBStatus );
272  inw ( ioaddr + SCBStatus );
273 
274  ifec_reset ( netdev );
275 
276  /* Free any resources */
277  ifec_free ( netdev );
278 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define outw(data, io_addr)
Definition: io.h:319
static unsigned long ioaddr
Definition: davicom.c:129
static void ifec_free(struct net_device *netdev)
Definition: eepro100.c:692
#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 ifec_reset(struct net_device *netdev)
Definition: eepro100.c:666
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition: eepro100.c:291
static struct tlan_private * priv
Definition: tlan.c:225

References DBGP, ifec_free(), ifec_net_irq(), ifec_reset(), inw(), ioaddr, netdev, outw, priv, net_device::priv, and SCBStatus.

◆ ifec_net_irq()

static void ifec_net_irq ( struct net_device netdev,
int  enable 
)
static

Definition at line 291 of file eepro100.c.

292 {
293  struct ifec_private *priv = netdev->priv;
294  unsigned long ioaddr = priv->ioaddr;
295 
296  DBGP ( "ifec_net_irq\n" );
297 
298  outw ( enable ? INTERRUPT_MASK : SCBMaskAll, ioaddr + SCBCmd );
299 }
#define INTERRUPT_MASK
Definition: eepro100.c:281
#define outw(data, io_addr)
Definition: io.h:319
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static struct tlan_private * priv
Definition: tlan.c:225

References DBGP, INTERRUPT_MASK, ioaddr, netdev, outw, priv, net_device::priv, SCBCmd, and SCBMaskAll.

Referenced by ifec_net_close(), ifec_net_open(), and ifec_reset().

◆ ifec_net_open()

static int ifec_net_open ( struct net_device netdev)
static

Definition at line 310 of file eepro100.c.

311 {
312  struct ifec_private *priv = netdev->priv;
313  struct ifec_ias *ias = NULL;
314  struct ifec_cfg *cfg = NULL;
315  int i, options;
316  int rc = -ENOMEM;
317 
318  DBGP ( "ifec_net_open: " );
319 
320  /* Ensure interrupts are disabled. */
321  ifec_net_irq ( netdev, 0 );
322 
323  /* Initialize Command Unit and Receive Unit base addresses. */
325  ifec_scb_cmd ( netdev, virt_to_bus ( &priv->stats ), CUStatsAddr );
326  ifec_scb_cmd ( netdev, 0, CUCmdBase );
327 
328  /* Initialize both rings */
329  if ( ( rc = ifec_rx_setup ( netdev ) ) != 0 )
330  goto error;
331  if ( ( rc = ifec_tx_setup ( netdev ) ) != 0 )
332  goto error;
333 
334  /* Initialize MDIO */
335  options = 0x00; /* 0x40 = 10mbps half duplex, 0x00 = Autosense */
337 
338  /* Prepare MAC address w/ Individual Address Setup (ias) command.*/
339  ias = malloc_phys ( sizeof ( *ias ), CB_ALIGN );
340  if ( !ias ) {
341  rc = -ENOMEM;
342  goto error;
343  }
344  ias->command = CmdIASetup;
345  ias->status = 0;
346  memcpy ( ias->ia, netdev->ll_addr, ETH_ALEN );
347 
348  /* Prepare operating parameters w/ a configure command. */
349  cfg = malloc_phys ( sizeof ( *cfg ), CB_ALIGN );
350  if ( !cfg ) {
351  rc = -ENOMEM;
352  goto error;
353  }
354  memcpy ( cfg, &ifec_cfg, sizeof ( *cfg ) );
355  cfg->link = virt_to_bus ( priv->tcbs );
356  cfg->byte[19] = ( options & 0x10 ) ? 0xC0 : 0x80;
357  ias->link = virt_to_bus ( cfg );
358 
359  /* Issue the ias and configure commands. */
360  ifec_scb_cmd ( netdev, virt_to_bus ( ias ), CUStart );
362  priv->configured = 1;
363 
364  /* Wait up to 10 ms for configuration to initiate */
365  for ( i = 10; i && !cfg->status; i-- )
366  mdelay ( 1 );
367  if ( ! cfg->status ) {
368  DBG ( "Failed to initiate!\n" );
369  goto error;
370  }
371  free_phys ( ias, sizeof ( *ias ) );
372  free_phys ( cfg, sizeof ( *cfg ) );
373  DBG2 ( "cfg " );
374 
375  /* Enable rx by sending ring address to card */
376  if ( priv->rfds[0] != NULL ) {
377  ifec_scb_cmd ( netdev, virt_to_bus( priv->rfds[0] ), RUStart );
379  }
380  DBG2 ( "rx_start\n" );
381 
382  return 0;
383 
384 error:
385  free_phys ( cfg, sizeof ( *cfg ) );
386  free_phys ( ias, sizeof ( *ias ) );
387  ifec_free ( netdev );
388  ifec_reset ( netdev );
389  return rc;
390 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u16 command
Definition: eepro100.h:133
struct arbelprm_completion_with_error error
Definition: arbel.h:12
static int ifec_scb_cmd(struct net_device *netdev, u32 ptr, u8 cmd)
Definition: eepro100.c:943
u8 ia[6]
Definition: eepro100.h:135
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void ifec_free(struct net_device *netdev)
Definition: eepro100.c:692
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
static int options
Definition: 3c515.c:286
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static void ifec_mdio_setup(struct net_device *netdev, int options)
Definition: eepro100.c:604
static int ifec_tx_setup(struct net_device *netdev)
Definition: eepro100.c:1020
static void ifec_reset(struct net_device *netdev)
Definition: eepro100.c:666
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition: eepro100.c:291
#define ETH_ALEN
Definition: if_ether.h:8
static int ifec_rx_setup(struct net_device *netdev)
Definition: eepro100.c:916
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
Definition: sis900.h:23
static int ifec_scb_cmd_wait(struct net_device *netdev)
Definition: eepro100.c:965
static struct tlan_private * priv
Definition: tlan.c:225
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
#define CB_ALIGN
Definition: eepro100.h:18
u32 link
Definition: eepro100.h:134
volatile s16 status
Definition: eepro100.h:132
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.c:706
#define DBG2(...)
Definition: compiler.h:515

References CB_ALIGN, cfg, CmdIASetup, ifec_ias::command, CUCmdBase, CUStart, CUStatsAddr, DBG, DBG2, DBGP, ENOMEM, error, ETH_ALEN, free_phys(), ifec_ias::ia, ifec_free(), ifec_mdio_setup(), ifec_net_irq(), ifec_reset(), ifec_rx_setup(), ifec_scb_cmd(), ifec_scb_cmd_wait(), ifec_tx_setup(), ifec_ias::link, net_device::ll_addr, malloc_phys(), mdelay(), memcpy(), netdev, NULL, options, priv, net_device::priv, rc, RUAddrLoad, RUStart, ifec_ias::status, and virt_to_bus().

◆ ifec_net_poll()

static void ifec_net_poll ( struct net_device netdev)
static

Definition at line 401 of file eepro100.c.

402 {
403  struct ifec_private *priv = netdev->priv;
404  unsigned short intr_status;
405 
406  DBGP ( "ifec_net_poll\n" );
407 
408  /* acknowledge interrupts ASAP */
409  intr_status = inw ( priv->ioaddr + SCBStatus );
410  outw ( intr_status, priv->ioaddr + SCBStatus );
411  inw ( priv->ioaddr + SCBStatus );
412 
413  DBG2 ( "poll - status: 0x%04X\n", intr_status );
414 
415  /* anything to do here? */
416  if ( ( intr_status & ( ~INTERRUPT_MASK ) ) == 0 )
417  return;
418 
419  /* process received and transmitted packets */
422 
423  ifec_check_ru_status ( netdev, intr_status );
424 
425  return;
426 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define INTERRUPT_MASK
Definition: eepro100.c:281
#define outw(data, io_addr)
Definition: io.h:319
static void ifec_tx_process(struct net_device *netdev)
Definition: eepro100.c:986
static void ifec_check_ru_status(struct net_device *netdev, unsigned short intr_status)
Definition: eepro100.c:755
#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 ifec_rx_process(struct net_device *netdev)
Definition: eepro100.c:794
static struct tlan_private * priv
Definition: tlan.c:225
#define DBG2(...)
Definition: compiler.h:515

References DBG2, DBGP, ifec_check_ru_status(), ifec_rx_process(), ifec_tx_process(), INTERRUPT_MASK, inw(), netdev, outw, priv, net_device::priv, and SCBStatus.

◆ ifec_net_transmit()

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

Definition at line 437 of file eepro100.c.

439 {
440  struct ifec_private *priv = netdev->priv;
441  struct ifec_tcb *tcb = priv->tcb_head->next;
442  unsigned long ioaddr = priv->ioaddr;
443 
444  DBGP ( "ifec_net_transmit\n" );
445 
446  /* Wait for TCB to become available. */
447  if ( tcb->status || tcb->iob ) {
448  DBG ( "TX overflow\n" );
449  return -ENOBUFS;
450  }
451 
452  DBG2 ( "transmitting packet (%zd bytes). status = %hX, cmd=%hX\n",
453  iob_len ( iobuf ), tcb->status, inw ( ioaddr + SCBCmd ) );
454 
455  tcb->command = CmdSuspend | CmdTx | CmdTxFlex;
456  tcb->count = 0x01208000;
457  tcb->tbd_addr0 = virt_to_bus ( iobuf->data );
458  tcb->tbd_size0 = 0x3FFF & iob_len ( iobuf );
459  tcb->iob = iobuf;
460 
461  ifec_tx_wake ( netdev );
462 
463  /* Append to end of ring. */
464  priv->tcb_head = tcb;
465 
466  return 0;
467 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
s32 tbd_size0
Definition: eepro100.h:115
Definition: eepro100.h:56
s32 count
Definition: eepro100.h:111
struct io_buffer * iob
Definition: eepro100.h:117
u32 tbd_addr0
Definition: eepro100.h:114
static unsigned long ioaddr
Definition: davicom.c:129
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
volatile s16 status
Definition: eepro100.h:107
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
static struct tlan_private * priv
Definition: tlan.c:225
u16 command
Definition: eepro100.h:108
void * data
Start of data.
Definition: iobuf.h:52
void ifec_tx_wake(struct net_device *netdev)
Definition: eepro100.c:1073
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define DBG2(...)
Definition: compiler.h:515

References CmdSuspend, CmdTx, CmdTxFlex, ifec_tcb::command, ifec_tcb::count, io_buffer::data, DBG, DBG2, DBGP, ENOBUFS, ifec_tx_wake(), inw(), ioaddr, ifec_tcb::iob, iob_len(), netdev, priv, net_device::priv, SCBCmd, ifec_tcb::status, ifec_tcb::tbd_addr0, ifec_tcb::tbd_size0, and virt_to_bus().

◆ ifec_spi_read_bit()

static int ifec_spi_read_bit ( struct bit_basher basher,
unsigned int  bit_id 
)
static

Definition at line 486 of file eepro100.c.

488 {
489  struct ifec_private *priv =
490  container_of ( basher, struct ifec_private, spi.basher );
491  unsigned long ee_addr = priv->ioaddr + CSREeprom;
492  unsigned int ret = 0;
493  uint16_t mask;
494 
495  DBGP ( "ifec_spi_read_bit\n" );
496 
497  mask = ifec_ee_bits[bit_id];
498  ret = inw (ee_addr);
499 
500  return ( ret & mask ) ? 1 : 0;
501 }
struct bit_basher basher
Bit-bashing interface.
Definition: spi_bit.h:20
unsigned short uint16_t
Definition: stdint.h:11
struct spi_bit_basher spi
Definition: eepro100.h:166
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
#define DBGP(...)
Definition: compiler.h:532
static const uint16_t ifec_ee_bits[]
Definition: eepro100.c:472
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static struct tlan_private * priv
Definition: tlan.c:225

References spi_bit_basher::basher, container_of, CSREeprom, DBGP, ifec_ee_bits, inw(), priv, and ifec_private::spi.

◆ ifec_spi_write_bit()

static void ifec_spi_write_bit ( struct bit_basher basher,
unsigned int  bit_id,
unsigned long  data 
)
static

Definition at line 511 of file eepro100.c.

514 {
515  struct ifec_private *priv =
516  container_of ( basher, struct ifec_private, spi.basher );
517  unsigned long ee_addr = priv->ioaddr + CSREeprom;
518  short val;
519  uint16_t mask = ifec_ee_bits[bit_id];
520 
521  DBGP ( "ifec_spi_write_bit\n" );
522 
523  val = inw ( ee_addr );
524  val &= ~mask;
525  val |= data & mask;
526 
527  outw ( val, ee_addr );
528 }
struct bit_basher basher
Bit-bashing interface.
Definition: spi_bit.h:20
unsigned short uint16_t
Definition: stdint.h:11
struct spi_bit_basher spi
Definition: eepro100.h:166
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
void __asmcall int val
Definition: setjmp.h:12
#define outw(data, io_addr)
Definition: io.h:319
#define DBGP(...)
Definition: compiler.h:532
static const uint16_t ifec_ee_bits[]
Definition: eepro100.c:472
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static struct tlan_private * priv
Definition: tlan.c:225
uint8_t data[48]
Additional event data.
Definition: ena.h:22

References spi_bit_basher::basher, container_of, CSREeprom, data, DBGP, ifec_ee_bits, inw(), outw, priv, ifec_private::spi, and val.

◆ ifec_init_eeprom()

static void ifec_init_eeprom ( struct net_device netdev)
static

Definition at line 541 of file eepro100.c.

542 {
543  struct ifec_private *priv = netdev->priv;
544 
545  DBGP ( "ifec_init_eeprom\n" );
546 
547  priv->spi.basher.op = &ifec_basher_ops;
548  priv->spi.bus.mode = SPI_MODE_THREEWIRE;
549  init_spi_bit_basher ( &priv->spi );
550 
551  priv->eeprom.bus = &priv->spi.bus;
552 
553  /* init as 93c46(93c14 compatible) first, to set the command len,
554  * block size and word len. Needs to be set for address len detection.
555  */
556  init_at93c46 ( &priv->eeprom, 16 );
557 
558  /* detect address length, */
559  threewire_detect_address_len ( &priv->eeprom );
560 
561  /* address len == 8 means 93c66 instead of 93c46 */
562  if ( priv->eeprom.address_len == 8 )
563  init_at93c66 ( &priv->eeprom, 16 );
564 }
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
void init_spi_bit_basher(struct spi_bit_basher *spibit)
Initialise SPI bit-bashing interface.
Definition: spi_bit.c:235
static struct net_device * netdev
Definition: gdbudp.c:52
int threewire_detect_address_len(struct spi_device *device)
Autodetect device address length.
Definition: threewire.c:119
static struct tlan_private * priv
Definition: tlan.c:225
#define SPI_MODE_THREEWIRE
Threewire-compatible mode.
Definition: spi.h:199
static struct bit_basher_operations ifec_basher_ops
Definition: eepro100.c:531

References DBGP, ifec_basher_ops, init_spi_bit_basher(), netdev, priv, net_device::priv, SPI_MODE_THREEWIRE, and threewire_detect_address_len().

Referenced by ifec_pci_probe().

◆ ifec_mdio_read()

static int ifec_mdio_read ( struct net_device netdev,
int  phy_id,
int  location 
)
static

Definition at line 572 of file eepro100.c.

574 {
575  struct ifec_private *priv = netdev->priv;
576  unsigned long ioaddr = priv->ioaddr;
577  int val;
578  int boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
579 
580  DBGP ( "ifec_mdio_read\n" );
581 
582  outl ( 0x08000000 | ( location << 16 ) | ( phy_id << 21 ),
583  ioaddr + CSRCtrlMDI );
584  do {
585  udelay ( 16 );
586 
587  val = inl ( ioaddr + CSRCtrlMDI );
588 
589  if ( --boguscnt < 0 ) {
590  DBG ( " ifec_mdio_read() time out with val = %X.\n",
591  val );
592  break;
593  }
594  } while (! ( val & 0x10000000 ) );
595  return val & 0xffff;
596 }
void __asmcall int val
Definition: setjmp.h:12
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
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 outl(data, io_addr)
Definition: io.h:329
static struct tlan_private * priv
Definition: tlan.c:225
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References CSRCtrlMDI, DBG, DBGP, inl(), ioaddr, netdev, outl, priv, net_device::priv, udelay(), and val.

Referenced by ifec_mdio_setup().

◆ ifec_mdio_setup()

static void ifec_mdio_setup ( struct net_device netdev,
int  options 
)
static

Definition at line 604 of file eepro100.c.

605 {
606  struct ifec_private *priv = netdev->priv;
607  unsigned short mdio_register = priv->mdio_register;
608 
609  DBGP ( "ifec_mdio_setup\n" );
610 
611  if ( ( (mdio_register>>8) & 0x3f ) == DP83840
612  || ( (mdio_register>>8) & 0x3f ) == DP83840A ) {
613  int mdi_reg23 = ifec_mdio_read ( netdev, mdio_register
614  & 0x1f, 23 ) | 0x0422;
615  if (CONGENB)
616  mdi_reg23 |= 0x0100;
617  DBG2 ( "DP83840 specific setup, setting register 23 to "
618  "%hX.\n", mdi_reg23 );
619  ifec_mdio_write ( netdev, mdio_register & 0x1f, 23, mdi_reg23 );
620  }
621  DBG2 ( "dp83840 " );
622  if ( options != 0 ) {
623  ifec_mdio_write ( netdev, mdio_register & 0x1f, 0,
624  ( (options & 0x20) ? 0x2000 : 0 ) |
625  ( (options & 0x10) ? 0x0100 : 0 ) );
626  DBG2 ( "set mdio_register. " );
627  }
628 }
#define CONGENB
Definition: eepro100.h:7
#define DBGP(...)
Definition: compiler.h:532
static int options
Definition: 3c515.c:286
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static int ifec_mdio_read(struct net_device *netdev, int phy_id, int location)
Definition: eepro100.c:572
unsigned short mdio_register
Definition: eepro100.h:148
static struct tlan_private * priv
Definition: tlan.c:225
static int ifec_mdio_write(struct net_device *netdev, int phy_id, int location, int value)
Definition: eepro100.c:636
#define DBG2(...)
Definition: compiler.h:515

References CONGENB, DBG2, DBGP, DP83840, DP83840A, ifec_mdio_read(), ifec_mdio_write(), ifec_private::mdio_register, netdev, options, priv, and net_device::priv.

Referenced by ifec_net_open().

◆ ifec_mdio_write()

static int ifec_mdio_write ( struct net_device netdev,
int  phy_id,
int  location,
int  value 
)
static

Definition at line 636 of file eepro100.c.

638 {
639  struct ifec_private *priv = netdev->priv;
640  unsigned long ioaddr = priv->ioaddr;
641  int val;
642  int boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
643 
644  DBGP ( "ifec_mdio_write\n" );
645 
646  outl ( 0x04000000 | ( location << 16 ) | ( phy_id << 21 ) | value,
647  ioaddr + CSRCtrlMDI );
648  do {
649  udelay ( 16 );
650 
651  val = inl ( ioaddr + CSRCtrlMDI );
652  if ( --boguscnt < 0 ) {
653  DBG ( " ifec_mdio_write() time out with val = %X.\n",
654  val );
655  break;
656  }
657  } while (! ( val & 0x10000000 ) );
658  return val & 0xffff;
659 }
void __asmcall int val
Definition: setjmp.h:12
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
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 outl(data, io_addr)
Definition: io.h:329
static struct tlan_private * priv
Definition: tlan.c:225
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References CSRCtrlMDI, DBG, DBGP, inl(), ioaddr, netdev, outl, priv, net_device::priv, udelay(), val, and value.

Referenced by ifec_mdio_setup().

◆ ifec_reset()

static void ifec_reset ( struct net_device netdev)
static

Definition at line 666 of file eepro100.c.

667 {
668  struct ifec_private *priv = netdev->priv;
669  unsigned long ioaddr = priv->ioaddr;
670 
671  DBGP ( "ifec_reset\n" );
672 
673  /* do partial reset first */
675  inw ( ioaddr + SCBStatus );
676  udelay ( 20 );
677 
678  /* full reset */
679  outl ( PortReset, ioaddr + CSRPort );
680  inw ( ioaddr + SCBStatus );
681  udelay ( 20 );
682 
683  /* disable interrupts again */
684  ifec_net_irq ( netdev, 0 );
685 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
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 outl(data, io_addr)
Definition: io.h:329
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition: eepro100.c:291
static struct tlan_private * priv
Definition: tlan.c:225

References CSRPort, DBGP, ifec_net_irq(), inw(), ioaddr, netdev, outl, PortPartialReset, PortReset, priv, net_device::priv, SCBStatus, and udelay().

Referenced by ifec_net_close(), ifec_net_open(), ifec_pci_probe(), and ifec_pci_remove().

◆ ifec_free()

static void ifec_free ( struct net_device netdev)
static

Definition at line 692 of file eepro100.c.

693 {
694  struct ifec_private *priv = netdev->priv;
695  int i;
696 
697  DBGP ( "ifec_free\n" );
698 
699  /* free all allocated receive io_buffers */
700  for ( i = 0; i < RFD_COUNT; i++ ) {
701  free_iob ( priv->rx_iobs[i] );
702  priv->rx_iobs[i] = NULL;
703  priv->rfds[i] = NULL;
704  }
705 
706  /* free TX ring buffer */
707  free_phys ( priv->tcbs, TX_RING_BYTES );
708 
709  priv->tcbs = NULL;
710 }
#define TX_RING_BYTES
Definition: eepro100.h:23
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:152
#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 RFD_COUNT
Definition: eepro100.h:20
static struct tlan_private * priv
Definition: tlan.c:225
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References DBGP, free_iob(), free_phys(), netdev, NULL, priv, net_device::priv, RFD_COUNT, and TX_RING_BYTES.

Referenced by ifec_net_close(), and ifec_net_open().

◆ ifec_rfd_init()

static void ifec_rfd_init ( struct ifec_rfd rfd,
s16  command,
u32  link 
)
static

Definition at line 719 of file eepro100.c.

720 {
721  DBGP ( "ifec_rfd_init\n" );
722 
723  rfd->status = 0;
724  rfd->command = command;
725  rfd->rx_buf_addr = 0xFFFFFFFF;
726  rfd->count = 0;
727  rfd->size = RFD_PACKET_LEN;
728  rfd->link = link;
729 }
s16 command
Definition: eepro100.h:123
u16 size
Definition: eepro100.h:127
volatile s16 status
Definition: eepro100.h:122
u32 link
Definition: eepro100.h:124
u32 rx_buf_addr
Definition: eepro100.h:125
#define DBGP(...)
Definition: compiler.h:532
u32 link
Link to next descriptor.
Definition: ar9003_mac.h:68
static int command
Definition: epic100.c:68
u16 count
Definition: eepro100.h:126
#define RFD_PACKET_LEN
Definition: eepro100.h:15

References command, ifec_rfd::command, ifec_rfd::count, DBGP, link, ifec_rfd::link, RFD_PACKET_LEN, ifec_rfd::rx_buf_addr, ifec_rfd::size, and ifec_rfd::status.

Referenced by ifec_get_rx_desc().

◆ ifec_reprime_ru()

static void ifec_reprime_ru ( struct net_device netdev)
static

Definition at line 736 of file eepro100.c.

737 {
738  struct ifec_private *priv = netdev->priv;
739  int cur_rx = priv->cur_rx;
740 
741  DBGP ( "ifec_reprime_ru\n" );
742 
743  if ( priv->rfds[cur_rx] != NULL ) {
744  ifec_scb_cmd ( netdev, virt_to_bus ( priv->rfds[cur_rx] ),
745  RUStart );
747  }
748 }
static int ifec_scb_cmd(struct net_device *netdev, u32 ptr, u8 cmd)
Definition: eepro100.c:943
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static int ifec_scb_cmd_wait(struct net_device *netdev)
Definition: eepro100.c:965
static struct tlan_private * priv
Definition: tlan.c:225
static unsigned int cur_rx
Definition: epic100.c:84
unsigned int cur_rx
Definition: tlan.c:206
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References cur_rx, tlan_private::cur_rx, DBGP, ifec_scb_cmd(), ifec_scb_cmd_wait(), netdev, NULL, priv, net_device::priv, RUStart, and virt_to_bus().

Referenced by ifec_check_ru_status().

◆ ifec_check_ru_status()

static void ifec_check_ru_status ( struct net_device netdev,
unsigned short  intr_status 
)
static

Definition at line 755 of file eepro100.c.

757 {
758  struct ifec_private *priv = netdev->priv;
759 
760  DBGP ( "ifec_check_ru_status\n" );
761 
762  /*
763  * The chip may have suspended reception for various reasons.
764  * Check for that, and re-prime it should this be the case.
765  */
766  switch ( ( intr_status >> 2 ) & 0xf ) {
767  case 0: /* Idle */
768  case 4: /* Ready */
769  break;
770  case 1: /* Suspended */
771  case 2: /* No resources (RFDs) */
772  case 9: /* Suspended with no more RBDs */
773  case 10: /* No resources due to no RBDs */
774  case 12: /* Ready with no RBDs */
775  DBG ( "ifec_net_poll: RU reprimed.\n" );
777  break;
778  default:
779  /* reserved values */
780  DBG ( "ifec_net_poll: RU state anomaly: %i\n",
781  ( inw ( priv->ioaddr + SCBStatus ) >> 2 ) & 0xf );
782  break;
783  }
784 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
static void ifec_reprime_ru(struct net_device *netdev)
Definition: eepro100.c:736
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static struct tlan_private * priv
Definition: tlan.c:225
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, DBGP, ifec_reprime_ru(), inw(), netdev, priv, net_device::priv, and SCBStatus.

Referenced by ifec_net_poll(), and ifec_refill_rx_ring().

◆ ifec_rx_process()

static void ifec_rx_process ( struct net_device netdev)
static

Definition at line 794 of file eepro100.c.

795 {
796  struct ifec_private *priv = netdev->priv;
797  int cur_rx = priv->cur_rx;
798  struct io_buffer *iob = priv->rx_iobs[cur_rx];
799  struct ifec_rfd *rfd = priv->rfds[cur_rx];
800  unsigned int rx_len;
801  s16 status;
802 
803  DBGP ( "ifec_rx_process\n" );
804 
805  /* Process any received packets */
806  while ( iob && rfd && ( status = rfd->status ) ) {
807  rx_len = rfd->count & RFDMaskCount;
808 
809  DBG2 ( "Got a packet: Len = %d, cur_rx = %d.\n", rx_len,
810  cur_rx );
811  DBGIO_HD ( (void*)rfd->packet, 0x30 );
812 
813  if ( ( status & ( RFD_STATUS & ~RFDShort ) ) != RFD_OK ) {
814  DBG ( "Corrupted packet received. "
815  "Status = %#08hx\n", status );
816  netdev_rx_err ( netdev, iob, -EINVAL );
817  } else {
818  /* Hand off the packet to the network subsystem */
819  iob_put ( iob, rx_len );
820  DBG2 ( "Received packet: %p, len: %d\n", iob, rx_len );
821  netdev_rx ( netdev, iob );
822  }
823 
824  /* make sure we don't reuse this RFD */
825  priv->rx_iobs[cur_rx] = NULL;
826  priv->rfds[cur_rx] = NULL;
827 
828  /* Next RFD */
829  priv->cur_rx = ( cur_rx + 1 ) % RFD_COUNT;
830  cur_rx = priv->cur_rx;
831  iob = priv->rx_iobs[cur_rx];
832  rfd = priv->rfds[cur_rx];
833  }
834 
836 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
int16_t s16
Definition: stdint.h:20
#define iob_put(iobuf, len)
Definition: iobuf.h:124
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
#define DBGIO_HD(...)
Definition: compiler.h:551
volatile s16 status
Definition: eepro100.h:122
static void ifec_refill_rx_ring(struct net_device *netdev)
Definition: eepro100.c:876
#define RFD_STATUS
Definition: eepro100.c:786
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
char packet[RFD_PACKET_LEN]
Definition: eepro100.h:128
uint8_t status
Status.
Definition: ena.h:16
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
u16 count
Definition: eepro100.h:126
#define RFD_COUNT
Definition: eepro100.h:20
static struct tlan_private * priv
Definition: tlan.c:225
static unsigned int cur_rx
Definition: epic100.c:84
unsigned int cur_rx
Definition: tlan.c:206
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define DBG2(...)
Definition: compiler.h:515
A persistent I/O buffer.
Definition: iobuf.h:37

References ifec_rfd::count, cur_rx, tlan_private::cur_rx, DBG, DBG2, DBGIO_HD, DBGP, EINVAL, ifec_refill_rx_ring(), iob_put, netdev, netdev_rx(), netdev_rx_err(), NULL, ifec_rfd::packet, priv, net_device::priv, RFD_COUNT, RFD_OK, RFD_STATUS, RFDMaskCount, RFDShort, status, and ifec_rfd::status.

Referenced by ifec_net_poll().

◆ ifec_get_rx_desc()

static int ifec_get_rx_desc ( struct net_device netdev,
int  cur,
int  cmd,
int  link 
)
static

Definition at line 848 of file eepro100.c.

850 {
851  struct ifec_private *priv = netdev->priv;
852  struct ifec_rfd *rfd = priv->rfds[cur];
853 
854  DBGP ( "ifec_get_rx_desc\n" );
855 
856  priv->rx_iobs[cur] = alloc_iob ( sizeof ( *rfd ) );
857  if ( ! priv->rx_iobs[cur] ) {
858  DBG ( "alloc_iob failed. desc. nr: %d\n", cur );
859  priv->rfds[cur] = NULL;
860  return -ENOMEM;
861  }
862 
863  /* Initialize new tail. */
864  priv->rfds[cur] = priv->rx_iobs[cur]->data;
865  ifec_rfd_init ( priv->rfds[cur], cmd, link );
866  iob_reserve ( priv->rx_iobs[cur], RFD_HEADER_LEN );
867 
868  return 0;
869 }
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:130
#define RFD_HEADER_LEN
Definition: eepro100.h:17
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
u32 link
Link to next descriptor.
Definition: ar9003_mac.h:68
static void ifec_rfd_init(struct ifec_rfd *rfd, s16 command, u32 link)
Definition: eepro100.c:719
#define iob_reserve(iobuf, len)
Definition: iobuf.h:71
static struct tlan_private * priv
Definition: tlan.c:225
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References alloc_iob(), cmd, DBG, DBGP, ENOMEM, ifec_rfd_init(), iob_reserve, link, netdev, NULL, priv, net_device::priv, and RFD_HEADER_LEN.

Referenced by ifec_refill_rx_ring().

◆ ifec_refill_rx_ring()

static void ifec_refill_rx_ring ( struct net_device netdev)
static

Definition at line 876 of file eepro100.c.

877 {
878  struct ifec_private *priv = netdev->priv;
879  int i, cur_rx;
880  unsigned short intr_status;
881 
882  DBGP ( "ifec_refill_rx_ring\n" );
883 
884  for ( i = 0; i < RFD_COUNT; i++ ) {
885  cur_rx = ( priv->cur_rx + i ) % RFD_COUNT;
886  /* only refill if empty */
887  if ( priv->rfds[cur_rx] != NULL ||
888  priv->rx_iobs[cur_rx] != NULL )
889  continue;
890 
891  DBG2 ( "refilling RFD %d\n", cur_rx );
892 
894  CmdSuspend | CmdEndOfList, 0 ) == 0 ) {
895  if ( i > 0 ) {
896  int prev_rx = ( ( ( cur_rx + RFD_COUNT ) - 1 )
897  % RFD_COUNT );
898  struct ifec_rfd *rfd = priv->rfds[prev_rx];
899 
900  rfd->command = 0;
901  rfd->link = virt_to_bus ( priv->rfds[cur_rx] );
902  }
903  }
904  }
905 
906  intr_status = inw ( priv->ioaddr + SCBStatus );
907  ifec_check_ru_status ( netdev, intr_status );
908 }
s16 command
Definition: eepro100.h:123
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
u32 link
Definition: eepro100.h:124
static void ifec_check_ru_status(struct net_device *netdev, unsigned short intr_status)
Definition: eepro100.c:755
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define RFD_COUNT
Definition: eepro100.h:20
static struct tlan_private * priv
Definition: tlan.c:225
static unsigned int cur_rx
Definition: epic100.c:84
static int ifec_get_rx_desc(struct net_device *netdev, int cur, int cmd, int link)
Definition: eepro100.c:848
unsigned int cur_rx
Definition: tlan.c:206
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define DBG2(...)
Definition: compiler.h:515

References CmdEndOfList, CmdSuspend, ifec_rfd::command, cur_rx, tlan_private::cur_rx, DBG2, DBGP, ifec_check_ru_status(), ifec_get_rx_desc(), inw(), ifec_rfd::link, netdev, NULL, priv, net_device::priv, RFD_COUNT, SCBStatus, and virt_to_bus().

Referenced by ifec_rx_process(), and ifec_rx_setup().

◆ ifec_rx_setup()

static int ifec_rx_setup ( struct net_device netdev)
static

Definition at line 916 of file eepro100.c.

917 {
918  struct ifec_private *priv = netdev->priv;
919  int i;
920 
921  DBGP ( "ifec_rx_setup\n" );
922 
923  priv->cur_rx = 0;
924 
925  /* init values for ifec_refill_rx_ring() */
926  for ( i = 0; i < RFD_COUNT; i++ ) {
927  priv->rfds[i] = NULL;
928  priv->rx_iobs[i] = NULL;
929  }
931 
932  return 0;
933 }
static void ifec_refill_rx_ring(struct net_device *netdev)
Definition: eepro100.c:876
#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 RFD_COUNT
Definition: eepro100.h:20
static struct tlan_private * priv
Definition: tlan.c:225
unsigned int cur_rx
Definition: tlan.c:206
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References tlan_private::cur_rx, DBGP, ifec_refill_rx_ring(), netdev, NULL, priv, net_device::priv, and RFD_COUNT.

Referenced by ifec_net_open().

◆ ifec_scb_cmd()

static int ifec_scb_cmd ( struct net_device netdev,
u32  ptr,
u8  cmd 
)
static

Definition at line 943 of file eepro100.c.

944 {
945  struct ifec_private *priv = netdev->priv;
946  unsigned long ioaddr = priv->ioaddr;
947  int rc;
948 
949  DBGP ( "ifec_scb_cmd\n" );
950 
951  rc = ifec_scb_cmd_wait ( netdev ); /* Wait until ready */
952  if ( !rc ) {
953  outl ( ptr, ioaddr + SCBPointer );
954  outb ( cmd, ioaddr + SCBCmd ); /* Issue command */
955  }
956  return rc;
957 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define outl(data, io_addr)
Definition: io.h:329
#define outb(data, io_addr)
Definition: io.h:309
static int ifec_scb_cmd_wait(struct net_device *netdev)
Definition: eepro100.c:965
static struct tlan_private * priv
Definition: tlan.c:225
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, DBGP, ifec_scb_cmd_wait(), ioaddr, netdev, outb, outl, priv, net_device::priv, rc, SCBCmd, and SCBPointer.

Referenced by ifec_net_open(), ifec_reprime_ru(), and ifec_tx_wake().

◆ ifec_scb_cmd_wait()

static int ifec_scb_cmd_wait ( struct net_device netdev)
static

Definition at line 965 of file eepro100.c.

966 {
967  struct ifec_private *priv = netdev->priv;
968  unsigned long cmd_ioaddr = priv->ioaddr + SCBCmd;
969  int rc, wait = CU_CMD_TIMEOUT;
970 
971  DBGP ( "ifec_scb_cmd_wait\n" );
972 
973  for ( ; wait && ( rc = inb ( cmd_ioaddr ) ); wait-- )
974  udelay ( 1 );
975 
976  if ( !wait )
977  DBG ( "ifec_scb_cmd_wait timeout!\n" );
978  return rc;
979 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
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 CU_CMD_TIMEOUT
Definition: eepro100.h:12
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
static struct tlan_private * priv
Definition: tlan.c:225
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References CU_CMD_TIMEOUT, DBG, DBGP, inb(), netdev, priv, net_device::priv, rc, SCBCmd, and udelay().

Referenced by ifec_net_open(), ifec_reprime_ru(), ifec_scb_cmd(), and ifec_tx_wake().

◆ ifec_tx_process()

static void ifec_tx_process ( struct net_device netdev)
static

Definition at line 986 of file eepro100.c.

987 {
988  struct ifec_private *priv = netdev->priv;
989  struct ifec_tcb *tcb = priv->tcb_tail;
990  s16 status;
991 
992  DBGP ( "ifec_tx_process\n" );
993 
994  /* Check status of transmitted packets */
995  while ( ( status = tcb->status ) && tcb->iob ) {
996  if ( status & TCB_U ) {
997  /* report error to iPXE */
998  DBG ( "ifec_tx_process : tx error!\n " );
1000  } else {
1001  /* report successful transmit */
1002  netdev_tx_complete ( netdev, tcb->iob );
1003  }
1004  DBG2 ( "tx completion\n" );
1005 
1006  tcb->iob = NULL;
1007  tcb->status = 0;
1008 
1009  priv->tcb_tail = tcb->next; /* Next TCB */
1010  tcb = tcb->next;
1011  }
1012 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:766
int16_t s16
Definition: stdint.h:20
struct io_buffer * iob
Definition: eepro100.h:117
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
Definition: eepro100.h:64
static struct net_device * netdev
Definition: gdbudp.c:52
volatile s16 status
Definition: eepro100.h:107
struct ifec_tcb * next
Definition: eepro100.h:118
uint8_t status
Status.
Definition: ena.h:16
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:470
static struct tlan_private * priv
Definition: tlan.c:225
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define DBG2(...)
Definition: compiler.h:515

References DBG, DBG2, DBGP, EINVAL, ifec_tcb::iob, netdev, netdev_tx_complete(), netdev_tx_complete_err(), ifec_tcb::next, NULL, priv, net_device::priv, status, ifec_tcb::status, and TCB_U.

Referenced by ifec_net_poll().

◆ ifec_tx_setup()

static int ifec_tx_setup ( struct net_device netdev)
static

Definition at line 1020 of file eepro100.c.

1021 {
1022  struct ifec_private *priv = netdev->priv;
1023  struct ifec_tcb *tcb;
1024  int i;
1025 
1026  DBGP ( "ifec_tx_setup\n" );
1027 
1028  /* allocate tx ring */
1029  priv->tcbs = malloc_phys ( TX_RING_BYTES, CB_ALIGN );
1030  if ( !priv->tcbs ) {
1031  DBG ( "TX-ring allocation failed\n" );
1032  return -ENOMEM;
1033  }
1034 
1035  tcb = priv->tcb_tail = priv->tcbs;
1036  priv->tx_curr = priv->tx_tail = 0;
1037  priv->tx_cnt = 0;
1038 
1039  for ( i = 0; i < TCB_COUNT; i++, tcb++ ) {
1040  tcb->status = 0;
1041  tcb->count = 0x01208000;
1042  tcb->iob = NULL;
1043  tcb->tbda_addr = virt_to_bus ( &tcb->tbd_addr0 );
1044  tcb->link = virt_to_bus ( tcb + 1 );
1045  tcb->next = tcb + 1;
1046  }
1047  /* We point tcb_head at the last TCB, so the first ifec_net_transmit()
1048  * will use the first (head->next) TCB to transmit. */
1049  priv->tcb_head = --tcb;
1050  tcb->link = virt_to_bus ( priv->tcbs );
1051  tcb->next = priv->tcbs;
1052 
1053  return 0;
1054 }
u32 tbda_addr
Definition: eepro100.h:110
#define TX_RING_BYTES
Definition: eepro100.h:23
s32 count
Definition: eepro100.h:111
struct io_buffer * iob
Definition: eepro100.h:117
u32 tbd_addr0
Definition: eepro100.h:114
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
volatile s16 status
Definition: eepro100.h:107
struct ifec_tcb * next
Definition: eepro100.h:118
static struct tlan_private * priv
Definition: tlan.c:225
#define CB_ALIGN
Definition: eepro100.h:18
u32 link
Definition: eepro100.h:109
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define TCB_COUNT
Definition: eepro100.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.c:706

References CB_ALIGN, ifec_tcb::count, DBG, DBGP, ENOMEM, ifec_tcb::iob, ifec_tcb::link, malloc_phys(), netdev, ifec_tcb::next, NULL, priv, net_device::priv, ifec_tcb::status, ifec_tcb::tbd_addr0, ifec_tcb::tbda_addr, TCB_COUNT, TX_RING_BYTES, and virt_to_bus().

Referenced by ifec_net_open().

◆ ifec_tx_wake()

void ifec_tx_wake ( struct net_device netdev)

Definition at line 1073 of file eepro100.c.

1074 {
1075  struct ifec_private *priv = netdev->priv;
1076  unsigned long ioaddr = priv->ioaddr;
1077  struct ifec_tcb *tcb = priv->tcb_head->next;
1078 
1079  DBGP ( "ifec_tx_wake\n" );
1080 
1081  /* For the special case of the first transmit, we issue a START. The
1082  * card won't RESUME after the configure command. */
1083  if ( priv->configured ) {
1084  priv->configured = 0;
1085  ifec_scb_cmd ( netdev, virt_to_bus ( tcb ), CUStart );
1087  return;
1088  }
1089 
1090  /* Resume if suspended. */
1091  switch ( ( inw ( ioaddr + SCBStatus ) >> 6 ) & 0x3 ) {
1092  case 0: /* Idle - We should not reach this state. */
1093  DBG2 ( "ifec_tx_wake: tx idle!\n" );
1094  ifec_scb_cmd ( netdev, virt_to_bus ( tcb ), CUStart );
1096  return;
1097  case 1: /* Suspended */
1098  DBG2 ( "s" );
1099  break;
1100  default: /* Active */
1101  DBG2 ( "a" );
1102  }
1104  outl ( 0, ioaddr + SCBPointer );
1105  priv->tcb_head->command &= ~CmdSuspend;
1106  /* Immediately issue Resume command */
1107  outb ( CUResume, ioaddr + SCBCmd );
1109 }
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
static int ifec_scb_cmd(struct net_device *netdev, u32 ptr, u8 cmd)
Definition: eepro100.c:943
static unsigned long ioaddr
Definition: davicom.c:129
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define outl(data, io_addr)
Definition: io.h:329
#define outb(data, io_addr)
Definition: io.h:309
static int ifec_scb_cmd_wait(struct net_device *netdev)
Definition: eepro100.c:965
static struct tlan_private * priv
Definition: tlan.c:225
#define DBG2(...)
Definition: compiler.h:515

References CmdSuspend, CUResume, CUStart, DBG2, DBGP, ifec_scb_cmd(), ifec_scb_cmd_wait(), inw(), ioaddr, netdev, outb, outl, priv, net_device::priv, SCBCmd, SCBPointer, SCBStatus, and virt_to_bus().

Referenced by ifec_net_transmit().

Variable Documentation

◆ ifec_cfg

struct ifec_cfg ifec_cfg
static
Initial value:
= {
.status = 0,
.command = CmdConfigure | CmdSuspend,
.link = 0,
.byte = { 22,
( TX_FIFO << 4 ) | RX_FIFO,
0, 0,
TX_DMA_COUNT + 0x80,
0x32,
0x03,
1,
0,
0x2E,
0,
0x60,
0, 0xf2,
0x48,
0, 0x40,
0xf2,
0x80,
0x3f,
0x0D }
}
#define RX_DMA_COUNT
Definition: eepro100.h:11
Definition: 3c515.c:139
#define TX_DMA_COUNT
Definition: eepro100.h:10
Definition: 3c515.c:139

Definition at line 127 of file eepro100.c.

◆ ifec_operations

struct net_device_operations ifec_operations
static
Initial value:
= {
.open = ifec_net_open,
.close = ifec_net_close,
.transmit = ifec_net_transmit,
.poll = ifec_net_poll,
.irq = ifec_net_irq
}
static void ifec_net_poll(struct net_device *netdev)
Definition: eepro100.c:401
static int ifec_net_open(struct net_device *netdev)
Definition: eepro100.c:310
static int ifec_net_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Definition: eepro100.c:437
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition: eepro100.c:291
static void ifec_net_close(struct net_device *netdev)
Definition: eepro100.c:258

Definition at line 152 of file eepro100.c.

Referenced by ifec_pci_probe().

◆ ifec_ee_bits

const uint16_t ifec_ee_bits[]
static
Initial value:
= {
}
#define EE_DATA_READ
Definition: davicom.c:80
Master In Slave Out.
Definition: spi_bit.h:39
#define EE_ENB
Definition: davicom.c:81
#define EE_SHIFT_CLK
Definition: davicom.c:75
#define SPI_BIT_SS(slave)
Determine bit index for a particular slave.
Definition: spi_bit.h:50
Master Out Slave In.
Definition: spi_bit.h:37
Serial clock.
Definition: spi_bit.h:35
#define EE_DATA_WRITE
Definition: davicom.c:77

Definition at line 472 of file eepro100.c.

Referenced by ifec_spi_read_bit(), and ifec_spi_write_bit().

◆ ifec_basher_ops

struct bit_basher_operations ifec_basher_ops
static
Initial value:
= {
}
static void ifec_spi_write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Definition: eepro100.c:511
static int ifec_spi_read_bit(struct bit_basher *basher, unsigned int bit_id)
Definition: eepro100.c:486

Definition at line 531 of file eepro100.c.

Referenced by ifec_init_eeprom().

◆ ifec_nics

struct pci_device_id ifec_nics[]
static

Definition at line 1113 of file eepro100.c.

◆ __pci_driver

struct pci_driver ifec_driver __pci_driver
Initial value:
= {
.ids = ifec_nics,
.id_count = ( sizeof (ifec_nics) / sizeof (ifec_nics[0]) ),
.probe = ifec_pci_probe,
}
static void ifec_pci_remove(struct pci_device *pci)
Definition: eepro100.c:237
static struct pci_device_id ifec_nics[]
Definition: eepro100.c:1113
static int ifec_pci_probe(struct pci_device *pci)
Definition: eepro100.c:172
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39

Definition at line 1152 of file eepro100.c.