iPXE
efx_common.h File Reference
#include <stdbool.h>
#include <ipxe/io.h>
#include <ipxe/netdevice.h>
#include "efx_bitfield.h"
#include "mcdi.h"

Go to the source code of this file.

Data Structures

struct  efx_special_buffer
 A buffer table allocation backing a tx dma, rx dma or eventq. More...
struct  efx_tx_queue
 A transmit queue. More...
struct  efx_rx_queue
 A receive queue. More...
struct  efx_ev_queue
 An event queue. More...
struct  efx_nic
 Hardware access. More...
struct  efx_nic_type
 Efx device type definition. More...

Macros

#define __packed   __attribute__((__packed__))
#define __force   /*nothing*/
#define BUILD_BUG_ON_ZERO(e)
#define BUILD_BUG_ON(e)
#define ARRAY_SIZE(x)
#define EFX_BUF_ALIGN   4096
#define EFX_RXD_SIZE   512
#define EFX_RXD_MASK   (EFX_RXD_SIZE - 1)
#define EFX_TXD_SIZE   512
#define EFX_TXD_MASK   (EFX_TXD_SIZE - 1)
#define EFX_EVQ_SIZE   512
#define EFX_EVQ_MASK   (EFX_EVQ_SIZE - 1)
#define EFX_NUM_RX_DESC   64
#define EFX_NUM_RX_DESC_MASK   (EFX_NUM_RX_DESC - 1)
#define EFX_RX_BUF_SIZE   1600
#define EFX_STATE_POLLING   1
#define EFX_MAC_FRAME_LEN(_mtu)
#define efx_writel_table(efx, value, index, reg)
#define efx_writel_page(efx, value, index, reg)

Typedefs

typedef uint16_t __le16
typedef uint32_t __le32
typedef uint64_t __le64
typedef efx_qword_t efx_rx_desc_t
typedef efx_qword_t efx_tx_desc_t
typedef efx_qword_t efx_event_t
typedef unsigned long long dma_addr_t

Enumerations

enum  efx_revision { EFX_HUNTINGTON }

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static void _efx_writel (struct efx_nic *efx, uint32_t value, unsigned int reg)
static uint32_t _efx_readl (struct efx_nic *efx, unsigned int reg)
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 rev)
void efx_remove (struct net_device *netdev)

Variables

const struct efx_nic_type hunt_nic_type

Macro Definition Documentation

◆ __packed

#define __packed   __attribute__((__packed__))

Definition at line 26 of file efx_common.h.

◆ __force

#define __force   /*nothing*/

Definition at line 27 of file efx_common.h.

◆ BUILD_BUG_ON_ZERO

#define BUILD_BUG_ON_ZERO ( e)
Value:
(sizeof(struct{int: -!!(e); }))

Definition at line 33 of file efx_common.h.

◆ BUILD_BUG_ON

#define BUILD_BUG_ON ( e)
Value:
#define BUILD_BUG_ON_ZERO(e)
Definition efx_common.h:33

Definition at line 34 of file efx_common.h.

◆ ARRAY_SIZE

◆ EFX_BUF_ALIGN

#define EFX_BUF_ALIGN   4096

Definition at line 55 of file efx_common.h.

Referenced by efx_hunt_alloc_special_buffer().

◆ EFX_RXD_SIZE

#define EFX_RXD_SIZE   512

Definition at line 56 of file efx_common.h.

Referenced by efx_hunt_rx_init(), hunt_rx_fini(), and hunt_rx_init().

◆ EFX_RXD_MASK

#define EFX_RXD_MASK   (EFX_RXD_SIZE - 1)

Definition at line 57 of file efx_common.h.

Referenced by efx_hunt_notify_rx_desc(), efx_hunt_receive(), and efx_hunt_rxq_fill().

◆ EFX_TXD_SIZE

#define EFX_TXD_SIZE   512

◆ EFX_TXD_MASK

#define EFX_TXD_MASK   (EFX_TXD_SIZE - 1)

Definition at line 59 of file efx_common.h.

Referenced by efx_hunt_notify_tx_desc(), efx_hunt_transmit(), and efx_hunt_transmit_done().

◆ EFX_EVQ_SIZE

#define EFX_EVQ_SIZE   512

Definition at line 60 of file efx_common.h.

Referenced by efx_hunt_ev_init(), hunt_ev_fini(), and hunt_ev_init().

