New upstream version 18.08
[deb_dpdk.git] / lib / librte_ethdev / rte_ethdev.c
similarity index 77%
rename from lib/librte_ether/rte_ethdev.c
rename to lib/librte_ethdev/rte_ethdev.c
index 0590f0c..4c32025 100644 (file)
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include <errno.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <inttypes.h>
 #include <netinet/in.h>
 #include <rte_errno.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
-#include <rte_compat.h>
+#include <rte_kvargs.h>
 
 #include "rte_ether.h"
 #include "rte_ethdev.h"
 #include "rte_ethdev_driver.h"
 #include "ethdev_profile.h"
 
+int rte_eth_dev_logtype;
+
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
-static uint8_t eth_dev_last_created_port;
+static uint16_t eth_dev_last_created_port;
 
 /* spinlock for eth device callbacks */
 static rte_spinlock_t rte_eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;
@@ -123,6 +126,7 @@ static const struct {
        RTE_RX_OFFLOAD_BIT2STR(SCATTER),
        RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
        RTE_RX_OFFLOAD_BIT2STR(SECURITY),
+       RTE_RX_OFFLOAD_BIT2STR(KEEP_CRC),
 };
 
 #undef RTE_RX_OFFLOAD_BIT2STR
@@ -222,19 +226,41 @@ rte_eth_dev_shared_data_prepare(void)
        rte_spinlock_unlock(&rte_eth_shared_data_lock);
 }
 
-struct rte_eth_dev *
-rte_eth_dev_allocated(const char *name)
+static bool
+is_allocated(const struct rte_eth_dev *ethdev)
+{
+       return ethdev->data->name[0] != '\0';
+}
+
+static struct rte_eth_dev *
+_rte_eth_dev_allocated(const char *name)
 {
        unsigned i;
 
        for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-               if ((rte_eth_devices[i].state == RTE_ETH_DEV_ATTACHED) &&
+               if (rte_eth_devices[i].data != NULL &&
                    strcmp(rte_eth_devices[i].data->name, name) == 0)
                        return &rte_eth_devices[i];
        }
        return NULL;
 }
 
+struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+       struct rte_eth_dev *ethdev;
+
+       rte_eth_dev_shared_data_prepare();
+
+       rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
+
+       ethdev = _rte_eth_dev_allocated(name);
+
+       rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+       return ethdev;
+}
+
 static uint16_t
 rte_eth_dev_find_free_port(void)
 {
@@ -257,7 +283,6 @@ eth_dev_get(uint16_t port_id)
        struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
 
        eth_dev->data = &rte_eth_dev_shared_data->data[port_id];
-       eth_dev->state = RTE_ETH_DEV_ATTACHED;
 
        eth_dev_last_created_port = port_id;
 
@@ -275,15 +300,17 @@ rte_eth_dev_allocate(const char *name)
        /* Synchronize port creation between primary and secondary threads. */
        rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
-       port_id = rte_eth_dev_find_free_port();
-       if (port_id == RTE_MAX_ETHPORTS) {
-               RTE_LOG(ERR, EAL, "Reached maximum number of Ethernet ports\n");
+       if (_rte_eth_dev_allocated(name) != NULL) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethernet device with name %s already allocated\n",
+                       name);
                goto unlock;
        }
 
-       if (rte_eth_dev_allocated(name) != NULL) {
-               RTE_LOG(ERR, EAL, "Ethernet Device with name %s already allocated!\n",
-                               name);
+       port_id = rte_eth_dev_find_free_port();
+       if (port_id == RTE_MAX_ETHPORTS) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Reached maximum number of Ethernet ports\n");
                goto unlock;
        }
 
@@ -295,9 +322,6 @@ rte_eth_dev_allocate(const char *name)
 unlock:
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
 
-       if (eth_dev != NULL)
-               _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_NEW, NULL);
-
        return eth_dev;
 }
 
