iPXE
Macros | Functions | Variables
eepro100.c File Reference
#include <stdint.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 280 of file eepro100.c.

◆ RFD_STATUS

#define RFD_STATUS
Value:

Definition at line 785 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 171 of file eepro100.c.

172 {
173  struct net_device *netdev;
174  struct ifec_private *priv;
175  int rc;
176 
177  DBGP ( "ifec_pci_probe: " );
178 
179  if ( pci->ioaddr == 0 )
180  return -EINVAL;
181 
182  netdev = alloc_etherdev ( sizeof(*priv) );
183  if ( !netdev )
184  return -ENOMEM;
185 
187  priv = netdev->priv;
188 
189  pci_set_drvdata ( pci, netdev );
190  netdev->dev = &pci->dev;
191 
192  /* enable bus master, etc */
193  adjust_pci_device( pci );
194 
195  DBGP ( "pci " );
196 
197  memset ( priv, 0, sizeof(*priv) );
198  priv->ioaddr = pci->ioaddr;
199 
200  ifec_reset ( netdev );
201  DBGP ( "reset " );
202 
204 
205  /* read MAC address */
206  nvs_read ( &priv->eeprom.nvs, EEPROM_ADDR_MAC_0, netdev->hw_addr,
207  ETH_ALEN );
208  /* read mdio_register */
209  nvs_read ( &priv->eeprom.nvs, EEPROM_ADDR_MDIO_REGISTER,
210  &priv->mdio_register, 2 );
211 
212  if ( ( rc = register_netdev ( netdev ) ) != 0 )
213  goto error;
214 
216 
217  DBGP ( "ints\n" );
218 
219  return 0;
220 
221 error:
222  ifec_reset ( netdev );
224  netdev_put ( netdev );
225 
226  return rc;
227 }
#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:200
static void ifec_init_eeprom(struct net_device *netdev)
Definition: eepro100.c:540
struct arbelprm_completion_with_error error
Definition: arbel.h:12
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
struct device dev
Generic device.
Definition: pci.h:189
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:338
#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:555
#define EEPROM_ADDR_MDIO_REGISTER
Definition: eepro100.h:27
void * priv
Driver private data.
Definition: netdevice.h:425
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:768
static struct net_device * netdev
Definition: gdbudp.c:52
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
A network device.
Definition: netdevice.h:348
static void ifec_reset(struct net_device *netdev)
Definition: eepro100.c:665
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
#define ETH_ALEN
Definition: if_ether.h:8
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
static struct tlan_private * priv
Definition: tlan.c:224
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
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:151
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
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 236 of file eepro100.c.

237 {
238  struct net_device *netdev = pci_get_drvdata ( pci );
239 
240  DBGP ( "ifec_pci_remove\n" );
241 
243  ifec_reset ( netdev );
245  netdev_put ( netdev );
246 }
#define DBGP(...)
Definition: compiler.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
A network device.
Definition: netdevice.h:348
static void ifec_reset(struct net_device *netdev)
Definition: eepro100.c:665
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348

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 257 of file eepro100.c.

258 {
259  struct ifec_private *priv = netdev->priv;
260  unsigned long ioaddr = priv->ioaddr;
261  unsigned short intr_status;
262 
263  DBGP ( "ifec_net_close\n" );
264 
265  /* disable interrupts */
266  ifec_net_irq ( netdev, 0 );
267 
268  /* Ack & clear ints */
269  intr_status = inw ( ioaddr + SCBStatus );
270  outw ( intr_status, ioaddr + SCBStatus );
271  inw ( ioaddr + SCBStatus );
272 
273  ifec_reset ( netdev );
274 
275  /* Free any resources */
276  ifec_free ( netdev );
277 }
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:691
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
static void ifec_reset(struct net_device *netdev)
Definition: eepro100.c:665
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition: eepro100.c:290
static struct tlan_private * priv
Definition: tlan.c:224

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 290 of file eepro100.c.

