4 * Copyright (c) 2015-2016 Amazon.com, Inc. or its affiliates.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _ENA_ETHDEV_H_
35 #define _ENA_ETHDEV_H_
41 #define ENA_REGS_BAR 0
44 #define ENA_MAX_NUM_QUEUES 128
45 #define ENA_DEFAULT_RING_SIZE (1024)
46 #define ENA_MIN_FRAME_LEN 64
47 #define ENA_NAME_MAX_LEN 20
48 #define ENA_PKT_MAX_BUFS 17
50 #define ENA_MMIO_DISABLE_REG_READ BIT(0)
59 struct ena_tx_buffer {
60 struct rte_mbuf *mbuf;
61 unsigned int tx_descs;
62 unsigned int num_of_bufs;
63 struct ena_com_buf bufs[ENA_PKT_MAX_BUFS];
70 enum ena_ring_type type;
71 enum ena_admin_placement_policy_type tx_mem_queue_type;
72 /* Holds the empty requests for TX OOO completions */
73 uint16_t *empty_tx_reqs;
75 struct ena_tx_buffer *tx_buffer_info; /* contex of tx packet */
76 struct rte_mbuf **rx_buffer_info; /* contex of rx packet */
78 unsigned int ring_size; /* number of tx/rx_buffer_info's entries */
80 struct ena_com_io_cq *ena_com_io_cq;
81 struct ena_com_io_sq *ena_com_io_sq;
83 struct ena_com_rx_buf_info ena_bufs[ENA_PKT_MAX_BUFS]
86 struct rte_mempool *mb_pool;
89 /* Max length PMD can push to device for LLQ */
90 uint8_t tx_max_header_size;
92 struct ena_adapter *adapter;
93 } __rte_cache_aligned;
95 enum ena_adapter_state {
96 ENA_ADAPTER_STATE_FREE = 0,
97 ENA_ADAPTER_STATE_INIT = 1,
98 ENA_ADAPTER_STATE_RUNNING = 2,
99 ENA_ADAPTER_STATE_STOPPED = 3,
100 ENA_ADAPTER_STATE_CONFIG = 4,
103 struct ena_driver_stats {
104 rte_atomic64_t ierrors;
105 rte_atomic64_t oerrors;
106 rte_atomic64_t rx_nombuf;
109 struct ena_stats_dev {
119 struct ena_stats_tx {
127 u64 linearize_failed;
134 struct ena_stats_rx {
143 u64 small_copy_len_pkt;
146 /* board specific private data structure */
148 /* OS defined structs */
149 struct rte_pci_device *pdev;
150 struct rte_eth_dev_data *rte_eth_dev_data;
151 struct rte_eth_dev *rte_dev;
153 struct ena_com_dev ena_dev __rte_cache_aligned;
156 struct ena_ring tx_ring[ENA_MAX_NUM_QUEUES] __rte_cache_aligned;
160 struct ena_ring rx_ring[ENA_MAX_NUM_QUEUES] __rte_cache_aligned;
168 char name[ENA_NAME_MAX_LEN];
169 u8 mac_addr[ETHER_ADDR_LEN];
174 struct ena_driver_stats *drv_stats;
175 enum ena_adapter_state state;
179 #endif /* _ENA_ETHDEV_H_ */