@@ -322,8 +346,8 @@ rte_eth_dev_attach_secondary(const char *name)
                        break;
        }
        if (i == RTE_MAX_ETHPORTS) {
-               RTE_PMD_DEBUG_TRACE(
-                       "device %s is not driven by the primary process\n",
+               RTE_ETHDEV_LOG(ERR,
+                       "Device %s is not driven by the primary process\n",
                        name);
        } else {
                eth_dev = eth_dev_get(i);
@@ -342,6 +366,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 
        rte_eth_dev_shared_data_prepare();
 
+       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+
        rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
        eth_dev->state = RTE_ETH_DEV_UNUSED;
@@ -350,8 +376,6 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
 
-       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
-
        return 0;
 }
 
@@ -370,13 +394,14 @@ rte_eth_is_valid_owner_id(uint64_t owner_id)
 {
        if (owner_id == RTE_ETH_DEV_NO_OWNER ||
            rte_eth_dev_shared_data->next_owner_id <= owner_id) {
-               RTE_PMD_DEBUG_TRACE("Invalid owner_id=%016lX.\n", owner_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid owner_id=%016"PRIx64"\n",
+                       owner_id);
                return 0;
        }
        return 1;
 }
 
-uint64_t __rte_experimental
+uint64_t
 rte_eth_find_next_owned_by(uint16_t port_id, const uint64_t owner_id)
 {
        while (port_id < RTE_MAX_ETHPORTS &&
@@ -408,10 +433,15 @@ static int
 _rte_eth_dev_owner_set(const uint16_t port_id, const uint64_t old_owner_id,
                       const struct rte_eth_dev_owner *new_owner)
 {
+       struct rte_eth_dev *ethdev = &rte_eth_devices[port_id];
        struct rte_eth_dev_owner *port_owner;
        int sret;
 
-       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+       if (port_id >= RTE_MAX_ETHPORTS || !is_allocated(ethdev)) {
+               RTE_ETHDEV_LOG(ERR, "Port id %"PRIu16" is not allocated\n",
+                       port_id);
+               return -ENODEV;
+       }
 
        if (!rte_eth_is_valid_owner_id(new_owner->id) &&
            !rte_eth_is_valid_owner_id(old_owner_id))
@@ -419,22 +449,22 @@ _rte_eth_dev_owner_set(const uint16_t port_id, const uint64_t old_owner_id,
 
        port_owner = &rte_eth_devices[port_id].data->owner;
        if (port_owner->id != old_owner_id) {
-               RTE_PMD_DEBUG_TRACE("Cannot set owner to port %d already owned"
-                                   " by %s_%016lX.\n", port_id,
-                                   port_owner->name, port_owner->id);
+               RTE_ETHDEV_LOG(ERR,
+                       "Cannot set owner to port %u already owned by %s_%016"PRIX64"\n",
+                       port_id, port_owner->name, port_owner->id);
                return -EPERM;
        }
 
        sret = snprintf(port_owner->name, RTE_ETH_MAX_OWNER_NAME_LEN, "%s",
                        new_owner->name);
        if (sret < 0 || sret >= RTE_ETH_MAX_OWNER_NAME_LEN)
-               RTE_PMD_DEBUG_TRACE("Port %d owner name was truncated.\n",
-                                   port_id);
+               RTE_ETHDEV_LOG(ERR, "Port %u owner name was truncated\n",
+                       port_id);
 
        port_owner->id = new_owner->id;
 
-       RTE_PMD_DEBUG_TRACE("Port %d owner is %s_%016lX.\n", port_id,
-                           new_owner->name, new_owner->id);
+       RTE_ETHDEV_LOG(DEBUG, "Port %u owner is %s_%016"PRIx64"\n",
+               port_id, new_owner->name, new_owner->id);
 
        return 0;
 }
@@ -482,11 +512,13 @@ rte_eth_dev_owner_delete(const uint64_t owner_id)
        rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
        if (rte_eth_is_valid_owner_id(owner_id)) {
-               RTE_ETH_FOREACH_DEV_OWNED_BY(port_id, owner_id)
-                       memset(&rte_eth_devices[port_id].data->owner, 0,
-                              sizeof(struct rte_eth_dev_owner));
-               RTE_PMD_DEBUG_TRACE("All port owners owned by %016X identifier"
-                                   " have removed.\n", owner_id);
+               for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
+                       if (rte_eth_devices[port_id].data->owner.id == owner_id)
+                               memset(&rte_eth_devices[port_id].data->owner, 0,
+                                      sizeof(struct rte_eth_dev_owner));
+               RTE_ETHDEV_LOG(ERR,
+                       "All port owners owned by %016"PRIx64" identifier have removed\n",
+                       owner_id);
        }
 
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
@@ -496,17 +528,18 @@ int __rte_experimental
 rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)
 {
        int ret = 0;
+       struct rte_eth_dev *ethdev = &rte_eth_devices[port_id];
 
        rte_eth_dev_shared_data_prepare();
 
        rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
-       if (!rte_eth_dev_is_valid_port(port_id)) {
-               RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+       if (port_id >= RTE_MAX_ETHPORTS || !is_allocated(ethdev)) {
+               RTE_ETHDEV_LOG(ERR, "Port id %"PRIu16" is not allocated\n",
+                       port_id);
                ret = -ENODEV;
        } else {
-               rte_memcpy(owner, &rte_eth_devices[port_id].data->owner,
-                          sizeof(*owner));
+               rte_memcpy(owner, &ethdev->data->owner, sizeof(*owner));
        }
 
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
@@ -521,7 +554,7 @@ rte_eth_dev_socket_id(uint16_t port_id)
 }
 
 void *
-rte_eth_dev_get_sec_ctx(uint8_t port_id)
+rte_eth_dev_get_sec_ctx(uint16_t port_id)
 {
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, NULL);
        return rte_eth_devices[port_id].security_ctx;
@@ -529,6 +562,12 @@ rte_eth_dev_get_sec_ctx(uint8_t port_id)
 
 uint16_t
 rte_eth_dev_count(void)
+{
+       return rte_eth_dev_count_avail();
+}
+
+uint16_t
+rte_eth_dev_count_avail(void)
 {
        uint16_t p;
        uint16_t count;
@@ -541,6 +580,18 @@ rte_eth_dev_count(void)
        return count;
 }
 
+uint16_t __rte_experimental
+rte_eth_dev_count_total(void)
+{
+       uint16_t port, count = 0;
+
+       for (port = 0; port < RTE_MAX_ETHPORTS; port++)
+               if (rte_eth_devices[port].state != RTE_ETH_DEV_UNUSED)
+                       count++;
+
+       return count;
+}
+
 int
 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name)
 {
@@ -549,7 +600,7 @@ rte_eth_dev_get_name_by_port(uint16_t port_id, char *name)
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
        if (name == NULL) {
-               RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
+               RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
                return -EINVAL;
        }
 
@@ -566,14 +617,13 @@ rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)
        uint32_t pid;
 
        if (name == NULL) {
-               RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
+               RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
                return -EINVAL;
        }
 
        for (pid = 0; pid < RTE_MAX_ETHPORTS; pid++) {
                if (rte_eth_devices[pid].state != RTE_ETH_DEV_UNUSED &&
-                   !strncmp(name, rte_eth_dev_shared_data->data[pid].name,
-                            strlen(name))) {
+                   !strcmp(name, rte_eth_dev_shared_data->data[pid].name)) {
                        *port_id = pid;
                        return 0;
                }
@@ -596,35 +646,37 @@ eth_err(uint16_t port_id, int ret)
 int
 rte_eth_dev_attach(const char *devargs, uint16_t *port_id)
 {
+       int current = rte_eth_dev_count_total();
+       struct rte_devargs da;
        int ret = -1;
-       int current = rte_eth_dev_count();
-       char *name = NULL;
-       char *args = NULL;
+
+       memset(&da, 0, sizeof(da));
 
        if ((devargs == NULL) || (port_id == NULL)) {
                ret = -EINVAL;
                goto err;
        }
 
-       /* parse devargs, then retrieve device name and args */
-       if (rte_eal_parse_devargs_str(devargs, &name, &args))
+       /* parse devargs */
+       if (rte_devargs_parse(&da, devargs))
                goto err;
 
-       ret = rte_eal_dev_attach(name, args);
+       ret = rte_eal_hotplug_add(da.bus->name, da.name, da.args);
        if (ret < 0)
                goto err;
 
        /* no point looking at the port count if no port exists */
-       if (!rte_eth_dev_count()) {
-               RTE_LOG(ERR, EAL, "No port found for device (%s)\n", name);
+       if (!rte_eth_dev_count_total()) {
+               RTE_ETHDEV_LOG(ERR, "No port found for device (%s)\n", da.name);
                ret = -1;
                goto err;
        }
 
        /* if nothing happened, there is a bug here, since some driver told us
         * it did attach a device, but did not create a port.
+        * FIXME: race condition in case of plug-out of another device
         */
-       if (current == rte_eth_dev_count()) {
+       if (current == rte_eth_dev_count_total()) {
                ret = -1;
                goto err;
        }
@@ -633,45 +685,42 @@ rte_eth_dev_attach(const char *devargs, uint16_t *port_id)
        ret = 0;
 
 err:
-       free(name);
-       free(args);
+       free(da.args);
        return ret;
 }
 
 /* detach the device, then store the name of the device */
 int
-rte_eth_dev_detach(uint16_t port_id, char *name)
+rte_eth_dev_detach(uint16_t port_id, char *name __rte_unused)
 {
+       struct rte_device *dev;
+       struct rte_bus *bus;
        uint32_t dev_flags;
        int ret = -1;
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
-       if (name == NULL) {
-               ret = -EINVAL;
-               goto err;
-       }
-
        dev_flags = rte_eth_devices[port_id].data->dev_flags;
        if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
-               RTE_LOG(ERR, EAL, "Port %" PRIu16 " is bonded, cannot detach\n",
-                       port_id);
-               ret = -ENOTSUP;
-               goto err;
+               RTE_ETHDEV_LOG(ERR,
+                       "Port %"PRIu16" is bonded, cannot detach\n", port_id);
+               return -ENOTSUP;
        }
 
-       snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
-                "%s", rte_eth_devices[port_id].data->name);
+       dev = rte_eth_devices[port_id].device;
+       if (dev == NULL)
+               return -EINVAL;
+
+       bus = rte_bus_find_by_device(dev);
+       if (bus == NULL)
+               return -ENOENT;
 
-       ret = rte_eal_dev_detach(rte_eth_devices[port_id].device);
+       ret = rte_eal_hotplug_remove(bus->name, dev->name);
        if (ret < 0)
-               goto err;
+               return ret;
 
        rte_eth_dev_release_port(&rte_eth_devices[port_id]);
        return 0;
-
-err:
-       return ret;
 }
 
 static int
@@ -732,16 +781,23 @@ rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id)
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
        dev = &rte_eth_devices[port_id];
+       if (!dev->data->dev_started) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Port %u must be started before start any queue\n",
+                       port_id);
+               return -EINVAL;
+       }
+
        if (rx_queue_id >= dev->data->nb_rx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
                return -EINVAL;
        }
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
 
        if (dev->data->rx_queue_state[rx_queue_id] != RTE_ETH_QUEUE_STATE_STOPPED) {
-               RTE_PMD_DEBUG_TRACE("Queue %" PRIu16" of device with port_id=%" PRIu8
-                       " already started\n",
+               RTE_ETHDEV_LOG(INFO,
+                       "Queue %"PRIu16" of device with port_id=%"PRIu16" already started\n",
                        rx_queue_id, port_id);
                return 0;
        }
@@ -760,15 +816,15 @@ rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id)
 
        dev = &rte_eth_devices[port_id];
        if (rx_queue_id >= dev->data->nb_rx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
                return -EINVAL;
        }
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
 
        if (dev->data->rx_queue_state[rx_queue_id] == RTE_ETH_QUEUE_STATE_STOPPED) {
-               RTE_PMD_DEBUG_TRACE("Queue %" PRIu16" of device with port_id=%" PRIu8
-                       " already stopped\n",
+               RTE_ETHDEV_LOG(INFO,
+                       "Queue %"PRIu16" of device with port_id=%"PRIu16" already stopped\n",
                        rx_queue_id, port_id);
                return 0;
        }
@@ -785,23 +841,28 @@ rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id)
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
        dev = &rte_eth_devices[port_id];
+       if (!dev->data->dev_started) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Port %u must be started before start any queue\n",
+                       port_id);
+               return -EINVAL;
+       }
+
        if (tx_queue_id >= dev->data->nb_tx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", tx_queue_id);
                return -EINVAL;
        }
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
 
        if (dev->data->tx_queue_state[tx_queue_id] != RTE_ETH_QUEUE_STATE_STOPPED) {
-               RTE_PMD_DEBUG_TRACE("Queue %" PRIu16" of device with port_id=%" PRIu8
-                       " already started\n",
+               RTE_ETHDEV_LOG(INFO,
+                       "Queue %"PRIu16" of device with port_id=%"PRIu16" already started\n",
                        tx_queue_id, port_id);
                return 0;
        }
 
-       return eth_err(port_id, dev->dev_ops->tx_queue_start(dev,
-                                                            tx_queue_id));
-
+       return eth_err(port_id, dev->dev_ops->tx_queue_start(dev, tx_queue_id));
 }
 
 int
@@ -813,15 +874,15 @@ rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id)
 
        dev = &rte_eth_devices[port_id];
        if (tx_queue_id >= dev->data->nb_tx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", tx_queue_id);
                return -EINVAL;
        }
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
 
        if (dev->data->tx_queue_state[tx_queue_id] == RTE_ETH_QUEUE_STATE_STOPPED) {
-               RTE_PMD_DEBUG_TRACE("Queue %" PRIu16" of device with port_id=%" PRIu8
-                       " already stopped\n",
+               RTE_ETHDEV_LOG(INFO,
+                       "Queue %"PRIu16" of device with port_id=%"PRIu16" already stopped\n",
                        tx_queue_id, port_id);
                return 0;
        }
@@ -913,95 +974,6 @@ rte_eth_speed_bitflag(uint32_t speed, int duplex)
        }
 }
 
