iPXE
Macros | Functions | Variables
thunderx.c File Reference

Cavium ThunderX Ethernet driver. More...

#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/pciea.h>
#include <ipxe/umalloc.h>
#include "thunderx.h"
#include "thunderxcfg.h"

Go to the source code of this file.

Macros

#define TXNICCOL(x)   ( &txnic_pfs + (x)->node )
 Debug colour for physical function and BGX messages. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static LIST_HEAD (txnic_bgxs)
 List of BGX Ethernet interfaces. More...
 
static LIST_HEAD (txnic_pfs)
 List of physical functions. More...
 
 EFI_REQUEST_PROTOCOL (EFI_THUNDER_CONFIG_PROTOCOL, &txcfg)
 
static void txnic_diag (struct txnic *vnic)
 Show virtual NIC diagnostics (for debugging) More...
 
static int txnic_create_sq (struct txnic *vnic)
 Create send queue. More...
 
static int txnic_disable_sq (struct txnic *vnic)
 Disable send queue. More...
 
static void txnic_destroy_sq (struct txnic *vnic)
 Destroy send queue. More...
 
static int txnic_send (struct txnic *vnic, struct io_buffer *iobuf)
 Send packet. More...
 
static void txnic_complete_sqe (struct txnic *vnic, struct txnic_cqe_send *cqe)
 Complete send queue entry. More...
 
static int txnic_create_rq (struct txnic *vnic)
 Create receive queue. More...
 
static int txnic_disable_rq (struct txnic *vnic)
 Disable receive queue. More...
 
static void txnic_destroy_rq (struct txnic *vnic)
 Destroy receive queue. More...
 
static void txnic_refill_rq (struct txnic *vnic)
 Refill receive queue. More...
 
static void txnic_complete_rqe (struct txnic *vnic, struct txnic_cqe_rx *cqe)
 Complete receive queue entry. More...
 
static int txnic_create_cq (struct txnic *vnic)
 Create completion queue. More...
 
static int txnic_disable_cq (struct txnic *vnic)
 Disable completion queue. More...
 
static void txnic_destroy_cq (struct txnic *vnic)
 Destroy completion queue. More...
 
static void txnic_poll_cq (struct txnic *vnic)
 Poll completion queue. More...
 
static int txnic_open (struct txnic *vnic)
 Open virtual NIC. More...
 
static void txnic_close (struct txnic *vnic)
 Close virtual NIC. More...
 
static void txnic_poll (struct txnic *vnic)
 Poll virtual NIC. More...
 
static struct txnictxnic_alloc (struct device *dev, unsigned long membase)
 Allocate virtual NIC. More...
 
static void txnic_free (struct txnic *vnic)
 Free virtual NIC. More...
 
static void txnic_lmac_diag (struct txnic_lmac *lmac)
 Show LMAC diagnostics (for debugging) More...
 
static void txnic_lmac_update_link (struct txnic_lmac *lmac)
 Update LMAC link state. More...
 
static void txnic_lmac_poll_link (struct txnic_lmac *lmac)
 Poll LMAC link state. More...
 
static void txnic_lmac_reset (struct txnic_lmac *lmac)
 Reset LMAC. More...
 
static int txnic_lmac_open (struct net_device *netdev)
 Open network device. More...
 
static void txnic_lmac_close (struct net_device *netdev)
 Close network device. More...
 
static int txnic_lmac_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void txnic_lmac_poll (struct net_device *netdev)
 Poll network device. More...
 
static int txnic_lmac_probe (struct txnic_lmac *lmac)
 Probe logical MAC virtual NIC. More...
 
static void txnic_lmac_remove (struct txnic_lmac *lmac)
 Remove logical MAC virtual NIC. More...
 
static int txnic_lmac_probe_all (struct txnic_pf *pf, struct txnic_bgx *bgx)
 Probe all LMACs on a BGX Ethernet interface. More...
 
static void txnic_lmac_remove_all (struct txnic_pf *pf, struct txnic_bgx *bgx)
 Remove all LMACs on a BGX Ethernet interface. More...
 
static int txnic_pf_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void txnic_pf_remove (struct pci_device *pci)
 Remove PCI device. More...
 
static int txnic_bgx_detect (struct txnic_bgx *bgx)
 Detect BGX Ethernet interface LMAC type. More...
 
static void txnic_bgx_init (struct txnic_bgx *bgx, unsigned int type)
 Initialise BGX Ethernet interface. More...
 
static void txnic_bgx_mac (struct txnic_lmac *lmac)
 Get MAC address. More...
 
static void txnic_bgx_spu_init (struct txnic_lmac *lmac)
 Initialise Super PHY Unit (SPU) More...
 
static void txnic_bgx_lmac_init (struct txnic_bgx *bgx, unsigned int lmac_idx)
 Initialise LMAC. More...
 
static int txnic_bgx_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void txnic_bgx_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

static EFI_THUNDER_CONFIG_PROTOCOLtxcfg
 Board configuration protocol. More...
 
static struct net_device_operations txnic_lmac_operations
 Network device operations. More...
 
static struct pci_device_id txnic_pf_ids []
 NIC physical function PCI device IDs. More...
 
struct pci_driver txnic_pf_driver __pci_driver
 NIC physical function PCI driver. More...
 
static struct txnic_lmac_type txnic_lmac_types []
 LMAC types. More...
 
static struct pci_device_id txnic_bgx_ids []
 BGX PCI device IDs. More...
 

Detailed Description

Cavium ThunderX Ethernet driver.

Definition in file thunderx.c.

Macro Definition Documentation

◆ TXNICCOL

#define TXNICCOL (   x)    ( &txnic_pfs + (x)->node )

Debug colour for physical function and BGX messages.

Definition at line 58 of file thunderx.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ LIST_HEAD() [1/2]

static LIST_HEAD ( txnic_bgxs  )
static

List of BGX Ethernet interfaces.

◆ LIST_HEAD() [2/2]

static LIST_HEAD ( txnic_pfs  )
static

List of physical functions.

◆ EFI_REQUEST_PROTOCOL()

EFI_REQUEST_PROTOCOL ( EFI_THUNDER_CONFIG_PROTOCOL  ,
txcfg 
)

◆ txnic_diag()

static void txnic_diag ( struct txnic vnic)
static

Show virtual NIC diagnostics (for debugging)

Parameters
vnicVirtual NIC

Definition at line 76 of file thunderx.c.

76  {
77 
78  DBGC ( vnic, "TXNIC %s SQ %05zx(%05llx)/%05zx(%05llx) %08llx\n",
79  vnic->name,
80  ( ( vnic->sq.prod % TXNIC_SQES ) * TXNIC_SQ_STRIDE ),
81  readq ( vnic->regs + TXNIC_QS_SQ_TAIL(0) ),
82  ( ( vnic->sq.cons % TXNIC_SQES ) * TXNIC_SQ_STRIDE ),
83  readq ( vnic->regs + TXNIC_QS_SQ_HEAD(0) ),
84  readq ( vnic->regs + TXNIC_QS_SQ_STATUS(0) ) );
85  DBGC ( vnic, "TXNIC %s RQ %05zx(%05llx)/%05zx(%05llx) %016llx\n",
86  vnic->name,
87  ( ( vnic->rq.prod % TXNIC_RQES ) * TXNIC_RQ_STRIDE ),
88  readq ( vnic->regs + TXNIC_QS_RBDR_TAIL(0) ),
89  ( ( vnic->rq.cons % TXNIC_RQES ) * TXNIC_RQ_STRIDE ),
90  readq ( vnic->regs + TXNIC_QS_RBDR_HEAD(0) ),
91  readq ( vnic->regs + TXNIC_QS_RBDR_STATUS0(0) ) );
92  DBGC ( vnic, "TXNIC %s CQ xxxxx(%05llx)/%05x(%05llx) %08llx:%08llx\n",
93  vnic->name, readq ( vnic->regs + TXNIC_QS_CQ_TAIL(0) ),
94  ( ( vnic->cq.cons % TXNIC_CQES ) * TXNIC_CQ_STRIDE ),
95  readq ( vnic->regs + TXNIC_QS_CQ_HEAD(0) ),
96  readq ( vnic->regs + TXNIC_QS_CQ_STATUS(0) ),
97  readq ( vnic->regs + TXNIC_QS_CQ_STATUS2(0) ) );
98 }
#define TXNIC_QS_CQ_HEAD(q)
Completion queue head pointer.
Definition: thunderx.h:313
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
struct txnic_sq sq
Send queue.
Definition: thunderx.h:426
unsigned int cons
Consumer counter.
Definition: thunderx.h:281
unsigned int prod
Producer counter.
Definition: thunderx.h:279
#define TXNIC_SQ_STRIDE
Send queue stride.
Definition: thunderx.h:179
#define TXNIC_QS_SQ_STATUS(q)
Send queue status.
Definition: thunderx.h:100
unsigned int cons
Consumer counter.
Definition: thunderx.h:189
unsigned int cons
Consumer counter.
Definition: thunderx.h:404
#define TXNIC_CQ_STRIDE
Completion queue stride.
Definition: thunderx.h:396
struct txnic_rq rq
Receive queue.
Definition: thunderx.h:428
#define TXNIC_QS_CQ_TAIL(q)
Completion queue tail pointer.
Definition: thunderx.h:316
#define TXNIC_QS_SQ_HEAD(q)
Send queue head pointer.
Definition: thunderx.h:91
#define TXNIC_RQES
Number of receive queue entries.
Definition: thunderx.h:251
#define TXNIC_CQES
Number of completion queue entries.
Definition: thunderx.h:390
void * regs
Registers.
Definition: thunderx.h:419
#define TXNIC_QS_CQ_STATUS2(q)
Completion queue status 2.
Definition: thunderx.h:327
#define TXNIC_QS_CQ_STATUS(q)
Completion queue status.
Definition: thunderx.h:322
#define TXNIC_QS_RBDR_STATUS0(q)
Receive buffer descriptor ring status 0.
Definition: thunderx.h:233
#define TXNIC_QS_RBDR_TAIL(q)
Receive buffer descriptor ring tail pointer.
Definition: thunderx.h:227
#define TXNIC_SQES
Number of send queue entries.
Definition: thunderx.h:167
struct txnic_cq cq
Completion queue.
Definition: thunderx.h:430
unsigned int prod
Producer counter.
Definition: thunderx.h:187
#define TXNIC_RQ_STRIDE
Receive queue stride.
Definition: thunderx.h:271
#define TXNIC_QS_RBDR_HEAD(q)
Receive buffer descriptor ring head pointer.
Definition: thunderx.h:224
#define TXNIC_QS_SQ_TAIL(q)
Send queue tail pointer.
Definition: thunderx.h:94

References txnic_sq::cons, txnic_rq::cons, txnic_cq::cons, txnic::cq, DBGC, txnic::name, txnic_sq::prod, txnic_rq::prod, readq(), txnic::regs, txnic::rq, txnic::sq, TXNIC_CQ_STRIDE, TXNIC_CQES, TXNIC_QS_CQ_HEAD, TXNIC_QS_CQ_STATUS, TXNIC_QS_CQ_STATUS2, TXNIC_QS_CQ_TAIL, TXNIC_QS_RBDR_HEAD, TXNIC_QS_RBDR_STATUS0, TXNIC_QS_RBDR_TAIL, TXNIC_QS_SQ_HEAD, TXNIC_QS_SQ_STATUS, TXNIC_QS_SQ_TAIL, TXNIC_RQ_STRIDE, TXNIC_RQES, TXNIC_SQ_STRIDE, and TXNIC_SQES.

◆ txnic_create_sq()

static int txnic_create_sq ( struct txnic vnic)
static

Create send queue.

Parameters
vnicVirtual NIC
Return values
rcReturn status code

Definition at line 113 of file thunderx.c.