◆ EFX_EVQ_MASK

#define EFX_EVQ_MASK   (EFX_EVQ_SIZE - 1)

Definition at line 61 of file efx_common.h.

Referenced by efx_hunt_poll().

◆ EFX_NUM_RX_DESC

#define EFX_NUM_RX_DESC   64

Definition at line 68 of file efx_common.h.

Referenced by efx_hunt_close(), and efx_hunt_rxq_fill().

◆ EFX_NUM_RX_DESC_MASK

#define EFX_NUM_RX_DESC_MASK   (EFX_NUM_RX_DESC - 1)

Definition at line 69 of file efx_common.h.

Referenced by efx_hunt_receive().

◆ EFX_RX_BUF_SIZE

#define EFX_RX_BUF_SIZE   1600

Definition at line 74 of file efx_common.h.

Referenced by efx_hunt_build_rx_desc(), and efx_hunt_rxq_fill().

◆ EFX_STATE_POLLING

#define EFX_STATE_POLLING   1

Definition at line 78 of file efx_common.h.

Referenced by hunt_poll().

◆ EFX_MAC_FRAME_LEN

#define EFX_MAC_FRAME_LEN ( _mtu)
Value:
(((_mtu) \
+ /* EtherII already included */ \
+ 4 /* FCS */ \
/* No VLAN supported */ \
+ 16 /* bug16772 */ \
+ 7) & ~7)

Definition at line 190 of file efx_common.h.

190#define EFX_MAC_FRAME_LEN(_mtu) \
191 (((_mtu) \
192 + /* EtherII already included */ \
193 + 4 /* FCS */ \
194 /* No VLAN supported */ \
195 + 16 /* bug16772 */ \
196 + 7) & ~7)

Referenced by hunt_set_mac().

◆ efx_writel_table