-/**
- * A conversion function from rxmode bitfield API.
- */
-static void
-rte_eth_convert_rx_offload_bitfield(const struct rte_eth_rxmode *rxmode,
-                                   uint64_t *rx_offloads)
-{
-       uint64_t offloads = 0;
-
-       if (rxmode->header_split == 1)
-               offloads |= DEV_RX_OFFLOAD_HEADER_SPLIT;
-       if (rxmode->hw_ip_checksum == 1)
-               offloads |= DEV_RX_OFFLOAD_CHECKSUM;
-       if (rxmode->hw_vlan_filter == 1)
-               offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
-       if (rxmode->hw_vlan_strip == 1)
-               offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
-       if (rxmode->hw_vlan_extend == 1)
-               offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
-       if (rxmode->jumbo_frame == 1)
-               offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
-       if (rxmode->hw_strip_crc == 1)
-               offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
-       if (rxmode->enable_scatter == 1)
-               offloads |= DEV_RX_OFFLOAD_SCATTER;
-       if (rxmode->enable_lro == 1)
-               offloads |= DEV_RX_OFFLOAD_TCP_LRO;
-       if (rxmode->hw_timestamp == 1)
-               offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
-       if (rxmode->security == 1)
-               offloads |= DEV_RX_OFFLOAD_SECURITY;
-
-       *rx_offloads = offloads;
-}
-
-/**
- * A conversion function from rxmode offloads API.
- */
-static void
-rte_eth_convert_rx_offloads(const uint64_t rx_offloads,
-                           struct rte_eth_rxmode *rxmode)
-{
-
-       if (rx_offloads & DEV_RX_OFFLOAD_HEADER_SPLIT)
-               rxmode->header_split = 1;
-       else
-               rxmode->header_split = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_CHECKSUM)
-               rxmode->hw_ip_checksum = 1;
-       else
-               rxmode->hw_ip_checksum = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_VLAN_FILTER)
-               rxmode->hw_vlan_filter = 1;
-       else
-               rxmode->hw_vlan_filter = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
-               rxmode->hw_vlan_strip = 1;
-       else
-               rxmode->hw_vlan_strip = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)
-               rxmode->hw_vlan_extend = 1;
-       else
-               rxmode->hw_vlan_extend = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
-               rxmode->jumbo_frame = 1;
-       else
-               rxmode->jumbo_frame = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_CRC_STRIP)
-               rxmode->hw_strip_crc = 1;
-       else
-               rxmode->hw_strip_crc = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_SCATTER)
-               rxmode->enable_scatter = 1;
-       else
-               rxmode->enable_scatter = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_TCP_LRO)
-               rxmode->enable_lro = 1;
-       else
-               rxmode->enable_lro = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_TIMESTAMP)
-               rxmode->hw_timestamp = 1;
-       else
-               rxmode->hw_timestamp = 0;
-       if (rx_offloads & DEV_RX_OFFLOAD_SECURITY)
-               rxmode->security = 1;
-       else
-               rxmode->security = 0;
-}
-
 const char * __rte_experimental
 rte_eth_dev_rx_offload_name(uint64_t offload)
 {
@@ -1045,43 +1017,49 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
+       dev = &rte_eth_devices[port_id];
+
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
+
+       rte_eth_dev_info_get(port_id, &dev_info);
+
+       /* If number of queues specified by application for both Rx and Tx is
+        * zero, use driver preferred values. This cannot be done individually
+        * as it is valid for either Tx or Rx (but not both) to be zero.
+        * If driver does not provide any preferred valued, fall back on
+        * EAL defaults.
+        */
+       if (nb_rx_q == 0 && nb_tx_q == 0) {
+               nb_rx_q = dev_info.default_rxportconf.nb_queues;
+               if (nb_rx_q == 0)
+                       nb_rx_q = RTE_ETH_DEV_FALLBACK_RX_NBQUEUES;
+               nb_tx_q = dev_info.default_txportconf.nb_queues;
+               if (nb_tx_q == 0)
+                       nb_tx_q = RTE_ETH_DEV_FALLBACK_TX_NBQUEUES;
+       }
+
        if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) {
-               RTE_PMD_DEBUG_TRACE(
+               RTE_ETHDEV_LOG(ERR,
                        "Number of RX queues requested (%u) is greater than max supported(%d)\n",
                        nb_rx_q, RTE_MAX_QUEUES_PER_PORT);
                return -EINVAL;
        }
 
        if (nb_tx_q > RTE_MAX_QUEUES_PER_PORT) {
-               RTE_PMD_DEBUG_TRACE(
+               RTE_ETHDEV_LOG(ERR,
                        "Number of TX queues requested (%u) is greater than max supported(%d)\n",
                        nb_tx_q, RTE_MAX_QUEUES_PER_PORT);
                return -EINVAL;
        }
 
-       dev = &rte_eth_devices[port_id];
-
-       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
-
        if (dev->data->dev_started) {
-               RTE_PMD_DEBUG_TRACE(
-                   "port %d must be stopped to allow configuration\n", port_id);
+               RTE_ETHDEV_LOG(ERR,
+                       "Port %u must be stopped to allow configuration\n",
+                       port_id);
                return -EBUSY;
        }
 
-       /*
-        * Convert between the offloads API to enable PMDs to support
-        * only one of them.
-        */
-       if (dev_conf->rxmode.ignore_offload_bitfield == 0) {
-               rte_eth_convert_rx_offload_bitfield(
-                               &dev_conf->rxmode, &local_conf.rxmode.offloads);
-       } else {
-               rte_eth_convert_rx_offloads(dev_conf->rxmode.offloads,
-                                           &local_conf.rxmode);
-       }
-
        /* Copy the dev_conf parameter into the dev structure */
        memcpy(&dev->data->dev_conf, &local_conf, sizeof(dev->data->dev_conf));
 
@@ -1090,36 +1068,29 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
         * than the maximum number of RX and TX queues supported by the
         * configured device.
         */
-       (*dev->dev_ops->dev_infos_get)(dev, &dev_info);
-
-       if (nb_rx_q == 0 && nb_tx_q == 0) {
-               RTE_PMD_DEBUG_TRACE("ethdev port_id=%d both rx and tx queue cannot be 0\n", port_id);
-               return -EINVAL;
-       }
-
        if (nb_rx_q > dev_info.max_rx_queues) {
-               RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
-                               port_id, nb_rx_q, dev_info.max_rx_queues);
+               RTE_ETHDEV_LOG(ERR, "Ethdev port_id=%u nb_rx_queues=%u > %u\n",
+                       port_id, nb_rx_q, dev_info.max_rx_queues);
                return -EINVAL;
        }
 
        if (nb_tx_q > dev_info.max_tx_queues) {
-               RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
-                               port_id, nb_tx_q, dev_info.max_tx_queues);
+               RTE_ETHDEV_LOG(ERR, "Ethdev port_id=%u nb_tx_queues=%u > %u\n",
+                       port_id, nb_tx_q, dev_info.max_tx_queues);
                return -EINVAL;
        }
 
        /* Check that the device supports requested interrupts */
        if ((dev_conf->intr_conf.lsc == 1) &&
-               (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
-                       RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-                                       dev->device->driver->name);
-                       return -EINVAL;
+                       (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
+               RTE_ETHDEV_LOG(ERR, "Driver %s does not support lsc\n",
+                       dev->device->driver->name);
+               return -EINVAL;
        }
        if ((dev_conf->intr_conf.rmv == 1) &&
-           (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
-               RTE_PMD_DEBUG_TRACE("driver %s does not support rmv\n",
-                                   dev->device->driver->name);
+                       (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_RMV))) {
+               RTE_ETHDEV_LOG(ERR, "Driver %s does not support rmv\n",
+                       dev->device->driver->name);
                return -EINVAL;
        }
 
@@ -1128,19 +1099,16 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
         * length is supported by the configured device.
         */
        if (local_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
-               if (dev_conf->rxmode.max_rx_pkt_len >
-                   dev_info.max_rx_pktlen) {
-                       RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
-                               " > max valid value %u\n",
-                               port_id,
-                               (unsigned)dev_conf->rxmode.max_rx_pkt_len,
-                               (unsigned)dev_info.max_rx_pktlen);
+               if (dev_conf->rxmode.max_rx_pkt_len > dev_info.max_rx_pktlen) {
+                       RTE_ETHDEV_LOG(ERR,
+                               "Ethdev port_id=%u max_rx_pkt_len %u > max valid value %u\n",
+                               port_id, dev_conf->rxmode.max_rx_pkt_len,
+                               dev_info.max_rx_pktlen);
                        return -EINVAL;
                } else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
-                       RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
-                               " < min valid value %u\n",
-                               port_id,
-                               (unsigned)dev_conf->rxmode.max_rx_pkt_len,
+                       RTE_ETHDEV_LOG(ERR,
+                               "Ethdev port_id=%u max_rx_pkt_len %u < min valid value %u\n",
+                               port_id, dev_conf->rxmode.max_rx_pkt_len,
                                (unsigned)ETHER_MIN_LEN);
                        return -EINVAL;
                }
@@ -1152,28 +1120,71 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
                                                        ETHER_MAX_LEN;
        }
 
+       /* Any requested offloading must be within its device capabilities */
+       if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+            local_conf.rxmode.offloads) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethdev port_id=%u requested Rx offloads 0x%"PRIx64" doesn't match Rx offloads "
+                       "capabilities 0x%"PRIx64" in %s()\n",
+                       port_id, local_conf.rxmode.offloads,
+                       dev_info.rx_offload_capa,
+                       __func__);
+               return -EINVAL;
+       }
+       if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+            local_conf.txmode.offloads) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethdev port_id=%u requested Tx offloads 0x%"PRIx64" doesn't match Tx offloads "
+                       "capabilities 0x%"PRIx64" in %s()\n",
+                       port_id, local_conf.txmode.offloads,
+                       dev_info.tx_offload_capa,
+                       __func__);
+               return -EINVAL;
+       }
+
+       if ((local_conf.rxmode.offloads & DEV_RX_OFFLOAD_CRC_STRIP) &&
+                       (local_conf.rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC)) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Port id=%u not allowed to set both CRC STRIP and KEEP CRC offload flags\n",
+                       port_id);
+               return -EINVAL;
+       }
+
+       /* Check that device supports requested rss hash functions. */
+       if ((dev_info.flow_type_rss_offloads |
+            dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
+           dev_info.flow_type_rss_offloads) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethdev port_id=%u invalid rss_hf: 0x%"PRIx64", valid value: 0x%"PRIx64"\n",
+                       port_id, dev_conf->rx_adv_conf.rss_conf.rss_hf,
+                       dev_info.flow_type_rss_offloads);
+               return -EINVAL;
+       }
+
        /*
         * Setup new number of RX/TX queues and reconfigure device.
         */
        diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
        if (diag != 0) {
-               RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
-                               port_id, diag);
+               RTE_ETHDEV_LOG(ERR,
+                       "Port%u rte_eth_dev_rx_queue_config = %d\n",
+                       port_id, diag);
                return diag;
        }
 
        diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
        if (diag != 0) {
-               RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
-                               port_id, diag);
+               RTE_ETHDEV_LOG(ERR,
+                       "Port%u rte_eth_dev_tx_queue_config = %d\n",
+                       port_id, diag);
                rte_eth_dev_rx_queue_config(dev, 0);
                return diag;
        }
 
        diag = (*dev->dev_ops->dev_configure)(dev);
        if (diag != 0) {
-               RTE_PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
-                               port_id, diag);
+               RTE_ETHDEV_LOG(ERR, "Port%u dev_configure = %d\n",
+                       port_id, diag);
                rte_eth_dev_rx_queue_config(dev, 0);
                rte_eth_dev_tx_queue_config(dev, 0);
                return eth_err(port_id, diag);