113  {
114 
115  /* Reset send queue */
116  vnic->sq.prod = 0;
117  vnic->sq.cons = 0;
118  writeq ( TXNIC_QS_SQ_CFG_RESET, ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
119 
120  /* Configure and enable send queue */
121  writeq ( user_to_phys ( vnic->sq.sqe, 0 ),
122  ( vnic->regs + TXNIC_QS_SQ_BASE(0) ) );
124  ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
125 
126  DBGC ( vnic, "TXNIC %s SQ at [%08lx,%08lx)\n",
127  vnic->name, user_to_phys ( vnic->sq.sqe, 0 ),
128  user_to_phys ( vnic->sq.sqe, TXNIC_SQ_SIZE ) );
129  return 0;
130 }
#define TXNIC_QS_SQ_BASE(q)
Send queue base address.
Definition: thunderx.h:88
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define TXNIC_QS_SQ_CFG_RESET
Definition: thunderx.h:82
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
#define TXNIC_QS_SQ_CFG_QSIZE_1K
Definition: thunderx.h:84
struct txnic_sq sq
Send queue.
Definition: thunderx.h:426
unsigned int cons
Consumer counter.
Definition: thunderx.h:189
userptr_t sqe
Send queue entries.
Definition: thunderx.h:191
void * regs
Registers.
Definition: thunderx.h:419
#define TXNIC_QS_SQ_CFG(q)
Send queue configuration.
Definition: thunderx.h:80
#define TXNIC_SQ_SIZE
Send queue size.
Definition: thunderx.h:182
unsigned int prod
Producer counter.
Definition: thunderx.h:187
#define TXNIC_QS_SQ_CFG_ENA
Definition: thunderx.h:81
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References txnic_sq::cons, DBGC, txnic::name, txnic_sq::prod, txnic::regs, txnic::sq, txnic_sq::sqe, TXNIC_QS_SQ_BASE, TXNIC_QS_SQ_CFG, TXNIC_QS_SQ_CFG_ENA, TXNIC_QS_SQ_CFG_QSIZE_1K, TXNIC_QS_SQ_CFG_RESET, TXNIC_SQ_SIZE, user_to_phys(), and writeq().

Referenced by txnic_open().

◆ txnic_disable_sq()

static int txnic_disable_sq ( struct txnic vnic)
static

Disable send queue.

Parameters
vnicVirtual NIC
Return values
rcReturn status code

Definition at line 138 of file thunderx.c.

138  {
140  unsigned int i;
141 
142  /* Disable send queue */
143  writeq ( 0, ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
144 
145  /* Wait for send queue to be stopped */
146  for ( i = 0 ; i < TXNIC_SQ_STOP_MAX_WAIT_MS ; i++ ) {
147 
148  /* Check if send queue is stopped */
149  status = readq ( vnic->regs + TXNIC_QS_SQ_STATUS(0) );
151  return 0;
152 
153  /* Delay */
154  mdelay ( 1 );
155  }
156 
157  DBGC ( vnic, "TXNIC %s SQ disable timed out\n", vnic->name );
158  return -ETIMEDOUT;
159 }
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
uint8_t status
Status.
Definition: ena.h:16
#define TXNIC_QS_SQ_STATUS(q)
Send queue status.
Definition: thunderx.h:100
#define TXNIC_QS_SQ_STATUS_STOPPED
Definition: thunderx.h:101
void * regs
Registers.
Definition: thunderx.h:419
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define TXNIC_QS_SQ_CFG(q)
Send queue configuration.
Definition: thunderx.h:80
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define TXNIC_SQ_STOP_MAX_WAIT_MS
Maximum time to wait for a send queue to stop.
Definition: thunderx.h:107

References DBGC, ETIMEDOUT, mdelay(), txnic::name, readq(), txnic::regs, status, TXNIC_QS_SQ_CFG, TXNIC_QS_SQ_STATUS, TXNIC_QS_SQ_STATUS_STOPPED, TXNIC_SQ_STOP_MAX_WAIT_MS, and writeq().

Referenced by txnic_destroy_sq().

◆ txnic_destroy_sq()

static void txnic_destroy_sq ( struct txnic vnic)
static

Destroy send queue.

Parameters
vnicVirtual NIC

Definition at line 166 of file thunderx.c.

166  {
167  int rc;
168 
169  /* Disable send queue */
170  if ( ( rc = txnic_disable_sq ( vnic ) ) != 0 ) {
171  /* Nothing else we can do */
172  return;
173  }
174 
175  /* Reset send queue */
176  writeq ( TXNIC_QS_SQ_CFG_RESET, ( vnic->regs + TXNIC_QS_SQ_CFG(0) ) );
177 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int txnic_disable_sq(struct txnic *vnic)
Disable send queue.
Definition: thunderx.c:138
#define TXNIC_QS_SQ_CFG_RESET
Definition: thunderx.h:82
void * regs
Registers.
Definition: thunderx.h:419
#define TXNIC_QS_SQ_CFG(q)
Send queue configuration.
Definition: thunderx.h:80
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References rc, txnic::regs, txnic_disable_sq(), TXNIC_QS_SQ_CFG, TXNIC_QS_SQ_CFG_RESET, and writeq().

Referenced by txnic_close(), and txnic_open().

◆ txnic_send()

static int txnic_send ( struct txnic vnic,
struct io_buffer iobuf 
)
static

Send packet.

Parameters
vnicVirtual NIC
iobufI/O buffer
Return values
rcReturn status code

Definition at line 186 of file thunderx.c.

186  {
187  struct txnic_sqe sqe;
188  unsigned int sq_idx;
189  size_t offset;
190  size_t len;
191 
192  /* Get next send queue entry */
193  if ( ( vnic->sq.prod - vnic->sq.cons ) >= TXNIC_SQ_FILL ) {
194  DBGC ( vnic, "TXNIC %s out of send queue entries\n",
195  vnic->name );
196  return -ENOBUFS;
197  }
198  sq_idx = ( vnic->sq.prod++ % TXNIC_SQES );
199  offset = ( sq_idx * TXNIC_SQ_STRIDE );
200 
201  /* Populate send descriptor */
202  len = iob_len ( iobuf );
203  memset ( &sqe, 0, sizeof ( sqe ) );
204  sqe.hdr.total = cpu_to_le32 ( ( len >= ETH_ZLEN ) ? len : ETH_ZLEN );
205  sqe.hdr.subdcnt = ( TXNIC_SQE_SUBDESCS - 1 );
206  sqe.hdr.flags = TXNIC_SEND_HDR_FLAGS;
207  sqe.gather.size = cpu_to_le16 ( len );
208  sqe.gather.flags = TXNIC_SEND_GATHER_FLAGS;
209  sqe.gather.addr = cpu_to_le64 ( virt_to_bus ( iobuf->data ) );
210  DBGC2 ( vnic, "TXNIC %s SQE %#03x is [%08lx,%08lx)\n",
211  vnic->name, sq_idx, virt_to_bus ( iobuf->data ),
212  ( virt_to_bus ( iobuf->data ) + len ) );
213 
214  /* Copy send descriptor to ring */
215  copy_to_user ( vnic->sq.sqe, offset, &sqe, sizeof ( sqe ) );
216 
217  /* Ring doorbell */
218  wmb();
219  writeq ( TXNIC_SQE_SUBDESCS, ( vnic->regs + TXNIC_QS_SQ_DOOR(0) ) );
220 
221  return 0;
222 }
wmb()
#define TXNIC_QS_SQ_DOOR(q)
Send queue doorbell.
Definition: thunderx.h:97
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
#define cpu_to_le64(value)
Definition: byteswap.h:108
struct txnic_sq sq
Send queue.
Definition: thunderx.h:426
#define TXNIC_SEND_HDR_FLAGS
Flags for send header subdescriptor.
Definition: thunderx.h:127
#define TXNIC_SQ_STRIDE
Send queue stride.
Definition: thunderx.h:179
#define TXNIC_SEND_GATHER_FLAGS
Flags for send gather subdescriptor.
Definition: thunderx.h:145
#define TXNIC_SQE_SUBDESCS
Number of subdescriptors per send queue entry.
Definition: thunderx.h:160
A send queue entry.
Definition: thunderx.h:152
unsigned int cons
Consumer counter.
Definition: thunderx.h:189
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define cpu_to_le32(value)
Definition: byteswap.h:107
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
Definition: uaccess.h:324
#define ETH_ZLEN
Definition: if_ether.h:10
userptr_t sqe
Send queue entries.
Definition: thunderx.h:191
void * regs
Registers.
Definition: thunderx.h:419
#define TXNIC_SQ_FILL
Send queue maximum fill level.
Definition: thunderx.h:173
uint32_t len
Length.
Definition: ena.h:14
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:44
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define TXNIC_SQES
Number of send queue entries.
Definition: thunderx.h:167
unsigned int prod
Producer counter.
Definition: thunderx.h:187
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
void * memset(void *dest, int character, size_t len) __nonnull

References txnic_send_gather::addr, txnic_sq::cons, copy_to_user(), cpu_to_le16, cpu_to_le32, cpu_to_le64, io_buffer::data, DBGC, DBGC2, ENOBUFS, ETH_ZLEN, txnic_send_header::flags, txnic_send_gather::flags, txnic_sqe::gather, txnic_sqe::hdr, iob_len(), len, memset(), txnic::name, offset, txnic_sq::prod, txnic::regs, txnic_send_gather::size, txnic::sq, txnic_sq::sqe, txnic_send_header::subdcnt, txnic_send_header::total, TXNIC_QS_SQ_DOOR, TXNIC_SEND_GATHER_FLAGS, TXNIC_SEND_HDR_FLAGS, TXNIC_SQ_FILL, TXNIC_SQ_STRIDE, TXNIC_SQE_SUBDESCS, TXNIC_SQES, virt_to_bus(), wmb(), and writeq().

Referenced by txnic_lmac_transmit().

◆ txnic_complete_sqe()

static void txnic_complete_sqe ( struct txnic vnic,
struct txnic_cqe_send cqe 
)
static

Complete send queue entry.

Parameters
vnicVirtual NIC
cqeSend completion queue entry

Definition at line 230 of file thunderx.c.

231  {
232  struct net_device *netdev = vnic->netdev;
233  unsigned int sq_idx;
234  unsigned int status;
235 
236  /* Parse completion */
237  sq_idx = ( le16_to_cpu ( cqe->sqe_ptr ) / TXNIC_SQE_SUBDESCS );
238  status = cqe->send_status;
239 
240  /* Sanity check */
241  assert ( sq_idx == ( vnic->sq.cons % TXNIC_SQES ) );
242 
243  /* Free send queue entry */
244  vnic->sq.cons++;
245 
246  /* Complete transmission */
247  if ( status ) {
248  DBGC ( vnic, "TXNIC %s SQE %#03x complete (status %#02x)\n",
249  vnic->name, sq_idx, status );
251  } else {
252  DBGC2 ( vnic, "TXNIC %s SQE %#03x complete\n",
253  vnic->name, sq_idx );
255  }
256 }
uint16_t sqe_ptr
Send queue entry pointer.
Definition: thunderx.h:336
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition: netdevice.h:758
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
void netdev_tx_complete_next_err(struct net_device *netdev, int rc)
Complete network transmission.
Definition: netdevice.c:434
struct txnic_sq sq
Send queue.
Definition: thunderx.h:426
uint8_t send_status
Status.
Definition: thunderx.h:332
uint8_t status
Status.
Definition: ena.h:16
#define TXNIC_SQE_SUBDESCS
Number of subdescriptors per send queue entry.
Definition: thunderx.h:160
unsigned int cons
Consumer counter.
Definition: thunderx.h:189
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static struct net_device * netdev
Definition: gdbudp.c:52
A network device.
Definition: netdevice.h:348
#define le16_to_cpu(value)
Definition: byteswap.h:112
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
#define TXNIC_SQES
Number of send queue entries.
Definition: thunderx.h:167
struct net_device * netdev
Network device.
Definition: thunderx.h:423

References assert(), txnic_sq::cons, DBGC, DBGC2, EIO, le16_to_cpu, txnic::name, netdev, txnic::netdev, netdev_tx_complete_next(), netdev_tx_complete_next_err(), txnic_cqe_send::send_status, txnic::sq, txnic_cqe_send::sqe_ptr, status, TXNIC_SQE_SUBDESCS, and TXNIC_SQES.

Referenced by txnic_poll_cq().

◆ txnic_create_rq()

static int txnic_create_rq ( struct txnic vnic)
static

Create receive queue.

Parameters
vnicVirtual NIC
Return values
rcReturn status code

Definition at line 271 of file thunderx.c.

271  {
272 
273  /* Reset receive buffer descriptor ring */
274  vnic->rq.prod = 0;
275  vnic->rq.cons = 0;
277  ( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) );
278 
279  /* Configure and enable receive buffer descriptor ring */
280  writeq ( user_to_phys ( vnic->rq.rqe, 0 ),
281  ( vnic->regs + TXNIC_QS_RBDR_BASE(0) ) );
284  TXNIC_LINE_SIZE ) ),
285  ( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) );
286 
287  /* Enable receive queue */
288  writeq ( TXNIC_QS_RQ_CFG_ENA, ( vnic->regs + TXNIC_QS_RQ_CFG(0) ) );
289 
290  DBGC ( vnic, "TXNIC %s RQ at [%08lx,%08lx)\n",
291  vnic->name, user_to_phys ( vnic->rq.rqe, 0 ),
292  user_to_phys ( vnic->rq.rqe, TXNIC_RQ_SIZE ) );
293  return 0;
294 }
#define TXNIC_QS_RQ_CFG_ENA
Definition: thunderx.h:203
#define TXNIC_RQE_SIZE
Receive queue entry size.
Definition: thunderx.h:263
#define TXNIC_QS_RQ_CFG(q)
Receive queue configuration.
Definition: thunderx.h:202
#define TXNIC_QS_RBDR_CFG_QSIZE_8K
Definition: thunderx.h:216
#define TXNIC_LINE_SIZE
Size of a cache line.
Definition: thunderx.h:25
const char * name
Device name (for debugging)
Definition: thunderx.h:421
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
#define TXNIC_RQ_SIZE
Receive queue size.
Definition: thunderx.h:274
unsigned int cons
Consumer counter.
Definition: thunderx.h:281
unsigned int prod
Producer counter.
Definition: thunderx.h:279
#define TXNIC_QS_RBDR_CFG_RESET
Definition: thunderx.h:214
#define TXNIC_QS_RBDR_BASE(q)
Receive buffer descriptor ring base address.
Definition: thunderx.h:221
struct txnic_rq rq
Receive queue.
Definition: thunderx.h:428
#define TXNIC_QS_RBDR_CFG_ENA
Definition: thunderx.h:213
void * regs
Registers.
Definition: thunderx.h:419
#define TXNIC_QS_RBDR_CFG_LINES(sz)
Definition: thunderx.h:218
userptr_t rqe
Receive queue entries.
Definition: thunderx.h:283
#define TXNIC_QS_RBDR_CFG(q)
Receive buffer descriptor ring configuration.
Definition: thunderx.h:212
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References txnic_rq::cons, DBGC, txnic::name, txnic_rq::prod, txnic::regs, txnic::rq, txnic_rq::rqe, TXNIC_LINE_SIZE, TXNIC_QS_RBDR_BASE, TXNIC_QS_RBDR_CFG, TXNIC_QS_RBDR_CFG_ENA, TXNIC_QS_RBDR_CFG_LINES, TXNIC_QS_RBDR_CFG_QSIZE_8K, TXNIC_QS_RBDR_CFG_RESET, TXNIC_QS_RQ_CFG, TXNIC_QS_RQ_CFG_ENA, TXNIC_RQ_SIZE, TXNIC_RQE_SIZE, user_to_phys(), and writeq().

Referenced by txnic_open().

◆ txnic_disable_rq()

static int txnic_disable_rq ( struct txnic vnic)
static

Disable receive queue.

Parameters
vnicVirtual NIC
Return values
rcReturn status code

Definition at line 302 of file thunderx.c.

302  {
303  uint64_t cfg;
304  unsigned int i;
305 
306  /* Disable receive queue */
307  writeq ( 0, ( vnic->regs + TXNIC_QS_RQ_CFG(0) ) );
308 
309  /* Wait for receive queue to be disabled */
310  for ( i = 0 ; i < TXNIC_RQ_DISABLE_MAX_WAIT_MS ; i++ ) {
311 
312  /* Check if receive queue is disabled */
313  cfg = readq ( vnic->regs + TXNIC_QS_RQ_CFG(0) );
314  if ( ! ( cfg & TXNIC_QS_RQ_CFG_ENA ) )
315  return 0;
316 
317  /* Delay */
318  mdelay ( 1 );
319  }
320 
321  DBGC ( vnic, "TXNIC %s RQ disable timed out\n", vnic->name );
322  return -ETIMEDOUT;
323 }
#define TXNIC_QS_RQ_CFG_ENA
Definition: thunderx.h:203
#define TXNIC_QS_RQ_CFG(q)
Receive queue configuration.
Definition: thunderx.h:202
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
#define TXNIC_RQ_DISABLE_MAX_WAIT_MS
Maximum time to wait for a receive queue to disable.
Definition: thunderx.h:209
void * regs
Registers.
Definition: thunderx.h:419
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
Definition: sis900.h:23
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References cfg, DBGC, ETIMEDOUT, mdelay(), txnic::name, readq(), txnic::regs, TXNIC_QS_RQ_CFG, TXNIC_QS_RQ_CFG_ENA, TXNIC_RQ_DISABLE_MAX_WAIT_MS, and writeq().

Referenced by txnic_destroy_rq().

◆ txnic_destroy_rq()

static void txnic_destroy_rq ( struct txnic vnic)
static

Destroy receive queue.

Parameters
vnicVirtual NIC

Definition at line 330 of file thunderx.c.

330  {
331  unsigned int i;
332  int rc;
333 
334  /* Disable receive queue */
335  if ( ( rc = txnic_disable_rq ( vnic ) ) != 0 ) {
336  /* Leak memory; there's nothing else we can do */
337  return;
338  }
339 
340  /* Disable receive buffer descriptor ring */
341  writeq ( 0, ( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) );
342 
343  /* Reset receive buffer descriptor ring */
345  ( vnic->regs + TXNIC_QS_RBDR_CFG(0) ) );
346 
347  /* Free any unused I/O buffers */
348  for ( i = 0 ; i < TXNIC_RQ_FILL ; i++ ) {
349  if ( vnic->rq.iobuf[i] )
350  free_iob ( vnic->rq.iobuf[i] );
351  vnic->rq.iobuf[i] = NULL;
352  }
353 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define TXNIC_QS_RBDR_CFG_RESET
Definition: thunderx.h:214
struct txnic_rq rq
Receive queue.
Definition: thunderx.h:428
static int txnic_disable_rq(struct txnic *vnic)
Disable receive queue.
Definition: thunderx.c:302
#define TXNIC_RQ_FILL
Receive queue maximum fill level.
Definition: thunderx.h:257
struct io_buffer * iobuf[TXNIC_RQ_FILL]
I/O buffers.
Definition: thunderx.h:285
void * regs
Registers.
Definition: thunderx.h:419
#define TXNIC_QS_RBDR_CFG(q)
Receive buffer descriptor ring configuration.
Definition: thunderx.h:212
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References free_iob(), txnic_rq::iobuf, NULL, rc, txnic::regs, txnic::rq, txnic_disable_rq(), TXNIC_QS_RBDR_CFG, TXNIC_QS_RBDR_CFG_RESET, TXNIC_RQ_FILL, and writeq().

Referenced by txnic_close(), and txnic_open().

◆ txnic_refill_rq()

static void txnic_refill_rq ( struct txnic vnic)
static

Refill receive queue.

Parameters
vnicVirtual NIC

Definition at line 360 of file thunderx.c.

360  {
361  struct io_buffer *iobuf;
362  struct txnic_rqe rqe;
363  unsigned int rq_idx;
364  unsigned int rq_iobuf_idx;
365  unsigned int refilled = 0;
366  size_t offset;
367 
368  /* Refill ring */
369  while ( ( vnic->rq.prod - vnic->rq.cons ) < TXNIC_RQ_FILL ) {
370 
371  /* Allocate I/O buffer */
372  iobuf = alloc_iob ( TXNIC_RQE_SIZE );
373  if ( ! iobuf ) {
374  /* Wait for next refill */
375  break;
376  }
377 
378  /* Get next receive descriptor */
379  rq_idx = ( vnic->rq.prod++ % TXNIC_RQES );
380  offset = ( rq_idx * TXNIC_RQ_STRIDE );
381 
382  /* Populate receive descriptor */
383  rqe.rbdre.addr = cpu_to_le64 ( virt_to_bus ( iobuf->data ) );
384  DBGC2 ( vnic, "TXNIC %s RQE %#03x is [%08lx,%08lx)\n",
385  vnic->name, rq_idx, virt_to_bus ( iobuf->data ),
386  ( virt_to_bus ( iobuf->data ) + TXNIC_RQE_SIZE ) );
387 
388  /* Copy receive descriptor to ring */
389  copy_to_user ( vnic->rq.rqe, offset, &rqe, sizeof ( rqe ) );
390  refilled++;
391 
392  /* Record I/O buffer */
393  rq_iobuf_idx = ( rq_idx % TXNIC_RQ_FILL );
394  assert ( vnic->rq.iobuf[rq_iobuf_idx] == NULL );
395  vnic->rq.iobuf[rq_iobuf_idx] = iobuf;
396  }
397 
398  /* Ring doorbell */
399  wmb();
400  writeq ( refilled, ( vnic->regs + TXNIC_QS_RBDR_DOOR(0) ) );
401 }
wmb()
#define TXNIC_RQE_SIZE
Receive queue entry size.
Definition: thunderx.h:263
#define TXNIC_QS_RBDR_DOOR(q)
Receive buffer descriptor ring doorbell.
Definition: thunderx.h:230
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define cpu_to_le64(value)
Definition: byteswap.h:108
unsigned int cons
Consumer counter.
Definition: thunderx.h:281
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
unsigned int prod
Producer counter.
Definition: thunderx.h:279
A receive queue entry.
Definition: thunderx.h:242
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
struct txnic_rq rq
Receive queue.
Definition: thunderx.h:428
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
Definition: uaccess.h:324
#define TXNIC_RQES
Number of receive queue entries.
Definition: thunderx.h:251
#define TXNIC_RQ_FILL
Receive queue maximum fill level.
Definition: thunderx.h:257
struct io_buffer * iobuf[TXNIC_RQ_FILL]
I/O buffers.
Definition: thunderx.h:285
void * regs
Registers.
Definition: thunderx.h:419
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:44
userptr_t rqe
Receive queue entries.
Definition: thunderx.h:283
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define TXNIC_RQ_STRIDE
Receive queue stride.
Definition: thunderx.h:271
A persistent I/O buffer.
Definition: iobuf.h:32

References txnic_rbdr_entry::addr, alloc_iob(), assert(), txnic_rq::cons, copy_to_user(), cpu_to_le64, io_buffer::data, DBGC2, txnic_rq::iobuf, txnic::name, NULL, offset, txnic_rq::prod, txnic_rqe::rbdre, txnic::regs, txnic::rq, txnic_rq::rqe, TXNIC_QS_RBDR_DOOR, TXNIC_RQ_FILL, TXNIC_RQ_STRIDE, TXNIC_RQE_SIZE, TXNIC_RQES, virt_to_bus(), wmb(), and writeq().

Referenced by txnic_open(), and txnic_poll().

◆ txnic_complete_rqe()

static void txnic_complete_rqe ( struct txnic vnic,
struct txnic_cqe_rx cqe 
)
static

Complete receive queue entry.

Parameters
vnicVirtual NIC
cqeReceive completion queue entry

Definition at line 409 of file thunderx.c.

410  {
411  struct net_device *netdev = vnic->netdev;
412  struct io_buffer *iobuf;
413  unsigned int errop;
414  unsigned int rq_idx;
415  unsigned int rq_iobuf_idx;
416  size_t apad_len;
417  size_t len;
418 
419  /* Parse completion */
420  errop = cqe->errop;
421  apad_len = TXNIC_CQE_RX_APAD_LEN ( cqe->apad );
422  len = le16_to_cpu ( cqe->len );
423 
424  /* Get next receive I/O buffer */
425  rq_idx = ( vnic->rq.cons++ % TXNIC_RQES );
426  rq_iobuf_idx = ( rq_idx % TXNIC_RQ_FILL );
427  iobuf = vnic->rq.iobuf[rq_iobuf_idx];
428  vnic->rq.iobuf[rq_iobuf_idx] = NULL;
429 
430  /* Populate I/O buffer */
431  iob_reserve ( iobuf, apad_len );
432  iob_put ( iobuf, len );
433 
434  /* Hand off to network stack */
435  if ( errop ) {
436  DBGC ( vnic, "TXNIC %s RQE %#03x error (length %zd, errop "
437  "%#02x)\n", vnic->name, rq_idx, len, errop );
438  netdev_rx_err ( netdev, iobuf, -EIO );
439  } else {
440  DBGC2 ( vnic, "TXNIC %s RQE %#03x complete (length %zd)\n",
441  vnic->name, rq_idx, len );
442  netdev_rx ( netdev, iobuf );
443  }
444 }
#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
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
uint8_t errop
Error opcode.
Definition: thunderx.h:347
unsigned int cons
Consumer counter.
Definition: thunderx.h:281
#define TXNIC_CQE_RX_APAD_LEN(apad)
Applied padding.
Definition: thunderx.h:366
static struct net_device * netdev
Definition: gdbudp.c:52
struct txnic_rq rq
Receive queue.
Definition: thunderx.h:428
A network device.
Definition: netdevice.h:348
#define TXNIC_RQES
Number of receive queue entries.
Definition: thunderx.h:251
#define TXNIC_RQ_FILL
Receive queue maximum fill level.
Definition: thunderx.h:257
#define le16_to_cpu(value)
Definition: byteswap.h:112
struct io_buffer * iobuf[TXNIC_RQ_FILL]
I/O buffers.
Definition: thunderx.h:285
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:470
uint8_t apad
Padding.
Definition: thunderx.h:355
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
uint16_t len
Length.
Definition: thunderx.h:359
struct net_device * netdev
Network device.
Definition: thunderx.h:423
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A persistent I/O buffer.
Definition: iobuf.h:32

References txnic_cqe_rx::apad, txnic_rq::cons, DBGC, DBGC2, EIO, txnic_cqe_rx::errop, iob_put, iob_reserve, txnic_rq::iobuf, le16_to_cpu, len, txnic_cqe_rx::len, txnic::name, netdev, txnic::netdev, netdev_rx(), netdev_rx_err(), NULL, txnic::rq, TXNIC_CQE_RX_APAD_LEN, TXNIC_RQ_FILL, and TXNIC_RQES.

