iPXE
Data Structures | Macros | Functions
efx_hunt.h File Reference
#include "efx_common.h"

Go to the source code of this file.

Data Structures

struct  efx_mcdi_req_s
 MCDI request structure. More...
 

Macros

#define EFX_EV_SIZE(_nevs)   ((_nevs) * sizeof(efx_qword_t))
 
#define EFX_EVQ_NBUFS(_nevs)   (EFX_EV_SIZE(_nevs) / EFX_BUF_ALIGN)
 
#define EFX_RXQ_SIZE(_ndescs)   ((_ndescs) * sizeof(efx_qword_t))
 
#define EFX_RXQ_NBUFS(_ndescs)   (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_ALIGN)
 
#define EFX_TXQ_SIZE(_ndescs)   ((_ndescs) * sizeof(efx_qword_t))
 
#define EFX_TXQ_NBUFS(_ndescs)   (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_ALIGN)
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void efx_hunt_free_special_buffer (void *buf, int bytes)
 
int efx_hunt_transmit (struct net_device *netdev, struct io_buffer *iob)
 
void efx_hunt_poll (struct net_device *netdev)
 
void efx_hunt_irq (struct net_device *netdev, int enable)
 
int efx_hunt_ev_init (struct net_device *netdev, dma_addr_t *dma_addr)
 
int efx_hunt_rx_init (struct net_device *netdev, dma_addr_t *dma_addr)
 
int efx_hunt_tx_init (struct net_device *netdev, dma_addr_t *dma_addr)
 
int efx_hunt_open (struct net_device *netdev)
 
void efx_hunt_close (struct net_device *netdev)
 

Macro Definition Documentation

◆ EFX_EV_SIZE

#define EFX_EV_SIZE (   _nevs)    ((_nevs) * sizeof(efx_qword_t))

Definition at line 34 of file efx_hunt.h.

◆ EFX_EVQ_NBUFS

#define EFX_EVQ_NBUFS (   _nevs)    (EFX_EV_SIZE(_nevs) / EFX_BUF_ALIGN)

Definition at line 35 of file efx_hunt.h.

◆ EFX_RXQ_SIZE

#define EFX_RXQ_SIZE (   _ndescs)    ((_ndescs) * sizeof(efx_qword_t))

Definition at line 37 of file efx_hunt.h.

◆ EFX_RXQ_NBUFS

#define EFX_RXQ_NBUFS (   _ndescs)    (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_ALIGN)

Definition at line 38 of file efx_hunt.h.

◆ EFX_TXQ_SIZE

#define EFX_TXQ_SIZE (   _ndescs)    ((_ndescs) * sizeof(efx_qword_t))

Definition at line 40 of file efx_hunt.h.

◆ EFX_TXQ_NBUFS

#define EFX_TXQ_NBUFS (   _ndescs)    (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_ALIGN)

Definition at line 41 of file efx_hunt.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efx_hunt_free_special_buffer()

void efx_hunt_free_special_buffer ( void *  buf,
int  bytes 
)

Definition at line 40 of file efx_hunt.c.

41 {
43 }
struct io_buffer * buf[EFX_TXD_SIZE]
Definition: efx_common.h:94
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
uint8_t bytes[64]
Definition: ib_mad.h:16

References bytes, and free_phys().

Referenced by hunt_ev_fini(), hunt_rx_fini(), and hunt_tx_fini().

◆ efx_hunt_transmit()

int efx_hunt_transmit ( struct net_device netdev,
struct io_buffer iob 
)

Definition at line 102 of file efx_hunt.c.