@@ -1182,8 +1193,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
        /* Initialize Rx profiling if enabled at compilation time. */
        diag = __rte_eth_profile_rx_init(port_id, dev);
        if (diag != 0) {
-               RTE_PMD_DEBUG_TRACE("port%d __rte_eth_profile_rx_init = %d\n",
-                               port_id, diag);
+               RTE_ETHDEV_LOG(ERR, "Port%u __rte_eth_profile_rx_init = %d\n",
+                       port_id, diag);
                rte_eth_dev_rx_queue_config(dev, 0);
                rte_eth_dev_tx_queue_config(dev, 0);
                return eth_err(port_id, diag);
@@ -1196,8 +1207,7 @@ void
 _rte_eth_dev_reset(struct rte_eth_dev *dev)
 {
        if (dev->data->dev_started) {
-               RTE_PMD_DEBUG_TRACE(
-                       "port %d must be stopped to allow reset\n",
+               RTE_ETHDEV_LOG(ERR, "Port %u must be stopped to allow reset\n",
                        dev->data->port_id);
                return;
        }
@@ -1276,8 +1286,8 @@ rte_eth_dev_start(uint16_t port_id)
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
        if (dev->data->dev_started != 0) {
-               RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu16
-                       " already started\n",
+               RTE_ETHDEV_LOG(INFO,
+                       "Device with port_id=%"PRIu16" already started\n",
                        port_id);
                return 0;
        }
@@ -1308,8 +1318,8 @@ rte_eth_dev_stop(uint16_t port_id)
        RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
 
        if (dev->data->dev_started == 0) {
-               RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu16
-                       " already stopped\n",
+               RTE_ETHDEV_LOG(INFO,
+                       "Device with port_id=%"PRIu16" already stopped\n",
                        port_id);
                return;
        }
@@ -1421,16 +1431,10 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 
        dev = &rte_eth_devices[port_id];
        if (rx_queue_id >= dev->data->nb_rx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
                return -EINVAL;
        }
 
-       if (dev->data->dev_started) {
-               RTE_PMD_DEBUG_TRACE(
-                   "port %d must be stopped to allow configuration\n", port_id);
-               return -EBUSY;
-       }
-
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
 
@@ -1441,39 +1445,53 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
         */
        rte_eth_dev_info_get(port_id, &dev_info);
        if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
-               RTE_PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
-                               mp->name, (int) mp->private_data_size,
-                               (int) sizeof(struct rte_pktmbuf_pool_private));
+               RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
+                       mp->name, (int)mp->private_data_size,
+                       (int)sizeof(struct rte_pktmbuf_pool_private));
                return -ENOSPC;
        }
        mbp_buf_size = rte_pktmbuf_data_room_size(mp);
 
        if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
-               RTE_PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
-                               "(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
-                               "=%d)\n",
-                               mp->name,
-                               (int)mbp_buf_size,
-                               (int)(RTE_PKTMBUF_HEADROOM +
-                                     dev_info.min_rx_bufsize),
-                               (int)RTE_PKTMBUF_HEADROOM,
-                               (int)dev_info.min_rx_bufsize);
+               RTE_ETHDEV_LOG(ERR,
+                       "%s mbuf_data_room_size %d < %d (RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)=%d)\n",
+                       mp->name, (int)mbp_buf_size,
+                       (int)(RTE_PKTMBUF_HEADROOM + dev_info.min_rx_bufsize),
+                       (int)RTE_PKTMBUF_HEADROOM,
+                       (int)dev_info.min_rx_bufsize);
                return -EINVAL;
        }
 
+       /* Use default specified by driver, if nb_rx_desc is zero */
+       if (nb_rx_desc == 0) {
+               nb_rx_desc = dev_info.default_rxportconf.ring_size;
+               /* If driver default is also zero, fall back on EAL default */
+               if (nb_rx_desc == 0)
+                       nb_rx_desc = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;
+       }
+
        if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
                        nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
                        nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
 
-               RTE_PMD_DEBUG_TRACE("Invalid value for nb_rx_desc(=%hu), "
-                       "should be: <= %hu, = %hu, and a product of %hu\n",
-                       nb_rx_desc,
-                       dev_info.rx_desc_lim.nb_max,
+               RTE_ETHDEV_LOG(ERR,
+                       "Invalid value for nb_rx_desc(=%hu), should be: <= %hu, = %hu, and a product of %hu\n",
+                       nb_rx_desc, dev_info.rx_desc_lim.nb_max,
                        dev_info.rx_desc_lim.nb_min,
                        dev_info.rx_desc_lim.nb_align);
                return -EINVAL;
        }
 
+       if (dev->data->dev_started &&
+               !(dev_info.dev_capa &
+                       RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))
+               return -EBUSY;
+
+       if (dev->data->dev_started &&
+               (dev->data->rx_queue_state[rx_queue_id] !=
+                       RTE_ETH_QUEUE_STATE_STOPPED))
+               return -EBUSY;
+
        rxq = dev->data->rx_queues;
        if (rxq[rx_queue_id]) {
                RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
@@ -1486,13 +1504,34 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
                rx_conf = &dev_info.default_rxconf;
 
        local_conf = *rx_conf;
-       if (dev->data->dev_conf.rxmode.ignore_offload_bitfield == 0) {
-               /**
-                * Reflect port offloads to queue offloads in order for
-                * offloads to not be discarded.
-                */
-               rte_eth_convert_rx_offload_bitfield(&dev->data->dev_conf.rxmode,
-                                                   &local_conf.offloads);
+
+       /*
+        * If an offloading has already been enabled in
+        * rte_eth_dev_configure(), it has been enabled on all queues,
+        * so there is no need to enable it in this queue again.
+        * The local_conf.offloads input to underlying PMD only carries
+        * those offloadings which are only enabled on this queue and
+        * not enabled on all queues.
+        */
+       local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+       /*
+        * New added offloadings for this queue are those not enabled in
+        * rte_eth_dev_configure() and they must be per-queue type.
+        * A pure per-port offloading can't be enabled on a queue while
+        * disabled on another queue. A pure per-port offloading can't
+        * be enabled for any queue as new added one if it hasn't been
+        * enabled in rte_eth_dev_configure().
+        */
+       if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+            local_conf.offloads) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethdev port_id=%d rx_queue_id=%d, new added offloads 0x%"PRIx64" must be "
+                       "within pre-queue offload capabilities 0x%"PRIx64" in %s()\n",
+                       port_id, rx_queue_id, local_conf.offloads,
+                       dev_info.rx_queue_offload_capa,
+                       __func__);
+               return -EINVAL;
        }
 
        ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
@@ -1506,55 +1545,6 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
        return eth_err(port_id, ret);
 }
 
-/**
- * A conversion function from txq_flags API.
- */
-static void
-rte_eth_convert_txq_flags(const uint32_t txq_flags, uint64_t *tx_offloads)
-{
-       uint64_t offloads = 0;
-
-       if (!(txq_flags & ETH_TXQ_FLAGS_NOMULTSEGS))
-               offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
-       if (!(txq_flags & ETH_TXQ_FLAGS_NOVLANOFFL))
-               offloads |= DEV_TX_OFFLOAD_VLAN_INSERT;
-       if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP))
-               offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
-       if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMUDP))
-               offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
-       if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMTCP))
-               offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
-       if ((txq_flags & ETH_TXQ_FLAGS_NOREFCOUNT) &&
-           (txq_flags & ETH_TXQ_FLAGS_NOMULTMEMP))
-               offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
-
-       *tx_offloads = offloads;
-}
-
-/**
- * A conversion function from offloads API.
- */
-static void
-rte_eth_convert_txq_offloads(const uint64_t tx_offloads, uint32_t *txq_flags)
-{
-       uint32_t flags = 0;
-
-       if (!(tx_offloads & DEV_TX_OFFLOAD_MULTI_SEGS))
-               flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
-       if (!(tx_offloads & DEV_TX_OFFLOAD_VLAN_INSERT))
-               flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
-       if (!(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM))
-               flags |= ETH_TXQ_FLAGS_NOXSUMSCTP;
-       if (!(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM))
-               flags |= ETH_TXQ_FLAGS_NOXSUMUDP;
-       if (!(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM))
-               flags |= ETH_TXQ_FLAGS_NOXSUMTCP;
-       if (tx_offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
-               flags |= (ETH_TXQ_FLAGS_NOREFCOUNT | ETH_TXQ_FLAGS_NOMULTMEMP);
-
-       *txq_flags = flags;
-}
-
 int
 rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
                       uint16_t nb_tx_desc, unsigned int socket_id,
@@ -1569,33 +1559,43 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 
        dev = &rte_eth_devices[port_id];
        if (tx_queue_id >= dev->data->nb_tx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", tx_queue_id);
                return -EINVAL;
        }
 
-       if (dev->data->dev_started) {
-               RTE_PMD_DEBUG_TRACE(
-                   "port %d must be stopped to allow configuration\n", port_id);
-               return -EBUSY;
-       }
-
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
 
        rte_eth_dev_info_get(port_id, &dev_info);
 
+       /* Use default specified by driver, if nb_tx_desc is zero */
+       if (nb_tx_desc == 0) {
+               nb_tx_desc = dev_info.default_txportconf.ring_size;
+               /* If driver default is zero, fall back on EAL default */
+               if (nb_tx_desc == 0)
+                       nb_tx_desc = RTE_ETH_DEV_FALLBACK_TX_RINGSIZE;
+       }
        if (nb_tx_desc > dev_info.tx_desc_lim.nb_max ||
            nb_tx_desc < dev_info.tx_desc_lim.nb_min ||
            nb_tx_desc % dev_info.tx_desc_lim.nb_align != 0) {
-               RTE_PMD_DEBUG_TRACE("Invalid value for nb_tx_desc(=%hu), "
-                               "should be: <= %hu, = %hu, and a product of %hu\n",
-                               nb_tx_desc,
-                               dev_info.tx_desc_lim.nb_max,
-                               dev_info.tx_desc_lim.nb_min,
-                               dev_info.tx_desc_lim.nb_align);
+               RTE_ETHDEV_LOG(ERR,
+                       "Invalid value for nb_tx_desc(=%hu), should be: <= %hu, = %hu, and a product of %hu\n",
+                       nb_tx_desc, dev_info.tx_desc_lim.nb_max,
+                       dev_info.tx_desc_lim.nb_min,
+                       dev_info.tx_desc_lim.nb_align);
                return -EINVAL;
        }
 
+       if (dev->data->dev_started &&
+               !(dev_info.dev_capa &
+                       RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP))
+               return -EBUSY;
+
+       if (dev->data->dev_started &&
+               (dev->data->tx_queue_state[tx_queue_id] !=
+                       RTE_ETH_QUEUE_STATE_STOPPED))
+               return -EBUSY;
+
        txq = dev->data->tx_queues;
        if (txq[tx_queue_id]) {
                RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release,
@@ -1607,19 +1607,35 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
        if (tx_conf == NULL)
                tx_conf = &dev_info.default_txconf;
 
+       local_conf = *tx_conf;
+
        /*
-        * Convert between the offloads API to enable PMDs to support
-        * only one of them.
+        * If an offloading has already been enabled in
+        * rte_eth_dev_configure(), it has been enabled on all queues,
+        * so there is no need to enable it in this queue again.
+        * The local_conf.offloads input to underlying PMD only carries
+        * those offloadings which are only enabled on this queue and
+        * not enabled on all queues.
         */
-       local_conf = *tx_conf;
-       if (tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE) {
-               rte_eth_convert_txq_offloads(tx_conf->offloads,
-                                            &local_conf.txq_flags);
-               /* Keep the ignore flag. */
-               local_conf.txq_flags |= ETH_TXQ_FLAGS_IGNORE;
-       } else {
-               rte_eth_convert_txq_flags(tx_conf->txq_flags,
-                                         &local_conf.offloads);
+       local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
+
+       /*
+        * New added offloadings for this queue are those not enabled in
+        * rte_eth_dev_configure() and they must be per-queue type.
+        * A pure per-port offloading can't be enabled on a queue while
+        * disabled on another queue. A pure per-port offloading can't
+        * be enabled for any queue as new added one if it hasn't been
+        * enabled in rte_eth_dev_configure().
+        */
+       if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+            local_conf.offloads) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethdev port_id=%d tx_queue_id=%d, new added offloads 0x%"PRIx64" must be "
+                       "within pre-queue offload capabilities 0x%"PRIx64" in %s()\n",
+                       port_id, tx_queue_id, local_conf.offloads,
+                       dev_info.tx_queue_offload_capa,
+                       __func__);
+               return -EINVAL;
        }
 
        return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