Referenced by txnic_poll_cq().

◆ txnic_create_cq()

static int txnic_create_cq ( struct txnic vnic)
static

Create completion queue.

Parameters
vnicVirtual NIC
Return values
rcReturn status code

Definition at line 459 of file thunderx.c.

459  {
460 
461  /* Reset completion queue */
462  vnic->cq.cons = 0;
463  writeq ( TXNIC_QS_CQ_CFG_RESET, ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
464 
465  /* Configure and enable completion queue */
466  writeq ( user_to_phys ( vnic->cq.cqe, 0 ),
467  ( vnic->regs + TXNIC_QS_CQ_BASE(0) ) );
469  ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
470 
471  DBGC ( vnic, "TXNIC %s CQ at [%08lx,%08lx)\n",
472  vnic->name, user_to_phys ( vnic->cq.cqe, 0 ),
473  user_to_phys ( vnic->cq.cqe, TXNIC_CQ_SIZE ) );
474  return 0;
475 }
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define TXNIC_QS_CQ_CFG_QSIZE_256
Definition: thunderx.h:300
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
#define TXNIC_QS_CQ_CFG_RESET
Definition: thunderx.h:298
#define TXNIC_QS_CQ_BASE(q)
Completion queue base address.
Definition: thunderx.h:310
unsigned int cons
Consumer counter.
Definition: thunderx.h:404
#define TXNIC_QS_CQ_CFG(q)
Completion queue configuration.
Definition: thunderx.h:296
userptr_t cqe
Completion queue entries.
Definition: thunderx.h:406
void * regs
Registers.
Definition: thunderx.h:419
struct txnic_cq cq
Completion queue.
Definition: thunderx.h:430
#define TXNIC_CQ_SIZE
Completion queue size.
Definition: thunderx.h:399
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define TXNIC_QS_CQ_CFG_ENA
Definition: thunderx.h:297

References txnic_cq::cons, txnic::cq, txnic_cq::cqe, DBGC, txnic::name, txnic::regs, TXNIC_CQ_SIZE, TXNIC_QS_CQ_BASE, TXNIC_QS_CQ_CFG, TXNIC_QS_CQ_CFG_ENA, TXNIC_QS_CQ_CFG_QSIZE_256, TXNIC_QS_CQ_CFG_RESET, user_to_phys(), and writeq().

Referenced by txnic_open().

◆ txnic_disable_cq()

static int txnic_disable_cq ( struct txnic vnic)
static

Disable completion queue.

Parameters
vnicVirtual NIC
Return values
rcReturn status code

Definition at line 483 of file thunderx.c.

483  {
484  uint64_t cfg;
485  unsigned int i;
486 
487  /* Disable completion queue */
488  writeq ( 0, ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
489 
490  /* Wait for completion queue to be disabled */
491  for ( i = 0 ; i < TXNIC_CQ_DISABLE_MAX_WAIT_MS ; i++ ) {
492 
493  /* Check if completion queue is disabled */
494  cfg = readq ( vnic->regs + TXNIC_QS_CQ_CFG(0) );
495  if ( ! ( cfg & TXNIC_QS_CQ_CFG_ENA ) )
496  return 0;
497 
498  /* Delay */
499  mdelay ( 1 );
500  }
501 
502  DBGC ( vnic, "TXNIC %s CQ disable timed out\n", vnic->name );
503  return -ETIMEDOUT;
504 }
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
#define TXNIC_QS_CQ_CFG(q)
Completion queue configuration.
Definition: thunderx.h:296
void * regs
Registers.
Definition: thunderx.h:419
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
Definition: sis900.h:23
#define TXNIC_CQ_DISABLE_MAX_WAIT_MS
Maximum time to wait for a completion queue to disable.
Definition: thunderx.h:307
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define TXNIC_QS_CQ_CFG_ENA
Definition: thunderx.h:297

References cfg, DBGC, ETIMEDOUT, mdelay(), txnic::name, readq(), txnic::regs, TXNIC_CQ_DISABLE_MAX_WAIT_MS, TXNIC_QS_CQ_CFG, TXNIC_QS_CQ_CFG_ENA, and writeq().

Referenced by txnic_destroy_cq().

◆ txnic_destroy_cq()

static void txnic_destroy_cq ( struct txnic vnic)
static

Destroy completion queue.

Parameters
vnicVirtual NIC

Definition at line 511 of file thunderx.c.

511  {
512  int rc;
513 
514  /* Disable completion queue */
515  if ( ( rc = txnic_disable_cq ( vnic ) ) != 0 ) {
516  /* Leak memory; there's nothing else we can do */
517  return;
518  }
519 
520  /* Reset completion queue */
521  writeq ( TXNIC_QS_CQ_CFG_RESET, ( vnic->regs + TXNIC_QS_CQ_CFG(0) ) );
522 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define TXNIC_QS_CQ_CFG_RESET
Definition: thunderx.h:298
static int txnic_disable_cq(struct txnic *vnic)
Disable completion queue.
Definition: thunderx.c:483
#define TXNIC_QS_CQ_CFG(q)
Completion queue configuration.
Definition: thunderx.h:296
void * regs
Registers.
Definition: thunderx.h:419
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References rc, txnic::regs, txnic_disable_cq(), TXNIC_QS_CQ_CFG, TXNIC_QS_CQ_CFG_RESET, and writeq().

Referenced by txnic_close(), and txnic_open().

◆ txnic_poll_cq()

static void txnic_poll_cq ( struct txnic vnic)
static

Poll completion queue.

Parameters
vnicVirtual NIC

Definition at line 529 of file thunderx.c.

529  {
530  union txnic_cqe cqe;
532  size_t offset;
533  unsigned int qcount;
534  unsigned int cq_idx;
535  unsigned int i;
536 
537  /* Get number of completions */
538  status = readq ( vnic->regs + TXNIC_QS_CQ_STATUS(0) );
539  qcount = TXNIC_QS_CQ_STATUS_QCOUNT ( status );
540  if ( ! qcount )
541  return;
542 
543  /* Process completion queue entries */
544  for ( i = 0 ; i < qcount ; i++ ) {
545 
546  /* Get completion queue entry */
547  cq_idx = ( vnic->cq.cons++ % TXNIC_CQES );
548  offset = ( cq_idx * TXNIC_CQ_STRIDE );
549  copy_from_user ( &cqe, vnic->cq.cqe, offset, sizeof ( cqe ) );
550 
551  /* Process completion queue entry */
552  switch ( cqe.common.cqe_type ) {
553  case TXNIC_CQE_TYPE_SEND:
554  txnic_complete_sqe ( vnic, &cqe.send );
555  break;
556  case TXNIC_CQE_TYPE_RX:
557  txnic_complete_rqe ( vnic, &cqe.rx );
558  break;
559  default:
560  DBGC ( vnic, "TXNIC %s unknown completion type %d\n",
561  vnic->name, cqe.common.cqe_type );
562  DBGC_HDA ( vnic, user_to_phys ( vnic->cq.cqe, offset ),
563  &cqe, sizeof ( cqe ) );
564  break;
565  }
566  }
567 
568  /* Ring doorbell */
569  writeq ( qcount, ( vnic->regs + TXNIC_QS_CQ_DOOR(0) ) );
570 }
static void txnic_complete_rqe(struct txnic *vnic, struct txnic_cqe_rx *cqe)
Complete receive queue entry.
Definition: thunderx.c:409
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
const char * name
Device name (for debugging)
Definition: thunderx.h:421
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
#define TXNIC_CQE_TYPE_SEND
Send completion queue entry type.
Definition: thunderx.h:342
uint8_t status
Status.
Definition: ena.h:16
#define TXNIC_QS_CQ_DOOR(q)
Completion queue doorbell.
Definition: thunderx.h:319
#define TXNIC_QS_CQ_STATUS_QCOUNT(status)
Definition: thunderx.h:323
#define TXNIC_CQE_TYPE_RX
Receive completion queue entry type.
Definition: thunderx.h:363
#define DBGC_HDA(...)
Definition: compiler.h:506
unsigned int cons
Consumer counter.
Definition: thunderx.h:404
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define TXNIC_CQ_STRIDE
Completion queue stride.
Definition: thunderx.h:396
userptr_t cqe
Completion queue entries.
Definition: thunderx.h:406
#define TXNIC_CQES
Number of completion queue entries.
Definition: thunderx.h:390
void * regs
Registers.
Definition: thunderx.h:419
#define TXNIC_QS_CQ_STATUS(q)
Completion queue status.
Definition: thunderx.h:322
static void txnic_complete_sqe(struct txnic *vnic, struct txnic_cqe_send *cqe)
Complete send queue entry.
Definition: thunderx.c:230
struct txnic_cq cq
Completion queue.
Definition: thunderx.h:430
A completion queue entry.
Definition: thunderx.h:377
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References txnic_cqe::common, txnic_cq::cons, copy_from_user(), txnic::cq, txnic_cq::cqe, txnic_cqe_common::cqe_type, DBGC, DBGC_HDA, txnic::name, offset, readq(), txnic::regs, txnic_cqe::rx, txnic_cqe::send, status, txnic_complete_rqe(), txnic_complete_sqe(), TXNIC_CQ_STRIDE, TXNIC_CQE_TYPE_RX, TXNIC_CQE_TYPE_SEND, TXNIC_CQES, TXNIC_QS_CQ_DOOR, TXNIC_QS_CQ_STATUS, TXNIC_QS_CQ_STATUS_QCOUNT, user_to_phys(), and writeq().

Referenced by txnic_poll().

◆ txnic_open()

static int txnic_open ( struct txnic vnic)
static

Open virtual NIC.

Parameters
vnicVirtual NIC
Return values
rcReturn status code

Definition at line 585 of file thunderx.c.

585  {
586  int rc;
587 
588  /* Create completion queue */
589  if ( ( rc = txnic_create_cq ( vnic ) ) != 0 )
590  goto err_create_cq;
591 
592  /* Create send queue */
593  if ( ( rc = txnic_create_sq ( vnic ) ) != 0 )
594  goto err_create_sq;
595 
596  /* Create receive queue */
597  if ( ( rc = txnic_create_rq ( vnic ) ) != 0 )
598  goto err_create_rq;
599 
600  /* Refill receive queue */
601  txnic_refill_rq ( vnic );
602 
603  return 0;
604 
605  txnic_destroy_rq ( vnic );
606  err_create_rq:
607  txnic_destroy_sq ( vnic );
608  err_create_sq:
609  txnic_destroy_cq ( vnic );
610  err_create_cq:
611  return rc;
612 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int txnic_create_sq(struct txnic *vnic)
Create send queue.
Definition: thunderx.c:113
static void txnic_destroy_sq(struct txnic *vnic)
Destroy send queue.
Definition: thunderx.c:166
static void txnic_destroy_cq(struct txnic *vnic)
Destroy completion queue.
Definition: thunderx.c:511
static int txnic_create_cq(struct txnic *vnic)
Create completion queue.
Definition: thunderx.c:459
static int txnic_create_rq(struct txnic *vnic)
Create receive queue.
Definition: thunderx.c:271
static void txnic_refill_rq(struct txnic *vnic)
Refill receive queue.
Definition: thunderx.c:360
static void txnic_destroy_rq(struct txnic *vnic)
Destroy receive queue.
Definition: thunderx.c:330

References rc, txnic_create_cq(), txnic_create_rq(), txnic_create_sq(), txnic_destroy_cq(), txnic_destroy_rq(), txnic_destroy_sq(), and txnic_refill_rq().

Referenced by txnic_lmac_open().

◆ txnic_close()

static void txnic_close ( struct txnic vnic)
static

Close virtual NIC.

Parameters
vnicVirtual NIC

Definition at line 619 of file thunderx.c.

619  {
620 
621  /* Destroy receive queue */
622  txnic_destroy_rq ( vnic );
623 
624  /* Destroy send queue */
625  txnic_destroy_sq ( vnic );
626 
627  /* Destroy completion queue */
628  txnic_destroy_cq ( vnic );
629 }
static void txnic_destroy_sq(struct txnic *vnic)
Destroy send queue.
Definition: thunderx.c:166
static void txnic_destroy_cq(struct txnic *vnic)
Destroy completion queue.
Definition: thunderx.c:511
static void txnic_destroy_rq(struct txnic *vnic)
Destroy receive queue.
Definition: thunderx.c:330

References txnic_destroy_cq(), txnic_destroy_rq(), and txnic_destroy_sq().

Referenced by txnic_lmac_close(), and txnic_lmac_open().

◆ txnic_poll()

static void txnic_poll ( struct txnic vnic)
static

Poll virtual NIC.

Parameters
vnicVirtual NIC

Definition at line 636 of file thunderx.c.

636  {
637 
638  /* Poll completion queue */
639  txnic_poll_cq ( vnic );
640 
641  /* Refill receive queue */
642  txnic_refill_rq ( vnic );
643 }
static void txnic_poll_cq(struct txnic *vnic)
Poll completion queue.
Definition: thunderx.c:529
static void txnic_refill_rq(struct txnic *vnic)
Refill receive queue.
Definition: thunderx.c:360

References txnic_poll_cq(), and txnic_refill_rq().

Referenced by txnic_lmac_poll().

◆ txnic_alloc()

static struct txnic* txnic_alloc ( struct device dev,
unsigned long  membase 
)
static

Allocate virtual NIC.

Parameters
devUnderlying device
membaseRegister base address
Return values
vnicVirtual NIC, or NULL on failure

Definition at line 652 of file thunderx.c.

653  {
654  struct net_device *netdev;
655  struct txnic *vnic;
656 
657  /* Allocate network device */
658  netdev = alloc_etherdev ( sizeof ( *vnic ) );
659  if ( ! netdev )
660  goto err_alloc_netdev;
661  netdev->dev = dev;
662  vnic = netdev->priv;
663  vnic->netdev = netdev;
664  vnic->name = dev->name;
665 
666  /* Allow caller to reuse netdev->priv. (The generic virtual
667  * NIC code never assumes that netdev->priv==vnic.)
668  */
669  netdev->priv = NULL;
670 
671  /* Allocate completion queue */
672  vnic->cq.cqe = umalloc ( TXNIC_CQ_SIZE );
673  if ( ! vnic->cq.cqe )
674  goto err_alloc_cq;
675 
676  /* Allocate send queue */
677  vnic->sq.sqe = umalloc ( TXNIC_SQ_SIZE );
678  if ( ! vnic->sq.sqe )
679  goto err_alloc_sq;
680 
681  /* Allocate receive queue */
682  vnic->rq.rqe = umalloc ( TXNIC_RQ_SIZE );
683  if ( ! vnic->rq.rqe )
684  goto err_alloc_rq;
685 
686  /* Map registers */
687  vnic->regs = ioremap ( membase, TXNIC_VF_BAR_SIZE );
688  if ( ! vnic->regs )
689  goto err_ioremap;
690 
691  return vnic;
692 
693  iounmap ( vnic->regs );
694  err_ioremap:
695  ufree ( vnic->rq.rqe );
696  err_alloc_rq:
697  ufree ( vnic->sq.sqe );
698  err_alloc_sq:
699  ufree ( vnic->cq.cqe );
700  err_alloc_cq:
702  netdev_put ( netdev );
703  err_alloc_netdev:
704  return NULL;
705 }
const char * name
Device name (for debugging)
Definition: thunderx.h:421
char name[40]
Name.
Definition: device.h:75
#define TXNIC_RQ_SIZE
Receive queue size.
Definition: thunderx.h:274
struct txnic_sq sq
Send queue.
Definition: thunderx.h:426
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
struct txnic_rq rq
Receive queue.
Definition: thunderx.h:428
A virtual NIC.
Definition: thunderx.h:417
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
userptr_t cqe
Completion queue entries.
Definition: thunderx.h:406
userptr_t sqe
Send queue entries.
Definition: thunderx.h:191
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
void * regs
Registers.
Definition: thunderx.h:419
static __always_inline void ufree(userptr_t userptr)
Free external memory.
Definition: umalloc.h:65
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:54
userptr_t rqe
Receive queue entries.
Definition: thunderx.h:283
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define TXNIC_SQ_SIZE
Send queue size.
Definition: thunderx.h:182
#define TXNIC_VF_BAR_SIZE
Virtual function BAR size.
Definition: thunderx.h:28
struct net_device * netdev
Network device.
Definition: thunderx.h:423
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
struct txnic_cq cq
Completion queue.
Definition: thunderx.h:430
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define TXNIC_CQ_SIZE
Completion queue size.
Definition: thunderx.h:399

References alloc_etherdev(), txnic::cq, txnic_cq::cqe, net_device::dev, ioremap(), iounmap(), device::name, txnic::name, netdev, txnic::netdev, netdev_nullify(), netdev_put(), NULL, net_device::priv, txnic::regs, txnic::rq, txnic_rq::rqe, txnic::sq, txnic_sq::sqe, TXNIC_CQ_SIZE, TXNIC_RQ_SIZE, TXNIC_SQ_SIZE, TXNIC_VF_BAR_SIZE, ufree(), and umalloc().

Referenced by txnic_lmac_probe().

◆ txnic_free()

static void txnic_free ( struct txnic vnic)
static

Free virtual NIC.

Parameters
vnicVirtual NIC

Definition at line 712 of file thunderx.c.

712  {
713  struct net_device *netdev = vnic->netdev;
714 
715  /* Unmap registers */
716  iounmap ( vnic->regs );
717 
718  /* Free receive queue */
719  ufree ( vnic->rq.rqe );
720 
721  /* Free send queue */
722  ufree ( vnic->sq.sqe );
723 
724  /* Free completion queue */
725  ufree ( vnic->cq.cqe );
726 
727  /* Free network device */
729  netdev_put ( netdev );
730 }
struct txnic_sq sq
Send queue.
Definition: thunderx.h:426
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
struct txnic_rq rq
Receive queue.
Definition: thunderx.h:428
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
userptr_t cqe
Completion queue entries.
Definition: thunderx.h:406
userptr_t sqe
Send queue entries.
Definition: thunderx.h:191
void * regs
Registers.
Definition: thunderx.h:419
static __always_inline void ufree(userptr_t userptr)
Free external memory.
Definition: umalloc.h:65
userptr_t rqe
Receive queue entries.
Definition: thunderx.h:283
void iounmap(volatile const void *io_addr)
Unmap I/O address.
struct net_device * netdev
Network device.
Definition: thunderx.h:423
struct txnic_cq cq
Completion queue.
Definition: thunderx.h:430

References txnic::cq, txnic_cq::cqe, iounmap(), netdev, txnic::netdev, netdev_nullify(), netdev_put(), txnic::regs, txnic::rq, txnic_rq::rqe, txnic::sq, txnic_sq::sqe, and ufree().

Referenced by txnic_lmac_probe(), and txnic_lmac_remove().

◆ txnic_lmac_diag()

static void txnic_lmac_diag ( struct txnic_lmac lmac)
static

Show LMAC diagnostics (for debugging)

Parameters
lmacLogical MAC

Definition at line 745 of file thunderx.c.

745  {
746  struct txnic *vnic = lmac->vnic;
749  uint64_t br_status1;
750  uint64_t br_status2;
751  uint64_t br_algn_status;
752  uint64_t br_pmd_status;
753  uint64_t an_status;
754 
755  /* Read status (clearing latching bits) */
758  status1 = readq ( lmac->regs + BGX_SPU_STATUS1 );
759  status2 = readq ( lmac->regs + BGX_SPU_STATUS2 );
760  DBGC ( vnic, "TXNIC %s SPU %02llx:%04llx%s%s%s\n",
761  vnic->name, status1, status2,
762  ( ( status1 & BGX_SPU_STATUS1_FLT ) ? " FLT" : "" ),
763  ( ( status1 & BGX_SPU_STATUS1_RCV_LNK ) ? " RCV_LNK" : "" ),
764  ( ( status2 & BGX_SPU_STATUS2_RCVFLT ) ? " RCVFLT" : "" ) );
765 
766  /* Read BASE-R status (clearing latching bits) */
769  ( lmac->regs + BGX_SPU_BR_STATUS2 ) );
770  br_status1 = readq ( lmac->regs + BGX_SPU_BR_STATUS1 );
771  br_status2 = readq ( lmac->regs + BGX_SPU_BR_STATUS2 );
772  DBGC ( vnic, "TXNIC %s BR %04llx:%04llx%s%s%s%s%s\n",
773  vnic->name, br_status2, br_status2,
774  ( ( br_status1 & BGX_SPU_BR_STATUS1_RCV_LNK ) ? " RCV_LNK" : ""),
775  ( ( br_status1 & BGX_SPU_BR_STATUS1_HI_BER ) ? " HI_BER" : "" ),
776  ( ( br_status1 & BGX_SPU_BR_STATUS1_BLK_LOCK ) ?
777  " BLK_LOCK" : "" ),
778  ( ( br_status2 & BGX_SPU_BR_STATUS2_LATCHED_LOCK ) ?
779  " LATCHED_LOCK" : "" ),
780  ( ( br_status2 & BGX_SPU_BR_STATUS2_LATCHED_BER ) ?
781  " LATCHED_BER" : "" ) );
782 
783  /* Read BASE-R alignment status */
784  br_algn_status = readq ( lmac->regs + BGX_SPU_BR_ALGN_STATUS );
785  DBGC ( vnic, "TXNIC %s BR ALGN %016llx%s\n", vnic->name, br_algn_status,
786  ( ( br_algn_status & BGX_SPU_BR_ALGN_STATUS_ALIGND ) ?
787  " ALIGND" : "" ) );
788 
789  /* Read BASE-R link training status */
790  br_pmd_status = readq ( lmac->regs + BGX_SPU_BR_PMD_STATUS );
791  DBGC ( vnic, "TXNIC %s BR PMD %04llx\n", vnic->name, br_pmd_status );
792 
793  /* Read autonegotiation status (clearing latching bits) */
795  ( lmac->regs + BGX_SPU_AN_STATUS ) );
796  an_status = readq ( lmac->regs + BGX_SPU_AN_STATUS );
797  DBGC ( vnic, "TXNIC %s BR AN %04llx%s%s%s%s%s\n", vnic->name, an_status,
798  ( ( an_status & BGX_SPU_AN_STATUS_XNP_STAT ) ? " XNP_STAT" : ""),
799  ( ( an_status & BGX_SPU_AN_STATUS_PAGE_RX ) ? " PAGE_RX" : "" ),
800  ( ( an_status & BGX_SPU_AN_STATUS_AN_COMPLETE ) ?
801  " AN_COMPLETE" : "" ),
802  ( ( an_status & BGX_SPU_AN_STATUS_LINK_STATUS ) ?
803  " LINK_STATUS" : "" ),
804  ( ( an_status & BGX_SPU_AN_STATUS_LP_AN_ABLE ) ?
805  " LP_AN_ABLE" : "" ) );
806 
807  /* Read transmit statistics */
808  DBGC ( vnic, "TXNIC %s TXF xc %#llx xd %#llx mc %#llx sc %#llx ok "
809  "%#llx bc %#llx mc %#llx un %#llx pa %#llx\n", vnic->name,
810  readq ( lmac->regs + BGX_CMR_TX_STAT0 ),
811  readq ( lmac->regs + BGX_CMR_TX_STAT1 ),
812  readq ( lmac->regs + BGX_CMR_TX_STAT2 ),
813  readq ( lmac->regs + BGX_CMR_TX_STAT3 ),
814  readq ( lmac->regs + BGX_CMR_TX_STAT5 ),
815  readq ( lmac->regs + BGX_CMR_TX_STAT14 ),
816  readq ( lmac->regs + BGX_CMR_TX_STAT15 ),
817  readq ( lmac->regs + BGX_CMR_TX_STAT16 ),
818  readq ( lmac->regs + BGX_CMR_TX_STAT17 ) );
819  DBGC ( vnic, "TXNIC %s TXB ok %#llx hist %#llx:%#llx:%#llx:%#llx:"
820  "%#llx:%#llx:%#llx:%#llx\n", vnic->name,
821  readq ( lmac->regs + BGX_CMR_TX_STAT4 ),
822  readq ( lmac->regs + BGX_CMR_TX_STAT6 ),
823  readq ( lmac->regs + BGX_CMR_TX_STAT7 ),
824  readq ( lmac->regs + BGX_CMR_TX_STAT8 ),
825  readq ( lmac->regs + BGX_CMR_TX_STAT9 ),
826  readq ( lmac->regs + BGX_CMR_TX_STAT10 ),
827  readq ( lmac->regs + BGX_CMR_TX_STAT11 ),
828  readq ( lmac->regs + BGX_CMR_TX_STAT12 ),
829  readq ( lmac->regs + BGX_CMR_TX_STAT13 ) );
830 
831  /* Read receive statistics */
832  DBGC ( vnic, "TXNIC %s RXF ok %#llx pa %#llx nm %#llx ov %#llx er "
833  "%#llx nc %#llx\n", vnic->name,
834  readq ( lmac->regs + BGX_CMR_RX_STAT0 ),
835  readq ( lmac->regs + BGX_CMR_RX_STAT2 ),
836  readq ( lmac->regs + BGX_CMR_RX_STAT4 ),
837  readq ( lmac->regs + BGX_CMR_RX_STAT6 ),
838  readq ( lmac->regs + BGX_CMR_RX_STAT8 ),
839  readq ( lmac->regs + BGX_CMR_RX_STAT9 ) );
840  DBGC ( vnic, "TXNIC %s RXB ok %#llx pa %#llx nm %#llx ov %#llx nc "
841  "%#llx\n", vnic->name,
842  readq ( lmac->regs + BGX_CMR_RX_STAT1 ),
843  readq ( lmac->regs + BGX_CMR_RX_STAT3 ),
844  readq ( lmac->regs + BGX_CMR_RX_STAT5 ),
845  readq ( lmac->regs + BGX_CMR_RX_STAT7 ),
846  readq ( lmac->regs + BGX_CMR_RX_STAT10 ) );
847 }
#define BGX_SPU_STATUS2_RCVFLT
Definition: thunderx.h:813
#define BGX_CMR_TX_STAT12
CMR transmit statistics 12.
Definition: thunderx.h:769
#define BGX_CMR_TX_STAT3
CMR transmit statistics 3.
Definition: thunderx.h:742
#define BGX_CMR_TX_STAT14
CMR transmit statistics 14.
Definition: thunderx.h:775
#define BGX_SPU_AN_STATUS
SPU autonegotiation status.
Definition: thunderx.h:853
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
#define BGX_SPU_BR_STATUS1_RCV_LNK
Definition: thunderx.h:817
#define BGX_SPU_BR_ALGN_STATUS_ALIGND
Definition: thunderx.h:828
#define BGX_SPU_STATUS1_RCV_LNK
Definition: thunderx.h:809
#define BGX_CMR_TX_STAT15
CMR transmit statistics 15.
Definition: thunderx.h:778
#define BGX_CMR_RX_STAT3
CMR receive statistics 3.
Definition: thunderx.h:691
#define BGX_CMR_TX_STAT10
CMR transmit statistics 10.
Definition: thunderx.h:763
#define BGX_SPU_BR_STATUS1_HI_BER
Definition: thunderx.h:818
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
#define BGX_CMR_RX_STAT2
CMR receive statistics 2.
Definition: thunderx.h:688
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
#define BGX_CMR_TX_STAT0
CMR transmit statistics 0.
Definition: thunderx.h:733
#define BGX_SPU_BR_STATUS2_LATCHED_BER
Definition: thunderx.h:824
unsigned long long uint64_t
Definition: stdint.h:13
#define BGX_SPU_STATUS1_FLT
Definition: thunderx.h:808
#define BGX_SPU_AN_STATUS_XNP_STAT
Definition: thunderx.h:854
#define BGX_CMR_TX_STAT7
CMR transmit statistics 7.
Definition: thunderx.h:754
#define BGX_SPU_BR_PMD_STATUS
SPU BASE-R link training status.
Definition: thunderx.h:835
#define BGX_CMR_TX_STAT6
CMR transmit statistics 6.
Definition: thunderx.h:751
#define BGX_SPU_AN_STATUS_PAGE_RX
Definition: thunderx.h:855
#define BGX_SPU_BR_STATUS1_BLK_LOCK
Definition: thunderx.h:819
void * regs
Registers.
Definition: thunderx.h:909
#define BGX_SPU_BR_STATUS2_LATCHED_LOCK
Definition: thunderx.h:823
#define BGX_CMR_TX_STAT2
CMR transmit statistics 2.
Definition: thunderx.h:739
#define BGX_SPU_BR_ALGN_STATUS
SPU BASE-R alignment status.
Definition: thunderx.h:827
#define BGX_CMR_RX_STAT5
CMR receive statistics 5.
Definition: thunderx.h:697
#define BGX_SPU_BR_STATUS1
SPU BASE-R status 1.
Definition: thunderx.h:816
u32 status1
Definition: ar9003_mac.h:68
#define BGX_SPU_STATUS2
SPU status 2.
Definition: thunderx.h:812
A virtual NIC.
Definition: thunderx.h:417
#define BGX_CMR_RX_STAT6
CMR receive statistics 6.
Definition: thunderx.h:700
#define BGX_SPU_BR_STATUS2
SPU BASE-R status 2.
Definition: thunderx.h:822
#define BGX_CMR_RX_STAT1
CMR receive statistics 1.
Definition: thunderx.h:685
#define BGX_CMR_TX_STAT13
CMR transmit statistics 13.
Definition: thunderx.h:772
#define BGX_CMR_TX_STAT1
CMR transmit statistics 1.
Definition: thunderx.h:736
#define BGX_SPU_AN_STATUS_AN_COMPLETE
Definition: thunderx.h:856
#define BGX_CMR_TX_STAT9
CMR transmit statistics 9.
Definition: thunderx.h:760
#define BGX_CMR_RX_STAT9
CMR receive statistics 9.
Definition: thunderx.h:709
#define BGX_SPU_STATUS1
SPU status 1.
Definition: thunderx.h:807
#define BGX_CMR_TX_STAT4
CMR transmit statistics 4.
Definition: thunderx.h:745
#define BGX_CMR_TX_STAT17
CMR transmit statistics 17.
Definition: thunderx.h:784
#define BGX_CMR_RX_STAT10
CMR receive statistics 10.
Definition: thunderx.h:712
#define BGX_CMR_TX_STAT16
CMR transmit statistics 16.
Definition: thunderx.h:781
#define BGX_CMR_RX_STAT4
CMR receive statistics 4.
Definition: thunderx.h:694
#define BGX_CMR_TX_STAT8
CMR transmit statistics 8.
Definition: thunderx.h:757
#define BGX_CMR_RX_STAT0
CMR receive statistics 0.
Definition: thunderx.h:682
#define BGX_SPU_AN_STATUS_LINK_STATUS
Definition: thunderx.h:857
u32 status2
Definition: ar9003_mac.h:69
#define BGX_CMR_RX_STAT7
CMR receive statistics 7.
Definition: thunderx.h:703
#define BGX_CMR_TX_STAT5
CMR transmit statistics 5.
Definition: thunderx.h:748
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define BGX_SPU_AN_STATUS_LP_AN_ABLE
Definition: thunderx.h:858
#define BGX_CMR_TX_STAT11
CMR transmit statistics 11.
Definition: thunderx.h:766
#define BGX_CMR_RX_STAT8
CMR receive statistics 8.
Definition: thunderx.h:706

References BGX_CMR_RX_STAT0, BGX_CMR_RX_STAT1, BGX_CMR_RX_STAT10, BGX_CMR_RX_STAT2, BGX_CMR_RX_STAT3, BGX_CMR_RX_STAT4, BGX_CMR_RX_STAT5, BGX_CMR_RX_STAT6, BGX_CMR_RX_STAT7, BGX_CMR_RX_STAT8, BGX_CMR_RX_STAT9, BGX_CMR_TX_STAT0, BGX_CMR_TX_STAT1, BGX_CMR_TX_STAT10, BGX_CMR_TX_STAT11, BGX_CMR_TX_STAT12, BGX_CMR_TX_STAT13, BGX_CMR_TX_STAT14, BGX_CMR_TX_STAT15, BGX_CMR_TX_STAT16, BGX_CMR_TX_STAT17, BGX_CMR_TX_STAT2, BGX_CMR_TX_STAT3, BGX_CMR_TX_STAT4, BGX_CMR_TX_STAT5, BGX_CMR_TX_STAT6, BGX_CMR_TX_STAT7, BGX_CMR_TX_STAT8, BGX_CMR_TX_STAT9, BGX_SPU_AN_STATUS, BGX_SPU_AN_STATUS_AN_COMPLETE, BGX_SPU_AN_STATUS_LINK_STATUS, BGX_SPU_AN_STATUS_LP_AN_ABLE, BGX_SPU_AN_STATUS_PAGE_RX, BGX_SPU_AN_STATUS_XNP_STAT, BGX_SPU_BR_ALGN_STATUS, BGX_SPU_BR_ALGN_STATUS_ALIGND, BGX_SPU_BR_PMD_STATUS, BGX_SPU_BR_STATUS1, BGX_SPU_BR_STATUS1_BLK_LOCK, BGX_SPU_BR_STATUS1_HI_BER, BGX_SPU_BR_STATUS1_RCV_LNK, BGX_SPU_BR_STATUS2, BGX_SPU_BR_STATUS2_LATCHED_BER, BGX_SPU_BR_STATUS2_LATCHED_LOCK, BGX_SPU_STATUS1, BGX_SPU_STATUS1_FLT, BGX_SPU_STATUS1_RCV_LNK, BGX_SPU_STATUS2, BGX_SPU_STATUS2_RCVFLT, DBGC, txnic::name, readq(), txnic_lmac::regs, status1, status2, txnic_lmac::vnic, and writeq().

◆ txnic_lmac_update_link()

static void txnic_lmac_update_link ( struct txnic_lmac lmac)
static

Update LMAC link state.

Parameters
lmacLogical MAC

Definition at line 854 of file thunderx.c.

854  {
855  struct txnic *vnic = lmac->vnic;
856  struct net_device *netdev = vnic->netdev;
858 
859  /* Read status (clearing latching bits) */
861  status1 = readq ( lmac->regs + BGX_SPU_STATUS1 );
862 
863  /* Report link status */
866  } else {
868  }
869 }
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
#define BGX_SPU_STATUS1_RCV_LNK
Definition: thunderx.h:809
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
unsigned long long uint64_t
Definition: stdint.h:13
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:186
void * regs
Registers.
Definition: thunderx.h:909
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
u32 status1
Definition: ar9003_mac.h:68
A virtual NIC.
Definition: thunderx.h:417
A network device.
Definition: netdevice.h:348
#define BGX_SPU_STATUS1
SPU status 1.
Definition: thunderx.h:807
struct net_device * netdev
Network device.
Definition: thunderx.h:423
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References BGX_SPU_STATUS1, BGX_SPU_STATUS1_RCV_LNK, netdev, txnic::netdev, netdev_link_down(), netdev_link_up(), readq(), txnic_lmac::regs, status1, txnic_lmac::vnic, and writeq().

Referenced by txnic_lmac_open(), txnic_lmac_poll_link(), and txnic_lmac_probe().

◆ txnic_lmac_poll_link()

static void txnic_lmac_poll_link ( struct txnic_lmac lmac)
static

Poll LMAC link state.

Parameters
lmacLogical MAC

Definition at line 876 of file thunderx.c.

876  {
877  struct txnic *vnic = lmac->vnic;
878  uint64_t intr;
879 
880  /* Get interrupt status */
881  intr = readq ( lmac->regs + BGX_SPU_INT );
882  if ( ! intr )
883  return;
884  DBGC ( vnic, "TXNIC %s INT %04llx%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
885  vnic->name, intr,
886  ( ( intr & BGX_SPU_INT_TRAINING_FAIL ) ? " TRAINING_FAIL" : "" ),
887  ( ( intr & BGX_SPU_INT_TRAINING_DONE ) ? " TRAINING_DONE" : "" ),
888  ( ( intr & BGX_SPU_INT_AN_COMPLETE ) ? " AN_COMPLETE" : "" ),
889  ( ( intr & BGX_SPU_INT_AN_LINK_GOOD ) ? " AN_LINK_GOOD" : "" ),
890  ( ( intr & BGX_SPU_INT_AN_PAGE_RX ) ? " AN_PAGE_RX" : "" ),
891  ( ( intr & BGX_SPU_INT_FEC_UNCORR ) ? " FEC_UNCORR" : "" ),
892  ( ( intr & BGX_SPU_INT_FEC_CORR ) ? " FEC_CORR" : "" ),
893  ( ( intr & BGX_SPU_INT_BIP_ERR ) ? " BIP_ERR" : "" ),
894  ( ( intr & BGX_SPU_INT_DBG_SYNC ) ? " DBG_SYNC" : "" ),
895  ( ( intr & BGX_SPU_INT_ALGNLOS ) ? " ALGNLOS" : "" ),
896  ( ( intr & BGX_SPU_INT_SYNLOS ) ? " SYNLOS" : "" ),
897  ( ( intr & BGX_SPU_INT_BITLCKLS ) ? " BITLCKLS" : "" ),
898  ( ( intr & BGX_SPU_INT_ERR_BLK ) ? " ERR_BLK" : "" ),
899  ( ( intr & BGX_SPU_INT_RX_LINK_DOWN ) ? " RX_LINK_DOWN" : "" ),
900  ( ( intr & BGX_SPU_INT_RX_LINK_UP ) ? " RX_LINK_UP" : "" ) );
901 
902  /* Clear interrupt status */
903  writeq ( intr, ( lmac->regs + BGX_SPU_INT ) );
904 
905  /* Update link state */
906  txnic_lmac_update_link ( lmac );
907 }
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
#define BGX_SPU_INT
SPU interrupt.
Definition: thunderx.h:861
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
const char * name
Device name (for debugging)
Definition: thunderx.h:421
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
#define BGX_SPU_INT_FEC_UNCORR
Definition: thunderx.h:867
#define BGX_SPU_INT_AN_PAGE_RX
Definition: thunderx.h:866
#define BGX_SPU_INT_ERR_BLK
Definition: thunderx.h:874
#define BGX_SPU_INT_BIP_ERR
Definition: thunderx.h:869
void * regs
Registers.
Definition: thunderx.h:909
#define BGX_SPU_INT_TRAINING_FAIL
Definition: thunderx.h:862
#define BGX_SPU_INT_AN_LINK_GOOD
Definition: thunderx.h:865
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
#define BGX_SPU_INT_SYNLOS
Definition: thunderx.h:872
#define BGX_SPU_INT_AN_COMPLETE
Definition: thunderx.h:864
A virtual NIC.
Definition: thunderx.h:417
#define BGX_SPU_INT_DBG_SYNC
Definition: thunderx.h:870
#define BGX_SPU_INT_FEC_CORR
Definition: thunderx.h:868
static void txnic_lmac_update_link(struct txnic_lmac *lmac)
Update LMAC link state.
Definition: thunderx.c:854
#define BGX_SPU_INT_BITLCKLS
Definition: thunderx.h:873
#define BGX_SPU_INT_RX_LINK_UP
Definition: thunderx.h:876
#define BGX_SPU_INT_RX_LINK_DOWN
Definition: thunderx.h:875
#define BGX_SPU_INT_TRAINING_DONE
Definition: thunderx.h:863
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define BGX_SPU_INT_ALGNLOS
Definition: thunderx.h:871

References BGX_SPU_INT, BGX_SPU_INT_ALGNLOS, BGX_SPU_INT_AN_COMPLETE, BGX_SPU_INT_AN_LINK_GOOD, BGX_SPU_INT_AN_PAGE_RX, BGX_SPU_INT_BIP_ERR, BGX_SPU_INT_BITLCKLS, BGX_SPU_INT_DBG_SYNC, BGX_SPU_INT_ERR_BLK, BGX_SPU_INT_FEC_CORR, BGX_SPU_INT_FEC_UNCORR, BGX_SPU_INT_RX_LINK_DOWN, BGX_SPU_INT_RX_LINK_UP, BGX_SPU_INT_SYNLOS, BGX_SPU_INT_TRAINING_DONE, BGX_SPU_INT_TRAINING_FAIL, DBGC, intr, txnic::name, readq(), txnic_lmac::regs, txnic_lmac_update_link(), txnic_lmac::vnic, and writeq().

Referenced by txnic_lmac_poll().

◆ txnic_lmac_reset()

static void txnic_lmac_reset ( struct txnic_lmac lmac)
static

Reset LMAC.

Parameters
lmacLogical MAC

Definition at line 914 of file thunderx.c.

914  {
915  struct txnic_bgx *bgx = lmac->bgx;
916  struct txnic_pf *pf = bgx->pf;
917  void *qsregs = ( pf->regs + TXNIC_PF_QS ( lmac->idx ) );
918 
919  /* There is no reset available for the physical function
920  * aspects of a virtual NIC; we have to explicitly reload a
921  * sensible set of default values.
922  */
923  writeq ( 0, ( qsregs + TXNIC_PF_QS_CFG ) );
924  writeq ( 0, ( qsregs + TXNIC_PF_QS_RQ_CFG(0) ) );
925  writeq ( 0, ( qsregs + TXNIC_PF_QS_RQ_DROP_CFG(0) ) );
926  writeq ( 0, ( qsregs + TXNIC_PF_QS_RQ_BP_CFG(0) ) );
927  writeq ( 0, ( qsregs + TXNIC_PF_QS_SQ_CFG(0) ) );
928 }
A physical function.
Definition: thunderx.h:579
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
#define TXNIC_PF_QS_RQ_DROP_CFG(q)
Receive queue drop configuration.
Definition: thunderx.h:562
#define TXNIC_PF_QS_RQ_BP_CFG(q)
Receive queue backpressure configuration.
Definition: thunderx.h:565
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
A BGX Ethernet interface.
Definition: thunderx.h:923
#define TXNIC_PF_QS_RQ_CFG(q)
Receive queue configuration.
Definition: thunderx.h:553
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
void * regs
Registers.
Definition: thunderx.h:581
unsigned int idx
Virtual NIC index.
Definition: thunderx.h:913
#define TXNIC_PF_QS_SQ_CFG(q)
Send queue configuration.
Definition: thunderx.h:571
#define TXNIC_PF_QS(qs)
Queue set registers.
Definition: thunderx.h:545
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define TXNIC_PF_QS_CFG
Queue set configuration.
Definition: thunderx.h:548
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition: thunderx.h:911

References txnic_pf::bgx, txnic_lmac::bgx, txnic_lmac::idx, txnic_bgx::lmac, txnic_bgx::pf, txnic_pf::regs, TXNIC_PF_QS, TXNIC_PF_QS_CFG, TXNIC_PF_QS_RQ_BP_CFG, TXNIC_PF_QS_RQ_CFG, TXNIC_PF_QS_RQ_DROP_CFG, TXNIC_PF_QS_SQ_CFG, and writeq().

Referenced by txnic_lmac_probe(), and txnic_lmac_remove().

◆ txnic_lmac_open()

static int txnic_lmac_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 936 of file thunderx.c.

936  {
937  struct txnic_lmac *lmac = netdev->priv;
938  struct txnic_bgx *bgx = lmac->bgx;
939  struct txnic_pf *pf = bgx->pf;
940  struct txnic *vnic = lmac->vnic;
941  unsigned int vnic_idx = lmac->idx;
942  unsigned int chan_idx = TXNIC_CHAN_IDX ( vnic_idx );
943  unsigned int tl4_idx = TXNIC_TL4_IDX ( vnic_idx );
944  unsigned int tl3_idx = TXNIC_TL3_IDX ( vnic_idx );
945  unsigned int tl2_idx = TXNIC_TL2_IDX ( vnic_idx );
946  void *lmregs = ( pf->regs + TXNIC_PF_LMAC ( vnic_idx ) );
947  void *chregs = ( pf->regs + TXNIC_PF_CHAN ( chan_idx ) );
948  void *qsregs = ( pf->regs + TXNIC_PF_QS ( vnic_idx ) );
949  size_t max_pkt_size;
950  int rc;
951 
952  /* Configure channel/match parse indices */
953  writeq ( ( TXNIC_PF_MPI_CFG_VNIC ( vnic_idx ) |
954  TXNIC_PF_MPI_CFG_RSSI_BASE ( vnic_idx ) ),
955  ( TXNIC_PF_MPI_CFG ( vnic_idx ) + pf->regs ) );
956  writeq ( ( TXNIC_PF_RSSI_RQ_RQ_QS ( vnic_idx ) ),
957  ( TXNIC_PF_RSSI_RQ ( vnic_idx ) + pf->regs ) );
958 
959  /* Configure LMAC */
960  max_pkt_size = ( netdev->max_pkt_len + 4 /* possible VLAN */ );
963  ( TXNIC_PF_LMAC_CFG + lmregs ) );
964  writeq ( ( TXNIC_PF_LMAC_CFG2_MAX_PKT_SIZE ( max_pkt_size ) ),
965  ( TXNIC_PF_LMAC_CFG2 + lmregs ) );
969  ( TXNIC_PF_LMAC_CREDIT + lmregs ) );
970 
971  /* Configure channels */
973  ( TXNIC_PF_CHAN_TX_CFG + chregs ) );
974  writeq ( ( TXNIC_PF_CHAN_RX_CFG_CPI_BASE ( vnic_idx ) ),
975  ( TXNIC_PF_CHAN_RX_CFG + chregs ) );
977  TXNIC_PF_CHAN_RX_BP_CFG_BPID ( vnic_idx ) ),
978  ( TXNIC_PF_CHAN_RX_BP_CFG + chregs ) );
979 
980  /* Configure traffic limiters */
982  ( TXNIC_PF_TL2_CFG ( tl2_idx ) + pf->regs ) );
984  ( TXNIC_PF_TL3_CFG ( tl3_idx ) + pf->regs ) );
985  writeq ( ( TXNIC_PF_TL3_CHAN_CHAN ( chan_idx ) ),
986  ( TXNIC_PF_TL3_CHAN ( tl3_idx ) + pf->regs ) );
987  writeq ( ( TXNIC_PF_TL4_CFG_SQ_QS ( vnic_idx ) |
989  ( TXNIC_PF_TL4_CFG ( tl4_idx ) + pf->regs ) );
990 
991  /* Configure send queue */
992  writeq ( ( TXNIC_PF_QS_SQ_CFG_CQ_QS ( vnic_idx ) ),
993  ( TXNIC_PF_QS_SQ_CFG(0) + qsregs ) );
994  writeq ( ( TXNIC_PF_QS_SQ_CFG2_TL4 ( tl4_idx ) ),
995  ( TXNIC_PF_QS_SQ_CFG2(0) + qsregs ) );
996 
997  /* Configure receive queue */
999  TXNIC_PF_QS_RQ_CFG_CQ_QS ( vnic_idx ) |
1000  TXNIC_PF_QS_RQ_CFG_RBDR_CONT_QS ( vnic_idx ) |
1001  TXNIC_PF_QS_RQ_CFG_RBDR_STRT_QS ( vnic_idx ) ),
1002  ( TXNIC_PF_QS_RQ_CFG(0) + qsregs ) );
1005  TXNIC_PF_QS_RQ_BP_CFG_BPID ( vnic_idx ) ),
1006  ( TXNIC_PF_QS_RQ_BP_CFG(0) + qsregs ) );
1007 
1008  /* Enable queue set */
1009  writeq ( ( TXNIC_PF_QS_CFG_ENA | TXNIC_PF_QS_CFG_VNIC ( vnic_idx ) ),
1010  ( TXNIC_PF_QS_CFG + qsregs ) );
1011 
1012  /* Open virtual NIC */
1013  if ( ( rc = txnic_open ( vnic ) ) != 0 )
1014  goto err_open;
1015 
1016  /* Update link state */
1017  txnic_lmac_update_link ( lmac );
1018 
1019  return 0;
1020 
1021  txnic_close ( vnic );
1022  err_open:
1023  writeq ( 0, ( qsregs + TXNIC_PF_QS_CFG ) );
1024  return rc;
1025 }
#define TXNIC_PF_QS_SQ_CFG_CQ_QS(qs)
Definition: thunderx.h:572
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
#define TXNIC_PF_TL4_CFG_RR_QUANTUM_DEFAULT
Definition: thunderx.h:541
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A physical function.
Definition: thunderx.h:579
#define TXNIC_PF_TL3_CFG(tl)
Traffic limiter 3 configuration.
Definition: thunderx.h:528
#define TXNIC_PF_CHAN_RX_BP_CFG_BPID(bp)
Definition: thunderx.h:519
#define TXNIC_PF_CHAN_RX_CFG_CPI_BASE(ix)
Definition: thunderx.h:514
#define TXNIC_PF_LMAC_CFG2_MAX_PKT_SIZE(sz)
Definition: thunderx.h:493
#define TXNIC_PF_RSSI_RQ(ix)
RSS indirection receive queue.
Definition: thunderx.h:478
#define TXNIC_PF_QS_RQ_BP_CFG_CQ_BP_ENA
Definition: thunderx.h:567
A Logical MAC (LMAC)
Definition: thunderx.h:907
#define TXNIC_PF_RSSI_RQ_RQ_QS(qs)
Definition: thunderx.h:479
#define TXNIC_PF_TL2_CFG(tl)
Traffic limiter 2 configuration.
Definition: thunderx.h:522
#define TXNIC_PF_LMAC_CFG
LMAC configuration.
Definition: thunderx.h:485
#define TXNIC_PF_QS_RQ_CFG_RBDR_STRT_QS(qs)
Definition: thunderx.h:559
#define TXNIC_PF_LMAC_CFG2
LMAC configuration 2.
Definition: thunderx.h:492
#define TXNIC_PF_QS_SQ_CFG2_TL4(tl)
Definition: thunderx.h:576
#define TXNIC_PF_TL4_CFG_SQ_QS(qs)
Definition: thunderx.h:539
#define TXNIC_PF_QS_SQ_CFG2(q)
Send queue configuration 2.
Definition: thunderx.h:575
#define TXNIC_TL2_IDX(vnic_idx)
Calculate traffic limiter 2 index.
Definition: thunderx.h:630
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
static int txnic_open(struct txnic *vnic)
Open virtual NIC.
Definition: thunderx.c:585
#define TXNIC_PF_QS_RQ_CFG_RBDR_CONT_QS(qs)
Definition: thunderx.h:558
#define TXNIC_PF_MPI_CFG(ix)
Match parse index configuration.
Definition: thunderx.h:473
#define TXNIC_PF_QS_CFG_ENA
Definition: thunderx.h:549
#define TXNIC_PF_TL3_CHAN_CHAN(ch)
Definition: thunderx.h:535
void * priv
Driver private data.
Definition: netdevice.h:425
#define TXNIC_PF_LMAC(lm)
LMAC registers.
Definition: thunderx.h:482
#define TXNIC_PF_CHAN_RX_BP_CFG_ENA
Definition: thunderx.h:518
static struct net_device * netdev
Definition: gdbudp.c:52
#define TXNIC_PF_LMAC_CREDIT
LMAC credit.
Definition: thunderx.h:496
#define TXNIC_TL3_IDX(vnic_idx)
Calculate traffic limiter 3 index.
Definition: thunderx.h:638
#define TXNIC_PF_QS_RQ_CFG_CQ_QS(qs)
Definition: thunderx.h:557
#define TXNIC_PF_CHAN_RX_CFG
Channel receive configuration.
Definition: thunderx.h:513
#define TXNIC_PF_QS_CFG_VNIC(vn)
Definition: thunderx.h:550
#define TXNIC_PF_CHAN(ch)
Channel registers.
Definition: thunderx.h:506
#define TXNIC_PF_QS_RQ_BP_CFG_BPID(bp)
Definition: thunderx.h:568
#define TXNIC_PF_MPI_CFG_VNIC(vn)
Definition: thunderx.h:474
#define TXNIC_PF_QS_RQ_BP_CFG(q)
Receive queue backpressure configuration.
Definition: thunderx.h:565
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
A virtual NIC.
Definition: thunderx.h:417
#define TXNIC_TL4_IDX(vnic_idx)
Calculate traffic limiter 4 index.
Definition: thunderx.h:646
#define TXNIC_PF_LMAC_CREDIT_CC_PACKET_CNT_DEFAULT
Definition: thunderx.h:501
#define TXNIC_CHAN_IDX(vnic_idx)
Calculate channel index.
Definition: thunderx.h:654
#define ETH_ZLEN
Definition: if_ether.h:10
A BGX Ethernet interface.
Definition: thunderx.h:923
#define TXNIC_PF_TL2_CFG_RR_QUANTUM_DEFAULT
Definition: thunderx.h:524
#define TXNIC_PF_CHAN_TX_CFG_BP_ENA
Definition: thunderx.h:510
#define TXNIC_PF_QS_RQ_CFG(q)
Receive queue configuration.
Definition: thunderx.h:553
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
static void txnic_lmac_update_link(struct txnic_lmac *lmac)
Update LMAC link state.
Definition: thunderx.c:854
#define TXNIC_PF_LMAC_CFG_MIN_PKT_SIZE(sz)
Definition: thunderx.h:489
#define TXNIC_PF_QS_RQ_BP_CFG_RBDR_BP_ENA
Definition: thunderx.h:566
#define TXNIC_PF_LMAC_CFG_ADJUST_DEFAULT
Definition: thunderx.h:487
void * regs
Registers.
Definition: thunderx.h:581
#define TXNIC_PF_CHAN_TX_CFG
Channel transmit configuration.
Definition: thunderx.h:509
static void txnic_close(struct txnic *vnic)
Close virtual NIC.
Definition: thunderx.c:619
#define TXNIC_PF_MPI_CFG_RSSI_BASE(ix)
Definition: thunderx.h:475
unsigned int idx
Virtual NIC index.
Definition: thunderx.h:913
#define TXNIC_PF_LMAC_CREDIT_CC_ENABLE
Definition: thunderx.h:503
#define TXNIC_PF_TL3_CHAN(tl)
Traffic limiter 3 channel mapping.
Definition: thunderx.h:534
#define TXNIC_PF_TL3_CFG_RR_QUANTUM_DEFAULT
Definition: thunderx.h:530
#define TXNIC_PF_CHAN_RX_BP_CFG
Channel receive backpressure configuration.
Definition: thunderx.h:517
#define TXNIC_PF_QS_SQ_CFG(q)
Send queue configuration.
Definition: thunderx.h:571
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:403
#define TXNIC_PF_QS(qs)
Queue set registers.
Definition: thunderx.h:545
#define TXNIC_PF_TL4_CFG(tl)
Traffic limiter 4 configuration.
Definition: thunderx.h:538
#define TXNIC_PF_LMAC_CREDIT_CC_UNIT_CNT_DEFAULT
Definition: thunderx.h:498
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define TXNIC_PF_QS_CFG
Queue set configuration.
Definition: thunderx.h:548
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition: thunderx.h:911
#define TXNIC_PF_QS_RQ_CFG_CACHING_ALL
Definition: thunderx.h:555