103 {
104  struct efx_nic *efx = netdev->priv;
105  struct efx_tx_queue *txq = &efx->txq;
106  int fill_level, space;
108  int buf_id;
109 
110  fill_level = txq->write_ptr - txq->read_ptr;
111  space = EFX_TXD_SIZE - fill_level - 1;
112  if (space < 1)
113  return -ENOBUFS;
114 
115  /* Save the iobuffer for later completion */
116  buf_id = txq->write_ptr & EFX_TXD_MASK;
117  assert(txq->buf[buf_id] == NULL);
118  txq->buf[buf_id] = iob;
119 
120  DBGCIO(efx, "tx_buf[%d] for iob %p data %p len %zd\n",
121  buf_id, iob, iob->data, iob_len(iob));
122 
123  /* Form the descriptor, and push it to hardware */
124  txd = txq->ring + buf_id;
126  ++txq->write_ptr;
128 
129  return 0;
130 }
#define EFX_TXD_MASK
Definition: efx_common.h:59
Hardware access.
Definition: efx_common.h:147
A transmit queue.
Definition: efx_common.h:89
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
efx_tx_desc_t * ring
Definition: efx_common.h:91
void * priv
Driver private data.
Definition: netdevice.h:431
static void efx_hunt_build_tx_desc(efx_tx_desc_t *txd, struct io_buffer *iob)
Definition: efx_hunt.c:77
static struct net_device * netdev
Definition: gdbudp.c:52
unsigned int read_ptr
Definition: efx_common.h:103
unsigned int write_ptr
Definition: efx_common.h:100
#define txd
Definition: davicom.c:144
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
#define DBGCIO(...)
Definition: compiler.h:556
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
struct efx_tx_queue txq
Definition: efx_common.h:165
void * data
Start of data.
Definition: iobuf.h:52
struct io_buffer * buf[EFX_TXD_SIZE]
Definition: efx_common.h:94
#define EFX_TXD_SIZE
Definition: efx_common.h:58
static void efx_hunt_notify_tx_desc(struct efx_nic *efx)
Definition: efx_hunt.c:91
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92

References assert(), efx_tx_queue::buf, io_buffer::data, DBGCIO, efx_hunt_build_tx_desc(), efx_hunt_notify_tx_desc(), EFX_TXD_MASK, EFX_TXD_SIZE, ENOBUFS, iob_len(), netdev, NULL, net_device::priv, efx_tx_queue::read_ptr, efx_tx_queue::ring, txd, efx_nic::txq, and efx_tx_queue::write_ptr.

◆ efx_hunt_poll()

void efx_hunt_poll ( struct net_device netdev)

Definition at line 406 of file efx_hunt.c.

407 {
408  struct efx_nic *efx = netdev->priv;
409  struct efx_ev_queue *evq = &efx->evq;
410  efx_event_t *evt;
411  int budget = 10;
412 
413  /* Read the event queue by directly looking for events
414  * (we don't even bother to read the eventq write ptr)
415  */
416  evt = evq->ring + evq->read_ptr;
417  while (efx_hunt_event_present(evt) && (budget > 0)) {
418  DBGCP(efx, "Event at index 0x%x address %p is "
419  EFX_QWORD_FMT "\n", evq->read_ptr,
420  evt, EFX_QWORD_VAL(*evt));
421 
422  budget -= efx_hunt_handle_event(efx, evt);
423 
424  /* Clear the event */
425  EFX_SET_QWORD(*evt);
426 
427  /* Move to the next event. We don't ack the event
428  * queue until the end
429  */
430  evq->read_ptr = ((evq->read_ptr + 1) & EFX_EVQ_MASK);
431  evt = evq->ring + evq->read_ptr;
432  }
433 
434  /* Push more rx buffers if needed */
435  efx_hunt_rxq_fill(efx);
436 
437  /* Clear any pending interrupts */
439 
440  /* Ack the event queue if interrupts are enabled */
441  if (efx->int_en)
443 }
static int efx_hunt_event_present(efx_event_t *event)
See if an event is present.
Definition: efx_hunt.c:338
Hardware access.
Definition: efx_common.h:147
#define EFX_EVQ_MASK
Definition: efx_common.h:61
static void efx_hunt_rxq_fill(struct efx_nic *efx)
Definition: efx_hunt.c:203
int int_en
INT_REG_KER.
Definition: efx_common.h:171
void * priv
Driver private data.
Definition: netdevice.h:431
#define EFX_SET_QWORD(qword)
Definition: efx_bitfield.h:400
static void efx_hunt_clear_interrupts(struct efx_nic *efx)
Definition: efx_hunt.c:315
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_QWORD_VAL(qword)
Definition: efx_bitfield.h:112
efx_event_t * ring
Definition: efx_common.h:132
struct efx_ev_queue evq
Definition: efx_common.h:166
#define EFX_QWORD_FMT
Definition: efx_bitfield.h:108
static unsigned int efx_hunt_handle_event(struct efx_nic *efx, efx_event_t *evt)
Definition: efx_hunt.c:368
#define DBGCP(...)
Definition: compiler.h:539
An event queue.
Definition: efx_common.h:128
unsigned int read_ptr
Definition: efx_common.h:138
static void efx_hunt_evq_read_ack(struct efx_nic *efx)
Definition: efx_hunt.c:345
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92