@@ -1765,20 +1781,6 @@ rte_eth_allmulticast_get(uint16_t port_id)
        return dev->data->all_multicast;
 }
 
-static inline int
-rte_eth_dev_atomic_read_link_status(struct rte_eth_dev *dev,
-                               struct rte_eth_link *link)
-{
-       struct rte_eth_link *dst = link;
-       struct rte_eth_link *src = &(dev->data->dev_link);
-
-       if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
-                                       *(uint64_t *)src) == 0)
-               return -1;
-
-       return 0;
-}
-
 void
 rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
 {
@@ -1787,8 +1789,9 @@ rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
        RTE_ETH_VALID_PORTID_OR_RET(port_id);
        dev = &rte_eth_devices[port_id];
 
-       if (dev->data->dev_conf.intr_conf.lsc != 0)
-               rte_eth_dev_atomic_read_link_status(dev, eth_link);
+       if (dev->data->dev_conf.intr_conf.lsc &&
+           dev->data->dev_started)
+               rte_eth_linkstatus_get(dev, eth_link);
        else {
                RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
                (*dev->dev_ops->link_update)(dev, 1);
@@ -1804,8 +1807,9 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
        RTE_ETH_VALID_PORTID_OR_RET(port_id);
        dev = &rte_eth_devices[port_id];
 
-       if (dev->data->dev_conf.intr_conf.lsc != 0)
-               rte_eth_dev_atomic_read_link_status(dev, eth_link);
+       if (dev->data->dev_conf.intr_conf.lsc &&
+           dev->data->dev_started)
+               rte_eth_linkstatus_get(dev, eth_link);
        else {
                RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
                (*dev->dev_ops->link_update)(dev, 0);
@@ -1895,19 +1899,19 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
        if (!id) {
-               RTE_PMD_DEBUG_TRACE("Error: id pointer is NULL\n");
+               RTE_ETHDEV_LOG(ERR, "Id pointer is NULL\n");
                return -ENOMEM;
        }
 
        if (!xstat_name) {
-               RTE_PMD_DEBUG_TRACE("Error: xstat_name pointer is NULL\n");
+               RTE_ETHDEV_LOG(ERR, "xstat_name pointer is NULL\n");
                return -ENOMEM;
        }
 
        /* Get count */
        cnt_xstats = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
        if (cnt_xstats  < 0) {
-               RTE_PMD_DEBUG_TRACE("Error: Cannot get count of xstats\n");
+               RTE_ETHDEV_LOG(ERR, "Cannot get count of xstats\n");
                return -ENODEV;
        }
 
@@ -1916,7 +1920,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
 
        if (cnt_xstats != rte_eth_xstats_get_names_by_id(
                        port_id, xstats_names, cnt_xstats, NULL)) {
-               RTE_PMD_DEBUG_TRACE("Error: Cannot get xstats lookup\n");
+               RTE_ETHDEV_LOG(ERR, "Cannot get xstats lookup\n");
                return -1;
        }
 
@@ -2039,7 +2043,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,
                sizeof(struct rte_eth_xstat_name));
 
        if (!xstats_names_copy) {
-               RTE_PMD_DEBUG_TRACE("ERROR: can't allocate memory");
+               RTE_ETHDEV_LOG(ERR, "Can't allocate memory\n");
                return -ENOMEM;
        }
 
@@ -2067,7 +2071,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,
        /* Filter stats */
        for (i = 0; i < size; i++) {
                if (ids[i] >= expected_entries) {
-                       RTE_PMD_DEBUG_TRACE("ERROR: id value isn't valid\n");
+                       RTE_ETHDEV_LOG(ERR, "Id value isn't valid\n");
                        free(xstats_names_copy);
                        return -1;
                }
@@ -2252,7 +2256,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
        /* Filter stats */
        for (i = 0; i < size; i++) {
                if (ids[i] >= expected_entries) {
-                       RTE_PMD_DEBUG_TRACE("ERROR: id value isn't valid\n");
+                       RTE_ETHDEV_LOG(ERR, "Id value isn't valid\n");
                        return -1;
                }
                values[i] = xstats[ids[i]].value;
@@ -2342,6 +2346,16 @@ set_queue_stats_mapping(uint16_t port_id, uint16_t queue_id, uint8_t stat_idx,
        dev = &rte_eth_devices[port_id];
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
+
+       if (is_rx && (queue_id >= dev->data->nb_rx_queues))
+               return -EINVAL;
+
+       if (!is_rx && (queue_id >= dev->data->nb_tx_queues))
+               return -EINVAL;
+
+       if (stat_idx >= RTE_ETHDEV_QUEUE_STAT_CNTRS)
+               return -EINVAL;
+
        return (*dev->dev_ops->queue_stats_mapping_set)
                        (dev, queue_id, stat_idx, is_rx);
 }
@@ -2393,12 +2407,15 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
        memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
        dev_info->rx_desc_lim = lim;
        dev_info->tx_desc_lim = lim;
+       dev_info->device = dev->device;
 
        RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
        (*dev->dev_ops->dev_infos_get)(dev, dev_info);
        dev_info->driver_name = dev->device->driver->name;
        dev_info->nb_rx_queues = dev->data->nb_rx_queues;
        dev_info->nb_tx_queues = dev->data->nb_tx_queues;
+
+       dev_info->dev_flags = &dev->data->dev_flags;
 }
 
 int
@@ -2477,13 +2494,14 @@ rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on)
        dev = &rte_eth_devices[port_id];
        if (!(dev->data->dev_conf.rxmode.offloads &
              DEV_RX_OFFLOAD_VLAN_FILTER)) {
-               RTE_PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
+               RTE_ETHDEV_LOG(ERR, "Port %u: vlan-filtering disabled\n",
+                       port_id);
                return -ENOSYS;
        }
 
        if (vlan_id > 4095) {
-               RTE_PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
-                               port_id, (unsigned) vlan_id);
+               RTE_ETHDEV_LOG(ERR, "Port_id=%u invalid vlan_id=%u > 4095\n",
+                       port_id, vlan_id);
                return -EINVAL;
        }
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
@@ -2516,7 +2534,7 @@ rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
        if (rx_queue_id >= dev->data->nb_rx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid rx_queue_id=%u\n", rx_queue_id);
                return -EINVAL;
        }
 
@@ -2601,19 +2619,10 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask)
                return ret;
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
-
-       /*
-        * Convert to the offload bitfield API just in case the underlying PMD
-        * still supporting it.
-        */
-       rte_eth_convert_rx_offloads(dev->data->dev_conf.rxmode.offloads,
-                                   &dev->data->dev_conf.rxmode);
        ret = (*dev->dev_ops->vlan_offload_set)(dev, mask);
        if (ret) {
                /* hit an error restore  original values */
                dev->data->dev_conf.rxmode.offloads = orig_offloads;
-               rte_eth_convert_rx_offloads(dev->data->dev_conf.rxmode.offloads,
-                                           &dev->data->dev_conf.rxmode);
        }
 
        return eth_err(port_id, ret);
@@ -2674,7 +2683,7 @@ rte_eth_dev_flow_ctrl_set(uint16_t port_id, struct rte_eth_fc_conf *fc_conf)
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
-               RTE_PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid send_xon, only 0/1 allowed\n");
                return -EINVAL;
        }
 
@@ -2691,7 +2700,7 @@ rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
-               RTE_PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid priority, only 0-7 allowed\n");
                return -EINVAL;
        }
 
@@ -2732,7 +2741,7 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
                return -EINVAL;
 
        if (max_rxq == 0) {
-               RTE_PMD_DEBUG_TRACE("No receive queue is available\n");
+               RTE_ETHDEV_LOG(ERR, "No receive queue is available\n");
                return -EINVAL;
        }
 
@@ -2741,8 +2750,9 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
                shift = i % RTE_RETA_GROUP_SIZE;
                if ((reta_conf[idx].mask & (1ULL << shift)) &&
                        (reta_conf[idx].reta[shift] >= max_rxq)) {
-                       RTE_PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
-                               "the maximum rxq index: %u\n", idx, shift,
+                       RTE_ETHDEV_LOG(ERR,
+                               "reta_conf[%u]->reta[%u]: %u exceeds the maximum rxq index: %u\n",
+                               idx, shift,
                                reta_conf[idx].reta[shift], max_rxq);
                        return -EINVAL;
                }
@@ -2804,9 +2814,19 @@ rte_eth_dev_rss_hash_update(uint16_t port_id,
                            struct rte_eth_rss_conf *rss_conf)
 {
        struct rte_eth_dev *dev;
+       struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
+       rte_eth_dev_info_get(port_id, &dev_info);
+       if ((dev_info.flow_type_rss_offloads | rss_conf->rss_hf) !=
+           dev_info.flow_type_rss_offloads) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethdev port_id=%u invalid rss_hf: 0x%"PRIx64", valid value: 0x%"PRIx64"\n",
+                       port_id, rss_conf->rss_hf,
+                       dev_info.flow_type_rss_offloads);
+               return -EINVAL;
+       }
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
        return eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev,
                                                                 rss_conf));