References txnic_pf::bgx, txnic_lmac::bgx, ETH_ZLEN, txnic_lmac::idx, txnic_bgx::lmac, net_device::max_pkt_len, netdev, txnic_bgx::pf, net_device::priv, rc, txnic_pf::regs, TXNIC_CHAN_IDX, txnic_close(), txnic_lmac_update_link(), txnic_open(), TXNIC_PF_CHAN, TXNIC_PF_CHAN_RX_BP_CFG, TXNIC_PF_CHAN_RX_BP_CFG_BPID, TXNIC_PF_CHAN_RX_BP_CFG_ENA, TXNIC_PF_CHAN_RX_CFG, TXNIC_PF_CHAN_RX_CFG_CPI_BASE, TXNIC_PF_CHAN_TX_CFG, TXNIC_PF_CHAN_TX_CFG_BP_ENA, TXNIC_PF_LMAC, TXNIC_PF_LMAC_CFG, TXNIC_PF_LMAC_CFG2, TXNIC_PF_LMAC_CFG2_MAX_PKT_SIZE, TXNIC_PF_LMAC_CFG_ADJUST_DEFAULT, TXNIC_PF_LMAC_CFG_MIN_PKT_SIZE, TXNIC_PF_LMAC_CREDIT, TXNIC_PF_LMAC_CREDIT_CC_ENABLE, TXNIC_PF_LMAC_CREDIT_CC_PACKET_CNT_DEFAULT, TXNIC_PF_LMAC_CREDIT_CC_UNIT_CNT_DEFAULT, TXNIC_PF_MPI_CFG, TXNIC_PF_MPI_CFG_RSSI_BASE, TXNIC_PF_MPI_CFG_VNIC, TXNIC_PF_QS, TXNIC_PF_QS_CFG, TXNIC_PF_QS_CFG_ENA, TXNIC_PF_QS_CFG_VNIC, TXNIC_PF_QS_RQ_BP_CFG, TXNIC_PF_QS_RQ_BP_CFG_BPID, TXNIC_PF_QS_RQ_BP_CFG_CQ_BP_ENA, TXNIC_PF_QS_RQ_BP_CFG_RBDR_BP_ENA, TXNIC_PF_QS_RQ_CFG, TXNIC_PF_QS_RQ_CFG_CACHING_ALL, TXNIC_PF_QS_RQ_CFG_CQ_QS, TXNIC_PF_QS_RQ_CFG_RBDR_CONT_QS, TXNIC_PF_QS_RQ_CFG_RBDR_STRT_QS, TXNIC_PF_QS_SQ_CFG, TXNIC_PF_QS_SQ_CFG2, TXNIC_PF_QS_SQ_CFG2_TL4, TXNIC_PF_QS_SQ_CFG_CQ_QS, TXNIC_PF_RSSI_RQ, TXNIC_PF_RSSI_RQ_RQ_QS, TXNIC_PF_TL2_CFG, TXNIC_PF_TL2_CFG_RR_QUANTUM_DEFAULT, TXNIC_PF_TL3_CFG, TXNIC_PF_TL3_CFG_RR_QUANTUM_DEFAULT, TXNIC_PF_TL3_CHAN, TXNIC_PF_TL3_CHAN_CHAN, TXNIC_PF_TL4_CFG, TXNIC_PF_TL4_CFG_RR_QUANTUM_DEFAULT, TXNIC_PF_TL4_CFG_SQ_QS, TXNIC_TL2_IDX, TXNIC_TL3_IDX, TXNIC_TL4_IDX, txnic_lmac::vnic, and writeq().

