net/ena: perform Tx cleanup before sending packets
[dpdk.git] / drivers / net / ena / ena_ethdev.c
index e2f7213..ed3dd16 100644 (file)
@@ -21,7 +21,7 @@
 #include <ena_eth_io_defs.h>
 
 #define DRV_MODULE_VER_MAJOR   2
-#define DRV_MODULE_VER_MINOR   4
+#define DRV_MODULE_VER_MINOR   5
 #define DRV_MODULE_VER_SUBMINOR        0
 
 #define __MERGE_64B_H_L(h, l) (((uint64_t)h << 32) | l)
 
 #define ENA_PTYPE_HAS_HASH     (RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP)
 
-enum ethtool_stringset {
-       ETH_SS_TEST             = 0,
-       ETH_SS_STATS,
-};
-
 struct ena_stats {
        char name[ETH_GSTRING_LEN];
        int stat_offset;
@@ -93,19 +88,20 @@ static const struct ena_stats ena_stats_tx_strings[] = {
        ENA_STAT_TX_ENTRY(cnt),
        ENA_STAT_TX_ENTRY(bytes),
        ENA_STAT_TX_ENTRY(prepare_ctx_err),
-       ENA_STAT_TX_ENTRY(linearize),
-       ENA_STAT_TX_ENTRY(linearize_failed),
        ENA_STAT_TX_ENTRY(tx_poll),
        ENA_STAT_TX_ENTRY(doorbells),
        ENA_STAT_TX_ENTRY(bad_req_id),
        ENA_STAT_TX_ENTRY(available_desc),
+       ENA_STAT_TX_ENTRY(missed_tx),
 };
 
 static const struct ena_stats ena_stats_rx_strings[] = {
        ENA_STAT_RX_ENTRY(cnt),
        ENA_STAT_RX_ENTRY(bytes),
        ENA_STAT_RX_ENTRY(refill_partial),
-       ENA_STAT_RX_ENTRY(bad_csum),
+       ENA_STAT_RX_ENTRY(l3_csum_bad),
+       ENA_STAT_RX_ENTRY(l4_csum_bad),
+       ENA_STAT_RX_ENTRY(l4_csum_good),
        ENA_STAT_RX_ENTRY(mbuf_alloc_fail),
        ENA_STAT_RX_ENTRY(bad_desc_num),
        ENA_STAT_RX_ENTRY(bad_req_id),
@@ -116,13 +112,13 @@ static const struct ena_stats ena_stats_rx_strings[] = {
 #define ENA_STATS_ARRAY_TX     ARRAY_SIZE(ena_stats_tx_strings)
 #define ENA_STATS_ARRAY_RX     ARRAY_SIZE(ena_stats_rx_strings)
 
-#define QUEUE_OFFLOADS (DEV_TX_OFFLOAD_TCP_CKSUM |\
-                       DEV_TX_OFFLOAD_UDP_CKSUM |\
-                       DEV_TX_OFFLOAD_IPV4_CKSUM |\
-                       DEV_TX_OFFLOAD_TCP_TSO)
-#define MBUF_OFFLOADS (PKT_TX_L4_MASK |\
-                      PKT_TX_IP_CKSUM |\
-                      PKT_TX_TCP_SEG)
+#define QUEUE_OFFLOADS (RTE_ETH_TX_OFFLOAD_TCP_CKSUM |\
+                       RTE_ETH_TX_OFFLOAD_UDP_CKSUM |\
+                       RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |\
+                       RTE_ETH_TX_OFFLOAD_TCP_TSO)
+#define MBUF_OFFLOADS (RTE_MBUF_F_TX_L4_MASK |\
+                      RTE_MBUF_F_TX_IP_CKSUM |\
+                      RTE_MBUF_F_TX_TCP_SEG)
 
 /** Vendor ID used by Amazon devices */
 #define PCI_VENDOR_ID_AMAZON 0x1D0F
@@ -130,15 +126,31 @@ static const struct ena_stats ena_stats_rx_strings[] = {
 #define PCI_DEVICE_ID_ENA_VF           0xEC20
 #define PCI_DEVICE_ID_ENA_VF_RSERV0    0xEC21
 
-#define        ENA_TX_OFFLOAD_MASK     (\
-       PKT_TX_L4_MASK |         \
-       PKT_TX_IPV6 |            \
-       PKT_TX_IPV4 |            \
-       PKT_TX_IP_CKSUM |        \
-       PKT_TX_TCP_SEG)
+#define        ENA_TX_OFFLOAD_MASK     (RTE_MBUF_F_TX_L4_MASK |         \
+       RTE_MBUF_F_TX_IPV6 |            \
+       RTE_MBUF_F_TX_IPV4 |            \
+       RTE_MBUF_F_TX_IP_CKSUM |        \
+       RTE_MBUF_F_TX_TCP_SEG)
 
 #define        ENA_TX_OFFLOAD_NOTSUP_MASK      \
-       (PKT_TX_OFFLOAD_MASK ^ ENA_TX_OFFLOAD_MASK)
+       (RTE_MBUF_F_TX_OFFLOAD_MASK ^ ENA_TX_OFFLOAD_MASK)
+
+/** HW specific offloads capabilities. */
+/* IPv4 checksum offload. */
+#define ENA_L3_IPV4_CSUM               0x0001
+/* TCP/UDP checksum offload for IPv4 packets. */
+#define ENA_L4_IPV4_CSUM               0x0002
+/* TCP/UDP checksum offload for IPv4 packets with pseudo header checksum. */
+#define ENA_L4_IPV4_CSUM_PARTIAL       0x0004
+/* TCP/UDP checksum offload for IPv6 packets. */
+#define ENA_L4_IPV6_CSUM               0x0008
+/* TCP/UDP checksum offload for IPv6 packets with pseudo header checksum. */
+#define ENA_L4_IPV6_CSUM_PARTIAL       0x0010
+/* TSO support for IPv4 packets. */
+#define ENA_IPV4_TSO                   0x0020
+
+/* Device supports setting RSS hash. */
+#define ENA_RX_RSS_HASH                        0x0040
 
 static const struct rte_pci_id pci_id_ena_map[] = {
        { RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_VF) },