291 {
292  struct ifec_private *priv = netdev->priv;
293  unsigned long ioaddr = priv->ioaddr;
294 
295  DBGP ( "ifec_net_irq\n" );
296 
297  outw ( enable ? INTERRUPT_MASK : SCBMaskAll, ioaddr + SCBCmd );
298 }
#define INTERRUPT_MASK
Definition: eepro100.c:280
#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:425
static struct net_device * netdev
Definition: gdbudp.c:52
static struct tlan_private * priv
Definition: tlan.c:224

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 309 of file eepro100.c.

310 {
311  struct ifec_private *priv = netdev->priv;
312  struct ifec_ias *ias = NULL;
313  struct ifec_cfg *cfg = NULL;
314  int i, options;
315  int rc = -ENOMEM;
316 
317  DBGP ( "ifec_net_open: " );
318 
319  /* Ensure interrupts are disabled. */
320  ifec_net_irq ( netdev, 0 );
321 
322  /* Initialize Command Unit and Receive Unit base addresses. */
324  ifec_scb_cmd ( netdev, virt_to_bus ( &priv->stats ), CUStatsAddr );
325  ifec_scb_cmd ( netdev, 0, CUCmdBase );
326 
327  /* Initialize both rings */
328  if ( ( rc = ifec_rx_setup ( netdev ) ) != 0 )
329  goto error;
330  if ( ( rc = ifec_tx_setup ( netdev ) ) != 0 )
331  goto error;
332 
333  /* Initialize MDIO */
334  options = 0x00; /* 0x40 = 10mbps half duplex, 0x00 = Autosense */
336 
337  /* Prepare MAC address w/ Individual Address Setup (ias) command.*/
338  ias = malloc_dma ( sizeof ( *ias ), CB_ALIGN );
339  if ( !ias ) {
340  rc = -ENOMEM;
341  goto error;
342  }
343  ias->command = CmdIASetup;
344  ias->status = 0;
345  memcpy ( ias->ia, netdev->ll_addr, ETH_ALEN );
346 
347  /* Prepare operating parameters w/ a configure command. */
348  cfg = malloc_dma ( sizeof ( *cfg ), CB_ALIGN );
349  if ( !cfg ) {
350  rc = -ENOMEM;
351  goto error;
352  }
353  memcpy ( cfg, &ifec_cfg, sizeof ( *cfg ) );
354  cfg->link = virt_to_bus ( priv->tcbs );
355  cfg->byte[19] = ( options & 0x10 ) ? 0xC0 : 0x80;
356  ias->link = virt_to_bus ( cfg );
357 
358  /* Issue the ias and configure commands. */
359  ifec_scb_cmd ( netdev, virt_to_bus ( ias ), CUStart );
361  priv->configured = 1;
362 
363  /* Wait up to 10 ms for configuration to initiate */
364  for ( i = 10; i && !cfg->status; i-- )
365  mdelay ( 1 );
366  if ( ! cfg->status ) {
367  DBG ( "Failed to initiate!\n" );
368  goto error;
369  }
370  free_dma ( ias, sizeof ( *ias ) );
371  free_dma ( cfg, sizeof ( *cfg ) );
372  DBG2 ( "cfg " );
373 
374  /* Enable rx by sending ring address to card */
375  if ( priv->rfds[0] != NULL ) {
376  ifec_scb_cmd ( netdev, virt_to_bus( priv->rfds[0] ), RUStart );
378  }
379  DBG2 ( "rx_start\n" );
380 
381  return 0;
382 
383 error:
384  free_dma ( cfg, sizeof ( *cfg ) );
385  free_dma ( ias, sizeof ( *ias ) );
386  ifec_free ( netdev );
387  ifec_reset ( netdev );
388  return rc;
389 }
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:942
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:691
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:425
static struct net_device * netdev
Definition: gdbudp.c:52
static void ifec_mdio_setup(struct net_device *netdev, int options)
Definition: eepro100.c:603
static int ifec_tx_setup(struct net_device *netdev)
Definition: eepro100.c:1019
static void ifec_reset(struct net_device *netdev)
Definition: eepro100.c:665
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition: eepro100.c:290
#define ETH_ALEN
Definition: if_ether.h:8
static int ifec_rx_setup(struct net_device *netdev)
Definition: eepro100.c:915
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:964
static struct tlan_private * priv
Definition: tlan.c:224
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
#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:381
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#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_dma(), 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_dma(), 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 400 of file eepro100.c.

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

