iPXE
Functions
efx_common.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/io.h>
#include <ipxe/pci.h>
#include <ipxe/malloc.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include "efx_common.h"
#include "efx_bitfield.h"
#include "mc_driver_pcol.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void efx_writel (struct efx_nic *efx, efx_dword_t *value, unsigned int reg)
 
void efx_readl (struct efx_nic *efx, efx_dword_t *value, unsigned int reg)
 
void efx_probe (struct net_device *netdev, enum efx_revision revision)
 
void efx_remove (struct net_device *netdev)
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efx_writel()

void efx_writel ( struct efx_nic efx,
efx_dword_t value,
unsigned int  reg 
)

Definition at line 48 of file efx_common.c.

49 {
50  DBGCIO(efx, "Writing partial register %x with " EFX_DWORD_FMT "\n",
52  _efx_writel(efx, value->u32[0], reg);
53 }
static void _efx_writel(struct efx_nic *efx, uint32_t value, unsigned int reg)
Definition: efx_common.h:205
#define EFX_DWORD_FMT
Definition: efx_bitfield.h:107
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static unsigned int unsigned int reg
Definition: intel.h:245
#define EFX_DWORD_VAL(dword)
Definition: efx_bitfield.h:110
#define DBGCIO(...)
Definition: compiler.h:556

References _efx_writel(), DBGCIO, EFX_DWORD_FMT, EFX_DWORD_VAL, reg, and value.

◆ efx_readl()

void efx_readl ( struct efx_nic efx,
efx_dword_t value,
unsigned int  reg 
)

Definition at line 56 of file efx_common.c.

57 {
58  value->u32[0] = _efx_readl(efx, reg);
59  DBGCIO(efx, "Read from register %x, got " EFX_DWORD_FMT "\n",
61 }
#define EFX_DWORD_FMT
Definition: efx_bitfield.h:107
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static unsigned int unsigned int reg
Definition: intel.h:245
#define EFX_DWORD_VAL(dword)
Definition: efx_bitfield.h:110
#define DBGCIO(...)
Definition: compiler.h:556
static uint32_t _efx_readl(struct efx_nic *efx, unsigned int reg)
Definition: efx_common.h:211

References _efx_readl(), DBGCIO, EFX_DWORD_FMT, EFX_DWORD_VAL, reg, and value.

Referenced by efx_hunt_clear_interrupts().

◆ efx_probe()

void efx_probe ( struct net_device netdev,
enum efx_revision  revision 
)

Definition at line 70 of file efx_common.c.

71 {
72  struct efx_nic *efx = netdev_priv(netdev);
73  struct pci_device *pci = container_of(netdev->dev,
74  struct pci_device, dev);
75  unsigned int reg = PCI_BASE_ADDRESS_0;
76  uint32_t bar_low;
77 
78  efx->netdev = netdev;
79  efx->revision = revision;
80 
81  /* Find the memory bar to use */
82  pci_read_config_dword(pci, reg, &bar_low);
85 
86  efx->mmio_start = pci_bar_start(pci, reg);
87  efx->mmio_len = pci_bar_size(pci, reg);
88  efx->membase = ioremap(efx->mmio_start, efx->mmio_len);
89 
90  DBGCP(efx, "BAR of %lx bytes at phys %lx mapped at %p\n",
91  efx->mmio_len, efx->mmio_start, efx->membase);
92 
93  /* Enable PCI access */
94  adjust_pci_device(pci);
95 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
Hardware access.
Definition: efx_common.h:147
#define PCI_BASE_ADDRESS_0
Definition: pci.h:61
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
struct device dev
Generic device.
Definition: pci.h:189
unsigned long mmio_len
Definition: efx_common.h:158
#define PCI_BASE_ADDRESS_IO_MASK
I/O BAR mask.
Definition: pci.h:68
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
#define PCI_BASE_ADDRESS_2
Definition: pci.h:63
static struct net_device * netdev
Definition: gdbudp.c:52
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
uint32_t revision
Definition: ib_mad.h:20
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Find the size of a PCI BAR.
Definition: pciextra.c:90
static unsigned int unsigned int reg
Definition: intel.h:245
A PCI device.
Definition: pci.h:187
enum efx_revision revision
Definition: efx_common.h:149
unsigned int uint32_t
Definition: stdint.h:12
#define PCI_BASE_ADDRESS_SPACE_IO
I/O BAR.
Definition: pci.h:67
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
void * membase
Memory and IO base.
Definition: efx_common.h:156
unsigned long mmio_start
Definition: efx_common.h:157
#define DBGCP(...)
Definition: compiler.h:539
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
struct net_device * netdev
Definition: efx_common.h:148

References adjust_pci_device(), container_of, DBGCP, pci_device::dev, net_device::dev, ioremap(), efx_nic::membase, efx_nic::mmio_len, efx_nic::mmio_start, netdev, efx_nic::netdev, netdev_priv(), pci_bar_size(), pci_bar_start(), PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_2, PCI_BASE_ADDRESS_IO_MASK, PCI_BASE_ADDRESS_SPACE_IO, pci_read_config_dword(), reg, revision, and efx_nic::revision.

Referenced by hunt_probe().

◆ efx_remove()

void efx_remove ( struct net_device netdev)

Definition at line 97 of file efx_common.c.

98 {
99  struct efx_nic *efx = netdev_priv(netdev);
100 
101  iounmap(efx->membase);
102  efx->membase = NULL;
103 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:566
Hardware access.
Definition: efx_common.h:147
static struct net_device * netdev
Definition: gdbudp.c:52
void * membase
Memory and IO base.
Definition: efx_common.h:156
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References iounmap(), efx_nic::membase, netdev, netdev_priv(), and NULL.

Referenced by hunt_probe(), and hunt_remove().