◆ txnic_lmac_close()

static void txnic_lmac_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 1032 of file thunderx.c.

1032  {
1033  struct txnic_lmac *lmac = netdev->priv;
1034  struct txnic_bgx *bgx = lmac->bgx;
1035  struct txnic_pf *pf = bgx->pf;
1036  struct txnic *vnic = lmac->vnic;
1037  void *qsregs = ( pf->regs + TXNIC_PF_QS ( lmac->idx ) );
1038 
1039  /* Close virtual NIC */
1040  txnic_close ( vnic );
1041 
1042  /* Disable queue set */
1043  writeq ( 0, ( qsregs + TXNIC_PF_QS_CFG ) );
1044 }
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
A physical function.
Definition: thunderx.h:579
A Logical MAC (LMAC)
Definition: thunderx.h:907
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
A virtual NIC.
Definition: thunderx.h:417
A BGX Ethernet interface.
Definition: thunderx.h:923
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
void * regs
Registers.
Definition: thunderx.h:581
static void txnic_close(struct txnic *vnic)
Close virtual NIC.
Definition: thunderx.c:619
unsigned int idx
Virtual NIC index.
Definition: thunderx.h:913
#define TXNIC_PF_QS(qs)
Queue set registers.
Definition: thunderx.h:545
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define TXNIC_PF_QS_CFG
Queue set configuration.
Definition: thunderx.h:548
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition: thunderx.h:911