#define efx_writel_table ( efx,
value,
index,
reg )
Value:
efx_writel(efx, value, (reg) + ((index) * reg##_STEP))
pseudo_bit_t value[0x00020]
Definition arbel.h:2
long index
Definition bigint.h:65
void efx_writel(struct efx_nic *efx, efx_dword_t *value, unsigned int reg)
Definition efx_common.c:49
static unsigned int unsigned int reg
Definition myson.h:162

Definition at line 216 of file efx_common.h.

216#define efx_writel_table(efx, value, index, reg) \
217 efx_writel(efx, value, (reg) + ((index) * reg##_STEP))

Referenced by efx_hunt_evq_read_ack().

◆ efx_writel_page

#define efx_writel_page ( efx,
value,
index,
reg )
Value:
efx_writel(efx, value, (reg) + ((index) * 0x2000))

Definition at line 219 of file efx_common.h.

219#define efx_writel_page(efx, value, index, reg) \
220 efx_writel(efx, value, (reg) + ((index) * 0x2000))

Referenced by efx_hunt_evq_read_ack(), efx_hunt_notify_rx_desc(), efx_hunt_notify_tx_desc(), and efx_hunt_open().

Typedef Documentation

◆ __le16

typedef uint16_t __le16

Definition at line 29 of file efx_common.h.

◆ __le32

typedef uint32_t __le32

Definition at line 30 of file efx_common.h.

◆ __le64

typedef uint64_t __le64

Definition at line 31 of file efx_common.h.

◆ efx_rx_desc_t

Definition at line 51 of file efx_common.h.

◆ efx_tx_desc_t

Definition at line 52 of file efx_common.h.

◆ efx_event_t

Definition at line 53 of file efx_common.h.

◆ dma_addr_t

typedef unsigned long long dma_addr_t

Definition at line 80 of file efx_common.h.

Enumeration Type Documentation

◆ efx_revision

Enumerator
EFX_HUNTINGTON 

Definition at line 142 of file efx_common.h.

142 {
144};
@ EFX_HUNTINGTON
Definition efx_common.h:143

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ _efx_writel()

void _efx_writel ( struct efx_nic * efx,
uint32_t value,
unsigned int reg )
inlinestatic

Definition at line 205 of file efx_common.h.

207{
208 writel((value), (efx)->membase + (reg));
209}
#define writel
Definition w89c840.c:160

References reg, value, and writel.

Referenced by efx_writel(), hunt_mcdi_copyin(), and hunt_probe().

◆ _efx_readl()

uint32_t _efx_readl ( struct efx_nic * efx,
unsigned int reg )
inlinestatic

Definition at line 211 of file efx_common.h.

212{
213 return readl((efx)->membase + (reg));
214}
#define readl
Definition w89c840.c:157

References readl, and reg.

Referenced by efx_readl().

◆ efx_writel()

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

Definition at line 49 of file efx_common.c.

50{
51 DBGCIO(efx, "Writing partial register %x with " EFX_DWORD_FMT "\n",
53 _efx_writel(efx, value->u32[0], reg);
54}
#define EFX_DWORD_VAL(dword)
#define EFX_DWORD_FMT
static void _efx_writel(struct efx_nic *efx, uint32_t value, unsigned int reg)
Definition efx_common.h:205
#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 )
extern

Definition at line 57 of file efx_common.c.

58{
59 value->u32[0] = _efx_readl(efx, reg);
60 DBGCIO(efx, "Read from register %x, got " EFX_DWORD_FMT "\n",
62}
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 rev )
extern

Definition at line 71 of file efx_common.c.

72{
73 struct efx_nic *efx = netdev->priv;
74 struct pci_device *pci = container_of(netdev->dev,
75 struct pci_device, dev);
76 unsigned int reg = PCI_BASE_ADDRESS_0;
77 uint32_t bar_low;
78
79 efx->netdev = netdev;
80 efx->revision = revision;
81
82 /* Find the memory bar to use */
83 pci_read_config_dword(pci, reg, &bar_low);
86
87 efx->mmio_start = pci_bar_start(pci, reg);
88 efx->mmio_len = pci_bar_size(pci, reg);
89 efx->membase = pci_ioremap(pci, efx->mmio_start, efx->mmio_len);
90
91 DBGCP(efx, "BAR of %lx bytes at phys %lx mapped at %p\n",
92 efx->mmio_len, efx->mmio_start, efx->membase);
93
94 /* Enable PCI access */
96}
unsigned int uint32_t
Definition stdint.h:12
static struct net_device * netdev
Definition gdbudp.c:53
#define DBGCP(...)
Definition compiler.h:539
uint32_t revision
Entry point revision.
Definition ib_mad.h:9
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Get the size of a PCI BAR.
Definition pci.c:164
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition pci.c:97
#define PCI_BASE_ADDRESS_SPACE_IO
I/O BAR.
Definition pci.h:69
#define PCI_BASE_ADDRESS_2
Definition pci.h:65
#define PCI_BASE_ADDRESS_0
Definition pci.h:63
#define PCI_BASE_ADDRESS_IO_MASK
I/O BAR mask.
Definition pci.h:70
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
Hardware access.
Definition efx_common.h:147
struct net_device * netdev
Definition efx_common.h:148
unsigned long mmio_start
Definition efx_common.h:157
unsigned long mmio_len
Definition efx_common.h:158
enum efx_revision revision
Definition efx_common.h:149
void * membase
Memory and IO base.
Definition efx_common.h:156
A PCI device.
Definition pci.h:211
struct device dev
Generic device.
Definition pci.h:213

References adjust_pci_device(), container_of, DBGCP, pci_device::dev, efx_nic::membase, efx_nic::mmio_len, efx_nic::mmio_start, efx_nic::netdev, netdev, 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_ioremap(), pci_read_config_dword(), reg, efx_nic::revision, and revision.

Referenced by hunt_probe().

◆ efx_remove()

void efx_remove ( struct net_device * netdev)
extern

Definition at line 98 of file efx_common.c.

99{
100 struct efx_nic *efx = netdev->priv;
101
102 iounmap(efx->membase);
103 efx->membase = NULL;
104}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
void iounmap(volatile const void *io_addr)
Unmap I/O address.

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

Referenced by hunt_probe(), and hunt_remove().

Variable Documentation

◆ hunt_nic_type

const struct efx_nic_type hunt_nic_type
extern

Definition at line 1314 of file sfc_hunt.c.

1314 {
1315 .mcdi_rpc = _hunt_mcdi,
1316};
int _hunt_mcdi(struct efx_nic *efx, unsigned int cmd, const efx_dword_t *inbuf, size_t inlen, efx_dword_t *outbuf, size_t outlen, size_t *outlen_actual, bool quiet)
Definition sfc_hunt.c:261

Referenced by hunt_probe().