References DBGCP, EFX_EVQ_MASK, efx_hunt_clear_interrupts(), efx_hunt_event_present(), efx_hunt_evq_read_ack(), efx_hunt_handle_event(), efx_hunt_rxq_fill(), EFX_QWORD_FMT, EFX_QWORD_VAL, EFX_SET_QWORD, efx_nic::evq, efx_nic::int_en, netdev, net_device::priv, efx_ev_queue::read_ptr, and efx_ev_queue::ring.

Referenced by hunt_poll().

◆ efx_hunt_irq()

void efx_hunt_irq ( struct net_device netdev,
int  enable 
)

Definition at line 445 of file efx_hunt.c.

446 {
447  struct efx_nic *efx = netdev->priv;
448 
449  efx->int_en = enable;
450 
451  /* If interrupts are enabled, prime the event queue. Otherwise ack any
452  * pending interrupts
453  */
454  if (enable)
456  else if (efx->netdev->state & NETDEV_OPEN)
458 }
Hardware access.
Definition: efx_common.h:147
#define NETDEV_OPEN
Network device is open.
Definition: netdevice.h:438
unsigned int state
Current device state.
Definition: netdevice.h:395
int int_en
INT_REG_KER.
Definition: efx_common.h:171
void * priv
Driver private data.
Definition: netdevice.h:431
static void efx_hunt_clear_interrupts(struct efx_nic *efx)
Definition: efx_hunt.c:315
static struct net_device * netdev
Definition: gdbudp.c:52
static void efx_hunt_evq_read_ack(struct efx_nic *efx)
Definition: efx_hunt.c:345
struct net_device * netdev
Definition: efx_common.h:148

References efx_hunt_clear_interrupts(), efx_hunt_evq_read_ack(), efx_nic::int_en, netdev, efx_nic::netdev, NETDEV_OPEN, net_device::priv, and net_device::state.

◆ efx_hunt_ev_init()

int efx_hunt_ev_init ( struct net_device netdev,
dma_addr_t dma_addr 
)

Definition at line 296 of file efx_hunt.c.

297 {
298  struct efx_nic *efx = netdev->priv;
299  struct efx_ev_queue *evq = &efx->evq;
300  size_t bytes;
301 
302  /* Allocate the hardware event queue */
303  bytes = sizeof(efx_event_t) * EFX_EVQ_SIZE;
305  if (evq->ring == NULL)
306  return -ENOMEM;
307 
308  memset(evq->ring, 0xff, bytes);
309  evq->read_ptr = 0;
310  *dma_addr = evq->entry.dma_addr;
311  return 0;
312 }
dma_addr_t dma_addr
Definition: efx_common.h:84
Hardware access.
Definition: efx_common.h:147
#define EFX_EVQ_SIZE
Definition: efx_common.h:60
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
struct efx_special_buffer entry
Definition: efx_common.h:135
efx_qword_t efx_event_t
Definition: efx_common.h:53
efx_event_t * ring
Definition: efx_common.h:132
struct efx_ev_queue evq
Definition: efx_common.h:166
An event queue.
Definition: efx_common.h:128
static void * efx_hunt_alloc_special_buffer(int bytes, struct efx_special_buffer *entry)
Definition: efx_hunt.c:45
unsigned int read_ptr
Definition: efx_common.h:138
uint8_t bytes[64]
Definition: ib_mad.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * memset(void *dest, int character, size_t len) __nonnull

