New upstream version 17.11.4
[deb_dpdk.git] / drivers / net / ena / ena_ethdev.c
index 80ce1f3..4e52656 100644 (file)
@@ -205,7 +205,7 @@ static void ena_init_rings(struct ena_adapter *adapter);
 static int ena_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 static int ena_start(struct rte_eth_dev *dev);
 static void ena_close(struct rte_eth_dev *dev);
-static void ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
+static int ena_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
 static void ena_rx_queue_release_all(struct rte_eth_dev *dev);
 static void ena_tx_queue_release_all(struct rte_eth_dev *dev);
 static void ena_rx_queue_release(void *queue);
@@ -260,16 +260,17 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
                                       struct ena_com_rx_ctx *ena_rx_ctx)
 {
        uint64_t ol_flags = 0;
+       uint32_t packet_type = 0;
 
        if (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP)
-               ol_flags |= PKT_TX_TCP_CKSUM;
+               packet_type |= RTE_PTYPE_L4_TCP;
        else if (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_UDP)
-               ol_flags |= PKT_TX_UDP_CKSUM;
+               packet_type |= RTE_PTYPE_L4_UDP;
 
        if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4)
-               ol_flags |= PKT_TX_IPV4;
+               packet_type |= RTE_PTYPE_L3_IPV4;
        else if (ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV6)
-               ol_flags |= PKT_TX_IPV6;
+               packet_type |= RTE_PTYPE_L3_IPV6;
 
        if (unlikely(ena_rx_ctx->l4_csum_err))
                ol_flags |= PKT_RX_L4_CKSUM_BAD;
@@ -277,6 +278,7 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
                ol_flags |= PKT_RX_IP_CKSUM_BAD;
 
        mbuf->ol_flags = ol_flags;
+       mbuf->packet_type = packet_type;
 }
 
 static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf,
@@ -707,7 +709,7 @@ static int ena_link_update(struct rte_eth_dev *dev,
        struct rte_eth_link *link = &dev->data->dev_link;
 
        link->link_status = 1;
-       link->link_speed = ETH_SPEED_NUM_10G;
+       link->link_speed = ETH_SPEED_NUM_NONE;
        link->link_duplex = ETH_LINK_FULL_DUPLEX;
 
        return 0;
@@ -811,7 +813,7 @@ static void ena_stats_restart(struct rte_eth_dev *dev)
        rte_atomic64_init(&adapter->drv_stats->rx_nombuf);
 }
 
-static void ena_stats_get(struct rte_eth_dev *dev,
+static int ena_stats_get(struct rte_eth_dev *dev,
                          struct rte_eth_stats *stats)
 {
        struct ena_admin_basic_stats ena_stats;
@@ -821,13 +823,13 @@ static void ena_stats_get(struct rte_eth_dev *dev,
        int rc;
 
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return;
+               return -ENOTSUP;
 
        memset(&ena_stats, 0, sizeof(ena_stats));
        rc = ena_com_get_dev_basic_stats(ena_dev, &ena_stats);
        if (unlikely(rc)) {
                RTE_LOG(ERR, PMD, "Could not retrieve statistics from ENA");
-               return;
+               return rc;
        }
 
        /* Set of basic statistics from ENA */
@@ -846,6 +848,7 @@ static void ena_stats_get(struct rte_eth_dev *dev,
        stats->ierrors = rte_atomic64_read(&adapter->drv_stats->ierrors);
        stats->oerrors = rte_atomic64_read(&adapter->drv_stats->oerrors);
        stats->rx_nombuf = rte_atomic64_read(&adapter->drv_stats->rx_nombuf);
+       return 0;
 }
 
 static int ena_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
@@ -904,7 +907,7 @@ static int ena_start(struct rte_eth_dev *dev)
                return rc;
 
        if (adapter->rte_dev->data->dev_conf.rxmode.mq_mode &
-           ETH_MQ_RX_RSS_FLAG) {
+           ETH_MQ_RX_RSS_FLAG && adapter->rte_dev->data->nb_rx_queues > 0) {
                rc = ena_rss_init_default(adapter);
                if (rc)
                        return rc;
@@ -1166,7 +1169,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 
                rte_prefetch0(mbufs[((next_to_use + 4) & ring_mask)]);
                /* prepare physical address for DMA transaction */
-               ebuf.paddr = mbuf->buf_physaddr + RTE_PKTMBUF_HEADROOM;
+               ebuf.paddr = mbuf->buf_iova + RTE_PKTMBUF_HEADROOM;
                ebuf.len = mbuf->buf_len - RTE_PKTMBUF_HEADROOM;
                /* pass resource to device */
                rc = ena_com_add_single_rx_desc(rxq->ena_com_io_sq,
@@ -1725,7 +1728,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                 * consideration pushed header
                 */
                if (mbuf->data_len > ena_tx_ctx.header_len) {
-                       ebuf->paddr = mbuf->buf_physaddr +
+                       ebuf->paddr = mbuf->buf_iova +
                                      mbuf->data_off +
                                      ena_tx_ctx.header_len;
                        ebuf->len = mbuf->data_len - ena_tx_ctx.header_len;
@@ -1734,7 +1737,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                }
 
                while ((mbuf = mbuf->next) != NULL) {
-                       ebuf->paddr = mbuf->buf_physaddr + mbuf->data_off;
+                       ebuf->paddr = mbuf->buf_iova + mbuf->data_off;
                        ebuf->len = mbuf->data_len;
                        ebuf++;
                        tx_info->num_of_bufs++;