@@ -2833,12 +2853,12 @@ rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        if (udp_tunnel == NULL) {
-               RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid udp_tunnel parameter\n");
                return -EINVAL;
        }
 
        if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-               RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid tunnel type\n");
                return -EINVAL;
        }
 
@@ -2858,12 +2878,12 @@ rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
        dev = &rte_eth_devices[port_id];
 
        if (udp_tunnel == NULL) {
-               RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid udp_tunnel parameter\n");
                return -EINVAL;
        }
 
        if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-               RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid tunnel type\n");
                return -EINVAL;
        }
 
@@ -2931,12 +2951,12 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *addr,
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
 
        if (is_zero_ether_addr(addr)) {
-               RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+               RTE_ETHDEV_LOG(ERR, "Port %u: Cannot add NULL MAC address\n",
                        port_id);
                return -EINVAL;
        }
        if (pool >= ETH_64_POOLS) {
-               RTE_PMD_DEBUG_TRACE("pool id must be 0-%d\n", ETH_64_POOLS - 1);
+               RTE_ETHDEV_LOG(ERR, "Pool id must be 0-%d\n", ETH_64_POOLS - 1);
                return -EINVAL;
        }
 
@@ -2944,7 +2964,7 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *addr,
        if (index < 0) {
                index = get_mac_addr_index(port_id, &null_mac_addr);
                if (index < 0) {
-                       RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
+                       RTE_ETHDEV_LOG(ERR, "Port %u: MAC address array full\n",
                                port_id);
                        return -ENOSPC;
                }
@@ -2982,7 +3002,9 @@ rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *addr)
 
        index = get_mac_addr_index(port_id, addr);
        if (index == 0) {
-               RTE_PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
+               RTE_ETHDEV_LOG(ERR,
+                       "Port %u: Cannot remove default MAC address\n",
+                       port_id);
                return -EADDRINUSE;
        } else if (index < 0)
                return 0;  /* Do nothing if address wasn't found */
@@ -3003,6 +3025,7 @@ int
 rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
 {
        struct rte_eth_dev *dev;
+       int ret;
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
@@ -3012,11 +3035,13 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
        dev = &rte_eth_devices[port_id];
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
 
+       ret = (*dev->dev_ops->mac_addr_set)(dev, addr);
+       if (ret < 0)
+               return ret;
+
        /* Update default address in NIC data structure */
        ether_addr_copy(addr, &dev->data->mac_addrs[0]);
 
-       (*dev->dev_ops->mac_addr_set)(dev, addr);
-
        return 0;
 }
 
@@ -3056,7 +3081,7 @@ rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
 
        dev = &rte_eth_devices[port_id];
        if (is_zero_ether_addr(addr)) {
-               RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+               RTE_ETHDEV_LOG(ERR, "Port %u: Cannot add NULL MAC address\n",
                        port_id);
                return -EINVAL;
        }
@@ -3068,15 +3093,16 @@ rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
 
        if (index < 0) {
                if (!on) {
-                       RTE_PMD_DEBUG_TRACE("port %d: the MAC address was not "
-                               "set in UTA\n", port_id);
+                       RTE_ETHDEV_LOG(ERR,
+                               "Port %u: the MAC address was not set in UTA\n",
+                               port_id);
                        return -EINVAL;
                }
 
                index = get_hash_mac_addr_index(port_id, &null_mac_addr);
                if (index < 0) {
-                       RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
-                                       port_id);
+                       RTE_ETHDEV_LOG(ERR, "Port %u: MAC address array full\n",
+                               port_id);
                        return -ENOSPC;
                }
        }
@@ -3124,14 +3150,15 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
        link = dev->data->dev_link;
 
        if (queue_idx > dev_info.max_tx_queues) {
-               RTE_PMD_DEBUG_TRACE("set queue rate limit:port %d: "
-                               "invalid queue id=%d\n", port_id, queue_idx);
+               RTE_ETHDEV_LOG(ERR,
+                       "Set queue rate limit:port %u: invalid queue id=%u\n",
+                       port_id, queue_idx);
                return -EINVAL;
        }
 
        if (tx_rate > link.link_speed) {
-               RTE_PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
-                               "bigger than link speed= %d\n",
+               RTE_ETHDEV_LOG(ERR,
+                       "Set queue rate limit:invalid tx_rate=%u, bigger than link speed= %d\n",
                        tx_rate, link.link_speed);
                return -EINVAL;
        }
@@ -3150,26 +3177,28 @@ rte_eth_mirror_rule_set(uint16_t port_id,
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        if (mirror_conf->rule_type == 0) {
-               RTE_PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
+               RTE_ETHDEV_LOG(ERR, "Mirror rule type can not be 0\n");
                return -EINVAL;
        }
 
        if (mirror_conf->dst_pool >= ETH_64_POOLS) {
-               RTE_PMD_DEBUG_TRACE("Invalid dst pool, pool id must be 0-%d\n",
-                               ETH_64_POOLS - 1);
+               RTE_ETHDEV_LOG(ERR, "Invalid dst pool, pool id must be 0-%d\n",
+                       ETH_64_POOLS - 1);
                return -EINVAL;
        }
 
        if ((mirror_conf->rule_type & (ETH_MIRROR_VIRTUAL_POOL_UP |
             ETH_MIRROR_VIRTUAL_POOL_DOWN)) &&
            (mirror_conf->pool_mask == 0)) {
-               RTE_PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not be 0.\n");
+               RTE_ETHDEV_LOG(ERR,
+                       "Invalid mirror pool, pool mask can not be 0\n");
                return -EINVAL;
        }
 
        if ((mirror_conf->rule_type & ETH_MIRROR_VLAN) &&
            mirror_conf->vlan.vlan_mask == 0) {
-               RTE_PMD_DEBUG_TRACE("Invalid vlan mask, vlan mask can not be 0.\n");
+               RTE_ETHDEV_LOG(ERR,
+                       "Invalid vlan mask, vlan mask can not be 0\n");
                return -EINVAL;
        }
 
@@ -3216,7 +3245,7 @@ rte_eth_dev_callback_register(uint16_t port_id,
                return -EINVAL;
 
        if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
-               RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid port_id=%d\n", port_id);
                return -EINVAL;
        }
 
@@ -3279,7 +3308,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
                return -EINVAL;
 
        if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
-               RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid port_id=%d\n", port_id);
                return -EINVAL;
        }
 
@@ -3348,6 +3377,17 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
        return rc;
 }
 
+void
+rte_eth_dev_probing_finish(struct rte_eth_dev *dev)
+{
+       if (dev == NULL)
+               return;
+
+       _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_NEW, NULL);
+
+       dev->state = RTE_ETH_DEV_ATTACHED;
+}
+
 int
 rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
 {
@@ -3362,13 +3402,13 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
        dev = &rte_eth_devices[port_id];
 
        if (!dev->intr_handle) {
-               RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+               RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
                return -ENOTSUP;
        }
 
        intr_handle = dev->intr_handle;
        if (!intr_handle->intr_vec) {
-               RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
+               RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
                return -EPERM;
        }
 
@@ -3376,9 +3416,9 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
                vec = intr_handle->intr_vec[qid];
                rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
                if (rc && rc != -EEXIST) {
-                       RTE_PMD_DEBUG_TRACE("p %u q %u rx ctl error"
-                                       " op %d epfd %d vec %u\n",
-                                       port_id, qid, op, epfd, vec);
+                       RTE_ETHDEV_LOG(ERR,
+                               "p %u q %u rx ctl error op %d epfd %d vec %u\n",
+                               port_id, qid, op, epfd, vec);
                }
        }
 
@@ -3401,7 +3441,103 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
        if (mz)
                return mz;
 
-       return rte_memzone_reserve_aligned(z_name, size, socket_id, 0, align);
+       return rte_memzone_reserve_aligned(z_name, size, socket_id,
+                       RTE_MEMZONE_IOVA_CONTIG, align);
+}
+
+int __rte_experimental
+rte_eth_dev_create(struct rte_device *device, const char *name,
+       size_t priv_data_size,
+       ethdev_bus_specific_init ethdev_bus_specific_init,
+       void *bus_init_params,
+       ethdev_init_t ethdev_init, void *init_params)
+{
+       struct rte_eth_dev *ethdev;
+       int retval;
+
+       RTE_FUNC_PTR_OR_ERR_RET(*ethdev_init, -EINVAL);
+
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+               ethdev = rte_eth_dev_allocate(name);
+               if (!ethdev) {
+                       retval = -ENODEV;
+                       goto probe_failed;
+               }
+
+               if (priv_data_size) {
+                       ethdev->data->dev_private = rte_zmalloc_socket(
+                               name, priv_data_size, RTE_CACHE_LINE_SIZE,
+                               device->numa_node);
+
+                       if (!ethdev->data->dev_private) {
+                               RTE_LOG(ERR, EAL, "failed to allocate private data");
+                               retval = -ENOMEM;
+                               goto probe_failed;
+                       }
+               }
+       } else {
+               ethdev = rte_eth_dev_attach_secondary(name);
+               if (!ethdev) {
+                       RTE_LOG(ERR, EAL, "secondary process attach failed, "
+                               "ethdev doesn't exist");
+                       retval = -ENODEV;
+                       goto probe_failed;
+               }
+       }
+
+       ethdev->device = device;
+
+       if (ethdev_bus_specific_init) {
+               retval = ethdev_bus_specific_init(ethdev, bus_init_params);
+               if (retval) {
+                       RTE_LOG(ERR, EAL,
+                               "ethdev bus specific initialisation failed");
+                       goto probe_failed;
+               }
+       }
+
+       retval = ethdev_init(ethdev, init_params);
+       if (retval) {
+               RTE_LOG(ERR, EAL, "ethdev initialisation failed");
+               goto probe_failed;
+       }
+
+       rte_eth_dev_probing_finish(ethdev);
+
+       return retval;
+probe_failed:
+       /* free ports private data if primary process */
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+               rte_free(ethdev->data->dev_private);
+
+       rte_eth_dev_release_port(ethdev);
+
+       return retval;
+}
+
+int  __rte_experimental
+rte_eth_dev_destroy(struct rte_eth_dev *ethdev,
+       ethdev_uninit_t ethdev_uninit)
+{
+       int ret;
+
+       ethdev = rte_eth_dev_allocated(ethdev->data->name);
+       if (!ethdev)
+               return -ENODEV;
+
+       RTE_FUNC_PTR_OR_ERR_RET(*ethdev_uninit, -EINVAL);
+       if (ethdev_uninit) {
+               ret = ethdev_uninit(ethdev);
+               if (ret)
+                       return ret;
+       }
+
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+               rte_free(ethdev->data->dev_private);
+
+       ethdev->data->dev_private = NULL;
+
+       return rte_eth_dev_release_port(ethdev);
 }
 
 int
