59 default:
return "<UNKNOWN>";
93 DBGC ( ena,
"ENA %p timed out waiting for reset status %#08x " 94 "(got %#08x)\n", ena, expected, stat );
203 if ( ! ena->
aq.
req ) {
212 sizeof ( ena->
acq.
rsp[0] ) );
215 sizeof ( ena->
aq.
req[0] ) );
217 DBGC ( ena,
"ENA %p AQ [%08lx,%08lx) ACQ [%08lx,%08lx)\n",
250 DBGC ( ena,
"ENA %p AQ and ACQ destroyed\n", ena );
268 memset ( ( ( (
void * ) req ) +
sizeof ( req->header ) ), 0,
269 ( sizeof ( *req ) -
sizeof ( req->header ) ) );
270 req->header.id = ena->
aq.
prod;
299 DBGC2 ( ena,
"ENA %p admin request %#x:\n",
314 DBGC2 ( ena,
"ENA %p admin response %#x:\n",
324 if ( (*rsp)->header.id != req->
header.
id ) {
325 DBGC ( ena,
"ENA %p admin response %#x mismatch:\n",
332 if ( (*rsp)->header.status != 0 ) {
333 DBGC ( ena,
"ENA %p admin response %#x status %d:\n",
335 (*rsp)->header.status );
345 DBGC ( ena,
"ENA %p timed out waiting for admin request %#x:\n",
403 DBGC ( ena,
"ENA %p AENQ [%08lx,%08lx)\n",
409 goto err_set_aenq_config;
434 DBGC ( ena,
"ENA %p AENQ destroyed\n", ena );
488 for ( i = 0 ; i < sq->
count ; i++ )
491 DBGC ( ena,
"ENA %p %s SQ%d at [%08lx,%08lx) fill %d db +%04x CQ%d\n",
529 DBGC ( ena,
"ENA %p %s SQ%d destroyed\n",
564 DBGC ( ena,
"ENA %p CQ%d creation failed (broken firmware?)\n",
575 DBGC ( ena,
"ENA %p CQ%d requested %d actual %d\n",
583 DBGC ( ena,
"ENA %p CQ%d at [%08lx,%08lx) db +%04x\n",
618 DBGC ( ena,
"ENA %p CQ%d destroyed\n", ena, cq->
id );
695 DBGC ( ena,
"ENA %p MAC %s MTU %zd\n",
754 stats = &
rsp->get_stats;
755 DBGC ( ena,
"ENA %p TX bytes %#llx packets %#llx\n", ena,
758 DBGC ( ena,
"ENA %p RX bytes %#llx packets %#llx drops %#llx\n", ena,
784 unsigned int refilled = 0;
821 DBGC2 ( ena,
"ENA %p RX %d at [%08llx,%08llx)\n", ena,
id,
822 ( (
unsigned long long )
address ),
917 DBGC ( ena,
"ENA %p out of transmit descriptors\n", ena );
947 DBGC2 ( ena,
"ENA %p TX %d at [%08llx,%08llx)\n", ena,
id,
948 ( (
unsigned long long )
address ),
991 DBGC2 ( ena,
"ENA %p TX %d complete\n", ena,
id );
1037 DBGC2 ( ena,
"ENA %p RX %d complete (length %zd)\n",
1093 DBGC ( ena,
"ENA %p found no PCI bridge\n", ena );
1099 DBGC ( ena,
"ENA %p at " PCI_FMT " may not be only device " 1136 memset ( ena, 0,
sizeof ( *ena ) );
1156 if ( ! ena->
regs ) {
1177 DBGC2 ( ena,
"ENA %p host info:\n", ena );
1186 goto err_create_admin;
1190 goto err_create_async;
1194 goto err_set_host_attributes;
1198 goto err_get_device_attributes;
1202 goto err_register_netdev;
1212 err_register_netdev:
1213 err_get_device_attributes:
1214 err_set_host_attributes:
1264 PCI_ROM ( 0x1d0f, 0xec20,
"ena-vf",
"ENA VF", 0 ),
1265 PCI_ROM ( 0x1d0f, 0xec21,
"ena-vf-llq",
"ENA VF (LLQ)", 0 ),
const char product_short_name[]
Product short name string.
#define PCI_FUNC(busdevfn)
struct ena_aq aq
Admin queue.
static void ena_refill_rx(struct net_device *netdev)
Refill receive queue.
#define ENA_ACQ_COUNT
Number of admin completion queue entries.
struct ena_tx_sqe * tx
Transmit submission queue entries.
static void ena_destroy_admin(struct ena_nic *ena)
Destroy admin queues.
struct ena_qp rx
Receive queue.
unsigned long membase
Memory base.
#define ENA_CTRL
Device control register.
struct arbelprm_rc_send_wqe rc
static void ena_remove(struct pci_device *pci)
Remove PCI device.
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
#define ENA_BASE_HI
Base address high register offset.
#define iob_put(iobuf, len)
#define ENA_RX_COUNT
Number of receive queue entries.
#define ENA_AQ_COUNT
Number of admin queue entries.
uint8_t rx_ids[ENA_RX_COUNT]
Receive buffer IDs.
#define ENA_AENQ_CONFIG
Async event notification queue config.
static void ena_poll_tx(struct net_device *netdev)
Poll for completed transmissions.
uint8_t mask
Actual number of entries minus one.
size_t len
Total length of entries.
unsigned int doorbell
Doorbell register offset.
uint8_t count
Number of entries.
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
#define ENA_GET_FEATURE
Get feature.
#define ENA_HOST_ATTRIBUTES
Host attributes.
#define ENA_CREATE_CQ
Create completion queue.
#define ENA_ACQ_BASE
Admin completion queue base address register.
unsigned int prod
Producer counter.
uint16_t id
Completion queue identifier.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct pci_device_id * ids
PCI ID table.
uint64_t address
Base address.
struct ena_tx_cqe * tx
Transmit completion queue entries.
size_t mtu
Maximum transmission unit length.
uint8_t size
Entry size (in 32-bit words)
static int ena_get_device_attributes(struct net_device *netdev)
Get device attributes.
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
static int ena_get_stats(struct ena_nic *ena)
Get statistics (for debugging)
Transmit submission queue entry.
struct ena_qp tx
Transmit queue.
struct ena_set_feature_req set_feature
Set feature.
uint16_t count
Number of entries.
union ena_sq::@39 sqe
Entries.
struct ena_aenq aenq
Async event notification queue.
#define ENA_SQE_CPL
Request completion.
Transmit completion queue entry.
unsigned long long uint64_t
uint8_t id
Request identifier.
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
static int ena_open(struct net_device *netdev)
Open network device.
#define PCI_BASE_ADDRESS_0
union ena_cq::@40 cqe
Entries.
#define cpu_to_le64(value)
uint16_t count
Number of entries.
uint8_t direction
Direction.
uint64_t rx_drops
Receive drop count.
#define ENA_AQ_BASE
Admin queue base address register.
#define ENA_GET_STATS
Get statistics.
#define PAGE_SIZE
Page size.
static void ena_close(struct net_device *netdev)
Close network device.
uint8_t size
Entry size (in 32-bit words)
static int ena_create_qp(struct ena_nic *ena, struct ena_qp *qp)
Create queue pair.
#define ENA_ACQ_CAPS
Admin completion queue capabilities register.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
struct device dev
Generic device.
#define ENA_CTRL_RESET
Reset.
uint32_t enabled
Bitmask of enabled AENQ groups (host -> device)
#define ENA_TX_COUNT
Number of transmit queue entries.
#define ENA_AENQ_BASE
Async event notification queue base address register.
uint64_t address
Base address.
#define ENOTSUP
Operation not supported.
unsigned int doorbell
Doorbell register offset.
Dynamic memory allocation.
uint8_t tx_ids[ENA_TX_COUNT]
Transmit buffer IDs.
union ena_feature feature
Feature.
static int ena_reset_wait(struct ena_nic *ena, uint32_t expected)
Wait for reset operation to be acknowledged.
static int ena_set_host_attributes(struct ena_nic *ena)
Set host attributes.
static int ena_destroy_qp(struct ena_nic *ena, struct ena_qp *qp)
Destroy queue pair.
static void ena_empty_rx(struct ena_nic *ena)
Discard unused receive I/O buffers.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
#define ENA_DEVICE_ATTRIBUTES
Device attributes.
static int ena_destroy_sq(struct ena_nic *ena, struct ena_sq *sq)
Destroy submission queue.
size_t len
Total length of entries.
#define ENA_CAPS(count, size)
Capability register value.
uint16_t id
Request identifier.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static signed char phys[4]
uint64_t tx_packets
Transmit packet count.
#define EILSEQ
Illegal byte sequence.
uint16_t id
Request identifier.
uint8_t id
Feature identifier.
#define ENA_BASE_LO
Base address low register offset.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
#define ENA_STAT_RESET
Reset in progress.
static void ena_set_caps(struct ena_nic *ena, unsigned int offset, unsigned int count, size_t size)
Set queue capabilities.
struct pci_bridge * pcibridge_find(struct pci_device *pci)
Find bridge attached to a PCI device.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define ENA_TX_CQE_ID(id)
Transmit completion request identifier.
union ena_aq_req * req
Requests.
#define ENA_AENQ_CAPS
Async event notification queue capabilities register.
uint64_t address
Base address.
void * priv
Driver private data.
static int ena_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
uint16_t cq_id
Completion queue identifier.
unsigned int cons
Consumer counter.
static int ena_set_aenq_config(struct ena_nic *ena, uint32_t enabled)
Set async event notification queue config.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct pci_device * pci
PCI device.
unsigned int cons
Consumer counter.
#define ENA_CQE_PHASE
Completion queue ownership phase flag.
static struct net_device * netdev
uint8_t size
Entry size (in 32-bit words)
uint16_t count
Number of entries.
static int ena_probe(struct pci_device *pci)
Probe PCI device.
#define ENA_STATS_TYPE_BASIC
Basic statistics.
#define ENA_AENQ_COUNT
Number of async event notification queue entries.
struct ena_aenq_event * evt
Events.
#define ENA_SQE_FIRST
This is the first descriptor.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
uint8_t id
Feature identifier.
struct ena_get_stats_req get_stats
Get statistics.
static struct net_device_operations ena_operations
ENA network device operations.
#define cpu_to_le32(value)
uint8_t id
Request identifier.
struct ena_create_cq_req create_cq
Create completion queue.
struct ena_destroy_cq_req destroy_cq
Destroy completion queue.
#define ENOTCONN
The socket is not connected.
uint8_t direction
Direction.
#define ENA_MSIX_NONE
Empty MSI-X vector.
static void ena_poll(struct net_device *netdev)
Poll for completed and received packets.
struct ena_rx_cqe * rx
Receive completion queue entries.
struct ena_cq cq
Completion queue.
#define ENA_HOST_INFO_VERSION_WTF
Driver version.
uint32_t vector
MSI-X vector.
static int ena_create_admin(struct ena_nic *ena)
Create admin queues.
#define ENA_ACQ_PHASE
Admin completion queue ownership phase flag.
#define PCI_FMT
PCI device debug message format.
#define PCI_SLOT(busdevfn)
static int ena_create_cq(struct ena_nic *ena, struct ena_cq *cq)
Create completion queue.
int register_netdev(struct net_device *netdev)
Register network device.
#define ENA_SQE_LAST
This is the last descriptor.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
#define ENA_AQ_DB
Admin queue doorbell register.
#define ENA_AQ_CAPS
Admin queue capabilities register.
static int ena_admin(struct ena_nic *ena, union ena_aq_req *req, union ena_acq_rsp **rsp)
Issue admin queue request.
#define ENODEV
No such device.
#define ENA_ALIGN
Queue alignment.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
uint16_t id
Completion queue identifier.
const char product_version[]
Product version string.
#define ENA_CREATE_SQ
Create submission queue.
#define ENA_AQ_PHASE
Admin queue ownership phase flag.
#define ENA_BAR_SIZE
BAR size.
static void ena_destroy_async(struct ena_nic *ena)
Destroy async event notification queue.
uint8_t actual
Actual number of entries.
static void ena_poll_rx(struct net_device *netdev)
Poll for received packets.
#define ENA_STATS_SCOPE_ETH
Ethernet statistics.
A PCI device ID list entry.
#define le16_to_cpu(value)
uint8_t requested
Requested number of entries.
#define ENA_DESTROY_CQ
Destroy completion queue.
struct ena_acq acq
Admin completion queue.
static struct xen_remove_from_physmap * remove
uint16_t id
Submission queue identifier.
struct io_buffer * rx_iobuf[ENA_RX_COUNT]
Receive I/O buffers, indexed by buffer ID.
Network device operations.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
Network device management.
uint8_t max
Maximum fill level.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
struct ena_get_feature_req get_feature
Get feature.
struct arbelprm_qp_db_record qp
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
struct ena_host_info * info
Host info.
#define ENA_SET_FEATURE
Set feature.
struct ena_sq sq
Submission queue.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint64_t rx_bytes
Receive byte count.
#define ENOBUFS
No buffer space available.
uint16_t id
Request identifier.
Receive submission queue entry.
int(* probe)(struct pci_device *pci)
Probe device.
#define ENA_DEVICE_MINE
My device.
void * data
Start of data.
Receive completion queue entry.
uint8_t direction
Direction.
Admin completion queue response.
#define EIO
Input/output error.
#define ENA_RESET_MAX_WAIT_MS
Maximum time to wait for reset.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
#define PCI_ARGS(pci)
PCI device debug message arguments.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
#define cpu_to_le16(value)
union ena_acq_rsp * rsp
Responses.
uint64_t tx_bytes
Transmit byte count.
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define ENA_SQE_PHASE
Submission queue ownership phase flag.
static int ena_create_async(struct ena_nic *ena)
Create async event notification queue.
union ena_feature feature
Feature.
uint16_t id
Submission queue identifier.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
static union ena_aq_req * ena_admin_req(struct ena_nic *ena)
Get next available admin queue request.
static void ena_set_base(struct ena_nic *ena, unsigned int offset, void *base)
Set queue base address.
struct ena_destroy_sq_req destroy_sq
Destroy submission queue.
static struct pci_device_id ena_nics[]
ENA PCI device IDs.
uint16_t offset
Offset to command line.
struct ena_rx_sqe * rx
Receive submission queue entries.
uint8_t fill
Fill level (limited to completion queue size)
#define ENA_ADMIN_MAX_WAIT_MS
Maximum time to wait for admin requests.
struct pci_driver ena_driver __pci_driver
ENA PCI driver.
static const char * ena_direction(unsigned int direction)
Get direction name (for debugging)
const char product_name[]
Product name string.
static int ena_destroy_cq(struct ena_nic *ena, struct ena_cq *cq)
Destroy completion queue.
struct ena_aq_header header
Header.
size_t max_pkt_len
Maximum packet length.
Amazon ENA network driver.
#define ENA_DESTROY_SQ
Destroy submission queue.
unsigned int prod
Producer counter.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define le64_to_cpu(value)
struct io_buffer * tx_iobuf[ENA_TX_COUNT]
Transmit I/O buffers, indexed by buffer ID.
uint64_t rx_packets
Receive packet count.
static void ena_clear_caps(struct ena_nic *ena, unsigned int offset)
Clear queue capabilities.
#define ENA_STAT
Device status register.
static int ena_membase(struct ena_nic *ena, struct pci_device *pci)
Assign memory BAR.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
#define ENA_HOST_INFO_SPEC_2_0
ENA specification version.
#define ETIMEDOUT
Connection timed out.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
uint8_t direction
Direction.
#define ENA_RX_FILL
Receive queue maximum fill level.
#define ENA_HOST_INFO_TYPE_IPXE
Operating system type.
struct ena_create_sq_req create_sq
Create submission queue.
static int ena_reset(struct ena_nic *ena)
Reset hardware.
static int ena_create_sq(struct ena_nic *ena, struct ena_sq *sq, struct ena_cq *cq)
Create submission queue.
uint16_t device
Device ID.
uint32_t membase
Memory base.
void * memset(void *dest, int character, size_t len) __nonnull