438 {
439  struct ifec_private *priv = netdev->priv;
440  struct ifec_tcb *tcb = priv->tcb_head->next;
441  unsigned long ioaddr = priv->ioaddr;
442 
443  DBGP ( "ifec_net_transmit\n" );
444 
445  /* Wait for TCB to become available. */
446  if ( tcb->status || tcb->iob ) {
447  DBG ( "TX overflow\n" );
448  return -ENOBUFS;
449  }
450 
451  DBG2 ( "transmitting packet (%zd bytes). status = %hX, cmd=%hX\n",
452  iob_len ( iobuf ), tcb->status, inw ( ioaddr + SCBCmd ) );
453 
454  tcb->command = CmdSuspend | CmdTx | CmdTxFlex;
455  tcb->count = 0x01208000;
456  tcb->tbd_addr0 = virt_to_bus ( iobuf->data );
457  tcb->tbd_size0 = 0x3FFF & iob_len ( iobuf );
458  tcb->iob = iobuf;
459 
460  ifec_tx_wake ( netdev );
461 
462  /* Append to end of ring. */
463  priv->tcb_head = tcb;
464 
465  return 0;
466 }
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:425
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:151
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
static struct tlan_private * priv
Definition: tlan.c:224
u16 command
Definition: eepro100.h:108
void * data
Start of data.
Definition: iobuf.h:44
void ifec_tx_wake(struct net_device *netdev)
Definition: eepro100.c:1072
#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 485 of file eepro100.c.

487 {
488  struct ifec_private *priv =
489  container_of ( basher, struct ifec_private, spi.basher );
490  unsigned long ee_addr = priv->ioaddr + CSREeprom;
491  unsigned int ret = 0;
492  uint16_t mask;
493 
494  DBGP ( "ifec_spi_read_bit\n" );
495 
496  mask = ifec_ee_bits[bit_id];
497  ret = inw (ee_addr);
498 
499  return ( ret & mask ) ? 1 : 0;
500 }
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:471
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static struct tlan_private * priv
Definition: tlan.c:224

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 510 of file eepro100.c.

513 {
514  struct ifec_private *priv =
515  container_of ( basher, struct ifec_private, spi.basher );
516  unsigned long ee_addr = priv->ioaddr + CSREeprom;
517  short val;
518  uint16_t mask = ifec_ee_bits[bit_id];
519 
520  DBGP ( "ifec_spi_write_bit\n" );
521 
522  val = inw ( ee_addr );
523  val &= ~mask;
524  val |= data & mask;
525 
526  outw ( val, ee_addr );
527 }
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 outw(data, io_addr)
Definition: io.h:319
#define DBGP(...)
Definition: compiler.h:532
static const uint16_t ifec_ee_bits[]
Definition: eepro100.c:471
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
void __asmcall int val
Definition: setjmp.h:28
static struct tlan_private * priv
Definition: tlan.c:224
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

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 540 of file eepro100.c.

541 {
542  struct ifec_private *priv = netdev->priv;
543 
544  DBGP ( "ifec_init_eeprom\n" );
545 
546  priv->spi.basher.op = &ifec_basher_ops;
547  priv->spi.bus.mode = SPI_MODE_THREEWIRE;
548  init_spi_bit_basher ( &priv->spi );
549 
550  priv->eeprom.bus = &priv->spi.bus;
551 
552  /* init as 93c46(93c14 compatible) first, to set the command len,
553  * block size and word len. Needs to be set for address len detection.
554  */
555  init_at93c46 ( &priv->eeprom, 16 );
556 
557  /* detect address length, */
558  threewire_detect_address_len ( &priv->eeprom );
559 
560  /* address len == 8 means 93c66 instead of 93c46 */
561  if ( priv->eeprom.address_len == 8 )
562  init_at93c66 ( &priv->eeprom, 16 );
563 }
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:425
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:224
#define SPI_MODE_THREEWIRE
Threewire-compatible mode.
Definition: spi.h:199
static struct bit_basher_operations ifec_basher_ops
Definition: eepro100.c:530

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 571 of file eepro100.c.