References bytes, efx_special_buffer::dma_addr, EFX_EVQ_SIZE, efx_hunt_alloc_special_buffer(), ENOMEM, efx_ev_queue::entry, efx_nic::evq, memset(), netdev, NULL, net_device::priv, efx_ev_queue::read_ptr, and efx_ev_queue::ring.

Referenced by hunt_ev_init().

◆ efx_hunt_rx_init()

int efx_hunt_rx_init ( struct net_device netdev,
dma_addr_t dma_addr 
)

Definition at line 272 of file efx_hunt.c.

273 {
274  struct efx_nic *efx = netdev->priv;
275  struct efx_rx_queue *rxq = &efx->rxq;
276  size_t bytes;
277 
278  /* Allocate hardware receive queue */
279  bytes = sizeof(efx_rx_desc_t) * EFX_RXD_SIZE;
281  if (rxq->ring == NULL)
282  return -ENOMEM;
283 
284  rxq->read_ptr = rxq->write_ptr = 0;
285  *dma_addr = rxq->entry.dma_addr;
286  return 0;
287 }
struct efx_special_buffer entry
Definition: efx_common.h:115
dma_addr_t dma_addr
Definition: efx_common.h:84
Hardware access.
Definition: efx_common.h:147
A receive queue.
Definition: efx_common.h:107
unsigned int read_ptr
Definition: efx_common.h:121
efx_rx_desc_t * ring
Definition: efx_common.h:109
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_RXD_SIZE
Definition: efx_common.h:56
struct efx_rx_queue rxq
Definition: efx_common.h:164
efx_qword_t efx_rx_desc_t
Definition: efx_common.h:51
unsigned int write_ptr
Definition: efx_common.h:118
static void * efx_hunt_alloc_special_buffer(int bytes, struct efx_special_buffer *entry)
Definition: efx_hunt.c:45
uint8_t bytes[64]
Definition: ib_mad.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References bytes, efx_special_buffer::dma_addr, efx_hunt_alloc_special_buffer(), EFX_RXD_SIZE, ENOMEM, efx_rx_queue::entry, netdev, NULL, net_device::priv, efx_rx_queue::read_ptr, efx_rx_queue::ring, efx_nic::rxq, and efx_rx_queue::write_ptr.

Referenced by hunt_rx_init().

◆ efx_hunt_tx_init()

int efx_hunt_tx_init ( struct net_device netdev,
dma_addr_t dma_addr 
)

Definition at line 157 of file efx_hunt.c.

158 {
159  struct efx_nic *efx = netdev->priv;
160  struct efx_tx_queue *txq = &efx->txq;
161  size_t bytes;
162 
163  /* Allocate hardware transmit queue */
164  bytes = sizeof(efx_tx_desc_t) * EFX_TXD_SIZE;
166  if (!txq->ring)
167  return -ENOMEM;
168 
169  txq->read_ptr = txq->write_ptr = 0;
170  *dma_addr = txq->entry.dma_addr;
171  return 0;
172 }
dma_addr_t dma_addr
Definition: efx_common.h:84
Hardware access.
Definition: efx_common.h:147
A transmit queue.
Definition: efx_common.h:89
#define ENOMEM
Not enough space.
Definition: errno.h:534
efx_tx_desc_t * ring
Definition: efx_common.h:91
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
efx_qword_t efx_tx_desc_t
Definition: efx_common.h:52
unsigned int read_ptr
Definition: efx_common.h:103
unsigned int write_ptr
Definition: efx_common.h:100
struct efx_tx_queue txq
Definition: efx_common.h:165
#define EFX_TXD_SIZE
Definition: efx_common.h:58
struct efx_special_buffer entry
Definition: efx_common.h:97
static void * efx_hunt_alloc_special_buffer(int bytes, struct efx_special_buffer *entry)
Definition: efx_hunt.c:45
uint8_t bytes[64]
Definition: ib_mad.h:16