References txnic_pf::bgx, txnic_lmac::bgx, txnic_lmac::idx, txnic_bgx::lmac, netdev, txnic_bgx::pf, net_device::priv, txnic_pf::regs, txnic_close(), TXNIC_PF_QS, TXNIC_PF_QS_CFG, txnic_lmac::vnic, and writeq().

◆ txnic_lmac_transmit()

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

Transmit packet.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 1053 of file thunderx.c.

1054  {
1055  struct txnic_lmac *lmac = netdev->priv;
1056  struct txnic *vnic = lmac->vnic;
1057 
1058  return txnic_send ( vnic, iobuf );
1059 }
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
A Logical MAC (LMAC)
Definition: thunderx.h:907
static int txnic_send(struct txnic *vnic, struct io_buffer *iobuf)
Send packet.
Definition: thunderx.c:186
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
A virtual NIC.
Definition: thunderx.h:417

References netdev, net_device::priv, txnic_send(), and txnic_lmac::vnic.

◆ txnic_lmac_poll()

static void txnic_lmac_poll ( struct net_device netdev)
static

Poll network device.

Parameters
netdevNetwork device

Definition at line 1066 of file thunderx.c.

1066  {
1067  struct txnic_lmac *lmac = netdev->priv;
1068  struct txnic *vnic = lmac->vnic;
1069 
1070  /* Poll virtual NIC */
1071  txnic_poll ( vnic );
1072 
1073  /* Poll link state */
1074  txnic_lmac_poll_link ( lmac );
1075 }
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
A Logical MAC (LMAC)
Definition: thunderx.h:907
static void txnic_poll(struct txnic *vnic)
Poll virtual NIC.
Definition: thunderx.c:636
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
A virtual NIC.
Definition: thunderx.h:417
static void txnic_lmac_poll_link(struct txnic_lmac *lmac)
Poll LMAC link state.
Definition: thunderx.c:876

References netdev, net_device::priv, txnic_lmac_poll_link(), txnic_poll(), and txnic_lmac::vnic.

◆ txnic_lmac_probe()

static int txnic_lmac_probe ( struct txnic_lmac lmac)
static

Probe logical MAC virtual NIC.

Parameters
lmacLogical MAC
Return values
rcReturn status code

Definition at line 1091 of file thunderx.c.

1091  {
1092  struct txnic_bgx *bgx = lmac->bgx;
1093  struct txnic_pf *pf = bgx->pf;
1094  struct txnic *vnic;
1095  struct net_device *netdev;
1096  unsigned long membase;
1097  int rc;
1098 
1099  /* Sanity check */
1100  assert ( lmac->vnic == NULL );
1101 
1102  /* Calculate register base address */
1103  membase = ( pf->vf_membase + ( lmac->idx * pf->vf_stride ) );
1104 
1105  /* Allocate and initialise network device */
1106  vnic = txnic_alloc ( &bgx->pci->dev, membase );
1107  if ( ! vnic ) {
1108  rc = -ENOMEM;
1109  goto err_alloc;
1110  }
1111  netdev = vnic->netdev;
1113  netdev->priv = lmac;
1114  lmac->vnic = vnic;
1115 
1116  /* Reset device */
1117  txnic_lmac_reset ( lmac );
1118 
1119  /* Set MAC address */
1120  memcpy ( netdev->hw_addr, lmac->mac.raw, ETH_ALEN );
1121 
1122  /* Register network device */
1123  if ( ( rc = register_netdev ( netdev ) ) != 0 )
1124  goto err_register;
1125  vnic->name = netdev->name;
1126  DBGC ( TXNICCOL ( pf ), "TXNIC %d/%d/%d is %s (%s)\n", pf->node,
1127  bgx->idx, lmac->idx, vnic->name, eth_ntoa ( lmac->mac.raw ) );
1128 
1129  /* Update link state */
1130  txnic_lmac_update_link ( lmac );
1131 
1132  return 0;
1133 
1135  err_register:
1136  txnic_lmac_reset ( lmac );
1137  txnic_free ( vnic );
1138  lmac->vnic = NULL;
1139  err_alloc:
1140  return rc;
1141 }
unsigned int idx
BGX index.
Definition: thunderx.h:931
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A physical function.
Definition: thunderx.h:579
const char * name
Device name (for debugging)
Definition: thunderx.h:421
static void txnic_lmac_reset(struct txnic_lmac *lmac)
Reset LMAC.
Definition: thunderx.c:914
#define DBGC(...)
Definition: compiler.h:505
unsigned long vf_stride
Virtual function BAR stride.
Definition: thunderx.h:590
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
#define ENOMEM
Not enough space.
Definition: errno.h:534
static struct net_device_operations txnic_lmac_operations
Network device operations.
Definition: thunderx.c:1078
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct pci_device * pci
PCI device.
Definition: thunderx.h:927
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
static struct txnic * txnic_alloc(struct device *dev, unsigned long membase)
Allocate virtual NIC.
Definition: thunderx.c:652
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
static void txnic_free(struct txnic *vnic)
Free virtual NIC.
Definition: thunderx.c:712
#define TXNICCOL(x)
Debug colour for physical function and BGX messages.
Definition: thunderx.c:58
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
A virtual NIC.
Definition: thunderx.h:417
A network device.
Definition: netdevice.h:348
#define ETH_ALEN
Definition: if_ether.h:8
uint8_t raw[ETH_ALEN]
Definition: thunderx.h:901
A BGX Ethernet interface.
Definition: thunderx.h:923
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
static void txnic_lmac_update_link(struct txnic_lmac *lmac)
Update LMAC link state.
Definition: thunderx.c:854
unsigned int node
Node ID.
Definition: thunderx.h:585
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
unsigned long vf_membase
Virtual function BAR base.
Definition: thunderx.h:588
unsigned int idx
Virtual NIC index.
Definition: thunderx.h:913
struct net_device * netdev
Network device.
Definition: thunderx.h:423
union txnic_lmac_address mac
MAC address.
Definition: thunderx.h:916
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition: thunderx.h:911

References assert(), txnic_pf::bgx, txnic_lmac::bgx, DBGC, pci_device::dev, ENOMEM, ETH_ALEN, eth_ntoa(), net_device::hw_addr, txnic_lmac::idx, txnic_bgx::idx, txnic_bgx::lmac, txnic_lmac::mac, memcpy(), net_device::name, txnic::name, netdev, txnic::netdev, netdev_init(), txnic_pf::node, NULL, txnic_bgx::pci, txnic_bgx::pf, net_device::priv, txnic_lmac_address::raw, rc, register_netdev(), txnic_alloc(), txnic_free(), txnic_lmac_operations, txnic_lmac_reset(), txnic_lmac_update_link(), TXNICCOL, unregister_netdev(), txnic_pf::vf_membase, txnic_pf::vf_stride, and txnic_lmac::vnic.

Referenced by txnic_lmac_probe_all().

◆ txnic_lmac_remove()

static void txnic_lmac_remove ( struct txnic_lmac lmac)
static

Remove logical MAC virtual NIC.

Parameters
lmacLogical MAC

Definition at line 1148 of file thunderx.c.

1148  {
1149  uint64_t config;
1150 
1151  /* Sanity check */
1152  assert ( lmac->vnic != NULL );
1153 
1154  /* Disable packet receive and transmit */
1155  config = readq ( lmac->regs + BGX_CMR_CONFIG );
1156  config &= ~( BGX_CMR_CONFIG_DATA_PKT_TX_EN |
1158  writeq ( config, ( lmac->regs + BGX_CMR_CONFIG ) );
1159 
1160  /* Unregister network device */
1161  unregister_netdev ( lmac->vnic->netdev );
1162 
1163  /* Reset device */
1164  txnic_lmac_reset ( lmac );
1165 
1166  /* Free virtual NIC */
1167  txnic_free ( lmac->vnic );
1168  lmac->vnic = NULL;
1169 }
struct txnic * vnic
Virtual NIC (if applicable)
Definition: thunderx.h:919
#define BGX_CMR_CONFIG
CMR configuration.
Definition: thunderx.h:668
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
static void txnic_lmac_reset(struct txnic_lmac *lmac)
Reset LMAC.
Definition: thunderx.c:914
unsigned long long uint64_t
Definition: stdint.h:13
void * regs
Registers.
Definition: thunderx.h:909
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
#define BGX_CMR_CONFIG_DATA_PKT_RX_EN
Definition: thunderx.h:670
static void txnic_free(struct txnic *vnic)
Free virtual NIC.
Definition: thunderx.c:712
#define BGX_CMR_CONFIG_DATA_PKT_TX_EN
Definition: thunderx.h:671
struct net_device * netdev
Network device.
Definition: thunderx.h:423
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References assert(), BGX_CMR_CONFIG, BGX_CMR_CONFIG_DATA_PKT_RX_EN, BGX_CMR_CONFIG_DATA_PKT_TX_EN, txnic::netdev, NULL, readq(), txnic_lmac::regs, txnic_free(), txnic_lmac_reset(), unregister_netdev(), txnic_lmac::vnic, and writeq().

Referenced by txnic_lmac_probe_all(), and txnic_lmac_remove_all().

◆ txnic_lmac_probe_all()

static int txnic_lmac_probe_all ( struct txnic_pf pf,
struct txnic_bgx bgx 
)
static

Probe all LMACs on a BGX Ethernet interface.

Parameters
pfPhysical function
bgxBGX Ethernet interface
Return values
rcReturn status code

Definition at line 1178 of file thunderx.c.

1178  {
1179  unsigned int bgx_idx;
1180  int lmac_idx;
1181  int count;
1182  int rc;
1183 
1184  /* Sanity checks */
1185  bgx_idx = bgx->idx;
1186  assert ( pf->node == bgx->node );
1187  assert ( pf->bgx[bgx_idx] == NULL );
1188  assert ( bgx->pf == NULL );
1189 
1190  /* Associate BGX with physical function */
1191  pf->bgx[bgx_idx] = bgx;
1192  bgx->pf = pf;
1193 
1194  /* Probe all LMACs */
1195  count = bgx->count;
1196  for ( lmac_idx = 0 ; lmac_idx < count ; lmac_idx++ ) {
1197  if ( ( rc = txnic_lmac_probe ( &bgx->lmac[lmac_idx] ) ) != 0 )
1198  goto err_probe;
1199  }
1200 
1201  return 0;
1202 
1203  lmac_idx = count;
1204  err_probe:
1205  for ( lmac_idx-- ; lmac_idx >= 0 ; lmac_idx-- )
1206  txnic_lmac_remove ( &bgx->lmac[lmac_idx] );
1207  pf->bgx[bgx_idx] = NULL;
1208  bgx->pf = NULL;
1209  return rc;
1210 }
unsigned int idx
BGX index.
Definition: thunderx.h:931
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned int count
Number of LMACs.
Definition: thunderx.h:936
static int txnic_lmac_probe(struct txnic_lmac *lmac)
Probe logical MAC virtual NIC.
Definition: thunderx.c:1091
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
unsigned int node
Node ID.
Definition: thunderx.h:929
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
static void txnic_lmac_remove(struct txnic_lmac *lmac)
Remove logical MAC virtual NIC.
Definition: thunderx.c:1148
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
unsigned int node
Node ID.
Definition: thunderx.h:585
uint16_t count
Number of entries.
Definition: ena.h:22
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), txnic_pf::bgx, count, txnic_bgx::count, txnic_bgx::idx, txnic_bgx::lmac, txnic_pf::node, txnic_bgx::node, NULL, txnic_bgx::pf, rc, txnic_lmac_probe(), and txnic_lmac_remove().

Referenced by txnic_bgx_probe(), and txnic_pf_probe().

◆ txnic_lmac_remove_all()

static void txnic_lmac_remove_all ( struct txnic_pf pf,
struct txnic_bgx bgx 
)
static

Remove all LMACs on a BGX Ethernet interface.

Parameters
pfPhysical function
bgxBGX Ethernet interface

Definition at line 1218 of file thunderx.c.

1219  {
1220  unsigned int lmac_idx;
1221 
1222  /* Sanity checks */
1223  assert ( pf->bgx[bgx->idx] == bgx );
1224  assert ( bgx->pf == pf );
1225 
1226  /* Remove all LMACs */
1227  for ( lmac_idx = 0 ; lmac_idx < bgx->count ; lmac_idx++ )
1228  txnic_lmac_remove ( &bgx->lmac[lmac_idx] );
1229 
1230  /* Disassociate BGX from physical function */
1231  pf->bgx[bgx->idx] = NULL;
1232  bgx->pf = NULL;
1233 }
unsigned int idx
BGX index.
Definition: thunderx.h:931
unsigned int count
Number of LMACs.
Definition: thunderx.h:936
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
static void txnic_lmac_remove(struct txnic_lmac *lmac)
Remove logical MAC virtual NIC.
Definition: thunderx.c:1148
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), txnic_pf::bgx, txnic_bgx::count, txnic_bgx::idx, txnic_bgx::lmac, NULL, txnic_bgx::pf, and txnic_lmac_remove().

Referenced by txnic_bgx_probe(), txnic_bgx_remove(), txnic_pf_probe(), and txnic_pf_remove().

◆ txnic_pf_probe()

static int txnic_pf_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 1248 of file thunderx.c.