@@ -3417,27 +3553,27 @@ rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
 
        dev = &rte_eth_devices[port_id];
        if (queue_id >= dev->data->nb_rx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%u\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
                return -EINVAL;
        }
 
        if (!dev->intr_handle) {
-               RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+               RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
                return -ENOTSUP;
        }
 
        intr_handle = dev->intr_handle;
        if (!intr_handle->intr_vec) {
-               RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
+               RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
                return -EPERM;
        }
 
        vec = intr_handle->intr_vec[queue_id];
        rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
        if (rc && rc != -EEXIST) {
-               RTE_PMD_DEBUG_TRACE("p %u q %u rx ctl error"
-                               " op %d epfd %d vec %u\n",
-                               port_id, queue_id, op, epfd, vec);
+               RTE_ETHDEV_LOG(ERR,
+                       "p %u q %u rx ctl error op %d epfd %d vec %u\n",
+                       port_id, queue_id, op, epfd, vec);
                return rc;
        }
 
@@ -3490,153 +3626,8 @@ rte_eth_dev_filter_supported(uint16_t port_id,
 }
 
 int
-rte_eth_dev_filter_ctrl_v22(uint16_t port_id,
-                           enum rte_filter_type filter_type,
-                           enum rte_filter_op filter_op, void *arg);
-
-int
-rte_eth_dev_filter_ctrl_v22(uint16_t port_id,
-                           enum rte_filter_type filter_type,
-                           enum rte_filter_op filter_op, void *arg)
-{
-       struct rte_eth_fdir_info_v22 {
-               enum rte_fdir_mode mode;
-               struct rte_eth_fdir_masks mask;
-               struct rte_eth_fdir_flex_conf flex_conf;
-               uint32_t guarant_spc;
-               uint32_t best_spc;
-               uint32_t flow_types_mask[1];
-               uint32_t max_flexpayload;
-               uint32_t flex_payload_unit;
-               uint32_t max_flex_payload_segment_num;
-               uint16_t flex_payload_limit;
-               uint32_t flex_bitmask_unit;
-               uint32_t max_flex_bitmask_num;
-       };
-
-       struct rte_eth_hash_global_conf_v22 {
-               enum rte_eth_hash_function hash_func;
-               uint32_t sym_hash_enable_mask[1];
-               uint32_t valid_bit_mask[1];
-       };
-
-       struct rte_eth_hash_filter_info_v22 {
-               enum rte_eth_hash_filter_info_type info_type;
-               union {
-                       uint8_t enable;
-                       struct rte_eth_hash_global_conf_v22 global_conf;
-                       struct rte_eth_input_set_conf input_set_conf;
-               } info;
-       };
-
-       struct rte_eth_dev *dev;
-
-       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-
-       dev = &rte_eth_devices[port_id];
-       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
-       if (filter_op == RTE_ETH_FILTER_INFO) {
-               int retval;
-               struct rte_eth_fdir_info_v22 *fdir_info_v22;
-               struct rte_eth_fdir_info fdir_info;
-
-               fdir_info_v22 = (struct rte_eth_fdir_info_v22 *)arg;
-
-               retval = (*dev->dev_ops->filter_ctrl)(dev, filter_type,
-                         filter_op, (void *)&fdir_info);
-               fdir_info_v22->mode = fdir_info.mode;
-               fdir_info_v22->mask = fdir_info.mask;
-               fdir_info_v22->flex_conf = fdir_info.flex_conf;
-               fdir_info_v22->guarant_spc = fdir_info.guarant_spc;
-               fdir_info_v22->best_spc = fdir_info.best_spc;
-               fdir_info_v22->flow_types_mask[0] =
-                       (uint32_t)fdir_info.flow_types_mask[0];
-               fdir_info_v22->max_flexpayload = fdir_info.max_flexpayload;
-               fdir_info_v22->flex_payload_unit = fdir_info.flex_payload_unit;
-               fdir_info_v22->max_flex_payload_segment_num =
-                       fdir_info.max_flex_payload_segment_num;
-               fdir_info_v22->flex_payload_limit =
-                       fdir_info.flex_payload_limit;
-               fdir_info_v22->flex_bitmask_unit = fdir_info.flex_bitmask_unit;
-               fdir_info_v22->max_flex_bitmask_num =
-                       fdir_info.max_flex_bitmask_num;
-               return retval;
-       } else if (filter_op == RTE_ETH_FILTER_GET) {
-               int retval;
-               struct rte_eth_hash_filter_info f_info;
-               struct rte_eth_hash_filter_info_v22 *f_info_v22 =
-                       (struct rte_eth_hash_filter_info_v22 *)arg;
-
-               f_info.info_type = f_info_v22->info_type;
-               retval = (*dev->dev_ops->filter_ctrl)(dev, filter_type,
-                         filter_op, (void *)&f_info);
-
-               switch (f_info_v22->info_type) {
-               case RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT:
-                       f_info_v22->info.enable = f_info.info.enable;
-                       break;
-               case RTE_ETH_HASH_FILTER_GLOBAL_CONFIG:
-                       f_info_v22->info.global_conf.hash_func =
-                               f_info.info.global_conf.hash_func;
-                       f_info_v22->info.global_conf.sym_hash_enable_mask[0] =
-                               (uint32_t)
-                               f_info.info.global_conf.sym_hash_enable_mask[0];
-                       f_info_v22->info.global_conf.valid_bit_mask[0] =
-                               (uint32_t)
-                               f_info.info.global_conf.valid_bit_mask[0];
-                       break;
-               case RTE_ETH_HASH_FILTER_INPUT_SET_SELECT:
-                       f_info_v22->info.input_set_conf =
-                               f_info.info.input_set_conf;
-                       break;
-               default:
-                       break;
-               }
-               return retval;
-       } else if (filter_op == RTE_ETH_FILTER_SET) {
-               struct rte_eth_hash_filter_info f_info;
-               struct rte_eth_hash_filter_info_v22 *f_v22 =
-                       (struct rte_eth_hash_filter_info_v22 *)arg;
-
-               f_info.info_type = f_v22->info_type;
-               switch (f_v22->info_type) {
-               case RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT:
-                       f_info.info.enable = f_v22->info.enable;
-                       break;
-               case RTE_ETH_HASH_FILTER_GLOBAL_CONFIG:
-                       f_info.info.global_conf.hash_func =
-                               f_v22->info.global_conf.hash_func;
-                       f_info.info.global_conf.sym_hash_enable_mask[0] =
-                               (uint32_t)
-                               f_v22->info.global_conf.sym_hash_enable_mask[0];
-                       f_info.info.global_conf.valid_bit_mask[0] =
-                               (uint32_t)
-                               f_v22->info.global_conf.valid_bit_mask[0];
-                       break;
-               case RTE_ETH_HASH_FILTER_INPUT_SET_SELECT:
-                       f_info.info.input_set_conf =
-                               f_v22->info.input_set_conf;
-                       break;
-               default:
-                       break;
-               }
-               return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op,
-                                                   (void *)&f_info);
-       } else
-               return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op,
-                                                   arg);
-}
-VERSION_SYMBOL(rte_eth_dev_filter_ctrl, _v22, 2.2);
-
-int
-rte_eth_dev_filter_ctrl_v1802(uint16_t port_id,
-                             enum rte_filter_type filter_type,
-                             enum rte_filter_op filter_op, void *arg);
-
-int
-rte_eth_dev_filter_ctrl_v1802(uint16_t port_id,
-                             enum rte_filter_type filter_type,
-                             enum rte_filter_op filter_op, void *arg)
+rte_eth_dev_filter_ctrl(uint16_t port_id, enum rte_filter_type filter_type,
+                       enum rte_filter_op filter_op, void *arg)
 {
        struct rte_eth_dev *dev;
 
@@ -3647,13 +3638,8 @@ rte_eth_dev_filter_ctrl_v1802(uint16_t port_id,
        return eth_err(port_id, (*dev->dev_ops->filter_ctrl)(dev, filter_type,
                                                             filter_op, arg));
 }
-BIND_DEFAULT_SYMBOL(rte_eth_dev_filter_ctrl, _v1802, 18.02);
-MAP_STATIC_SYMBOL(int rte_eth_dev_filter_ctrl(uint16_t port_id,
-                 enum rte_filter_type filter_type,
-                 enum rte_filter_op filter_op, void *arg),
-                 rte_eth_dev_filter_ctrl_v1802);
 
-void *
+const struct rte_eth_rxtx_callback *
 rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
                rte_rx_callback_fn fn, void *user_param)
 {
@@ -3695,7 +3681,7 @@ rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
        return cb;
 }
 
-void *
+const struct rte_eth_rxtx_callback *
 rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
                rte_rx_callback_fn fn, void *user_param)
 {
@@ -3730,7 +3716,7 @@ rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
        return cb;
 }
 