@@ -148,10 +160,9 @@ static const struct rte_pci_id pci_id_ena_map[] = {
 
 static struct ena_aenq_handlers aenq_handlers;
 
-static int ena_device_init(struct ena_com_dev *ena_dev,
+static int ena_device_init(struct ena_adapter *adapter,
                           struct rte_pci_device *pdev,
-                          struct ena_com_dev_get_features_ctx *get_feat_ctx,
-                          bool *wd_state);
+                          struct ena_com_dev_get_features_ctx *get_feat_ctx);
 static int ena_dev_configure(struct rte_eth_dev *dev);
 static void ena_tx_map_mbuf(struct ena_ring *tx_ring,
        struct ena_tx_buffer *tx_info,
@@ -206,6 +217,10 @@ static int ena_queue_start(struct rte_eth_dev *dev, struct ena_ring *ring);
 static int ena_queue_start_all(struct rte_eth_dev *dev,
                               enum ena_ring_type ring_type);
 static void ena_stats_restart(struct rte_eth_dev *dev);
+static uint64_t ena_get_rx_port_offloads(struct ena_adapter *adapter);
+static uint64_t ena_get_tx_port_offloads(struct ena_adapter *adapter);
+static uint64_t ena_get_rx_queue_offloads(struct ena_adapter *adapter);
+static uint64_t ena_get_tx_queue_offloads(struct ena_adapter *adapter);
 static int ena_infos_get(struct rte_eth_dev *dev,
                         struct rte_eth_dev_info *dev_info);
 static void ena_interrupt_handler_rte(void *cb_arg);
@@ -233,6 +248,7 @@ static int ena_rx_queue_intr_enable(struct rte_eth_dev *dev,
                                    uint16_t queue_id);
 static int ena_rx_queue_intr_disable(struct rte_eth_dev *dev,
                                     uint16_t queue_id);
+static int ena_configure_aenq(struct ena_adapter *adapter);
 
 static const struct eth_dev_ops ena_dev_ops = {
        .dev_configure        = ena_dev_configure,
@@ -259,10 +275,12 @@ static const struct eth_dev_ops ena_dev_ops = {
        .rss_hash_conf_get    = ena_rss_hash_conf_get,
 };
 
-static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
+static inline void ena_rx_mbuf_prepare(struct ena_ring *rx_ring,
+                                      struct rte_mbuf *mbuf,
                                       struct ena_com_rx_ctx *ena_rx_ctx,
                                       bool fill_hash)
 {
+       struct ena_stats_rx *rx_stats = &rx_ring->rx_stats;
        uint64_t ol_flags = 0;
        uint32_t packet_type = 0;
 
@@ -273,25 +291,31 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 
        if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4) {
                packet_type |= RTE_PTYPE_L3_IPV4;
-               if (unlikely(ena_rx_ctx->l3_csum_err))
-                       ol_flags |= PKT_RX_IP_CKSUM_BAD;
-               else
-                       ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+               if (unlikely(ena_rx_ctx->l3_csum_err)) {
+                       ++rx_stats->l3_csum_bad;
+                       ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
+               } else {
+                       ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
+               }
        } else if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV6) {
                packet_type |= RTE_PTYPE_L3_IPV6;
        }
 
-       if (!ena_rx_ctx->l4_csum_checked || ena_rx_ctx->frag)
-               ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
-       else
-               if (unlikely(ena_rx_ctx->l4_csum_err))
-                       ol_flags |= PKT_RX_L4_CKSUM_BAD;
-               else
-                       ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+       if (!ena_rx_ctx->l4_csum_checked || ena_rx_ctx->frag) {
+               ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_UNKNOWN;
+       } else {
+               if (unlikely(ena_rx_ctx->l4_csum_err)) {
+                       ++rx_stats->l4_csum_bad;
+                       ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
+               } else {
+                       ++rx_stats->l4_csum_good;
+                       ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
+               }
+       }
 
        if (fill_hash &&
            likely((packet_type & ENA_PTYPE_HAS_HASH) && !ena_rx_ctx->frag)) {
-               ol_flags |= PKT_RX_RSS_HASH;
+               ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
                mbuf->hash.rss = ena_rx_ctx->hash;
        }
 
@@ -309,19 +333,19 @@ static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf,
        if ((mbuf->ol_flags & MBUF_OFFLOADS) &&
            (queue_offloads & QUEUE_OFFLOADS)) {
                /* check if TSO is required */
-               if ((mbuf->ol_flags & PKT_TX_TCP_SEG) &&
-                   (queue_offloads & DEV_TX_OFFLOAD_TCP_TSO)) {
+               if ((mbuf->ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
+                   (queue_offloads & RTE_ETH_TX_OFFLOAD_TCP_TSO)) {
                        ena_tx_ctx->tso_enable = true;
 
                        ena_meta->l4_hdr_len = GET_L4_HDR_LEN(mbuf);
                }
 
                /* check if L3 checksum is needed */
-               if ((mbuf->ol_flags & PKT_TX_IP_CKSUM) &&
-                   (queue_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM))
+               if ((mbuf->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) &&
+                   (queue_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM))
                        ena_tx_ctx->l3_csum_enable = true;
 
-               if (mbuf->ol_flags & PKT_TX_IPV6) {
+               if (mbuf->ol_flags & RTE_MBUF_F_TX_IPV6) {
                        ena_tx_ctx->l3_proto = ENA_ETH_IO_L3_PROTO_IPV6;
                } else {
                        ena_tx_ctx->l3_proto = ENA_ETH_IO_L3_PROTO_IPV4;
@@ -334,13 +358,13 @@ static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf,
                }
 
                /* check if L4 checksum is needed */
-               if (((mbuf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) &&
-                   (queue_offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) {
+               if (((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM) &&
+                   (queue_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
                        ena_tx_ctx->l4_proto = ENA_ETH_IO_L4_PROTO_TCP;
                        ena_tx_ctx->l4_csum_enable = true;
-               } else if (((mbuf->ol_flags & PKT_TX_L4_MASK) ==
-                               PKT_TX_UDP_CKSUM) &&
-                               (queue_offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) {
+               } else if (((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+                               RTE_MBUF_F_TX_UDP_CKSUM) &&
+                               (queue_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
                        ena_tx_ctx->l4_proto = ENA_ETH_IO_L4_PROTO_UDP;
                        ena_tx_ctx->l4_csum_enable = true;
                } else {
@@ -473,7 +497,7 @@ err:
 static int ena_close(struct rte_eth_dev *dev)
 {
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
        struct ena_adapter *adapter = dev->data->dev_private;
        int ret = 0;
 
@@ -546,16 +570,13 @@ static void ena_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
        struct ena_ring *ring = dev->data->rx_queues[qid];
 
        /* Free ring resources */
-       if (ring->rx_buffer_info)
-               rte_free(ring->rx_buffer_info);
+       rte_free(ring->rx_buffer_info);
        ring->rx_buffer_info = NULL;
 
-       if (ring->rx_refill_buffer)
-               rte_free(ring->rx_refill_buffer);
+       rte_free(ring->rx_refill_buffer);
        ring->rx_refill_buffer = NULL;
 
-       if (ring->empty_rx_reqs)
-               rte_free(ring->empty_rx_reqs);
+       rte_free(ring->empty_rx_reqs);
        ring->empty_rx_reqs = NULL;
 
        ring->configured = 0;
@@ -569,14 +590,11 @@ static void ena_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
        struct ena_ring *ring = dev->data->tx_queues[qid];
 
        /* Free ring resources */
-       if (ring->push_buf_intermediate_buf)
-               rte_free(ring->push_buf_intermediate_buf);
+       rte_free(ring->push_buf_intermediate_buf);
 
-       if (ring->tx_buffer_info)
-               rte_free(ring->tx_buffer_info);
+       rte_free(ring->tx_buffer_info);
 
-       if (ring->empty_tx_reqs)
-               rte_free(ring->empty_tx_reqs);
+       rte_free(ring->empty_tx_reqs);
 
        ring->empty_tx_reqs = NULL;
        ring->tx_buffer_info = NULL;
@@ -621,9 +639,9 @@ static int ena_link_update(struct rte_eth_dev *dev,
        struct rte_eth_link *link = &dev->data->dev_link;
        struct ena_adapter *adapter = dev->data->dev_private;
 
-       link->link_status = adapter->link_status ? ETH_LINK_UP : ETH_LINK_DOWN;
-       link->link_speed = ETH_SPEED_NUM_NONE;
-       link->link_duplex = ETH_LINK_FULL_DUPLEX;
+       link->link_status = adapter->link_status ? RTE_ETH_LINK_UP : RTE_ETH_LINK_DOWN;
+       link->link_speed = RTE_ETH_SPEED_NUM_NONE;
+       link->link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
 
        return 0;
 }
@@ -901,7 +919,7 @@ static int ena_start(struct rte_eth_dev *dev)
        if (rc)
                goto err_start_tx;
 
-       if (adapter->edev_data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
+       if (adapter->edev_data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
                rc = ena_rss_configure(adapter);
                if (rc)
                        goto err_rss_init;
@@ -933,7 +951,7 @@ static int ena_stop(struct rte_eth_dev *dev)
        struct ena_adapter *adapter = dev->data->dev_private;
        struct ena_com_dev *ena_dev = &adapter->ena_dev;
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
        int rc;
 
        /* Cannot free memory in secondary process */
@@ -955,10 +973,9 @@ static int ena_stop(struct rte_eth_dev *dev)
        rte_intr_disable(intr_handle);
 
        rte_intr_efd_disable(intr_handle);
-       if (intr_handle->intr_vec != NULL) {
-               rte_free(intr_handle->intr_vec);
-               intr_handle->intr_vec = NULL;
-       }
+
+       /* Cleanup vector list */
+       rte_intr_vec_list_free(intr_handle);
 
        rte_intr_enable(intr_handle);
 
@@ -974,7 +991,7 @@ static int ena_create_io_queue(struct rte_eth_dev *dev, struct ena_ring *ring)
        struct ena_adapter *adapter = ring->adapter;
        struct ena_com_dev *ena_dev = &adapter->ena_dev;
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
        struct ena_com_create_io_ctx ctx =
                /* policy set to _HOST just to satisfy icc compiler */
                { ENA_ADMIN_PLACEMENT_POLICY_HOST,
@@ -994,7 +1011,10 @@ static int ena_create_io_queue(struct rte_eth_dev *dev, struct ena_ring *ring)
                ena_qid = ENA_IO_RXQ_IDX(ring->id);
                ctx.direction = ENA_COM_IO_QUEUE_DIRECTION_RX;
                if (rte_intr_dp_is_en(intr_handle))
-                       ctx.msix_vector = intr_handle->intr_vec[ring->id];
+                       ctx.msix_vector =
+                               rte_intr_vec_list_index_get(intr_handle,
+                                                                  ring->id);
+
                for (i = 0; i < ring->ring_size; i++)
                        ring->empty_rx_reqs[i] = i;
        }
@@ -1111,6 +1131,7 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev,
        struct ena_ring *txq = NULL;
        struct ena_adapter *adapter = dev->data->dev_private;
        unsigned int i;
+       uint16_t dyn_thresh;
 
        txq = &adapter->tx_ring[queue_idx];
 
@@ -1142,20 +1163,22 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev,
        txq->size_mask = nb_desc - 1;
        txq->numa_socket_id = socket_id;
        txq->pkts_without_db = false;
+       txq->last_cleanup_ticks = 0;
 
-       txq->tx_buffer_info = rte_zmalloc("txq->tx_buffer_info",
-                                         sizeof(struct ena_tx_buffer) *
-                                         txq->ring_size,
-                                         RTE_CACHE_LINE_SIZE);
+       txq->tx_buffer_info = rte_zmalloc_socket("txq->tx_buffer_info",
+               sizeof(struct ena_tx_buffer) * txq->ring_size,
+               RTE_CACHE_LINE_SIZE,
+               socket_id);
        if (!txq->tx_buffer_info) {
                PMD_DRV_LOG(ERR,
                        "Failed to allocate memory for Tx buffer info\n");
                return -ENOMEM;
        }
 
-       txq->empty_tx_reqs = rte_zmalloc("txq->empty_tx_reqs",
-                                        sizeof(u16) * txq->ring_size,
-                                        RTE_CACHE_LINE_SIZE);
+       txq->empty_tx_reqs = rte_zmalloc_socket("txq->empty_tx_reqs",
+               sizeof(uint16_t) * txq->ring_size,
+               RTE_CACHE_LINE_SIZE,
+               socket_id);
        if (!txq->empty_tx_reqs) {
                PMD_DRV_LOG(ERR,
                        "Failed to allocate memory for empty Tx requests\n");
@@ -1164,9 +1187,10 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev,
        }
 
        txq->push_buf_intermediate_buf =
-               rte_zmalloc("txq->push_buf_intermediate_buf",
-                           txq->tx_max_header_size,
-                           RTE_CACHE_LINE_SIZE);
+               rte_zmalloc_socket("txq->push_buf_intermediate_buf",
+                       txq->tx_max_header_size,
+                       RTE_CACHE_LINE_SIZE,
+                       socket_id);
        if (!txq->push_buf_intermediate_buf) {
                PMD_DRV_LOG(ERR, "Failed to alloc push buffer for LLQ\n");
                rte_free(txq->tx_buffer_info);
@@ -1177,10 +1201,21 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev,
        for (i = 0; i < txq->ring_size; i++)
                txq->empty_tx_reqs[i] = i;
 
-       if (tx_conf != NULL) {
-               txq->offloads =
-                       tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+       txq->offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
+       /* Check if caller provided the Tx cleanup threshold value. */
+       if (tx_conf->tx_free_thresh != 0) {
+               txq->tx_free_thresh = tx_conf->tx_free_thresh;
+       } else {
+               dyn_thresh = txq->ring_size -
+                       txq->ring_size / ENA_REFILL_THRESH_DIVIDER;
+               txq->tx_free_thresh = RTE_MAX(dyn_thresh,
+                       txq->ring_size - ENA_REFILL_THRESH_PACKET);
        }
+
+       txq->missing_tx_completion_threshold =
+               RTE_MIN(txq->ring_size / 2, ENA_DEFAULT_MISSING_COMP);
+
        /* Store pointer to this queue in upper layer */
        txq->configured = 1;
        dev->data->tx_queues[queue_idx] = txq;
@@ -1199,6 +1234,7 @@ static int ena_rx_queue_setup(struct rte_eth_dev *dev,
        struct ena_ring *rxq = NULL;
        size_t buffer_size;
        int i;
+       uint16_t dyn_thresh;
 
        rxq = &adapter->rx_ring[queue_idx];
        if (rxq->configured) {
@@ -1239,19 +1275,20 @@ static int ena_rx_queue_setup(struct rte_eth_dev *dev,
        rxq->numa_socket_id = socket_id;
        rxq->mb_pool = mp;
 
-       rxq->rx_buffer_info = rte_zmalloc("rxq->buffer_info",
+       rxq->rx_buffer_info = rte_zmalloc_socket("rxq->buffer_info",
                sizeof(struct ena_rx_buffer) * nb_desc,
-               RTE_CACHE_LINE_SIZE);
+               RTE_CACHE_LINE_SIZE,
+               socket_id);
        if (!rxq->rx_buffer_info) {
                PMD_DRV_LOG(ERR,
                        "Failed to allocate memory for Rx buffer info\n");
                return -ENOMEM;
        }
 
-       rxq->rx_refill_buffer = rte_zmalloc("rxq->rx_refill_buffer",
-                                           sizeof(struct rte_mbuf *) * nb_desc,
-                                           RTE_CACHE_LINE_SIZE);
-
+       rxq->rx_refill_buffer = rte_zmalloc_socket("rxq->rx_refill_buffer",
+               sizeof(struct rte_mbuf *) * nb_desc,
+               RTE_CACHE_LINE_SIZE,
+               socket_id);
        if (!rxq->rx_refill_buffer) {
                PMD_DRV_LOG(ERR,
                        "Failed to allocate memory for Rx refill buffer\n");
@@ -1260,9 +1297,10 @@ static int ena_rx_queue_setup(struct rte_eth_dev *dev,
                return -ENOMEM;
        }
 
-       rxq->empty_rx_reqs = rte_zmalloc("rxq->empty_rx_reqs",
-                                        sizeof(uint16_t) * nb_desc,
-                                        RTE_CACHE_LINE_SIZE);
+       rxq->empty_rx_reqs = rte_zmalloc_socket("rxq->empty_rx_reqs",
+               sizeof(uint16_t) * nb_desc,
+               RTE_CACHE_LINE_SIZE,
+               socket_id);
        if (!rxq->empty_rx_reqs) {
                PMD_DRV_LOG(ERR,
                        "Failed to allocate memory for empty Rx requests\n");
@@ -1278,6 +1316,14 @@ static int ena_rx_queue_setup(struct rte_eth_dev *dev,
 
        rxq->offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 
+       if (rx_conf->rx_free_thresh != 0) {
+               rxq->rx_free_thresh = rx_conf->rx_free_thresh;
+       } else {
+               dyn_thresh = rxq->ring_size / ENA_REFILL_THRESH_DIVIDER;
+               rxq->rx_free_thresh = RTE_MIN(dyn_thresh,
+                       (uint16_t)(ENA_REFILL_THRESH_PACKET));
+       }
+
        /* Store pointer to this queue in upper layer */
        rxq->configured = 1;
        dev->data->rx_queues[queue_idx] = rxq;
@@ -1359,7 +1405,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
                ++rxq->rx_stats.refill_partial;
        }
 
-       /* When we submitted free recources to device... */
+       /* When we submitted free resources to device... */
        if (likely(i > 0)) {
                /* ...let HW know that it can fill buffers with data. */
                ena_com_write_sq_doorbell(rxq->ena_com_io_sq);
@@ -1370,11 +1416,11 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
        return i;
 }
 
-static int ena_device_init(struct ena_com_dev *ena_dev,
+static int ena_device_init(struct ena_adapter *adapter,
                           struct rte_pci_device *pdev,
-                          struct ena_com_dev_get_features_ctx *get_feat_ctx,
-                          bool *wd_state)
+                          struct ena_com_dev_get_features_ctx *get_feat_ctx)
 {
+       struct ena_com_dev *ena_dev = &adapter->ena_dev;
        uint32_t aenq_groups;
        int rc;
        bool readless_supported;
@@ -1439,13 +1485,8 @@ static int ena_device_init(struct ena_com_dev *ena_dev,
                      BIT(ENA_ADMIN_WARNING);
 
        aenq_groups &= get_feat_ctx->aenq.supported_groups;
-       rc = ena_com_set_aenq_config(ena_dev, aenq_groups);
-       if (rc) {
-               PMD_DRV_LOG(ERR, "Cannot configure AENQ groups, rc: %d\n", rc);
-               goto err_admin_init;
-       }
 
-       *wd_state = !!(aenq_groups & BIT(ENA_ADMIN_KEEP_ALIVE));
+       adapter->all_aenq_groups = aenq_groups;
 
        return 0;
 
@@ -1471,7 +1512,7 @@ static void ena_interrupt_handler_rte(void *cb_arg)
 
 static void check_for_missing_keep_alive(struct ena_adapter *adapter)
 {
-       if (!adapter->wd_state)
+       if (!(adapter->active_aenq_groups & BIT(ENA_ADMIN_KEEP_ALIVE)))
                return;
 
        if (adapter->keep_alive_timeout == ENA_HW_HINTS_NO_TIMEOUT)
@@ -1496,14 +1537,99 @@ static void check_for_admin_com_state(struct ena_adapter *adapter)
        }
 }
 
+static int check_for_tx_completion_in_queue(struct ena_adapter *adapter,
+                                           struct ena_ring *tx_ring)
+{
+       struct ena_tx_buffer *tx_buf;
+       uint64_t timestamp;
+       uint64_t completion_delay;
+       uint32_t missed_tx = 0;
+       unsigned int i;
+       int rc = 0;
+
+       for (i = 0; i < tx_ring->ring_size; ++i) {
+               tx_buf = &tx_ring->tx_buffer_info[i];
+               timestamp = tx_buf->timestamp;
+
+               if (timestamp == 0)
+                       continue;
+
+               completion_delay = rte_get_timer_cycles() - timestamp;
+               if (completion_delay > adapter->missing_tx_completion_to) {
+                       if (unlikely(!tx_buf->print_once)) {
+                               PMD_TX_LOG(WARNING,
+                                       "Found a Tx that wasn't completed on time, qid %d, index %d. "
+                                       "Missing Tx outstanding for %" PRIu64 " msecs.\n",
+                                       tx_ring->id, i, completion_delay /
+                                       rte_get_timer_hz() * 1000);
+                               tx_buf->print_once = true;
+                       }
+                       ++missed_tx;
+               }
+       }
+
+       if (unlikely(missed_tx > tx_ring->missing_tx_completion_threshold)) {
+               PMD_DRV_LOG(ERR,
+                       "The number of lost Tx completions is above the threshold (%d > %d). "
+                       "Trigger the device reset.\n",
+                       missed_tx,
+                       tx_ring->missing_tx_completion_threshold);
+               adapter->reset_reason = ENA_REGS_RESET_MISS_TX_CMPL;
+               adapter->trigger_reset = true;
+               rc = -EIO;
+       }
+
+       tx_ring->tx_stats.missed_tx += missed_tx;
+
+       return rc;
+}
+
+static void check_for_tx_completions(struct ena_adapter *adapter)
+{
+       struct ena_ring *tx_ring;
+       uint64_t tx_cleanup_delay;
+       size_t qid;
+       int budget;
+       uint16_t nb_tx_queues = adapter->edev_data->nb_tx_queues;
+
+       if (adapter->missing_tx_completion_to == ENA_HW_HINTS_NO_TIMEOUT)
+               return;
+
+       nb_tx_queues = adapter->edev_data->nb_tx_queues;
+       budget = adapter->missing_tx_completion_budget;
+
+       qid = adapter->last_tx_comp_qid;
+       while (budget-- > 0) {
+               tx_ring = &adapter->tx_ring[qid];
+
+               /* Tx cleanup is called only by the burst function and can be
+                * called dynamically by the application. Also cleanup is
+                * limited by the threshold. To avoid false detection of the
+                * missing HW Tx completion, get the delay since last cleanup
+                * function was called.
+                */
+               tx_cleanup_delay = rte_get_timer_cycles() -
+                       tx_ring->last_cleanup_ticks;
+               if (tx_cleanup_delay < adapter->tx_cleanup_stall_delay)
+                       check_for_tx_completion_in_queue(adapter, tx_ring);
+               qid = (qid + 1) % nb_tx_queues;
+       }
+
+       adapter->last_tx_comp_qid = qid;
+}
+
 static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer,
                                  void *arg)
 {
        struct rte_eth_dev *dev = arg;
        struct ena_adapter *adapter = dev->data->dev_private;
 
+       if (unlikely(adapter->trigger_reset))
+               return;
+
        check_for_missing_keep_alive(adapter);
        check_for_admin_com_state(adapter);
+       check_for_tx_completions(adapter);
 
        if (unlikely(adapter->trigger_reset)) {
                PMD_DRV_LOG(ERR, "Trigger reset is on\n");
@@ -1612,6 +1738,50 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
        return max_num_io_queues;
 }
 
+static void
+ena_set_offloads(struct ena_offloads *offloads,
+                struct ena_admin_feature_offload_desc *offload_desc)
+{
+       if (offload_desc->tx & ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK)
+               offloads->tx_offloads |= ENA_IPV4_TSO;
+
+       /* Tx IPv4 checksum offloads */
+       if (offload_desc->tx &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L3_CSUM_IPV4_MASK)
+               offloads->tx_offloads |= ENA_L3_IPV4_CSUM;
+       if (offload_desc->tx &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_MASK)
+               offloads->tx_offloads |= ENA_L4_IPV4_CSUM;
+       if (offload_desc->tx &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK)
+               offloads->tx_offloads |= ENA_L4_IPV4_CSUM_PARTIAL;
+
+       /* Tx IPv6 checksum offloads */
+       if (offload_desc->tx &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_MASK)
+               offloads->tx_offloads |= ENA_L4_IPV6_CSUM;
+       if (offload_desc->tx &
+            ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_MASK)
+               offloads->tx_offloads |= ENA_L4_IPV6_CSUM_PARTIAL;
+
+       /* Rx IPv4 checksum offloads */
+       if (offload_desc->rx_supported &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L3_CSUM_IPV4_MASK)
+               offloads->rx_offloads |= ENA_L3_IPV4_CSUM;
+       if (offload_desc->rx_supported &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK)
+               offloads->rx_offloads |= ENA_L4_IPV4_CSUM;
+
+       /* Rx IPv6 checksum offloads */
+       if (offload_desc->rx_supported &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_MASK)
+               offloads->rx_offloads |= ENA_L4_IPV6_CSUM;
+
+       if (offload_desc->rx_supported &
+           ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_MASK)
+               offloads->rx_offloads |= ENA_RX_RSS_HASH;
+}
+
 static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 {
        struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 };
@@ -1626,7 +1796,6 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
        int rc;
        static int adapters_found;
        bool disable_meta_caching;
-       bool wd_state = false;
 
        eth_dev->dev_ops = &ena_dev_ops;
        eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;
@@ -1651,7 +1820,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
                     pci_dev->addr.devid,
                     pci_dev->addr.function);
 
-       intr_handle = &pci_dev->intr_handle;
+       intr_handle = pci_dev->intr_handle;
 
        adapter->regs = pci_dev->mem_resource[ENA_REGS_BAR].addr;
        adapter->dev_mem_base = pci_dev->mem_resource[ENA_MEM_BAR].addr;
@@ -1678,12 +1847,15 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
        }
 
        /* device specific initialization routine */
-       rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state);
+       rc = ena_device_init(adapter, pci_dev, &get_feat_ctx);
        if (rc) {
                PMD_INIT_LOG(CRIT, "Failed to init ENA device\n");
                goto err;
        }
-       adapter->wd_state = wd_state;
+
+       /* Check if device supports LSC */
+       if (!(adapter->all_aenq_groups & BIT(ENA_ADMIN_LINK_CHANGE)))
+               adapter->edev_data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
 
        set_default_llq_configurations(&llq_config, &get_feat_ctx.llq,
                adapter->use_large_llq_hdr);
@@ -1733,17 +1905,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
        /* Set max MTU for this device */
        adapter->max_mtu = get_feat_ctx.dev_attr.max_mtu;
 
-       /* set device support for offloads */
-       adapter->offloads.tso4_supported = (get_feat_ctx.offload.tx &
-               ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK) != 0;
-       adapter->offloads.tx_csum_supported = (get_feat_ctx.offload.tx &
-               ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK) != 0;
-       adapter->offloads.rx_csum_supported =
-               (get_feat_ctx.offload.rx_supported &
-               ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK) != 0;
-       adapter->offloads.rss_hash_supported =
-               (get_feat_ctx.offload.rx_supported &
-               ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_MASK) != 0;
+       ena_set_offloads(&adapter->offloads, &get_feat_ctx.offload);
 
        /* Copy MAC address and point DPDK to it */
        eth_dev->data->mac_addrs = (struct rte_ether_addr *)adapter->mac_addr;
@@ -1837,16 +1999,36 @@ static int eth_ena_dev_uninit(struct rte_eth_dev *eth_dev)
 static int ena_dev_configure(struct rte_eth_dev *dev)
 {
        struct ena_adapter *adapter = dev->data->dev_private;
+       int rc;
 
        adapter->state = ENA_ADAPTER_STATE_CONFIG;
 
-       if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
-               dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
-       dev->data->dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
+       if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+               dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+       dev->data->dev_conf.txmode.offloads |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
-       adapter->tx_selected_offloads = dev->data->dev_conf.txmode.offloads;
-       adapter->rx_selected_offloads = dev->data->dev_conf.rxmode.offloads;
-       return 0;
+       /* Scattered Rx cannot be turned off in the HW, so this capability must
+        * be forced.
+        */
+       dev->data->scattered_rx = 1;
+
+       adapter->last_tx_comp_qid = 0;
+
+       adapter->missing_tx_completion_budget =
+               RTE_MIN(ENA_MONITORED_TX_QUEUES, dev->data->nb_tx_queues);
+
+       adapter->missing_tx_completion_to = ENA_TX_TIMEOUT;
+       /* To avoid detection of the spurious Tx completion timeout due to
+        * application not calling the Tx cleanup function, set timeout for the
+        * Tx queue which should be half of the missing completion timeout for a
+        * safety. If there will be a lot of missing Tx completions in the
+        * queue, they will be detected sooner or later.
+        */
+       adapter->tx_cleanup_stall_delay = adapter->missing_tx_completion_to / 2;
+
+       rc = ena_configure_aenq(adapter);
+
+       return rc;
 }
 
 static void ena_init_rings(struct ena_adapter *adapter,
@@ -1878,12 +2060,65 @@ static void ena_init_rings(struct ena_adapter *adapter,
        }
 }
 
+static uint64_t ena_get_rx_port_offloads(struct ena_adapter *adapter)
+{
+       uint64_t port_offloads = 0;
+
+       if (adapter->offloads.rx_offloads & ENA_L3_IPV4_CSUM)
+               port_offloads |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM;
+
+       if (adapter->offloads.rx_offloads &
+           (ENA_L4_IPV4_CSUM | ENA_L4_IPV6_CSUM))
+               port_offloads |=
+                       RTE_ETH_RX_OFFLOAD_UDP_CKSUM | RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
+
+       if (adapter->offloads.rx_offloads & ENA_RX_RSS_HASH)
+               port_offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+       port_offloads |= RTE_ETH_RX_OFFLOAD_SCATTER;
+
+       return port_offloads;
+}
+
+static uint64_t ena_get_tx_port_offloads(struct ena_adapter *adapter)
+{
+       uint64_t port_offloads = 0;
+
+       if (adapter->offloads.tx_offloads & ENA_IPV4_TSO)
+               port_offloads |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
+
+       if (adapter->offloads.tx_offloads & ENA_L3_IPV4_CSUM)
+               port_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
+       if (adapter->offloads.tx_offloads &
+           (ENA_L4_IPV4_CSUM_PARTIAL | ENA_L4_IPV4_CSUM |
+            ENA_L4_IPV6_CSUM | ENA_L4_IPV6_CSUM_PARTIAL))
+               port_offloads |=
+                       RTE_ETH_TX_OFFLOAD_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
+
+       port_offloads |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+
+       return port_offloads;
+}
+
+static uint64_t ena_get_rx_queue_offloads(struct ena_adapter *adapter)
+{
+       RTE_SET_USED(adapter);
+
+       return 0;
+}
+
+static uint64_t ena_get_tx_queue_offloads(struct ena_adapter *adapter)
+{
+       RTE_SET_USED(adapter);
+
+       return 0;
+}
+
 static int ena_infos_get(struct rte_eth_dev *dev,
                          struct rte_eth_dev_info *dev_info)
 {
        struct ena_adapter *adapter;
        struct ena_com_dev *ena_dev;
-       uint64_t rx_feat = 0, tx_feat = 0;
 
        ena_assert_msg(dev->data != NULL, "Uninitialized device\n");
        ena_assert_msg(dev->data->dev_private != NULL, "Uninitialized device\n");
@@ -1893,39 +2128,20 @@ static int ena_infos_get(struct rte_eth_dev *dev,
        ena_assert_msg(ena_dev != NULL, "Uninitialized device\n");
 
        dev_info->speed_capa =
-                       ETH_LINK_SPEED_1G   |
-                       ETH_LINK_SPEED_2_5G |
-                       ETH_LINK_SPEED_5G   |
-                       ETH_LINK_SPEED_10G  |
-                       ETH_LINK_SPEED_25G  |
-                       ETH_LINK_SPEED_40G  |
-                       ETH_LINK_SPEED_50G  |
-                       ETH_LINK_SPEED_100G;
-
-       /* Set Tx & Rx features available for device */
-       if (adapter->offloads.tso4_supported)
-               tx_feat |= DEV_TX_OFFLOAD_TCP_TSO;
-
-       if (adapter->offloads.tx_csum_supported)
-               tx_feat |= DEV_TX_OFFLOAD_IPV4_CKSUM |
-                       DEV_TX_OFFLOAD_UDP_CKSUM |
-                       DEV_TX_OFFLOAD_TCP_CKSUM;
-
-       if (adapter->offloads.rx_csum_supported)
-               rx_feat |= DEV_RX_OFFLOAD_IPV4_CKSUM |
-                       DEV_RX_OFFLOAD_UDP_CKSUM  |
-                       DEV_RX_OFFLOAD_TCP_CKSUM;
-
-       rx_feat |= DEV_RX_OFFLOAD_JUMBO_FRAME;
-       tx_feat |= DEV_TX_OFFLOAD_MULTI_SEGS;
+                       RTE_ETH_LINK_SPEED_1G   |
+                       RTE_ETH_LINK_SPEED_2_5G |
+                       RTE_ETH_LINK_SPEED_5G   |
+                       RTE_ETH_LINK_SPEED_10G  |
+                       RTE_ETH_LINK_SPEED_25G  |
+                       RTE_ETH_LINK_SPEED_40G  |
+                       RTE_ETH_LINK_SPEED_50G  |
+                       RTE_ETH_LINK_SPEED_100G;
 
        /* Inform framework about available features */
-       dev_info->rx_offload_capa = rx_feat;
-       if (adapter->offloads.rss_hash_supported)
-               dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_RSS_HASH;
-       dev_info->rx_queue_offload_capa = rx_feat;
-       dev_info->tx_offload_capa = tx_feat;
-       dev_info->tx_queue_offload_capa = tx_feat;
+       dev_info->rx_offload_capa = ena_get_rx_port_offloads(adapter);
+       dev_info->tx_offload_capa = ena_get_tx_port_offloads(adapter);
+       dev_info->rx_queue_offload_capa = ena_get_rx_queue_offloads(adapter);
+       dev_info->tx_queue_offload_capa = ena_get_tx_queue_offloads(adapter);
 
        dev_info->flow_type_rss_offloads = ENA_ALL_RSS_HF;
        dev_info->hash_key_size = ENA_HASH_KEY_SIZE;
@@ -1941,9 +2157,6 @@ static int ena_infos_get(struct rte_eth_dev *dev,
        dev_info->max_tx_queues = adapter->max_num_io_queues;
        dev_info->reta_size = ENA_RX_RSS_TABLE_SIZE;
 
-       adapter->tx_supported_offloads = tx_feat;
-       adapter->rx_supported_offloads = rx_feat;
-
        dev_info->rx_desc_lim.nb_max = adapter->max_rx_ring_size;
        dev_info->rx_desc_lim.nb_min = ENA_MIN_RING_DESC;
        dev_info->rx_desc_lim.nb_seg_max = RTE_MIN(ENA_PKT_MAX_BUFS,
@@ -2071,7 +2284,6 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 {
        struct ena_ring *rx_ring = (struct ena_ring *)(rx_queue);
        unsigned int free_queue_entries;
-       unsigned int refill_threshold;
        uint16_t next_to_clean = rx_ring->next_to_clean;
        uint16_t descs_in_use;
        struct rte_mbuf *mbuf;
@@ -2089,7 +2301,7 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
        }
 #endif
 
-       fill_hash = rx_ring->offloads & DEV_RX_OFFLOAD_RSS_HASH;
+       fill_hash = rx_ring->offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
        descs_in_use = rx_ring->ring_size -
                ena_com_free_q_entries(rx_ring->ena_com_io_sq) - 1;
@@ -2137,13 +2349,11 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                }
 
                /* fill mbuf attributes if any */
-               ena_rx_mbuf_prepare(mbuf, &ena_rx_ctx, fill_hash);
+               ena_rx_mbuf_prepare(rx_ring, mbuf, &ena_rx_ctx, fill_hash);
 
                if (unlikely(mbuf->ol_flags &
-                               (PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD))) {
+                               (RTE_MBUF_F_RX_IP_CKSUM_BAD | RTE_MBUF_F_RX_L4_CKSUM_BAD)))
                        rte_atomic64_inc(&rx_ring->adapter->drv_stats->ierrors);
-                       ++rx_ring->rx_stats.bad_csum;
-               }
 
                rx_pkts[completed] = mbuf;
                rx_ring->rx_stats.bytes += mbuf->pkt_len;
@@ -2153,12 +2363,9 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
        rx_ring->next_to_clean = next_to_clean;
 
        free_queue_entries = ena_com_free_q_entries(rx_ring->ena_com_io_sq);
-       refill_threshold =
-               RTE_MIN(rx_ring->ring_size / ENA_REFILL_THRESH_DIVIDER,
-               (unsigned int)ENA_REFILL_THRESH_PACKET);
 
        /* Burst refill to save doorbells, memory barriers, const interval */
-       if (free_queue_entries > refill_threshold) {
+       if (free_queue_entries >= rx_ring->rx_free_thresh) {
                ena_com_update_dev_comp_head(rx_ring->ena_com_io_cq);
                ena_populate_rx_queue(rx_ring, free_queue_entries);
        }
@@ -2174,45 +2381,71 @@ eth_ena_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        uint32_t i;
        struct rte_mbuf *m;
        struct ena_ring *tx_ring = (struct ena_ring *)(tx_queue);
+       struct ena_adapter *adapter = tx_ring->adapter;
        struct rte_ipv4_hdr *ip_hdr;
        uint64_t ol_flags;
+       uint64_t l4_csum_flag;
+       uint64_t dev_offload_capa;
        uint16_t frag_field;
+       bool need_pseudo_csum;
 
+       dev_offload_capa = adapter->offloads.tx_offloads;
        for (i = 0; i != nb_pkts; i++) {
                m = tx_pkts[i];
                ol_flags = m->ol_flags;
 
-               if (!(ol_flags & PKT_TX_IPV4))
+               /* Check if any offload flag was set */
+               if (ol_flags == 0)
                        continue;
 
-               /* If there was not L2 header length specified, assume it is
-                * length of the ethernet header.
-                */
-               if (unlikely(m->l2_len == 0))
-                       m->l2_len = sizeof(struct rte_ether_hdr);
-
-               ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
-                                                m->l2_len);
-               frag_field = rte_be_to_cpu_16(ip_hdr->fragment_offset);
-
-               if ((frag_field & RTE_IPV4_HDR_DF_FLAG) != 0) {
-                       m->packet_type |= RTE_PTYPE_L4_NONFRAG;
-
-                       /* If IPv4 header has DF flag enabled and TSO support is
-                        * disabled, partial chcecksum should not be calculated.
-                        */
-                       if (!tx_ring->adapter->offloads.tso4_supported)
-                               continue;
+               l4_csum_flag = ol_flags & RTE_MBUF_F_TX_L4_MASK;
+               /* SCTP checksum offload is not supported by the ENA. */
+               if ((ol_flags & ENA_TX_OFFLOAD_NOTSUP_MASK) ||
+                   l4_csum_flag == RTE_MBUF_F_TX_SCTP_CKSUM) {
+                       PMD_TX_LOG(DEBUG,
+                               "mbuf[%" PRIu32 "] has unsupported offloads flags set: 0x%" PRIu64 "\n",
+                               i, ol_flags);
+                       rte_errno = ENOTSUP;
+                       return i;
                }
 
-               if ((ol_flags & ENA_TX_OFFLOAD_NOTSUP_MASK) != 0 ||
-                               (ol_flags & PKT_TX_L4_MASK) ==
-                               PKT_TX_SCTP_CKSUM) {
-                       rte_errno = ENOTSUP;
+               if (unlikely(m->nb_segs >= tx_ring->sgl_size &&
+                   !(tx_ring->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV &&
+                     m->nb_segs == tx_ring->sgl_size &&
+                     m->data_len < tx_ring->tx_max_header_size))) {
+                       PMD_TX_LOG(DEBUG,
+                               "mbuf[%" PRIu32 "] has too many segments: %" PRIu16 "\n",
+                               i, m->nb_segs);
+                       rte_errno = EINVAL;
                        return i;
                }
 
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
+               /* Check if requested offload is also enabled for the queue */
+               if ((ol_flags & RTE_MBUF_F_TX_IP_CKSUM &&
+                    !(tx_ring->offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) ||
+                   (l4_csum_flag == RTE_MBUF_F_TX_TCP_CKSUM &&
+                    !(tx_ring->offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) ||
+                   (l4_csum_flag == RTE_MBUF_F_TX_UDP_CKSUM &&
+                    !(tx_ring->offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM))) {
+                       PMD_TX_LOG(DEBUG,
+                               "mbuf[%" PRIu32 "]: requested offloads: %" PRIu16 " are not enabled for the queue[%u]\n",
+                               i, m->nb_segs, tx_ring->id);
+                       rte_errno = EINVAL;
+                       return i;
+               }
+
+               /* The caller is obligated to set l2 and l3 len if any cksum
+                * offload is enabled.
+                */
+               if (unlikely(ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK) &&
+                   (m->l2_len == 0 || m->l3_len == 0))) {
+                       PMD_TX_LOG(DEBUG,
+                               "mbuf[%" PRIu32 "]: l2_len or l3_len values are 0 while the offload was requested\n",
+                               i);
+                       rte_errno = EINVAL;
+                       return i;
+               }
                ret = rte_validate_tx_offload(m);
                if (ret != 0) {
                        rte_errno = -ret;
@@ -2220,16 +2453,76 @@ eth_ena_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                }
 #endif
 
-               /* In case we are supposed to TSO and have DF not set (DF=0)
-                * hardware must be provided with partial checksum, otherwise
-                * it will take care of necessary calculations.
+               /* Verify HW support for requested offloads and determine if
+                * pseudo header checksum is needed.
                 */
+               need_pseudo_csum = false;
+               if (ol_flags & RTE_MBUF_F_TX_IPV4) {
+                       if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM &&
+                           !(dev_offload_capa & ENA_L3_IPV4_CSUM)) {
+                               rte_errno = ENOTSUP;
+                               return i;
+                       }
 
-               ret = rte_net_intel_cksum_flags_prepare(m,
-                       ol_flags & ~PKT_TX_TCP_SEG);
-               if (ret != 0) {
-                       rte_errno = -ret;
-                       return i;
+                       if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
+                           !(dev_offload_capa & ENA_IPV4_TSO)) {
+                               rte_errno = ENOTSUP;
+                               return i;
+                       }
+
+                       /* Check HW capabilities and if pseudo csum is needed
+                        * for L4 offloads.
+                        */
+                       if (l4_csum_flag != RTE_MBUF_F_TX_L4_NO_CKSUM &&
+                           !(dev_offload_capa & ENA_L4_IPV4_CSUM)) {
+                               if (dev_offload_capa &
+                                   ENA_L4_IPV4_CSUM_PARTIAL) {
+                                       need_pseudo_csum = true;
+                               } else {
+                                       rte_errno = ENOTSUP;
+                                       return i;
+                               }
+                       }
+
+                       /* Parse the DF flag */
+                       ip_hdr = rte_pktmbuf_mtod_offset(m,
+                               struct rte_ipv4_hdr *, m->l2_len);
+                       frag_field = rte_be_to_cpu_16(ip_hdr->fragment_offset);
+                       if (frag_field & RTE_IPV4_HDR_DF_FLAG) {
+                               m->packet_type |= RTE_PTYPE_L4_NONFRAG;
+                       } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+                               /* In case we are supposed to TSO and have DF
+                                * not set (DF=0) hardware must be provided with
+                                * partial checksum.
+                                */
+                               need_pseudo_csum = true;
+                       }
+               } else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
+                       /* There is no support for IPv6 TSO as for now. */
+                       if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+                               rte_errno = ENOTSUP;
+                               return i;
+                       }
+
+                       /* Check HW capabilities and if pseudo csum is needed */
+                       if (l4_csum_flag != RTE_MBUF_F_TX_L4_NO_CKSUM &&
+                           !(dev_offload_capa & ENA_L4_IPV6_CSUM)) {
+                               if (dev_offload_capa &
+                                   ENA_L4_IPV6_CSUM_PARTIAL) {
+                                       need_pseudo_csum = true;
+                               } else {
+                                       rte_errno = ENOTSUP;
+                                       return i;
+                               }
+                       }
+               }
+
+               if (need_pseudo_csum) {
+                       ret = rte_net_intel_cksum_flags_prepare(m, ol_flags);
+                       if (ret != 0) {
+                               rte_errno = -ret;
+                               return i;
+                       }
                }
        }
 
@@ -2248,6 +2541,20 @@ static void ena_update_hints(struct ena_adapter *adapter,
                adapter->ena_dev.mmio_read.reg_read_to =
                        hints->mmio_read_timeout * 1000;
 
+       if (hints->missing_tx_completion_timeout) {
+               if (hints->missing_tx_completion_timeout ==
+                   ENA_HW_HINTS_NO_TIMEOUT) {
+                       adapter->missing_tx_completion_to =
+                               ENA_HW_HINTS_NO_TIMEOUT;
+               } else {
+                       /* Convert from msecs to ticks */
+                       adapter->missing_tx_completion_to = rte_get_timer_hz() *
+                               hints->missing_tx_completion_timeout / 1000;
+                       adapter->tx_cleanup_stall_delay =
+                               adapter->missing_tx_completion_to / 2;
+               }
+       }
+
        if (hints->driver_watchdog_timeout) {
                if (hints->driver_watchdog_timeout == ENA_HW_HINTS_NO_TIMEOUT)
                        adapter->keep_alive_timeout = ENA_HW_HINTS_NO_TIMEOUT;
@@ -2259,56 +2566,6 @@ static void ena_update_hints(struct ena_adapter *adapter,
        }
 }
 
-static int ena_check_space_and_linearize_mbuf(struct ena_ring *tx_ring,
-                                             struct rte_mbuf *mbuf)
-{
-       struct ena_com_dev *ena_dev;
-       int num_segments, header_len, rc;
-
-       ena_dev = &tx_ring->adapter->ena_dev;
-       num_segments = mbuf->nb_segs;
-       header_len = mbuf->data_len;
-
-       if (likely(num_segments < tx_ring->sgl_size))
-               goto checkspace;
-
-       if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV &&
-           (num_segments == tx_ring->sgl_size) &&
-           (header_len < tx_ring->tx_max_header_size))
-               goto checkspace;
-
-       /* Checking for space for 2 additional metadata descriptors due to
-        * possible header split and metadata descriptor. Linearization will
-        * be needed so we reduce the segments number from num_segments to 1
-        */
-       if (!ena_com_sq_have_enough_space(tx_ring->ena_com_io_sq, 3)) {
-               PMD_TX_LOG(DEBUG, "Not enough space in the Tx queue\n");
-               return ENA_COM_NO_MEM;
-       }
-       ++tx_ring->tx_stats.linearize;
-       rc = rte_pktmbuf_linearize(mbuf);
-       if (unlikely(rc)) {
-               PMD_TX_LOG(WARNING, "Mbuf linearize failed\n");
-               rte_atomic64_inc(&tx_ring->adapter->drv_stats->ierrors);
-               ++tx_ring->tx_stats.linearize_failed;
-               return rc;
-       }
-
-       return 0;
-
-checkspace:
-       /* Checking for space for 2 additional metadata descriptors due to
-        * possible header split and metadata descriptor
-        */
-       if (!ena_com_sq_have_enough_space(tx_ring->ena_com_io_sq,
-                                         num_segments + 2)) {
-               PMD_TX_LOG(DEBUG, "Not enough space in the Tx queue\n");
-               return ENA_COM_NO_MEM;
-       }
-
-       return 0;
-}
-
 static void ena_tx_map_mbuf(struct ena_ring *tx_ring,
        struct ena_tx_buffer *tx_info,
        struct rte_mbuf *mbuf,
@@ -2393,15 +2650,21 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf)
        int nb_hw_desc;
        int rc;
 
-       rc = ena_check_space_and_linearize_mbuf(tx_ring, mbuf);
-       if (unlikely(rc))
-               return rc;
+       /* Checking for space for 2 additional metadata descriptors due to
+        * possible header split and metadata descriptor
+        */
+       if (!ena_com_sq_have_enough_space(tx_ring->ena_com_io_sq,
+                                         mbuf->nb_segs + 2)) {
+               PMD_DRV_LOG(DEBUG, "Not enough space in the tx queue\n");
+               return ENA_COM_NO_MEM;
+       }
 
        next_to_use = tx_ring->next_to_use;
 
        req_id = tx_ring->empty_tx_reqs[next_to_use];
        tx_info = &tx_ring->tx_buffer_info[req_id];
        tx_info->num_of_bufs = 0;
+       RTE_ASSERT(tx_info->mbuf == NULL);
 
        ena_tx_map_mbuf(tx_ring, tx_info, mbuf, &push_header, &header_len);
 
@@ -2438,6 +2701,7 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf)
        }
 
        tx_info->tx_descs = nb_hw_desc;
+       tx_info->timestamp = rte_get_timer_cycles();
 
        tx_ring->tx_stats.cnt++;
        tx_ring->tx_stats.bytes += mbuf->pkt_len;
@@ -2450,12 +2714,12 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf)
 
 static void ena_tx_cleanup(struct ena_ring *tx_ring)
 {
-       unsigned int cleanup_budget;
        unsigned int total_tx_descs = 0;
+       uint16_t cleanup_budget;
        uint16_t next_to_clean = tx_ring->next_to_clean;
 
-       cleanup_budget = RTE_MIN(tx_ring->ring_size / ENA_REFILL_THRESH_DIVIDER,
-               (unsigned int)ENA_REFILL_THRESH_PACKET);
+       /* Attempt to release all Tx descriptors (ring_size - 1 -> size_mask) */
+       cleanup_budget = tx_ring->size_mask;
 
        while (likely(total_tx_descs < cleanup_budget)) {
                struct rte_mbuf *mbuf;
@@ -2470,6 +2734,7 @@ static void ena_tx_cleanup(struct ena_ring *tx_ring)
 
                /* Get Tx info & store how many descs were processed  */
                tx_info = &tx_ring->tx_buffer_info[req_id];
+               tx_info->timestamp = 0;
 
                mbuf = tx_info->mbuf;
                rte_pktmbuf_free(mbuf);
@@ -2490,12 +2755,16 @@ static void ena_tx_cleanup(struct ena_ring *tx_ring)
                ena_com_comp_ack(tx_ring->ena_com_io_sq, total_tx_descs);
                ena_com_update_dev_comp_head(tx_ring->ena_com_io_cq);
        }
+
+       /* Notify completion handler that the cleanup was just called */
+       tx_ring->last_cleanup_ticks = rte_get_timer_cycles();
 }
 
 static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                                  uint16_t nb_pkts)
 {
        struct ena_ring *tx_ring = (struct ena_ring *)(tx_queue);
+       int available_desc;
        uint16_t sent_idx = 0;
 
 #ifdef RTE_ETHDEV_DEBUG_TX
@@ -2507,6 +2776,10 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        }
 #endif
 
+       available_desc = ena_com_free_q_entries(tx_ring->ena_com_io_sq);
+       if (available_desc < tx_ring->tx_free_thresh)
+               ena_tx_cleanup(tx_ring);
+
        for (sent_idx = 0; sent_idx < nb_pkts; sent_idx++) {
                if (ena_xmit_mbuf(tx_ring, tx_pkts[sent_idx]))
                        break;
@@ -2515,9 +2788,6 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                        tx_ring->size_mask)]);
        }
 
-       tx_ring->tx_stats.available_desc =
-               ena_com_free_q_entries(tx_ring->ena_com_io_sq);
-
        /* If there are ready packets to be xmitted... */
        if (likely(tx_ring->pkts_without_db)) {
                /* ...let HW do its best :-) */
@@ -2526,8 +2796,6 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                tx_ring->pkts_without_db = false;
        }
 
-       ena_tx_cleanup(tx_ring);
-
        tx_ring->tx_stats.available_desc =
                ena_com_free_q_entries(tx_ring->ena_com_io_sq);
        tx_ring->tx_stats.tx_poll++;
@@ -2806,7 +3074,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,
 static int ena_setup_rx_intr(struct rte_eth_dev *dev)
 {
        struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
        int rc;
        uint16_t vectors_nb, i;
        bool rx_intr_requested = dev->data->dev_conf.intr_conf.rxq;
@@ -2833,9 +3101,9 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev)
                goto enable_intr;
        }
 
-       intr_handle->intr_vec = rte_zmalloc("intr_vec",
-               dev->data->nb_rx_queues * sizeof(*intr_handle->intr_vec), 0);
-       if (intr_handle->intr_vec == NULL) {
+       /* Allocate the vector list */
+       if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
+                                          dev->data->nb_rx_queues)) {
                PMD_DRV_LOG(ERR,
                        "Failed to allocate interrupt vector for %d queues\n",
                        dev->data->nb_rx_queues);
@@ -2854,7 +3122,9 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev)
        }
 
        for (i = 0; i < vectors_nb; ++i)
-               intr_handle->intr_vec[i] = RTE_INTR_VEC_RXTX_OFFSET + i;
+               if (rte_intr_vec_list_index_set(intr_handle, i,
+                                          RTE_INTR_VEC_RXTX_OFFSET + i))
+                       goto disable_intr_efd;
 
        rte_intr_enable(intr_handle);
        return 0;
@@ -2862,8 +3132,7 @@ static int ena_setup_rx_intr(struct rte_eth_dev *dev)
 disable_intr_efd:
        rte_intr_efd_disable(intr_handle);
 free_intr_vec:
-       rte_free(intr_handle->intr_vec);
-       intr_handle->intr_vec = NULL;
+       rte_intr_vec_list_free(intr_handle);
 enable_intr:
        rte_intr_enable(intr_handle);
        return rc;
@@ -2897,6 +3166,38 @@ static int ena_rx_queue_intr_disable(struct rte_eth_dev *dev,
        return 0;
 }
 
+static int ena_configure_aenq(struct ena_adapter *adapter)
+{
+       uint32_t aenq_groups = adapter->all_aenq_groups;
+       int rc;
+
+       /* All_aenq_groups holds all AENQ functions supported by the device and
+        * the HW, so at first we need to be sure the LSC request is valid.
+        */
+       if (adapter->edev_data->dev_conf.intr_conf.lsc != 0) {
+               if (!(aenq_groups & BIT(ENA_ADMIN_LINK_CHANGE))) {
+                       PMD_DRV_LOG(ERR,
+                               "LSC requested, but it's not supported by the AENQ\n");
+                       return -EINVAL;
+               }
+       } else {
+               /* If LSC wasn't enabled by the app, let's enable all supported
+                * AENQ procedures except the LSC.
+                */
+               aenq_groups &= ~BIT(ENA_ADMIN_LINK_CHANGE);
+       }
+
+       rc = ena_com_set_aenq_config(&adapter->ena_dev, aenq_groups);
+       if (rc != 0) {
+               PMD_DRV_LOG(ERR, "Cannot configure AENQ groups, rc=%d\n", rc);
+               return rc;
+       }
+
+       adapter->active_aenq_groups = aenq_groups;
+
+       return 0;
+}
+
 /*********************************************************************
  *  PMD configuration
  *********************************************************************/