573 {
574  struct ifec_private *priv = netdev->priv;
575  unsigned long ioaddr = priv->ioaddr;
576  int val;
577  int boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
578 
579  DBGP ( "ifec_mdio_read\n" );
580 
581  outl ( 0x08000000 | ( location << 16 ) | ( phy_id << 21 ),
582  ioaddr + CSRCtrlMDI );
583  do {
584  udelay ( 16 );
585 
586  val = inl ( ioaddr + CSRCtrlMDI );
587 
588  if ( --boguscnt < 0 ) {
589  DBG ( " ifec_mdio_read() time out with val = %X.\n",
590  val );
591  break;
592  }
593  } while (! ( val & 0x10000000 ) );
594  return val & 0xffff;
595 }
static unsigned long ioaddr
Definition: davicom.c:129
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:425
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
void __asmcall int val
Definition: setjmp.h:28
static struct tlan_private * priv
Definition: tlan.c:224
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 603 of file eepro100.c.

604 {
605  struct ifec_private *priv = netdev->priv;
606  unsigned short mdio_register = priv->mdio_register;
607 
608  DBGP ( "ifec_mdio_setup\n" );
609 
610  if ( ( (mdio_register>>8) & 0x3f ) == DP83840
611  || ( (mdio_register>>8) & 0x3f ) == DP83840A ) {
612  int mdi_reg23 = ifec_mdio_read ( netdev, mdio_register
613  & 0x1f, 23 ) | 0x0422;
614  if (CONGENB)
615  mdi_reg23 |= 0x0100;
616  DBG2 ( "DP83840 specific setup, setting register 23 to "
617  "%hX.\n", mdi_reg23 );
618  ifec_mdio_write ( netdev, mdio_register & 0x1f, 23, mdi_reg23 );
619  }
620  DBG2 ( "dp83840 " );
621  if ( options != 0 ) {
622  ifec_mdio_write ( netdev, mdio_register & 0x1f, 0,
623  ( (options & 0x20) ? 0x2000 : 0 ) |
624  ( (options & 0x10) ? 0x0100 : 0 ) );
625  DBG2 ( "set mdio_register. " );
626  }
627 }
#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:425
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:571
unsigned short mdio_register
Definition: eepro100.h:148
static struct tlan_private * priv
Definition: tlan.c:224
static int ifec_mdio_write(struct net_device *netdev, int phy_id, int location, int value)
Definition: eepro100.c:635
#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 635 of file eepro100.c.

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

666 {
667  struct ifec_private *priv = netdev->priv;
668  unsigned long ioaddr = priv->ioaddr;
669 
670  DBGP ( "ifec_reset\n" );
671 
672  /* do partial reset first */
674  inw ( ioaddr + SCBStatus );
675  udelay ( 20 );
676 
677  /* full reset */
678  outl ( PortReset, ioaddr + CSRPort );
679  inw ( ioaddr + SCBStatus );
680  udelay ( 20 );
681 
682  /* disable interrupts again */
683  ifec_net_irq ( netdev, 0 );
684 }
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:425
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:290
static struct tlan_private * priv
Definition: tlan.c:224

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 691 of file eepro100.c.

