net/enetc: fix Rx lock-up
[dpdk.git] / drivers / net / enetc / enetc_ethdev.c
index d07e61c..eb637d0 100644 (file)
@@ -1,10 +1,11 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018-2019 NXP
+ * Copyright 2018-2020 NXP
  */
 
 #include <stdbool.h>
 #include <rte_ethdev_pci.h>
 #include <rte_random.h>
+#include <dpaax_iova_table.h>
 
 #include "enetc_logs.h"
 #include "enetc.h"
@@ -130,7 +131,7 @@ print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr)
        char buf[RTE_ETHER_ADDR_FMT_SIZE];
 
        rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr);
-       ENETC_PMD_INFO("%s%s\n", name, buf);
+       ENETC_PMD_NOTICE("%s%s\n", name, buf);
 }
 
 static int
@@ -146,6 +147,9 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
        hw->hw.port = (void *)((size_t)hw->hw.reg + ENETC_PORT_BASE);
        hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE);
 
+       /* WA for Rx lock-up HW erratum */
+       enetc_port_wr(enetc_hw, ENETC_PM0_RX_FIFO, 1);
+
        /* Enabling Station Interface */
        enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN);
 
@@ -158,6 +162,8 @@ enetc_hardware_init(struct enetc_eth_hw *hw)
        if ((high_mac | low_mac) == 0) {
                char *first_byte;
 
+               ENETC_PMD_NOTICE("MAC is not available for this SI, "
+                               "set random MAC\n");
                mac = (uint32_t *)hw->mac.addr;
                *mac = (uint32_t)rte_rand();
                first_byte = (char *)mac;
@@ -894,6 +900,9 @@ enetc_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->data->mtu = RTE_ETHER_MAX_LEN - RTE_ETHER_HDR_LEN -
                RTE_ETHER_CRC_LEN;
 
+       if (rte_eal_iova_mode() == RTE_IOVA_PA)
+               dpaax_iova_table_populate();
+
        ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x",
                        eth_dev->data->port_id, pci_dev->id.vendor_id,
                        pci_dev->id.device_id);
@@ -904,6 +913,10 @@ static int
 enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
 {
        PMD_INIT_FUNC_TRACE();
+
+       if (rte_eal_iova_mode() == RTE_IOVA_PA)
+               dpaax_iova_table_depopulate();
+
        return 0;
 }