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",
218 ena, virt_to_phys ( ena->
aq.
req ),
219 ( virt_to_phys ( ena->
aq.
req ) + aq_len ),
220 virt_to_phys ( ena->
acq.
rsp ),
221 ( virt_to_phys ( ena->
acq.
rsp ) + acq_len ) );
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",
301 DBGC2_HDA ( ena, virt_to_phys ( req ), req,
sizeof ( *req ) );
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",
348 DBGC_HDA ( ena, virt_to_phys ( req ), req,
sizeof ( *req ) );
375 DBGC ( ena,
"ENA %p could not set AENQ configuration: %s\n",
406 DBGC ( ena,
"ENA %p AENQ [%08lx,%08lx)\n",
407 ena, virt_to_phys ( ena->
aenq.
evt ),
408 ( virt_to_phys ( ena->
aenq.
evt ) + aenq_len ) );
412 goto err_set_aenq_config;
437 DBGC ( ena,
"ENA %p AENQ destroyed\n", ena );
478 DBGC ( ena,
"ENA %p could not create %s SQ: %s\n",
505 for ( i = 0 ; i < sq->
count ; i++ )
508 DBGC ( ena,
"ENA %p %s SQ%d at ",
511 DBGC ( ena,
"LLQ [+%08zx,+%08zx)",
llqe,
514 DBGC ( ena,
"[%08lx,%08lx)", virt_to_phys ( sq->
sqe.
raw ),
515 ( virt_to_phys ( sq->
sqe.
raw ) + sq->
len ) );
517 DBGC ( ena,
" fill %d db +%04x CQ%d\n",
547 DBGC ( ena,
"ENA %p could not destroy %s SQ%d: %s\n",
556 DBGC ( ena,
"ENA %p %s SQ%d destroyed\n",
591 DBGC ( ena,
"ENA %p could not create CQ (broken firmware?): " 602 DBGC ( ena,
"ENA %p CQ%d requested %d actual %d\n",
610 DBGC ( ena,
"ENA %p CQ%d at [%08lx,%08lx) db +%04x\n",
611 ena, cq->
id, virt_to_phys ( cq->
cqe.
raw ),
640 DBGC ( ena,
"ENA %p could not destroy CQ%d: %s\n",
648 DBGC ( ena,
"ENA %p CQ%d destroyed\n", ena, cq->
id );
717 DBGC ( ena,
"ENA %p could not get device attributes: %s\n",
729 DBGC ( ena,
"ENA %p MAC %s MTU %zd features %#08x\n",
756 DBGC ( ena,
"ENA %p could not set host attributes: %s\n",
788 DBGC ( ena,
"ENA %p could not get LLQ configuration: %s\n",
800 DBGC ( ena,
"ENA %p LLQ supports %02x:%02x:%02x:%02x:%02x with %dx%d " 807 DBGC ( ena,
"ENA %p LLQ has no queues\n", ena );
811 DBGC ( ena,
"ENA %p LLQ does not support inline headers\n",
816 DBGC ( ena,
"ENA %p LLQ does not support 128-byte entries\n",
821 DBGC ( ena,
"ENA %p LLQ does not support two-descriptor " 831 DBGC ( ena,
"ENA %p LLQ enabling %02x:%02x:%02x:%02x:%02x\n",
847 DBGC ( ena,
"ENA %p could not set LLQ configuration: %s\n",
884 DBGC ( ena,
"ENA %p could not get statistics: %s\n",
890 stats = &
rsp->get_stats;
891 DBGC ( ena,
"ENA %p TX bytes %#llx packets %#llx\n", ena,
894 DBGC ( ena,
"ENA %p RX bytes %#llx packets %#llx drops %#llx\n", ena,
920 unsigned int refilled = 0;
957 DBGC2 ( ena,
"ENA %p RX %d at [%08llx,%08llx)\n", ena,
id,
958 ( (
unsigned long long )
address ),
1082 DBGC ( ena,
"ENA %p out of transmit descriptors\n", ena );
1127 src = ( (
const void * )
llqe );
1129 for ( i = 0 ; i < (
sizeof ( *llqe ) /
sizeof ( *src ) ); i++ )
1146 DBGC2 ( ena,
"ENA %p TX %d at [%08llx,%08llx)\n", ena,
id,
1147 ( (
unsigned long long )
address ),
1190 DBGC2 ( ena,
"ENA %p TX %d complete\n", ena,
id );
1236 DBGC2 ( ena,
"ENA %p RX %d complete (length %zd)\n",
1289 unsigned long *prefmembase,
1290 unsigned long *prefmemsize ) {
1304 DBGC ( ena,
"ENA %p found no PCI bridge\n", ena );
1312 DBGC ( ena,
"ENA %p at " PCI_FMT " may not be only device " 1321 DBGC ( ena,
"ENA %p at " PCI_FMT " claiming mem %08lx\n",
1329 DBGC ( ena,
"ENA %p at " PCI_FMT " claiming prefmem %08lx\n",
1346 unsigned long prefmembase;
1347 unsigned long prefmemsize;
1360 memset ( ena, 0,
sizeof ( *ena ) );
1376 &prefmemsize ) ) != 0 ) {
1382 if ( ! ena->
regs ) {
1388 if ( prefmemsize ) {
1394 DBGC ( ena,
"ENA %p has %ldkB of on-device memory\n",
1395 ena, ( prefmemsize >> 10 ) );
1414 DBGC2 ( ena,
"ENA %p host info:\n", ena );
1423 goto err_create_admin;
1427 goto err_create_async;
1431 goto err_set_host_attributes;
1435 goto err_get_device_attributes;
1445 goto err_register_netdev;
1455 err_register_netdev:
1456 err_get_device_attributes:
1457 err_set_host_attributes:
1514 PCI_ROM ( 0x1d0f, 0xec20,
"ena-vf",
"ENA VF", 0 ),
1515 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.
union ena_sq::@46 sqe
Entries.
#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.
uint8_t inlined
Maximum inline header length.
unsigned int doorbell
Doorbell register offset.
uint32_t stat
Completion status.
uint8_t count
Number of entries.
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
static int ena_llq_config(struct ena_nic *ena)
Configure low latency queues.
#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.
uint16_t mode
Acceleration mode.
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.
uint16_t size
Buffer size.
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.
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Get the size of a PCI BAR.
struct ena_set_feature_req set_feature
Set feature.
uint16_t count
Number of entries.
static int ena_membases(struct ena_nic *ena, struct pci_device *pci, unsigned long *prefmembase, unsigned long *prefmemsize)
Assign memory BARs.
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 int ena_open(struct net_device *netdev)
Open network device.
#define cpu_to_le64(value)
uint16_t count
Number of entries.
uint8_t direction
Direction.
uint64_t rx_drops
Receive drop count.
uint32_t llqe
LLQ descriptor ring offset.
#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.
#define ENA_MEM_BAR
On-device memory BAR.
struct device dev
Generic device.
#define ENA_CTRL_RESET
Reset.
uint16_t enabled
Single-entry bitmask of the enabled option value.
#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 ECANCELED
Operation canceled.
#define ENOTSUP
Operation not supported.
unsigned int doorbell
Doorbell register offset.
void pci_bar_set(struct pci_device *pci, unsigned int reg, unsigned long start)
Set the start of a PCI BAR.
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.
uint32_t features
Device features.
struct ena_llq_option desc
Descriptor counts.
#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.
uint8_t inlined
Inlined length.
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.
Headers are placed inline immediately after descriptors.
#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.
#define ENA_TX_SQE_META
This is a metadata entry.
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.
Use on-device memory (must be used in addition to host memory)
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)
static unsigned int count
Number of entries.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
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.
uint64_t prefmembase
Prefetchable memory base.
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.
struct ena_llq_option stride
Descriptor strides.
#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.
char * strerror(int errno)
Retrieve string representation of error number.
#define ENA_HOST_INFO_VERSION_WTF
Driver version.
uint32_t vector
MSI-X vector.
#define ENA_REGS_BAR
Register BAR.
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.
uint8_t inlined[96]
Inlined header data.
#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_REGS_SIZE
Register BAR size.
static void ena_destroy_async(struct ena_nic *ena)
Destroy async event notification queue.
uint8_t actual
Actual number of entries.
Low latency transmit queue bounce buffer.
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.
Two descriptors before inline headers.
Network device management.
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.
struct ena_tx_llqe * llq
Low latency queue bounce buffer.
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
struct ena_host_info * info
Host info.
void * llqe
Low latency queue base.
#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.
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
#define ENA_FEATURE_LLQ
Device supports low latency queues.
#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.
union ena_cq::@47 cqe
Entries.
void * data
Start of data.
Receive completion queue entry.
uint8_t direction
Direction.
Admin completion queue response.
#define EIO
Input/output error.
static void ena_cancel_tx(struct net_device *netdev)
Cancel uncompleted transmit I/O buffers.
#define ENA_RESET_MAX_WAIT_MS
Maximum time to wait for reset.
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
#define PCI_ARGS(pci)
PCI device debug message arguments.
struct ena_llq_option header
Header locations.
#define cpu_to_le16(value)
union ena_acq_rsp * rsp
Responses.
uint64_t tx_bytes
Transmit byte count.
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define ENA_SQE_PHASE
Submission queue ownership phase flag.
void * mem
On-device memory.
static int ena_create_async(struct ena_nic *ena)
Create async event notification queue.
struct ena_tx_sqe sqe
Transmit descriptor.
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 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.
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.
uint16_t offset
Offset to command line.
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.
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 ENA_LLQ_CONFIG
Low latency queue config.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
uint8_t direction
Direction.
uint16_t policy
Queue policy.
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
#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.
uint8_t inlined
Inlined length.
uint16_t device
Device ID.
uint32_t membase
Memory base.
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
void * memset(void *dest, int character, size_t len) __nonnull