1248  {
1249  struct txnic_pf *pf;
1250  struct txnic_bgx *bgx;
1251  unsigned long membase;
1252  unsigned int i;
1253  int rc;
1254 
1255  /* Allocate and initialise structure */
1256  pf = zalloc ( sizeof ( *pf ) );
1257  if ( ! pf ) {
1258  rc = -ENOMEM;
1259  goto err_alloc;
1260  }
1261  pf->pci = pci;
1262  pci_set_drvdata ( pci, pf );
1263 
1264  /* Get base addresses */
1265  membase = pciea_bar_start ( pci, PCIEA_BEI_BAR_0 );
1268 
1269  /* Calculate node ID */
1270  pf->node = txnic_address_node ( membase );
1271  DBGC ( TXNICCOL ( pf ), "TXNIC %d/*/* PF %s at %#lx (VF %#lx+%#lx)\n",
1272  pf->node, pci->dev.name, membase, pf->vf_membase, pf->vf_stride);
1273 
1274  /* Fix up PCI device */
1275  adjust_pci_device ( pci );
1276 
1277  /* Map registers */
1278  pf->regs = ioremap ( membase, TXNIC_PF_BAR_SIZE );
1279  if ( ! pf->regs ) {
1280  rc = -ENODEV;
1281  goto err_ioremap;
1282  }
1283 
1284  /* Configure physical function */
1288  ( pf->regs + TXNIC_PF_BP_CFG ) );
1289  for ( i = 0 ; i < TXNIC_NUM_BGX ; i++ ) {
1292  ( pf->regs + TXNIC_PF_INTF_SEND_CFG ( i ) ) );
1296  ( pf->regs + TXNIC_PF_INTF_BP_CFG ( i ) ) );
1297  }
1301  ( pf->regs + TXNIC_PF_PKIND_CFG(0) ) );
1302 
1303  /* Add to list of physical functions */
1304  list_add_tail ( &pf->list, &txnic_pfs );
1305 
1306  /* Probe all LMACs, if applicable */
1307  list_for_each_entry ( bgx, &txnic_bgxs, list ) {
1308  if ( bgx->node != pf->node )
1309  continue;
1310  if ( ( rc = txnic_lmac_probe_all ( pf, bgx ) ) != 0 )
1311  goto err_probe;
1312  }
1313 
1314  return 0;
1315 
1316  err_probe:
1317  for ( i = 0 ; i < TXNIC_NUM_BGX ; i++ ) {
1318  if ( pf->bgx[i] )
1319  txnic_lmac_remove_all ( pf, pf->bgx[i] );
1320  }
1321  list_del ( &pf->list );
1322  writeq ( 0, ( pf->regs + TXNIC_PF_CFG ) );
1323  iounmap ( pf->regs );
1324  err_ioremap:
1325  free ( pf );
1326  err_alloc:
1327  return rc;
1328 }
#define TXNIC_PF_PKIND_CFG(pk)
Port kind configuration.
Definition: thunderx.h:463
#define TXNIC_PF_BAR_SIZE
Physical function BAR size.
Definition: thunderx.h:31
#define TXNIC_PF_INTF_BP_CFG(in)
Interface backpressure configuration.
Definition: thunderx.h:457
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define TXNIC_PF_INTF_BP_CFG_BP_ENA
Definition: thunderx.h:458
A physical function.
Definition: thunderx.h:579
#define TXNIC_NUM_BGX
Maximum number of BGX Ethernet interfaces (per node)
Definition: thunderx.h:37
#define DBGC(...)
Definition: compiler.h:505
#define TXNIC_PF_CFG
Physical function configuration.
Definition: thunderx.h:441
char name[40]
Name.
Definition: device.h:75
#define TXNIC_PF_INTF_BP_CFG_BP_ID(bp)
Definition: thunderx.h:460
Virtual function BAR 0.
Definition: pciea.h:39
#define TXNIC_PF_PKIND_CFG_MAXLEN_DISABLE
Definition: thunderx.h:466
unsigned long vf_stride
Virtual function BAR stride.
Definition: thunderx.h:590
#define TXNIC_PF_PKIND_CFG_MINLEN_DISABLE
Definition: thunderx.h:469
#define TXNIC_PF_BP_CFG_BP_POLL_DLY_DEFAULT
Definition: thunderx.h:448
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
struct device dev
Generic device.
Definition: pci.h:189
#define TXNIC_PF_INTF_SEND_CFG(in)
Interface send configuration.
Definition: thunderx.h:452
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
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
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
unsigned int node
Node ID.
Definition: thunderx.h:929
struct pci_device * pci
PCI device.
Definition: thunderx.h:927
#define TXNIC_PF_PKIND_CFG_LENERR_EN
Definition: thunderx.h:464
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
#define TXNIC_PF_CFG_ENA
Definition: thunderx.h:442
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
static void txnic_lmac_remove_all(struct txnic_pf *pf, struct txnic_bgx *bgx)
Remove all LMACs on a BGX Ethernet interface.
Definition: thunderx.c:1218
#define TXNIC_PF_INTF_SEND_CFG_BLOCK_BGX
Definition: thunderx.h:453
Standard BAR 0.
Definition: pciea.h:32
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct list_head list
List of physical functions.
Definition: thunderx.h:593
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define TXNICCOL(x)
Debug colour for physical function and BGX messages.
Definition: thunderx.c:58
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
#define ENODEV
No such device.
Definition: errno.h:509
unsigned long pciea_bar_size(struct pci_device *pci, unsigned int bei)
Find the size of a PCI Enhanced Allocation BAR equivalent.
Definition: pciea.c:144
#define TXNIC_PF_INTF_SEND_CFG_BLOCK(bl)
Definition: thunderx.h:454
#define TXNIC_PF_BP_CFG
Backpressure configuration.
Definition: thunderx.h:445
A BGX Ethernet interface.
Definition: thunderx.h:923
static unsigned int txnic_address_node(uint64_t addr)
Calculate node ID.
Definition: thunderx.h:54
#define TXNIC_PF_BP_CFG_BP_POLL_ENA
Definition: thunderx.h:446
unsigned int node
Node ID.
Definition: thunderx.h:585
#define TXNIC_PF_INTF_BP_CFG_BP_ID_BGX
Definition: thunderx.h:459
unsigned long pciea_bar_start(struct pci_device *pci, unsigned int bei)
Find the start of a PCI Enhanced Allocation BAR equivalent.
Definition: pciea.c:130
unsigned long vf_membase
Virtual function BAR base.
Definition: thunderx.h:588
void * regs
Registers.
Definition: thunderx.h:581
struct pci_device * pci
PCI device.
Definition: thunderx.h:583
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
struct list_head list
List of BGX Ethernet interfaces.
Definition: thunderx.h:941
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
static int txnic_lmac_probe_all(struct txnic_pf *pf, struct txnic_bgx *bgx)
Probe all LMACs on a BGX Ethernet interface.
Definition: thunderx.c:1178

References adjust_pci_device(), txnic_pf::bgx, DBGC, pci_device::dev, ENODEV, ENOMEM, free, ioremap(), iounmap(), txnic_pf::list, txnic_bgx::list, list_add_tail, list_del, list_for_each_entry, device::name, txnic_pf::node, txnic_bgx::node, txnic_pf::pci, txnic_bgx::pci, pci_set_drvdata(), pciea_bar_size(), pciea_bar_start(), PCIEA_BEI_BAR_0, PCIEA_BEI_VF_BAR_0, txnic_bgx::pf, rc, txnic_pf::regs, txnic_address_node(), txnic_lmac_probe_all(), txnic_lmac_remove_all(), TXNIC_NUM_BGX, TXNIC_PF_BAR_SIZE, TXNIC_PF_BP_CFG, TXNIC_PF_BP_CFG_BP_POLL_DLY_DEFAULT, TXNIC_PF_BP_CFG_BP_POLL_ENA, TXNIC_PF_CFG, TXNIC_PF_CFG_ENA, TXNIC_PF_INTF_BP_CFG, TXNIC_PF_INTF_BP_CFG_BP_ENA, TXNIC_PF_INTF_BP_CFG_BP_ID, TXNIC_PF_INTF_BP_CFG_BP_ID_BGX, TXNIC_PF_INTF_SEND_CFG, TXNIC_PF_INTF_SEND_CFG_BLOCK, TXNIC_PF_INTF_SEND_CFG_BLOCK_BGX, TXNIC_PF_PKIND_CFG, TXNIC_PF_PKIND_CFG_LENERR_EN, TXNIC_PF_PKIND_CFG_MAXLEN_DISABLE, TXNIC_PF_PKIND_CFG_MINLEN_DISABLE, TXNICCOL, txnic_pf::vf_membase, txnic_pf::vf_stride, writeq(), and zalloc().

◆ txnic_pf_remove()

static void txnic_pf_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 1335 of file thunderx.c.

1335  {
1336  struct txnic_pf *pf = pci_get_drvdata ( pci );
1337  unsigned int i;
1338 
1339  /* Remove all LMACs, if applicable */
1340  for ( i = 0 ; i < TXNIC_NUM_BGX ; i++ ) {
1341  if ( pf->bgx[i] )
1342  txnic_lmac_remove_all ( pf, pf->bgx[i] );
1343  }
1344 
1345  /* Remove from list of physical functions */
1346  list_del ( &pf->list );
1347 
1348  /* Unmap registers */
1349  iounmap ( pf->regs );
1350 
1351  /* Free physical function */
1352  free ( pf );
1353 }
A physical function.
Definition: thunderx.h:579
#define TXNIC_NUM_BGX
Maximum number of BGX Ethernet interfaces (per node)
Definition: thunderx.h:37
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static void txnic_lmac_remove_all(struct txnic_pf *pf, struct txnic_bgx *bgx)
Remove all LMACs on a BGX Ethernet interface.
Definition: thunderx.c:1218
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct list_head list
List of physical functions.
Definition: thunderx.h:593
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348
void * regs
Registers.
Definition: thunderx.h:581
struct pci_device * pci
PCI device.
Definition: thunderx.h:583
void iounmap(volatile const void *io_addr)
Unmap I/O address.

References txnic_pf::bgx, free, iounmap(), txnic_pf::list, list_del, txnic_pf::pci, pci_get_drvdata(), txnic_pf::regs, txnic_lmac_remove_all(), and TXNIC_NUM_BGX.

◆ txnic_bgx_detect()

static int txnic_bgx_detect ( struct txnic_bgx bgx)
static

Detect BGX Ethernet interface LMAC type.

Parameters
bgxBGX Ethernet interface
Return values
typeLMAC type, or negative error

Definition at line 1405 of file thunderx.c.

1405  {
1406  uint64_t config;
1407  uint64_t br_pmd_control;
1408  uint64_t rx_lmacs;
1409  unsigned int type;
1410 
1411  /* We assume that the early (pre-UEFI) firmware will have
1412  * configured at least the LMAC 0 type and use of link
1413  * training, and may have overridden the number of LMACs.
1414  */
1415 
1416  /* Determine type from LMAC 0 */
1417  config = readq ( bgx->regs + BGX_CMR_CONFIG );
1418  type = BGX_CMR_CONFIG_LMAC_TYPE_GET ( config );
1419  if ( ( type >= ( sizeof ( txnic_lmac_types ) /
1420  sizeof ( txnic_lmac_types[0] ) ) ) ||
1421  ( txnic_lmac_types[type].count == 0 ) ) {
1422  DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/* BGX unknown type %d\n",
1423  bgx->node, bgx->idx, type );
1424  return -ENOTTY;
1425  }
1427 
1428  /* Check whether link training is required */
1429  br_pmd_control = readq ( bgx->regs + BGX_SPU_BR_PMD_CONTROL );
1430  bgx->training =
1431  ( !! ( br_pmd_control & BGX_SPU_BR_PMD_CONTROL_TRAIN_EN ) );
1432 
1433  /* Determine number of LMACs */
1434  rx_lmacs = readq ( bgx->regs + BGX_CMR_RX_LMACS );
1435  bgx->count = BGX_CMR_RX_LMACS_LMACS_GET ( rx_lmacs );
1436  if ( ( bgx->count == TXNIC_NUM_LMAC ) &&
1437  ( bgx->type->count != TXNIC_NUM_LMAC ) ) {
1438  DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/* assuming %d LMACs\n",
1439  bgx->node, bgx->idx, bgx->type->count );
1440  bgx->count = bgx->type->count;
1441  }
1442 
1443  return type;
1444 }
unsigned int idx
BGX index.
Definition: thunderx.h:931
#define BGX_CMR_CONFIG_LMAC_TYPE_GET(config)
Definition: thunderx.h:672
#define BGX_CMR_CONFIG
CMR configuration.
Definition: thunderx.h:668
unsigned int count
Number of LMACs.
Definition: thunderx.h:936
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
uint8_t type
Type.
Definition: ena.h:16
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
#define BGX_SPU_BR_PMD_CONTROL_TRAIN_EN
Definition: thunderx.h:832
unsigned int node
Node ID.
Definition: thunderx.h:929
#define BGX_CMR_RX_LMACS_LMACS_GET(lmacs)
Definition: thunderx.h:788
void * regs
Registers.
Definition: thunderx.h:925
#define TXNICCOL(x)
Debug colour for physical function and BGX messages.
Definition: thunderx.c:58
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
struct txnic_lmac_type * type
LMAC type.
Definition: thunderx.h:934
txnic_lmac_types
LMAC types.
Definition: thunderx.h:879
uint8_t count
Number of LMACs.
Definition: thunderx.h:892
#define BGX_SPU_BR_PMD_CONTROL
SPU BASE-R link training control.
Definition: thunderx.h:831
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
uint16_t count
Number of entries.
Definition: ena.h:22
#define TXNIC_NUM_LMAC
Maximum number of Logical MACs (per BGX)
Definition: thunderx.h:40
#define BGX_CMR_RX_LMACS
CMR receive logical MACs.
Definition: thunderx.h:787
int training
Link training is in use.
Definition: thunderx.h:938

References BGX_CMR_CONFIG, BGX_CMR_CONFIG_LMAC_TYPE_GET, BGX_CMR_RX_LMACS, BGX_CMR_RX_LMACS_LMACS_GET, BGX_SPU_BR_PMD_CONTROL, BGX_SPU_BR_PMD_CONTROL_TRAIN_EN, count, txnic_lmac_type::count, txnic_bgx::count, DBGC, ENOTTY, txnic_bgx::idx, txnic_bgx::node, readq(), txnic_bgx::regs, txnic_bgx::training, TXNIC_NUM_LMAC, TXNICCOL, type, and txnic_bgx::type.

Referenced by txnic_bgx_probe().

◆ txnic_bgx_init()

static void txnic_bgx_init ( struct txnic_bgx bgx,
unsigned int  type 
)
static

Initialise BGX Ethernet interface.

Parameters
bgxBGX Ethernet interface
typeLMAC type

Definition at line 1452 of file thunderx.c.

1452  {
1453  uint64_t global_config;
1454  uint32_t lane_to_sds;
1455  unsigned int i;
1456 
1457  /* Set number of LMACs */
1459  ( bgx->regs + BGX_CMR_RX_LMACS ) );
1461  ( bgx->regs + BGX_CMR_TX_LMACS ) );
1462 
1463  /* Set LMAC types and lane mappings, and disable all LMACs */
1464  lane_to_sds = bgx->type->lane_to_sds;
1465  for ( i = 0 ; i < bgx->count ; i++ ) {
1467  BGX_CMR_CONFIG_LANE_TO_SDS ( lane_to_sds ) ),
1468  ( bgx->regs + BGX_LMAC ( i ) + BGX_CMR_CONFIG ) );
1469  lane_to_sds >>= 8;
1470  }
1471 
1472  /* Reset all MAC address filtering */
1473  for ( i = 0 ; i < TXNIC_NUM_DMAC ; i++ )
1474  writeq ( 0, ( bgx->regs + BGX_CMR_RX_DMAC_CAM ( i ) ) );
1475 
1476  /* Reset NCSI steering */
1477  for ( i = 0 ; i < TXNIC_NUM_STEERING ; i++ )
1478  writeq ( 0, ( bgx->regs + BGX_CMR_RX_STEERING ( i ) ) );
1479 
1480  /* Enable backpressure to all channels */
1482  ( bgx->regs + BGX_CMR_CHAN_MSK_AND ) );
1483 
1484  /* Strip FCS */
1485  global_config = readq ( bgx->regs + BGX_CMR_GLOBAL_CONFIG );
1486  global_config |= BGX_CMR_GLOBAL_CONFIG_FCS_STRIP;
1487  writeq ( global_config, ( bgx->regs + BGX_CMR_GLOBAL_CONFIG ) );
1488 }
#define BGX_CMR_CONFIG
CMR configuration.
Definition: thunderx.h:668
unsigned int count
Number of LMACs.
Definition: thunderx.h:936
#define BGX_CMR_CHAN_MSK_AND_ALL(count)
Definition: thunderx.h:729
#define TXNIC_NUM_DMAC
Maximum number of destination MAC addresses (per BGX)
Definition: thunderx.h:43
#define BGX_CMR_RX_STEERING(i)
CMR receive steering.
Definition: thunderx.h:725
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
uint8_t type
Type.
Definition: ena.h:16
unsigned long long uint64_t
Definition: stdint.h:13
uint32_t lane_to_sds
Lane-to-SDS mapping.
Definition: thunderx.h:894
#define BGX_CMR_RX_DMAC_CAM(i)
CMR destination MAC CAM.
Definition: thunderx.h:722
#define BGX_CMR_GLOBAL_CONFIG
CMR global configuration.
Definition: thunderx.h:678
void * regs
Registers.
Definition: thunderx.h:925
#define BGX_LMAC(lm)
Per-LMAC registers.
Definition: thunderx.h:665
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
#define BGX_CMR_CHAN_MSK_AND
CMR backpressure channel mask AND.
Definition: thunderx.h:728
#define BGX_CMR_CONFIG_LMAC_TYPE_SET(ty)
Definition: thunderx.h:674
unsigned int uint32_t
Definition: stdint.h:12
#define TXNIC_NUM_STEERING
Maximum number of steering rules (per BGX)
Definition: thunderx.h:46
struct txnic_lmac_type * type
LMAC type.
Definition: thunderx.h:934
#define BGX_CMR_RX_LMACS_LMACS_SET(ct)
Definition: thunderx.h:790
#define BGX_CMR_CONFIG_LANE_TO_SDS(ls)
Definition: thunderx.h:675
#define BGX_CMR_RX_LMACS
CMR receive logical MACs.
Definition: thunderx.h:787
#define BGX_CMR_TX_LMACS
CMR transmit logical MACs.
Definition: thunderx.h:793
#define BGX_CMR_GLOBAL_CONFIG_FCS_STRIP
Definition: thunderx.h:679
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define BGX_CMR_TX_LMACS_LMACS_SET(ct)
Definition: thunderx.h:796

References BGX_CMR_CHAN_MSK_AND, BGX_CMR_CHAN_MSK_AND_ALL, BGX_CMR_CONFIG, BGX_CMR_CONFIG_LANE_TO_SDS, BGX_CMR_CONFIG_LMAC_TYPE_SET, BGX_CMR_GLOBAL_CONFIG, BGX_CMR_GLOBAL_CONFIG_FCS_STRIP, BGX_CMR_RX_DMAC_CAM, BGX_CMR_RX_LMACS, BGX_CMR_RX_LMACS_LMACS_SET, BGX_CMR_RX_STEERING, BGX_CMR_TX_LMACS, BGX_CMR_TX_LMACS_LMACS_SET, BGX_LMAC, txnic_bgx::count, txnic_lmac_type::lane_to_sds, readq(), txnic_bgx::regs, TXNIC_NUM_DMAC, TXNIC_NUM_STEERING, type, txnic_bgx::type, and writeq().

Referenced by txnic_bgx_probe().

◆ txnic_bgx_mac()

static void txnic_bgx_mac ( struct txnic_lmac lmac)
static

Get MAC address.

Parameters
lmacLogical MAC

Definition at line 1495 of file thunderx.c.

1495  {
1496  struct txnic_bgx *bgx = lmac->bgx;
1497  unsigned int lmac_idx = TXNIC_LMAC_IDX ( lmac->idx );
1498  uint64_t mac;
1499  EFI_STATUS efirc;
1500  int rc;
1501 
1502  /* Extract MAC from Board Configuration protocol, if available */
1503  if ( txcfg ) {
1504  if ( ( efirc = txcfg->GetLmacProp ( txcfg, bgx->node, bgx->idx,
1505  lmac_idx, MAC_ADDRESS,
1506  sizeof ( mac ),
1507  &mac ) ) == 0 ) {
1508  lmac->mac.be64 = cpu_to_be64 ( mac );
1509  } else {
1510  rc = -EEFI ( efirc );
1511  DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/%d could not get "
1512  "MAC address: %s\n", bgx->node, bgx->idx,
1513  lmac->idx, strerror ( rc ) );
1514  }
1515  } else {
1516  DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/%d has no board "
1517  "configuration protocol\n", bgx->node, bgx->idx,
1518  lmac->idx );
1519  }
1520 
1521  /* Use random MAC address if none available */
1522  if ( ! lmac->mac.be64 ) {
1523  DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/%d has no MAC address\n",
1524  bgx->node, bgx->idx, lmac->idx );
1525  eth_random_addr ( lmac->mac.raw );
1526  }
1527 }
unsigned int idx
BGX index.
Definition: thunderx.h:931
static EFI_THUNDER_CONFIG_PROTOCOL * txcfg
Board configuration protocol.
Definition: thunderx.c:61
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
unsigned int node
Node ID.
Definition: thunderx.h:929
EFI_THUNDER_CONFIG_PROTOCOL_GET_LMAC_PROP GetLmacProp
Definition: thunderxcfg.h:151
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define TXNICCOL(x)
Debug colour for physical function and BGX messages.
Definition: thunderx.c:58
uint8_t raw[ETH_ALEN]
Definition: thunderx.h:901
A BGX Ethernet interface.
Definition: thunderx.h:923
#define TXNIC_LMAC_IDX(vnic_idx)
Calculate logical MAC index.
Definition: thunderx.h:622
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
#define cpu_to_be64(value)
Definition: byteswap.h:111
unsigned int idx
Virtual NIC index.
Definition: thunderx.h:913
union txnic_lmac_address mac
MAC address.
Definition: thunderx.h:916
void eth_random_addr(void *hw_addr)
Generate random Ethernet address.
Definition: ethernet.c:159
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition: thunderx.h:911