692 {
693  struct ifec_private *priv = netdev_priv ( netdev );
694  int i;
695 
696  DBGP ( "ifec_free\n" );
697 
698  /* free all allocated receive io_buffers */
699  for ( i = 0; i < RFD_COUNT; i++ ) {
700  free_iob ( priv->rx_iobs[i] );
701  priv->rx_iobs[i] = NULL;
702  priv->rfds[i] = NULL;
703  }
704 
705  /* free TX ring buffer */
706  free_dma ( priv->tcbs, TX_RING_BYTES );
707 
708  priv->tcbs = NULL;
709 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
#define TX_RING_BYTES
Definition: eepro100.h:23
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define DBGP(...)
Definition: compiler.h:532
static struct net_device * netdev
Definition: gdbudp.c:52
#define RFD_COUNT
Definition: eepro100.h:20
static struct tlan_private * priv
Definition: tlan.c:224
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBGP, free_dma(), free_iob(), netdev, netdev_priv(), NULL, 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 718 of file eepro100.c.

719 {
720  DBGP ( "ifec_rfd_init\n" );
721 
722  rfd->status = 0;
723  rfd->command = command;
724  rfd->rx_buf_addr = 0xFFFFFFFF;
725  rfd->count = 0;
726  rfd->size = RFD_PACKET_LEN;
727  rfd->link = link;
728 }
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
u16 count
Definition: eepro100.h:126
#define RFD_PACKET_LEN
Definition: eepro100.h:15
uint8_t command
Command.
Definition: intel.h:18

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 735 of file eepro100.c.

736 {
737  struct ifec_private *priv = netdev->priv;
738  int cur_rx = priv->cur_rx;
739 
740  DBGP ( "ifec_reprime_ru\n" );
741 
742  if ( priv->rfds[cur_rx] != NULL ) {
743  ifec_scb_cmd ( netdev, virt_to_bus ( priv->rfds[cur_rx] ),
744  RUStart );
746  }
747 }
static int ifec_scb_cmd(struct net_device *netdev, u32 ptr, u8 cmd)
Definition: eepro100.c:942
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:425
static struct net_device * netdev
Definition: gdbudp.c:52
static int ifec_scb_cmd_wait(struct net_device *netdev)
Definition: eepro100.c:964
static struct tlan_private * priv
Definition: tlan.c:224
static unsigned int cur_rx
Definition: epic100.c:84
unsigned int cur_rx
Definition: tlan.c:205
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 754 of file eepro100.c.

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

References DBG, DBGP, 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 793 of file eepro100.c.

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

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 847 of file eepro100.c.

849 {
850  struct ifec_private *priv = netdev->priv;
851  struct ifec_rfd *rfd = priv->rfds[cur];
852 
853  DBGP ( "ifec_get_rx_desc\n" );
854 
855  priv->rx_iobs[cur] = alloc_iob ( sizeof ( *rfd ) );
856  if ( ! priv->rx_iobs[cur] ) {
857  DBG ( "alloc_iob failed. desc. nr: %d\n", cur );
858  priv->rfds[cur] = NULL;
859  return -ENOMEM;
860  }
861 
862  /* Initialize new tail. */
863  priv->rfds[cur] = priv->rx_iobs[cur]->data;
864  ifec_rfd_init ( priv->rfds[cur], cmd, link );
865  iob_reserve ( priv->rx_iobs[cur], RFD_HEADER_LEN );
866 
867  return 0;
868 }
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
#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:425
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:718
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
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 875 of file eepro100.c.

876 {
877  struct ifec_private *priv = netdev->priv;
878  int i, cur_rx;
879  unsigned short intr_status;
880 
881  DBGP ( "ifec_refill_rx_ring\n" );
882 
883  for ( i = 0; i < RFD_COUNT; i++ ) {
884  cur_rx = ( priv->cur_rx + i ) % RFD_COUNT;
885  /* only refill if empty */
886  if ( priv->rfds[cur_rx] != NULL ||
887  priv->rx_iobs[cur_rx] != NULL )
888  continue;
889 
890  DBG2 ( "refilling RFD %d\n", cur_rx );
891 
893  CmdSuspend | CmdEndOfList, 0 ) == 0 ) {
894  if ( i > 0 ) {
895  int prev_rx = ( ( ( cur_rx + RFD_COUNT ) - 1 )
896  % RFD_COUNT );
897  struct ifec_rfd *rfd = priv->rfds[prev_rx];
898 
899  rfd->command = 0;
900  rfd->link = virt_to_bus ( priv->rfds[cur_rx] );
901  }
902  }
903  }
904 
905  intr_status = inw ( priv->ioaddr + SCBStatus );
906  ifec_check_ru_status ( netdev, intr_status );
907 }
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:754
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:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define RFD_COUNT
Definition: eepro100.h:20
static struct tlan_private * priv
Definition: tlan.c:224
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:847
unsigned int cur_rx
Definition: tlan.c:205
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#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 915 of file eepro100.c.