-void *
+const struct rte_eth_rxtx_callback *
 rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
                rte_tx_callback_fn fn, void *user_param)
 {
@@ -3775,7 +3761,7 @@ rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
 
 int
 rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
-               struct rte_eth_rxtx_callback *user_cb)
+               const struct rte_eth_rxtx_callback *user_cb)
 {
 #ifndef RTE_ETHDEV_RXTX_CALLBACKS
        return -ENOTSUP;
@@ -3809,7 +3795,7 @@ rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
 
 int
 rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
-               struct rte_eth_rxtx_callback *user_cb)
+               const struct rte_eth_rxtx_callback *user_cb)
 {
 #ifndef RTE_ETHDEV_RXTX_CALLBACKS
        return -ENOTSUP;
@@ -3854,7 +3840,7 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 
        dev = &rte_eth_devices[port_id];
        if (queue_id >= dev->data->nb_rx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
                return -EINVAL;
        }
 
@@ -3878,7 +3864,7 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 
        dev = &rte_eth_devices[port_id];
        if (queue_id >= dev->data->nb_tx_queues) {
-               RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
                return -EINVAL;
        }
 
@@ -3886,6 +3872,7 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 
        memset(qinfo, 0, sizeof(*qinfo));
        dev->dev_ops->txq_info_get(dev, queue_id, qinfo);
+
        return 0;
 }
 
@@ -4043,6 +4030,32 @@ rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info)
        return eth_err(port_id, (*dev->dev_ops->set_eeprom)(dev, info));
 }
 
+int __rte_experimental
+rte_eth_dev_get_module_info(uint16_t port_id,
+                           struct rte_eth_dev_module_info *modinfo)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       dev = &rte_eth_devices[port_id];
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_module_info, -ENOTSUP);
+       return (*dev->dev_ops->get_module_info)(dev, modinfo);
+}
+
+int __rte_experimental
+rte_eth_dev_get_module_eeprom(uint16_t port_id,
+                             struct rte_dev_eeprom_info *info)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       dev = &rte_eth_devices[port_id];
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_module_eeprom, -ENOTSUP);
+       return (*dev->dev_ops->get_module_eeprom)(dev, info);
+}
+
 int
 rte_eth_dev_get_dcb_info(uint16_t port_id,
                             struct rte_eth_dcb_info *dcb_info)
@@ -4066,12 +4079,12 @@ rte_eth_dev_l2_tunnel_eth_type_conf(uint16_t port_id,
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        if (l2_tunnel == NULL) {
-               RTE_PMD_DEBUG_TRACE("Invalid l2_tunnel parameter\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid l2_tunnel parameter\n");
                return -EINVAL;
        }
 
        if (l2_tunnel->l2_tunnel_type >= RTE_TUNNEL_TYPE_MAX) {
-               RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid tunnel type\n");
                return -EINVAL;
        }
 
@@ -4093,17 +4106,17 @@ rte_eth_dev_l2_tunnel_offload_set(uint16_t port_id,
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
        if (l2_tunnel == NULL) {
-               RTE_PMD_DEBUG_TRACE("Invalid l2_tunnel parameter\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid l2_tunnel parameter\n");
                return -EINVAL;
        }
 
        if (l2_tunnel->l2_tunnel_type >= RTE_TUNNEL_TYPE_MAX) {
-               RTE_PMD_DEBUG_TRACE("Invalid tunnel type.\n");
+               RTE_ETHDEV_LOG(ERR, "Invalid tunnel type\n");
                return -EINVAL;
        }
 
        if (mask == 0) {
-               RTE_PMD_DEBUG_TRACE("Mask should have a value.\n");
+               RTE_ETHDEV_LOG(ERR, "Mask should have a value\n");
                return -EINVAL;
        }
 
@@ -4168,3 +4181,245 @@ rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool)
 
        return (*dev->dev_ops->pool_ops_supported)(dev, pool);
 }
+
+/**
+ * A set of values to describe the possible states of a switch domain.
+ */
+enum rte_eth_switch_domain_state {
+       RTE_ETH_SWITCH_DOMAIN_UNUSED = 0,
+       RTE_ETH_SWITCH_DOMAIN_ALLOCATED
+};
+
+/**
+ * Array of switch domains available for allocation. Array is sized to
+ * RTE_MAX_ETHPORTS elements as there cannot be more active switch domains than
+ * ethdev ports in a single process.
+ */
+struct rte_eth_dev_switch {
+       enum rte_eth_switch_domain_state state;
+} rte_eth_switch_domains[RTE_MAX_ETHPORTS];
+
+int __rte_experimental
+rte_eth_switch_domain_alloc(uint16_t *domain_id)
+{
+       unsigned int i;
+
+       *domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;
+
+       for (i = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID + 1;
+               i < RTE_MAX_ETHPORTS; i++) {
+               if (rte_eth_switch_domains[i].state ==
+                       RTE_ETH_SWITCH_DOMAIN_UNUSED) {
+                       rte_eth_switch_domains[i].state =
+                               RTE_ETH_SWITCH_DOMAIN_ALLOCATED;
+                       *domain_id = i;
+                       return 0;
+               }
+       }
+
+       return -ENOSPC;
+}
+
+int __rte_experimental
+rte_eth_switch_domain_free(uint16_t domain_id)
+{
+       if (domain_id == RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID ||
+               domain_id >= RTE_MAX_ETHPORTS)
+               return -EINVAL;
+
+       if (rte_eth_switch_domains[domain_id].state !=
+               RTE_ETH_SWITCH_DOMAIN_ALLOCATED)
+               return -EINVAL;
+
+       rte_eth_switch_domains[domain_id].state = RTE_ETH_SWITCH_DOMAIN_UNUSED;
+
+       return 0;
+}
+
+typedef int (*rte_eth_devargs_callback_t)(char *str, void *data);
+
+static int
+rte_eth_devargs_tokenise(struct rte_kvargs *arglist, const char *str_in)
+{
+       int state;
+       struct rte_kvargs_pair *pair;
+       char *letter;
+
+       arglist->str = strdup(str_in);
+       if (arglist->str == NULL)
+               return -ENOMEM;
+
+       letter = arglist->str;
+       state = 0;
+       arglist->count = 0;
+       pair = &arglist->pairs[0];
+       while (1) {
+               switch (state) {
+               case 0: /* Initial */
+                       if (*letter == '=')
+                               return -EINVAL;
+                       else if (*letter == '\0')
+                               return 0;
+
+                       state = 1;
+                       pair->key = letter;
+                       /* fall-thru */
+
+               case 1: /* Parsing key */
+                       if (*letter == '=') {
+                               *letter = '\0';
+                               pair->value = letter + 1;
+                               state = 2;
+                       } else if (*letter == ',' || *letter == '\0')
+                               return -EINVAL;
+                       break;
+
+
+               case 2: /* Parsing value */
+                       if (*letter == '[')
+                               state = 3;
+                       else if (*letter == ',') {
+                               *letter = '\0';
+                               arglist->count++;
+                               pair = &arglist->pairs[arglist->count];
+                               state = 0;
+                       } else if (*letter == '\0') {
+                               letter--;
+                               arglist->count++;
+                               pair = &arglist->pairs[arglist->count];
+                               state = 0;
+                       }
+                       break;
+
+               case 3: /* Parsing list */
+                       if (*letter == ']')
+                               state = 2;
+                       else if (*letter == '\0')
+                               return -EINVAL;
+                       break;
+               }
+               letter++;
+       }
+}
+
+static int
+rte_eth_devargs_parse_list(char *str, rte_eth_devargs_callback_t callback,
+       void *data)
+{
+       char *str_start;
+       int state;
+       int result;
+
+       if (*str != '[')
+               /* Single element, not a list */
+               return callback(str, data);
+
+       /* Sanity check, then strip the brackets */
+       str_start = &str[strlen(str) - 1];
+       if (*str_start != ']') {
+               RTE_LOG(ERR, EAL, "(%s): List does not end with ']'", str);
+               return -EINVAL;
+       }
+       str++;
+       *str_start = '\0';
+
+       /* Process list elements */
+       state = 0;
+       while (1) {
+               if (state == 0) {
+                       if (*str == '\0')
+                               break;
+                       if (*str != ',') {
+                               str_start = str;
+                               state = 1;
+                       }
+               } else if (state == 1) {
+                       if (*str == ',' || *str == '\0') {
+                               if (str > str_start) {
+                                       /* Non-empty string fragment */
+                                       *str = '\0';
+                                       result = callback(str_start, data);
+                                       if (result < 0)
+                                               return result;
+                               }
+                               state = 0;
+                       }
+               }
+               str++;
+       }
+       return 0;
+}
+
+static int
+rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list,
+       const uint16_t max_list)
+{
+       uint16_t lo, hi, val;
+       int result;
+
+       result = sscanf(str, "%hu-%hu", &lo, &hi);
+       if (result == 1) {
+               if (*len_list >= max_list)
+                       return -ENOMEM;
+               list[(*len_list)++] = lo;
+       } else if (result == 2) {
+               if (lo >= hi || lo > RTE_MAX_ETHPORTS || hi > RTE_MAX_ETHPORTS)
+                       return -EINVAL;
+               for (val = lo; val <= hi; val++) {
+                       if (*len_list >= max_list)
+                               return -ENOMEM;
+                       list[(*len_list)++] = val;
+               }
+       } else
+               return -EINVAL;
+       return 0;
+}
+
+
+static int
+rte_eth_devargs_parse_representor_ports(char *str, void *data)
+{
+       struct rte_eth_devargs *eth_da = data;
+
+       return rte_eth_devargs_process_range(str, eth_da->representor_ports,
+               &eth_da->nb_representor_ports, RTE_MAX_ETHPORTS);
+}
+
+int __rte_experimental
+rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da)
+{
+       struct rte_kvargs args;
+       struct rte_kvargs_pair *pair;
+       unsigned int i;
+       int result = 0;
+
+       memset(eth_da, 0, sizeof(*eth_da));
+
+       result = rte_eth_devargs_tokenise(&args, dargs);
+       if (result < 0)
+               goto parse_cleanup;
+
+       for (i = 0; i < args.count; i++) {
+               pair = &args.pairs[i];
+               if (strcmp("representor", pair->key) == 0) {
+                       result = rte_eth_devargs_parse_list(pair->value,
+                               rte_eth_devargs_parse_representor_ports,
+                               eth_da);
+                       if (result < 0)
+                               goto parse_cleanup;
+               }
+       }
+
+parse_cleanup:
+       if (args.str)
+               free(args.str);
+
+       return result;
+}
+
+RTE_INIT(ethdev_init_log)
+{
+       rte_eth_dev_logtype = rte_log_register("lib.ethdev");
+       if (rte_eth_dev_logtype >= 0)
+               rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO);
+}