References txnic_lmac_address::be64, txnic_lmac::bgx, cpu_to_be64, DBGC, EEFI, eth_random_addr(), _EFI_THUNDER_CONFIG_PROTOCOL::GetLmacProp, txnic_lmac::idx, txnic_bgx::idx, txnic_bgx::lmac, mac, txnic_lmac::mac, MAC_ADDRESS, txnic_bgx::node, txnic_lmac_address::raw, rc, strerror(), txcfg, TXNIC_LMAC_IDX, and TXNICCOL.

Referenced by txnic_bgx_lmac_init().

◆ txnic_bgx_spu_init()

static void txnic_bgx_spu_init ( struct txnic_lmac lmac)
static

Initialise Super PHY Unit (SPU)

Parameters
lmacLogical MAC

Definition at line 1534 of file thunderx.c.

1534  {
1535  struct txnic_bgx *bgx = lmac->bgx;
1536 
1537  /* Reset PHY */
1540 
1541  /* Power down PHY */
1543 
1544  /* Configure training, if applicable */
1545  if ( bgx->training ) {
1546  writeq ( 0, ( lmac->regs + BGX_SPU_BR_PMD_LP_CUP ) );
1547  writeq ( 0, ( lmac->regs + BGX_SPU_BR_PMD_LD_CUP ) );
1548  writeq ( 0, ( lmac->regs + BGX_SPU_BR_PMD_LD_REP ) );
1550  ( lmac->regs + BGX_SPU_BR_PMD_CONTROL ) );
1551  }
1552 
1553  /* Disable forward error correction */
1554  writeq ( 0, ( lmac->regs + BGX_SPU_FEC_CONTROL ) );
1555 
1556  /* Disable autonegotiation */
1557  writeq ( 0, ( lmac->regs + BGX_SPU_AN_CONTROL ) );
1558 
1559  /* Power up PHY */
1560  writeq ( 0, ( lmac->regs + BGX_SPU_CONTROL1 ) );
1561 }
#define BGX_SPU_FEC_CONTROL
SPU forward error correction control.
Definition: thunderx.h:847
#define BGX_SPU_AN_CONTROL
SPU autonegotation control.
Definition: thunderx.h:850
#define BGX_SPU_BR_PMD_LD_REP
SPU local device status report.
Definition: thunderx.h:844
#define BGX_SPU_CONTROL1
SPU control 1.
Definition: thunderx.h:799
#define BGX_SPU_RESET_DELAY_MS
SPU reset delay.
Definition: thunderx.h:804
void * regs
Registers.
Definition: thunderx.h:909
#define BGX_SPU_BR_PMD_CONTROL_TRAIN_EN
Definition: thunderx.h:832
#define BGX_SPU_BR_PMD_LD_CUP
SPU local device coefficient update.
Definition: thunderx.h:841
#define BGX_SPU_BR_PMD_LP_CUP
SPU link partner coefficient update.
Definition: thunderx.h:838
A BGX Ethernet interface.
Definition: thunderx.h:923
#define BGX_SPU_BR_PMD_CONTROL
SPU BASE-R link training control.
Definition: thunderx.h:831
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define BGX_SPU_CONTROL1_LO_PWR
Definition: thunderx.h:801
#define BGX_SPU_CONTROL1_RESET
Definition: thunderx.h:800
int training
Link training is in use.
Definition: thunderx.h:938
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition: thunderx.h:911

References txnic_lmac::bgx, BGX_SPU_AN_CONTROL, BGX_SPU_BR_PMD_CONTROL, BGX_SPU_BR_PMD_CONTROL_TRAIN_EN, BGX_SPU_BR_PMD_LD_CUP, BGX_SPU_BR_PMD_LD_REP, BGX_SPU_BR_PMD_LP_CUP, BGX_SPU_CONTROL1, BGX_SPU_CONTROL1_LO_PWR, BGX_SPU_CONTROL1_RESET, BGX_SPU_FEC_CONTROL, BGX_SPU_RESET_DELAY_MS, txnic_bgx::lmac, mdelay(), txnic_lmac::regs, txnic_bgx::training, and writeq().

Referenced by txnic_bgx_lmac_init().

◆ txnic_bgx_lmac_init()

static void txnic_bgx_lmac_init ( struct txnic_bgx bgx,
unsigned int  lmac_idx 
)
static

Initialise LMAC.

Parameters
bgxBGX Ethernet interface
lmac_idxLMAC index

Definition at line 1569 of file thunderx.c.

1570  {
1571  struct txnic_lmac *lmac = &bgx->lmac[lmac_idx];
1572  uint64_t config;
1573 
1574  /* Record associated BGX */
1575  lmac->bgx = bgx;
1576 
1577  /* Set register base address (already mapped) */
1578  lmac->regs = ( bgx->regs + BGX_LMAC ( lmac_idx ) );
1579 
1580  /* Calculate virtual NIC index */
1581  lmac->idx = TXNIC_VNIC_IDX ( bgx->idx, lmac_idx );
1582 
1583  /* Set MAC address */
1584  txnic_bgx_mac ( lmac );
1585 
1586  /* Initialise PHY */
1587  txnic_bgx_spu_init ( lmac );
1588 
1589  /* Accept all multicasts and broadcasts */
1592  ( lmac->regs + BGX_CMR_RX_DMAC_CTL ) );
1593 
1594  /* Enable LMAC */
1595  config = readq ( lmac->regs + BGX_CMR_CONFIG );
1596  config |= ( BGX_CMR_CONFIG_ENABLE |
1599  writeq ( config, ( lmac->regs + BGX_CMR_CONFIG ) );
1600 }
unsigned int idx
BGX index.
Definition: thunderx.h:931
#define BGX_CMR_CONFIG
CMR configuration.
Definition: thunderx.h:668
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
#define BGX_CMR_RX_DMAC_CTL_MCST_MODE_ACCEPT
Definition: thunderx.h:717
A Logical MAC (LMAC)
Definition: thunderx.h:907
unsigned long long uint64_t
Definition: stdint.h:13
void * regs
Registers.
Definition: thunderx.h:909
#define BGX_CMR_RX_DMAC_CTL_BCST_ACCEPT
Definition: thunderx.h:719
#define TXNIC_VNIC_IDX(bgx_idx, lmac_idx)
Calculate virtual NIC index.
Definition: thunderx.h:605
static void txnic_bgx_mac(struct txnic_lmac *lmac)
Get MAC address.
Definition: thunderx.c:1495
#define BGX_CMR_CONFIG_DATA_PKT_RX_EN
Definition: thunderx.h:670
void * regs
Registers.
Definition: thunderx.h:925
#define BGX_LMAC(lm)
Per-LMAC registers.
Definition: thunderx.h:665
static void txnic_bgx_spu_init(struct txnic_lmac *lmac)
Initialise Super PHY Unit (SPU)
Definition: thunderx.c:1534
struct txnic_lmac lmac[TXNIC_NUM_LMAC]
Logical MACs.
Definition: thunderx.h:946
#define BGX_CMR_CONFIG_DATA_PKT_TX_EN
Definition: thunderx.h:671
#define BGX_CMR_CONFIG_ENABLE
Definition: thunderx.h:669
unsigned int idx
Virtual NIC index.
Definition: thunderx.h:913
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#define BGX_CMR_RX_DMAC_CTL
CMR destination MAC control.
Definition: thunderx.h:715
struct txnic_bgx * bgx
Containing BGX Ethernet interface.
Definition: thunderx.h:911

References txnic_lmac::bgx, BGX_CMR_CONFIG, BGX_CMR_CONFIG_DATA_PKT_RX_EN, BGX_CMR_CONFIG_DATA_PKT_TX_EN, BGX_CMR_CONFIG_ENABLE, BGX_CMR_RX_DMAC_CTL, BGX_CMR_RX_DMAC_CTL_BCST_ACCEPT, BGX_CMR_RX_DMAC_CTL_MCST_MODE_ACCEPT, BGX_LMAC, txnic_lmac::idx, txnic_bgx::idx, txnic_bgx::lmac, readq(), txnic_lmac::regs, txnic_bgx::regs, txnic_bgx_mac(), txnic_bgx_spu_init(), TXNIC_VNIC_IDX, and writeq().

Referenced by txnic_bgx_probe().

◆ txnic_bgx_probe()

static int txnic_bgx_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 1608 of file thunderx.c.

1608  {
1609  struct txnic_bgx *bgx;
1610  struct txnic_pf *pf;
1611  unsigned long membase;
1612  unsigned int i;
1613  int type;
1614  int rc;
1615 
1616  /* Allocate and initialise structure */
1617  bgx = zalloc ( sizeof ( *bgx ) );
1618  if ( ! bgx ) {
1619  rc = -ENOMEM;
1620  goto err_alloc;
1621  }
1622  bgx->pci = pci;
1623  pci_set_drvdata ( pci, bgx );
1624 
1625  /* Get base address */
1626  membase = pciea_bar_start ( pci, PCIEA_BEI_BAR_0 );
1627 
1628  /* Calculate node ID and index */
1629  bgx->node = txnic_address_node ( membase );
1630  bgx->idx = txnic_address_bgx ( membase );
1631 
1632  /* Fix up PCI device */
1633  adjust_pci_device ( pci );
1634 
1635  /* Map registers */
1636  bgx->regs = ioremap ( membase, TXNIC_BGX_BAR_SIZE );
1637  if ( ! bgx->regs ) {
1638  rc = -ENODEV;
1639  goto err_ioremap;
1640  }
1641 
1642  /* Detect LMAC type */
1643  if ( ( type = txnic_bgx_detect ( bgx ) ) < 0 ) {
1644  rc = type;
1645  goto err_detect;
1646  }
1647  DBGC ( TXNICCOL ( bgx ), "TXNIC %d/%d/* BGX %s at %#lx %dx %s%s\n",
1648  bgx->node, bgx->idx, pci->dev.name, membase, bgx->count,
1649  bgx->type->name, ( bgx->training ? "(training)" : "" ) );
1650 
1651  /* Initialise interface */
1652  txnic_bgx_init ( bgx, type );
1653 
1654  /* Initialise all LMACs */
1655  for ( i = 0 ; i < bgx->count ; i++ )
1656  txnic_bgx_lmac_init ( bgx, i );
1657 
1658  /* Add to list of BGX devices */
1659  list_add_tail ( &bgx->list, &txnic_bgxs );
1660 
1661  /* Probe all LMACs, if applicable */
1662  list_for_each_entry ( pf, &txnic_pfs, list ) {
1663  if ( pf->node != bgx->node )
1664  continue;
1665  if ( ( rc = txnic_lmac_probe_all ( pf, bgx ) ) != 0 )
1666  goto err_probe;
1667  }
1668 
1669  return 0;
1670 
1671  if ( bgx->pf )
1673  list_del ( &bgx->list );
1674  err_probe:
1675  err_detect:
1676  iounmap ( bgx->regs );
1677  err_ioremap:
1678  free ( bgx );
1679  err_alloc:
1680  return rc;
1681 }
unsigned int idx
BGX index.
Definition: thunderx.h:931
static void txnic_bgx_init(struct txnic_bgx *bgx, unsigned int type)
Initialise BGX Ethernet interface.
Definition: thunderx.c:1452
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A physical function.
Definition: thunderx.h:579
unsigned int count
Number of LMACs.
Definition: thunderx.h:936
uint8_t type
Type.
Definition: ena.h:16
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:75
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
struct device dev
Generic device.
Definition: pci.h:189
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
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
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
unsigned int node
Node ID.
Definition: thunderx.h:929
struct pci_device * pci
PCI device.
Definition: thunderx.h:927
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
static void txnic_lmac_remove_all(struct txnic_pf *pf, struct txnic_bgx *bgx)
Remove all LMACs on a BGX Ethernet interface.
Definition: thunderx.c:1218
Standard BAR 0.
Definition: pciea.h:32
static void txnic_bgx_lmac_init(struct txnic_bgx *bgx, unsigned int lmac_idx)
Initialise LMAC.
Definition: thunderx.c:1569
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct list_head list
List of physical functions.
Definition: thunderx.h:593
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
void * regs
Registers.
Definition: thunderx.h:925
const char * name
Name.
Definition: thunderx.h:890
#define TXNICCOL(x)
Debug colour for physical function and BGX messages.
Definition: thunderx.c:58
struct txnic_bgx * bgx[TXNIC_NUM_BGX]
BGX Ethernet interfaces (if known)
Definition: thunderx.h:595
#define ENODEV
No such device.
Definition: errno.h:509
A BGX Ethernet interface.
Definition: thunderx.h:923
struct txnic_lmac_type * type
LMAC type.
Definition: thunderx.h:934
static unsigned int txnic_address_node(uint64_t addr)
Calculate node ID.
Definition: thunderx.h:54
unsigned int node
Node ID.
Definition: thunderx.h:585
unsigned long pciea_bar_start(struct pci_device *pci, unsigned int bei)
Find the start of a PCI Enhanced Allocation BAR equivalent.
Definition: pciea.c:130
struct pci_device * pci
PCI device.
Definition: thunderx.h:583
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define TXNIC_BGX_BAR_SIZE
BGX BAR size.
Definition: thunderx.h:34
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
int training
Link training is in use.
Definition: thunderx.h:938
struct list_head list
List of BGX Ethernet interfaces.
Definition: thunderx.h:941
static int txnic_lmac_probe_all(struct txnic_pf *pf, struct txnic_bgx *bgx)
Probe all LMACs on a BGX Ethernet interface.
Definition: thunderx.c:1178
static int txnic_bgx_detect(struct txnic_bgx *bgx)
Detect BGX Ethernet interface LMAC type.
Definition: thunderx.c:1405
static unsigned int txnic_address_bgx(uint64_t addr)
Calculate BGX Ethernet interface index.
Definition: thunderx.h:66

References adjust_pci_device(), txnic_pf::bgx, txnic_bgx::count, DBGC, pci_device::dev, ENODEV, ENOMEM, free, txnic_bgx::idx, ioremap(), iounmap(), txnic_pf::list, txnic_bgx::list, list_add_tail, list_del, list_for_each_entry, device::name, txnic_lmac_type::name, txnic_pf::node, txnic_bgx::node, txnic_pf::pci, txnic_bgx::pci, pci_set_drvdata(), pciea_bar_start(), PCIEA_BEI_BAR_0, txnic_bgx::pf, rc, txnic_bgx::regs, txnic_bgx::training, txnic_address_bgx(), txnic_address_node(), TXNIC_BGX_BAR_SIZE, txnic_bgx_detect(), txnic_bgx_init(), txnic_bgx_lmac_init(), txnic_lmac_probe_all(), txnic_lmac_remove_all(), TXNICCOL, type, txnic_bgx::type, and zalloc().

◆ txnic_bgx_remove()

static void txnic_bgx_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 1688 of file thunderx.c.

1688  {
1689  struct txnic_bgx *bgx = pci_get_drvdata ( pci );
1690 
1691  /* Remove all LMACs, if applicable */
1692  if ( bgx->pf )
1693  txnic_lmac_remove_all ( bgx->pf, bgx );
1694 
1695  /* Remove from list of BGX devices */
1696  list_del ( &bgx->list );
1697 
1698  /* Unmap registers */
1699  iounmap ( bgx->regs );
1700 
1701  /* Free BGX device */
1702  free ( bgx );
1703 }
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct txnic_pf * pf
Physical function (if known)
Definition: thunderx.h:943
struct pci_device * pci
PCI device.
Definition: thunderx.h:927
static void txnic_lmac_remove_all(struct txnic_pf *pf, struct txnic_bgx *bgx)
Remove all LMACs on a BGX Ethernet interface.
Definition: thunderx.c:1218
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * regs
Registers.
Definition: thunderx.h:925
A BGX Ethernet interface.
Definition: thunderx.h:923
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348
void iounmap(volatile const void *io_addr)
Unmap I/O address.
struct list_head list
List of BGX Ethernet interfaces.
Definition: thunderx.h:941

References free, iounmap(), txnic_bgx::list, list_del, txnic_bgx::pci, pci_get_drvdata(), txnic_bgx::pf, txnic_bgx::regs, and txnic_lmac_remove_all().

Variable Documentation

◆ txcfg

Board configuration protocol.

Definition at line 61 of file thunderx.c.

Referenced by txnic_bgx_mac().

◆ txnic_lmac_operations

struct net_device_operations txnic_lmac_operations
static
Initial value:
= {
.open = txnic_lmac_open,
.close = txnic_lmac_close,
.transmit = txnic_lmac_transmit,
.poll = txnic_lmac_poll,
}
static int txnic_lmac_open(struct net_device *netdev)
Open network device.
Definition: thunderx.c:936
static void txnic_lmac_close(struct net_device *netdev)
Close network device.
Definition: thunderx.c:1032
static void txnic_lmac_poll(struct net_device *netdev)
Poll network device.
Definition: thunderx.c:1066
static int txnic_lmac_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: thunderx.c:1053

Network device operations.

Definition at line 1078 of file thunderx.c.

Referenced by txnic_lmac_probe().

◆ txnic_pf_ids

struct pci_device_id txnic_pf_ids[]
static
Initial value:
= {
PCI_ROM ( 0x177d, 0xa01e, "thunder-pf", "ThunderX NIC PF", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

NIC physical function PCI device IDs.

Definition at line 1356 of file thunderx.c.

◆ __pci_driver

struct pci_driver txnic_bgx_driver __pci_driver
Initial value:
= {
.ids = txnic_pf_ids,
.id_count = ( sizeof ( txnic_pf_ids ) / sizeof ( txnic_pf_ids[0] ) ),
.probe = txnic_pf_probe,
}
static struct pci_device_id txnic_pf_ids[]
NIC physical function PCI device IDs.
Definition: thunderx.c:1356
static void txnic_pf_remove(struct pci_device *pci)
Remove PCI device.
Definition: thunderx.c:1335
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static int txnic_pf_probe(struct pci_device *pci)
Probe PCI device.
Definition: thunderx.c:1248

NIC physical function PCI driver.

BGX PCI driver.

Definition at line 1361 of file thunderx.c.

◆ txnic_lmac_types

Initial value:
= {
.name = "XAUI",
.count = 1,
.lane_to_sds = 0xe4,
},
.name = "RXAUI",
.count = 2,
.lane_to_sds = 0x0e04,
},
.name = "10GBASE-R",
.count = 4,
.lane_to_sds = 0x00000000,
},
.name = "40GBASE-R",
.count = 1,
.lane_to_sds = 0xe4,
},
}
40GBASE-R
Definition: thunderx.h:884
10GBASE-R
Definition: thunderx.h:883
10GBASE-X/XAUI or DXAUI
Definition: thunderx.h:881
Reduced XAUI.
Definition: thunderx.h:882

LMAC types.

Definition at line 1376 of file thunderx.c.

◆ txnic_bgx_ids

struct pci_device_id txnic_bgx_ids[]
static
Initial value:
= {
PCI_ROM ( 0x177d, 0xa026, "thunder-bgx", "ThunderX BGX", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

BGX PCI device IDs.

Definition at line 1706 of file thunderx.c.