916 {
917  struct ifec_private *priv = netdev->priv;
918  int i;
919 
920  DBGP ( "ifec_rx_setup\n" );
921 
922  priv->cur_rx = 0;
923 
924  /* init values for ifec_refill_rx_ring() */
925  for ( i = 0; i < RFD_COUNT; i++ ) {
926  priv->rfds[i] = NULL;
927  priv->rx_iobs[i] = NULL;
928  }
930 
931  return 0;
932 }
static void ifec_refill_rx_ring(struct net_device *netdev)
Definition: eepro100.c:875
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define RFD_COUNT
Definition: eepro100.h:20
static struct tlan_private * priv
Definition: tlan.c:224
unsigned int cur_rx
Definition: tlan.c:205
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 942 of file eepro100.c.

943 {
944  struct ifec_private *priv = netdev->priv;
945  unsigned long ioaddr = priv->ioaddr;
946  int rc;
947 
948  DBGP ( "ifec_scb_cmd\n" );
949 
950  rc = ifec_scb_cmd_wait ( netdev ); /* Wait until ready */
951  if ( !rc ) {
952  outl ( ptr, ioaddr + SCBPointer );
953  outb ( cmd, ioaddr + SCBCmd ); /* Issue command */
954  }
955  return rc;
956 }
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:425
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:964
static struct tlan_private * priv
Definition: tlan.c:224
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 964 of file eepro100.c.