References bytes, efx_special_buffer::dma_addr, efx_hunt_alloc_special_buffer(), EFX_TXD_SIZE, ENOMEM, efx_tx_queue::entry, netdev, net_device::priv, efx_tx_queue::read_ptr, efx_tx_queue::ring, efx_nic::txq, and efx_tx_queue::write_ptr.

Referenced by hunt_tx_init().

◆ efx_hunt_open()

int efx_hunt_open ( struct net_device netdev)

Definition at line 467 of file efx_hunt.c.

468 {
469  struct efx_nic *efx = netdev->priv;
471 
472  /* Set interrupt moderation to 0*/
474  ERF_DZ_TC_TIMER_MODE, 0,
475  ERF_DZ_TC_TIMER_VAL, 0);
476  efx_writel_page(efx, &cmd, 0, ER_DZ_EVQ_TMR);
477 
478  /* Ack the eventq */
479  if (efx->int_en)
481 
482  /* Push receive buffers */
483  efx_hunt_rxq_fill(efx);
484 
485  return 0;
486 }
Hardware access.
Definition: efx_common.h:147
#define ER_DZ_EVQ_TMR
Definition: ef10_regs.h:89
static void efx_hunt_rxq_fill(struct efx_nic *efx)
Definition: efx_hunt.c:203
#define efx_writel_page(efx, value, index, reg)
Definition: efx_common.h:219
A doubleword (4 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:87
int int_en
INT_REG_KER.
Definition: efx_common.h:171
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_POPULATE_DWORD_2(dword,...)
Definition: efx_bitfield.h:421
static void efx_hunt_evq_read_ack(struct efx_nic *efx)
Definition: efx_hunt.c:345
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, efx_hunt_evq_read_ack(), efx_hunt_rxq_fill(), EFX_POPULATE_DWORD_2, efx_writel_page, ER_DZ_EVQ_TMR, efx_nic::int_en, netdev, and net_device::priv.

Referenced by hunt_open().

◆ efx_hunt_close()

void efx_hunt_close ( struct net_device netdev)

Definition at line 488 of file efx_hunt.c.

489 {
490  struct efx_nic *efx = netdev->priv;
491  struct efx_rx_queue *rxq = &efx->rxq;
492  struct efx_tx_queue *txq = &efx->txq;
493  int i;
494 
495  /* Complete outstanding descriptors */
496  for (i = 0; i < EFX_NUM_RX_DESC; i++) {
497  if (rxq->buf[i]) {
498  free_iob(rxq->buf[i]);
499  rxq->buf[i] = NULL;
500  }
501  }
502 
503  for (i = 0; i < EFX_TXD_SIZE; i++) {
504  if (txq->buf[i]) {
505  netdev_tx_complete(efx->netdev, txq->buf[i]);
506  txq->buf[i] = NULL;
507  }
508  }
509 
510  /* Clear interrupts */
512 }
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:766
Hardware access.
Definition: efx_common.h:147
A transmit queue.
Definition: efx_common.h:89
A receive queue.
Definition: efx_common.h:107
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:152
void * priv
Driver private data.
Definition: netdevice.h:431
static void efx_hunt_clear_interrupts(struct efx_nic *efx)
Definition: efx_hunt.c:315
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_NUM_RX_DESC
Definition: efx_common.h:68
struct efx_rx_queue rxq
Definition: efx_common.h:164
struct efx_tx_queue txq
Definition: efx_common.h:165
struct io_buffer * buf[EFX_TXD_SIZE]
Definition: efx_common.h:94
#define EFX_TXD_SIZE
Definition: efx_common.h:58
struct io_buffer * buf[EFX_NUM_RX_DESC]
Definition: efx_common.h:112
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct net_device * netdev
Definition: efx_common.h:148

References efx_tx_queue::buf, efx_rx_queue::buf, efx_hunt_clear_interrupts(), EFX_NUM_RX_DESC, EFX_TXD_SIZE, free_iob(), netdev, efx_nic::netdev, netdev_tx_complete(), NULL, net_device::priv, efx_nic::rxq, and efx_nic::txq.

Referenced by hunt_close(), and hunt_open().