965 {
966  struct ifec_private *priv = netdev->priv;
967  unsigned long cmd_ioaddr = priv->ioaddr + SCBCmd;
968  int rc, wait = CU_CMD_TIMEOUT;
969 
970  DBGP ( "ifec_scb_cmd_wait\n" );
971 
972  for ( ; wait && ( rc = inb ( cmd_ioaddr ) ); wait-- )
973  udelay ( 1 );
974 
975  if ( !wait )
976  DBG ( "ifec_scb_cmd_wait timeout!\n" );
977  return rc;
978 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:425
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:224
#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 985 of file eepro100.c.

986 {
987  struct ifec_private *priv = netdev->priv;
988  struct ifec_tcb *tcb = priv->tcb_tail;
989  s16 status;
990 
991  DBGP ( "ifec_tx_process\n" );
992 
993  /* Check status of transmitted packets */
994  while ( ( status = tcb->status ) && tcb->iob ) {
995  if ( status & TCB_U ) {
996  /* report error to iPXE */
997  DBG ( "ifec_tx_process : tx error!\n " );
999  } else {
1000  /* report successful transmit */
1001  netdev_tx_complete ( netdev, tcb->iob );
1002  }
1003  DBG2 ( "tx completion\n" );
1004 
1005  tcb->iob = NULL;
1006  tcb->status = 0;
1007 
1008  priv->tcb_tail = tcb->next; /* Next TCB */
1009  tcb = tcb->next;
1010  }
1011 }
#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:746
int16_t s16
Definition: stdint.h:20
struct io_buffer * iob
Definition: eepro100.h:117
uint8_t status
Status.
Definition: ena.h:16
#define DBGP(...)
Definition: compiler.h:532
void * priv
Driver private data.
Definition: netdevice.h:425
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
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:395
static struct tlan_private * priv
Definition: tlan.c:224
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#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 1019 of file eepro100.c.

1020 {
1021  struct ifec_private *priv = netdev->priv;
1022  struct ifec_tcb *tcb;
1023  int i;
1024 
1025  DBGP ( "ifec_tx_setup\n" );
1026 
1027  /* allocate tx ring */
1028  priv->tcbs = malloc_dma ( TX_RING_BYTES, CB_ALIGN );
1029  if ( !priv->tcbs ) {
1030  DBG ( "TX-ring allocation failed\n" );
1031  return -ENOMEM;
1032  }
1033 
1034  tcb = priv->tcb_tail = priv->tcbs;
1035  priv->tx_curr = priv->tx_tail = 0;
1036  priv->tx_cnt = 0;
1037 
1038  for ( i = 0; i < TCB_COUNT; i++, tcb++ ) {
1039  tcb->status = 0;
1040  tcb->count = 0x01208000;
1041  tcb->iob = NULL;
1042  tcb->tbda_addr = virt_to_bus ( &tcb->tbd_addr0 );
1043  tcb->link = virt_to_bus ( tcb + 1 );
1044  tcb->next = tcb + 1;
1045  }
1046  /* We point tcb_head at the last TCB, so the first ifec_net_transmit()
1047  * will use the first (head->next) TCB to transmit. */
1048  priv->tcb_head = --tcb;
1049  tcb->link = virt_to_bus ( priv->tcbs );
1050  tcb->next = priv->tcbs;
1051 
1052  return 0;
1053 }
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:425
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:224
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
#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:362

References CB_ALIGN, ifec_tcb::count, DBG, DBGP, ENOMEM, ifec_tcb::iob, ifec_tcb::link, malloc_dma(), 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 1072 of file eepro100.c.

1073 {
1074  struct ifec_private *priv = netdev->priv;
1075  unsigned long ioaddr = priv->ioaddr;
1076  struct ifec_tcb *tcb = priv->tcb_head->next;
1077 
1078  DBGP ( "ifec_tx_wake\n" );
1079 
1080  /* For the special case of the first transmit, we issue a START. The
1081  * card won't RESUME after the configure command. */
1082  if ( priv->configured ) {
1083  priv->configured = 0;
1084  ifec_scb_cmd ( netdev, virt_to_bus ( tcb ), CUStart );
1086  return;
1087  }
1088 
1089  /* Resume if suspended. */
1090  switch ( ( inw ( ioaddr + SCBStatus ) >> 6 ) & 0x3 ) {
1091  case 0: /* Idle - We should not reach this state. */
1092  DBG2 ( "ifec_tx_wake: tx idle!\n" );
1093  ifec_scb_cmd ( netdev, virt_to_bus ( tcb ), CUStart );
1095  return;
1096  case 1: /* Suspended */
1097  DBG2 ( "s" );
1098  break;
1099  default: /* Active */
1100  DBG2 ( "a" );
1101  }
1103  outl ( 0, ioaddr + SCBPointer );
1104  priv->tcb_head->command &= ~CmdSuspend;
1105  /* Immediately issue Resume command */
1106  outb ( CUResume, ioaddr + SCBCmd );
1108 }
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:942
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:425
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:964
static struct tlan_private * priv
Definition: tlan.c:224
#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:140
#define TX_DMA_COUNT
Definition: eepro100.h:10
Definition: 3c515.c:140

Definition at line 126 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:400
static int ifec_net_open(struct net_device *netdev)
Definition: eepro100.c:309
static int ifec_net_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Definition: eepro100.c:436
static void ifec_net_irq(struct net_device *netdev, int enable)
Definition: eepro100.c:290
static void ifec_net_close(struct net_device *netdev)
Definition: eepro100.c:257

Definition at line 151 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
Serial clock.
Definition: spi_bit.h:35
#define EE_ENB
Definition: davicom.c:81
Master Out Slave In.
Definition: spi_bit.h:37
#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 In Slave Out.
Definition: spi_bit.h:39
#define EE_DATA_WRITE
Definition: davicom.c:77

Definition at line 471 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:510
static int ifec_spi_read_bit(struct bit_basher *basher, unsigned int bit_id)
Definition: eepro100.c:485

Definition at line 530 of file eepro100.c.

Referenced by ifec_init_eeprom().

◆ ifec_nics

struct pci_device_id ifec_nics[]
static

Definition at line 1112 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:236
static struct pci_device_id ifec_nics[]
Definition: eepro100.c:1112
static int ifec_pci_probe(struct pci_device *pci)
Definition: eepro100.c:171
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39

Definition at line 1151 of file eepro100.c.