ethdev: forbid MTU set before device configure
[dpdk.git] / lib / ethdev / rte_ethdev.c
index 5fae735..0d7dd68 100644 (file)
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 
+/* public fast-path API */
+struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS];
+
 /* spinlock for eth device callbacks */
 static rte_spinlock_t eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;
 
-/* spinlock for add/remove rx callbacks */
+/* spinlock for add/remove Rx callbacks */
 static rte_spinlock_t eth_dev_rx_cb_lock = RTE_SPINLOCK_INITIALIZER;
 
-/* spinlock for add/remove tx callbacks */
+/* spinlock for add/remove Tx callbacks */
 static rte_spinlock_t eth_dev_tx_cb_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* spinlock for shared data allocation */
@@ -118,7 +121,6 @@ static const struct {
        RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
        RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
        RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
-       RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
        RTE_RX_OFFLOAD_BIT2STR(SCATTER),
        RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
        RTE_RX_OFFLOAD_BIT2STR(SECURITY),
@@ -165,6 +167,15 @@ static const struct {
 
 #undef RTE_TX_OFFLOAD_BIT2STR
 
+static const struct {
+       uint64_t offload;
+       const char *name;
+} rte_eth_dev_capa_names[] = {
+       {RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP, "RUNTIME_RX_QUEUE_SETUP"},
+       {RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP, "RUNTIME_TX_QUEUE_SETUP"},
+       {RTE_ETH_DEV_CAPA_RXQ_SHARE, "RXQ_SHARE"},
+};
+
 /**
  * The user application callback description.
  *
@@ -536,7 +547,7 @@ unlock:
 
 /*
  * Attach to a port already registered by the primary process, which
- * makes sure that the same device would have the same port id both
+ * makes sure that the same device would have the same port ID both
  * in the primary and secondary process.
  */
 struct rte_eth_dev *
@@ -579,6 +590,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
                rte_eth_dev_callback_process(eth_dev,
                                RTE_ETH_EVENT_DESTROY, NULL);
 
+       eth_dev_fp_ops_reset(rte_eth_fp_ops + eth_dev->data->port_id);
+
        rte_spinlock_lock(&eth_dev_shared_data->ownership_lock);
 
        eth_dev->state = RTE_ETH_DEV_UNUSED;
@@ -664,7 +677,7 @@ eth_dev_owner_set(const uint16_t port_id, const uint64_t old_owner_id,
        struct rte_eth_dev_owner *port_owner;
 
        if (port_id >= RTE_MAX_ETHPORTS || !eth_dev_is_allocated(ethdev)) {
-               RTE_ETHDEV_LOG(ERR, "Port id %"PRIu16" is not allocated\n",
+               RTE_ETHDEV_LOG(ERR, "Port ID %"PRIu16" is not allocated\n",
                        port_id);
                return -ENODEV;
        }
@@ -756,7 +769,7 @@ rte_eth_dev_owner_delete(const uint64_t owner_id)
                        owner_id);
        } else {
                RTE_ETHDEV_LOG(ERR,
-                              "Invalid owner id=%016"PRIx64"\n",
+                              "Invalid owner ID=%016"PRIx64"\n",
                               owner_id);
                ret = -EINVAL;
        }
@@ -775,7 +788,7 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)
        ethdev = &rte_eth_devices[port_id];
 
        if (!eth_dev_is_allocated(ethdev)) {
-               RTE_ETHDEV_LOG(ERR, "Port id %"PRIu16" is not allocated\n",
+               RTE_ETHDEV_LOG(ERR, "Port ID %"PRIu16" is not allocated\n",
                        port_id);
                return -ENODEV;
        }
@@ -919,12 +932,12 @@ static int
 eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 {
        uint16_t old_nb_queues = dev->data->nb_rx_queues;
-       void **rxq;
        unsigned i;
 
        if (dev->data->rx_queues == NULL && nb_queues != 0) { /* first time configuration */
                dev->data->rx_queues = rte_zmalloc("ethdev->rx_queues",
-                               sizeof(dev->data->rx_queues[0]) * nb_queues,
+                               sizeof(dev->data->rx_queues[0]) *
+                               RTE_MAX_QUEUES_PER_PORT,
                                RTE_CACHE_LINE_SIZE);
                if (dev->data->rx_queues == NULL) {
                        dev->data->nb_rx_queues = 0;
@@ -934,20 +947,6 @@ eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
                for (i = nb_queues; i < old_nb_queues; i++)
                        eth_dev_rxq_release(dev, i);
 
-               rxq = dev->data->rx_queues;
-               rxq = rte_realloc(rxq, sizeof(rxq[0]) * nb_queues,
-                               RTE_CACHE_LINE_SIZE);
-               if (rxq == NULL)
-                       return -(ENOMEM);
-               if (nb_queues > old_nb_queues) {
-                       uint16_t new_qs = nb_queues - old_nb_queues;
-
-                       memset(rxq + old_nb_queues, 0,
-                               sizeof(rxq[0]) * new_qs);
-               }
-
-               dev->data->rx_queues = rxq;
-
        } else if (dev->data->rx_queues != NULL && nb_queues == 0) {
                for (i = nb_queues; i < old_nb_queues; i++)
                        eth_dev_rxq_release(dev, i);
@@ -1153,13 +1152,13 @@ static int
 eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 {
        uint16_t old_nb_queues = dev->data->nb_tx_queues;
-       void **txq;
        unsigned i;
 
        if (dev->data->tx_queues == NULL && nb_queues != 0) { /* first time configuration */
                dev->data->tx_queues = rte_zmalloc("ethdev->tx_queues",
-                                                  sizeof(dev->data->tx_queues[0]) * nb_queues,
-                                                  RTE_CACHE_LINE_SIZE);
+                               sizeof(dev->data->tx_queues[0]) *
+                               RTE_MAX_QUEUES_PER_PORT,
+                               RTE_CACHE_LINE_SIZE);
                if (dev->data->tx_queues == NULL) {
                        dev->data->nb_tx_queues = 0;
                        return -(ENOMEM);
@@ -1168,20 +1167,6 @@ eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
                for (i = nb_queues; i < old_nb_queues; i++)
                        eth_dev_txq_release(dev, i);
 
-               txq = dev->data->tx_queues;
-               txq = rte_realloc(txq, sizeof(txq[0]) * nb_queues,
-                                 RTE_CACHE_LINE_SIZE);
-               if (txq == NULL)
-                       return -ENOMEM;
-               if (nb_queues > old_nb_queues) {
-                       uint16_t new_qs = nb_queues - old_nb_queues;
-
-                       memset(txq + old_nb_queues, 0,
-                              sizeof(txq[0]) * new_qs);
-               }
-
-               dev->data->tx_queues = txq;
-
        } else if (dev->data->tx_queues != NULL && nb_queues == 0) {
                for (i = nb_queues; i < old_nb_queues; i++)
                        eth_dev_txq_release(dev, i);
@@ -1260,6 +1245,22 @@ rte_eth_dev_tx_offload_name(uint64_t offload)
        return name;
 }
 
+const char *
+rte_eth_dev_capability_name(uint64_t capability)
+{
+       const char *name = "UNKNOWN";
+       unsigned int i;
+
+       for (i = 0; i < RTE_DIM(rte_eth_dev_capa_names); ++i) {
+               if (capability == rte_eth_dev_capa_names[i].offload) {
+                       name = rte_eth_dev_capa_names[i].name;
+                       break;
+               }
+       }
+
+       return name;
+}
+
 static inline int
 eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size,
                   uint32_t max_rx_pkt_len, uint32_t dev_info_size)
@@ -1289,14 +1290,14 @@ eth_dev_check_lro_pkt_size(uint16_t port_id, uint32_t config_size,
 
 /*
  * Validate offloads that are requested through rte_eth_dev_configure against
- * the offloads successfully set by the ethernet device.
+ * the offloads successfully set by the Ethernet device.
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
  * @param req_offloads
  *   The offloads that have been requested through `rte_eth_dev_configure`.
  * @param set_offloads
- *   The offloads successfully set by the ethernet device.
+ *   The offloads successfully set by the Ethernet device.
  * @param offload_type
  *   The offload type i.e. Rx/Tx string.
  * @param offload_name
@@ -1317,7 +1318,7 @@ eth_dev_validate_offloads(uint16_t port_id, uint64_t req_offloads,
 
        while (offloads_diff != 0) {
                /* Check if any offload is requested but not enabled. */
-               offload = 1ULL << __builtin_ctzll(offloads_diff);
+               offload = RTE_BIT64(__builtin_ctzll(offloads_diff));
                if (offload & req_offloads) {
                        RTE_ETHDEV_LOG(ERR,
                                "Port %u failed to enable %s offload %s\n",
@@ -1338,6 +1339,60 @@ eth_dev_validate_offloads(uint16_t port_id, uint64_t req_offloads,
        return ret;
 }
 
+static uint32_t
+eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu)
+{
+       uint32_t overhead_len;
+
+       if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu)
+               overhead_len = max_rx_pktlen - max_mtu;
+       else
+               overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+
+       return overhead_len;
+}
+
+/* rte_eth_dev_info_get() should be called prior to this function */
+static int
+eth_dev_validate_mtu(uint16_t port_id, struct rte_eth_dev_info *dev_info,
+               uint16_t mtu)
+{
+       uint32_t overhead_len;
+       uint32_t frame_size;
+
+       if (mtu < dev_info->min_mtu) {
+               RTE_ETHDEV_LOG(ERR,
+                       "MTU (%u) < device min MTU (%u) for port_id %u\n",
+                       mtu, dev_info->min_mtu, port_id);
+               return -EINVAL;
+       }
+       if (mtu > dev_info->max_mtu) {
+               RTE_ETHDEV_LOG(ERR,
+                       "MTU (%u) > device max MTU (%u) for port_id %u\n",
+                       mtu, dev_info->max_mtu, port_id);
+               return -EINVAL;
+       }
+
+       overhead_len = eth_dev_get_overhead_len(dev_info->max_rx_pktlen,
+                       dev_info->max_mtu);
+       frame_size = mtu + overhead_len;
+       if (frame_size < RTE_ETHER_MIN_LEN) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Frame size (%u) < min frame size (%u) for port_id %u\n",
+                       frame_size, RTE_ETHER_MIN_LEN, port_id);
+               return -EINVAL;
+       }
+
+       if (frame_size > dev_info->max_rx_pktlen) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Frame size (%u) > device max frame size (%u) for port_id %u\n",
+                       frame_size, dev_info->max_rx_pktlen, port_id);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
                      const struct rte_eth_conf *dev_conf)
@@ -1345,7 +1400,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
        struct rte_eth_dev *dev;
        struct rte_eth_dev_info dev_info;
        struct rte_eth_conf orig_conf;
-       uint16_t overhead_len;
        int diag;
        int ret;
        uint16_t old_mtu;
@@ -1394,13 +1448,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
        if (ret != 0)
                goto rollback;
 
-       /* Get the real Ethernet overhead length */
-       if (dev_info.max_mtu != UINT16_MAX &&
-           dev_info.max_rx_pktlen > dev_info.max_mtu)
-               overhead_len = dev_info.max_rx_pktlen - dev_info.max_mtu;
-       else
-               overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
-
        /* 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.
@@ -1418,7 +1465,7 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
        if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) {
                RTE_ETHDEV_LOG(ERR,
-                       "Number of RX queues requested (%u) is greater than max supported(%d)\n",
+                       "Number of Rx queues requested (%u) is greater than max supported(%d)\n",
                        nb_rx_q, RTE_MAX_QUEUES_PER_PORT);
                ret = -EINVAL;
                goto rollback;
@@ -1426,15 +1473,15 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
        if (nb_tx_q > RTE_MAX_QUEUES_PER_PORT) {
                RTE_ETHDEV_LOG(ERR,
-                       "Number of TX queues requested (%u) is greater than max supported(%d)\n",
+                       "Number of Tx queues requested (%u) is greater than max supported(%d)\n",
                        nb_tx_q, RTE_MAX_QUEUES_PER_PORT);
                ret = -EINVAL;
                goto rollback;
        }
 
        /*
-        * Check that the numbers of RX and TX queues are not greater
-        * than the maximum number of RX and TX queues supported by the
+        * Check that the numbers of Rx and Tx queues are not greater
+        * than the maximum number of Rx and Tx queues supported by the
         * configured device.
         */
        if (nb_rx_q > dev_info.max_rx_queues) {
@@ -1467,50 +1514,32 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
                goto rollback;
        }
 
-       /*
-        * If jumbo frames are enabled, check that the maximum RX packet
-        * length is supported by the configured device.
-        */
-       if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
-               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);
-                       ret = -EINVAL;
-                       goto rollback;
-               } else if (dev_conf->rxmode.max_rx_pkt_len < RTE_ETHER_MIN_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 int)RTE_ETHER_MIN_LEN);
-                       ret = -EINVAL;
-                       goto rollback;
-               }
+       if (dev_conf->rxmode.mtu == 0)
+               dev->data->dev_conf.rxmode.mtu = RTE_ETHER_MTU;
 
-               /* Scale the MTU size to adapt max_rx_pkt_len */
-               dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len -
-                               overhead_len;
-       } else {
-               uint16_t pktlen = dev_conf->rxmode.max_rx_pkt_len;
-               if (pktlen < RTE_ETHER_MIN_MTU + overhead_len ||
-                   pktlen > RTE_ETHER_MTU + overhead_len)
-                       /* Use default value */
-                       dev->data->dev_conf.rxmode.max_rx_pkt_len =
-                                               RTE_ETHER_MTU + overhead_len;
-       }
+       ret = eth_dev_validate_mtu(port_id, &dev_info,
+                       dev->data->dev_conf.rxmode.mtu);
+       if (ret != 0)
+               goto rollback;
+
+       dev->data->mtu = dev->data->dev_conf.rxmode.mtu;
 
        /*
         * If LRO is enabled, check that the maximum aggregated packet
         * size is supported by the configured device.
         */
        if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+               uint32_t max_rx_pktlen;
+               uint32_t overhead_len;
+
+               overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen,
+                               dev_info.max_mtu);
+               max_rx_pktlen = dev->data->dev_conf.rxmode.mtu + overhead_len;
                if (dev_conf->rxmode.max_lro_pkt_size == 0)
-                       dev->data->dev_conf.rxmode.max_lro_pkt_size =
-                               dev->data->dev_conf.rxmode.max_rx_pkt_len;
+                       dev->data->dev_conf.rxmode.max_lro_pkt_size = max_rx_pktlen;
                ret = eth_dev_check_lro_pkt_size(port_id,
                                dev->data->dev_conf.rxmode.max_lro_pkt_size,
-                               dev->data->dev_conf.rxmode.max_rx_pkt_len,
+                               max_rx_pktlen,
                                dev_info.max_lro_pkt_size);
                if (ret != 0)
                        goto rollback;
@@ -1567,7 +1596,7 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
        }
 
        /*
-        * Setup new number of RX/TX queues and reconfigure device.
+        * Setup new number of Rx/Tx queues and reconfigure device.
         */
        diag = eth_dev_rx_queue_config(dev, nb_rx_q);
        if (diag != 0) {
@@ -1683,7 +1712,7 @@ eth_dev_mac_restore(struct rte_eth_dev *dev,
                        pool_mask = dev->data->mac_pool_sel[i];
 
                        do {
-                               if (pool_mask & 1ULL)
+                               if (pool_mask & UINT64_C(1))
                                        (*dev->dev_ops->mac_addr_add)(dev,
                                                addr, i, pool);
                                pool_mask >>= 1;
@@ -1820,6 +1849,9 @@ rte_eth_dev_start(uint16_t port_id)
                (*dev->dev_ops->link_update)(dev, 0);
        }
 
+       /* expose selection of PMD fast-path functions */
+       eth_dev_fp_ops_setup(rte_eth_fp_ops + port_id, dev);
+
        rte_ethdev_trace_start(port_id);
        return 0;
 }
@@ -1842,6 +1874,9 @@ rte_eth_dev_stop(uint16_t port_id)
                return 0;
        }
 
+       /* point fast-path functions to dummy ones */
+       eth_dev_fp_ops_reset(rte_eth_fp_ops + port_id);
+
        dev->data->dev_started = 0;
        ret = (*dev->dev_ops->dev_stop)(dev);
        rte_ethdev_trace_stop(port_id, ret);
@@ -1883,6 +1918,12 @@ rte_eth_dev_close(uint16_t port_id)
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
 
+       if (dev->data->dev_started) {
+               RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n",
+                              port_id);
+               return -EINVAL;
+       }
+
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP);
        *lasterr = (*dev->dev_ops->dev_close)(dev);
        if (*lasterr != 0)
@@ -1959,7 +2000,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
         * for each segment specified in extended configuration.
         */
        mp_first = rx_seg[0].mp;
-       offset_mask = (1u << seg_capa->offset_align_log2) - 1;
+       offset_mask = RTE_BIT32(seg_capa->offset_align_log2) - 1;
        for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
                struct rte_mempool *mpl = rx_seg[seg_idx].mp;
                uint32_t length = rx_seg[seg_idx].length;
@@ -2025,7 +2066,7 @@ 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_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", rx_queue_id);
                return -EINVAL;
        }
 
@@ -2159,17 +2200,32 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
                return -EINVAL;
        }
 
+       if (local_conf.share_group > 0 &&
+           (dev_info.dev_capa & RTE_ETH_DEV_CAPA_RXQ_SHARE) == 0) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Ethdev port_id=%d rx_queue_id=%d, enabled share_group=%hu while device doesn't support Rx queue share\n",
+                       port_id, rx_queue_id, local_conf.share_group);
+               return -EINVAL;
+       }
+
        /*
         * If LRO is enabled, check that the maximum aggregated packet
         * size is supported by the configured device.
         */
+       /* Get the real Ethernet overhead length */
        if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+               uint32_t overhead_len;
+               uint32_t max_rx_pktlen;
+               int ret;
+
+               overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen,
+                               dev_info.max_mtu);
+               max_rx_pktlen = dev->data->mtu + overhead_len;
                if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
-                       dev->data->dev_conf.rxmode.max_lro_pkt_size =
-                               dev->data->dev_conf.rxmode.max_rx_pkt_len;
-               int ret = eth_dev_check_lro_pkt_size(port_id,
+                       dev->data->dev_conf.rxmode.max_lro_pkt_size = max_rx_pktlen;
+               ret = eth_dev_check_lro_pkt_size(port_id,
                                dev->data->dev_conf.rxmode.max_lro_pkt_size,
-                               dev->data->dev_conf.rxmode.max_rx_pkt_len,
+                               max_rx_pktlen,
                                dev_info.max_lro_pkt_size);
                if (ret != 0)
                        return ret;
@@ -2203,7 +2259,7 @@ rte_eth_rx_hairpin_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_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", rx_queue_id);
                return -EINVAL;
        }
 
@@ -2275,7 +2331,7 @@ 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_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", tx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", tx_queue_id);
                return -EINVAL;
        }
 
@@ -2369,7 +2425,7 @@ rte_eth_tx_hairpin_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_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", tx_queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", tx_queue_id);
                return -EINVAL;
        }
 
@@ -3411,7 +3467,8 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
        dev_info->rx_desc_lim = lim;
        dev_info->tx_desc_lim = lim;
        dev_info->device = dev->device;
-       dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+       dev_info->min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN -
+               RTE_ETHER_CRC_LEN;
        dev_info->max_mtu = UINT16_MAX;
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
@@ -3437,6 +3494,26 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
        return 0;
 }
 
+int
+rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+       dev = &rte_eth_devices[port_id];
+
+       if (dev_conf == NULL) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Cannot get ethdev port %u configuration to NULL\n",
+                       port_id);
+               return -EINVAL;
+       }
+
+       memcpy(dev_conf, &dev->data->dev_conf, sizeof(struct rte_eth_conf));
+
+       return 0;
+}
+
 int
 rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
                                 uint32_t *ptypes, int num)
@@ -3561,6 +3638,31 @@ ptype_unknown:
        return ret;
 }
 
+int
+rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
+       unsigned int num)
+{
+       int32_t ret;
+       struct rte_eth_dev *dev;
+       struct rte_eth_dev_info dev_info;
+
+       if (ma == NULL) {
+               RTE_ETHDEV_LOG(ERR, "%s: invalid parameters\n", __func__);
+               return -EINVAL;
+       }
+
+       /* will check for us that port_id is a valid one */
+       ret = rte_eth_dev_info_get(port_id, &dev_info);
+       if (ret != 0)
+               return ret;
+
+       dev = &rte_eth_devices[port_id];
+       num = RTE_MIN(dev_info.max_mac_addrs, num);
+       memcpy(ma, dev->data->mac_addrs, num * sizeof(ma[0]));
+
+       return num;
+}
+
 int
 rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr)
 {
@@ -3621,12 +3723,20 @@ rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu)
                if (ret != 0)
                        return ret;
 
-               if (mtu < dev_info.min_mtu || mtu > dev_info.max_mtu)
-                       return -EINVAL;
+               ret = eth_dev_validate_mtu(port_id, &dev_info, mtu);
+               if (ret != 0)
+                       return ret;
+       }
+
+       if (dev->data->dev_configured == 0) {
+               RTE_ETHDEV_LOG(ERR,
+                       "Port %u must be configured before MTU set\n",
+                       port_id);
+               return -EINVAL;
        }
 
        ret = (*dev->dev_ops->mtu_set)(dev, mtu);
-       if (!ret)
+       if (ret == 0)
                dev->data->mtu = mtu;
 
        return eth_err(port_id, ret);
@@ -3643,7 +3753,7 @@ rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on)
 
        if (!(dev->data->dev_conf.rxmode.offloads &
              DEV_RX_OFFLOAD_VLAN_FILTER)) {
-               RTE_ETHDEV_LOG(ERR, "Port %u: vlan-filtering disabled\n",
+               RTE_ETHDEV_LOG(ERR, "Port %u: VLAN-filtering disabled\n",
                        port_id);
                return -ENOSYS;
        }
@@ -3666,9 +3776,9 @@ rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on)
                vbit = vlan_id % 64;
 
                if (on)
-                       vfc->ids[vidx] |= UINT64_C(1) << vbit;
+                       vfc->ids[vidx] |= RTE_BIT64(vbit);
                else
-                       vfc->ids[vidx] &= ~(UINT64_C(1) << vbit);
+                       vfc->ids[vidx] &= ~RTE_BIT64(vbit);
        }
 
        return eth_err(port_id, ret);
@@ -3940,7 +4050,7 @@ eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
        for (i = 0; i < reta_size; i++) {
                idx = i / RTE_RETA_GROUP_SIZE;
                shift = i % RTE_RETA_GROUP_SIZE;
-               if ((reta_conf[idx].mask & (1ULL << shift)) &&
+               if ((reta_conf[idx].mask & RTE_BIT64(shift)) &&
                        (reta_conf[idx].reta[shift] >= max_rxq)) {
                        RTE_ETHDEV_LOG(ERR,
                                "reta_conf[%u]->reta[%u]: %u exceeds the maximum rxq index: %u\n",
@@ -4263,7 +4373,7 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
                return -EINVAL;
        }
        if (pool >= ETH_64_POOLS) {
-               RTE_ETHDEV_LOG(ERR, "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;
        }
 
@@ -4279,7 +4389,7 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
                pool_mask = dev->data->mac_pool_sel[index];
 
                /* Check if both MAC address and pool is already there, and do nothing */
-               if (pool_mask & (1ULL << pool))
+               if (pool_mask & RTE_BIT64(pool))
                        return 0;
        }
 
@@ -4291,7 +4401,7 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
                rte_ether_addr_copy(addr, &dev->data->mac_addrs[index]);
 
                /* Update pool bitmap in NIC data structure */
-               dev->data->mac_pool_sel[index] |= (1ULL << pool);
+               dev->data->mac_pool_sel[index] |= RTE_BIT64(pool);
        }
 
        return eth_err(port_id, ret);
@@ -4488,7 +4598,7 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
 
        if (queue_idx > dev_info.max_tx_queues) {
                RTE_ETHDEV_LOG(ERR,
-                       "Set queue rate limit:port %u: invalid queue id=%u\n",
+                       "Set queue rate limit:port %u: invalid queue ID=%u\n",
                        port_id, queue_idx);
                return -EINVAL;
        }
@@ -4505,6 +4615,14 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
                                                        queue_idx, tx_rate));
 }
 
+RTE_INIT(eth_dev_init_fp_ops)
+{
+       uint32_t i;
+
+       for (i = 0; i != RTE_DIM(rte_eth_fp_ops); i++)
+               eth_dev_fp_ops_reset(rte_eth_fp_ops + i);
+}
+
 RTE_INIT(eth_dev_init_cb_lists)
 {
        uint16_t i;
@@ -4673,6 +4791,14 @@ rte_eth_dev_probing_finish(struct rte_eth_dev *dev)
        if (dev == NULL)
                return;
 
+       /*
+        * for secondary process, at that point we expect device
+        * to be already 'usable', so shared data and all function pointers
+        * for fast-path devops have to be setup properly inside rte_eth_dev.
+        */
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+               eth_dev_fp_ops_setup(rte_eth_fp_ops + dev->data->port_id, dev);
+
        rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_NEW, NULL);
 
        dev->state = RTE_ETH_DEV_ATTACHED;
@@ -4691,13 +4817,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_ETHDEV_LOG(ERR, "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_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+               RTE_ETHDEV_LOG(ERR, "Rx Intr vector unset\n");
                return -EPERM;
        }
 
@@ -4706,7 +4832,7 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
                rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
                if (rc && rc != -EEXIST) {
                        RTE_ETHDEV_LOG(ERR,
-                               "p %u q %u rx ctl error op %d epfd %d vec %u\n",
+                               "p %u q %u Rx ctl error op %d epfd %d vec %u\n",
                                port_id, qid, op, epfd, vec);
                }
        }
@@ -4727,18 +4853,18 @@ rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id)
        dev = &rte_eth_devices[port_id];
 
        if (queue_id >= dev->data->nb_rx_queues) {
-               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
                return -1;
        }
 
        if (!dev->intr_handle) {
-               RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
+               RTE_ETHDEV_LOG(ERR, "Rx Intr handle unset\n");
                return -1;
        }
 
        intr_handle = dev->intr_handle;
        if (!intr_handle->intr_vec) {
-               RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+               RTE_ETHDEV_LOG(ERR, "Rx Intr vector unset\n");
                return -1;
        }
 
@@ -4913,18 +5039,18 @@ 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_ETHDEV_LOG(ERR, "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_ETHDEV_LOG(ERR, "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_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+               RTE_ETHDEV_LOG(ERR, "Rx Intr vector unset\n");
                return -EPERM;
        }
 
@@ -4932,7 +5058,7 @@ rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
        rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
        if (rc && rc != -EEXIST) {
                RTE_ETHDEV_LOG(ERR,
-                       "p %u q %u rx ctl error op %d epfd %d vec %u\n",
+                       "p %u q %u Rx ctl error op %d epfd %d vec %u\n",
                        port_id, queue_id, op, epfd, vec);
                return rc;
        }
@@ -5210,7 +5336,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_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
                return -EINVAL;
        }
 
@@ -5255,7 +5381,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_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", queue_id);
                return -EINVAL;
        }
 
@@ -5300,7 +5426,7 @@ rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
        dev = &rte_eth_devices[port_id];
 
        if (queue_id >= dev->data->nb_rx_queues) {
-               RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
                return -EINVAL;
        }
 
@@ -5327,7 +5453,7 @@ rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
        dev = &rte_eth_devices[port_id];
 
        if (queue_id >= dev->data->nb_tx_queues) {
-               RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
+               RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", queue_id);
                return -EINVAL;
        }
 
@@ -6161,6 +6287,96 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
        return 0;
 }
 
+static int
+eth_dev_handle_port_info(const char *cmd __rte_unused,
+               const char *params,
+               struct rte_tel_data *d)
+{
+       struct rte_tel_data *rxq_state, *txq_state;
+       char mac_addr[RTE_ETHER_ADDR_LEN];
+       struct rte_eth_dev *eth_dev;
+       char *end_param;
+       int port_id, i;
+
+       if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+               return -1;
+
+       port_id = strtoul(params, &end_param, 0);
+       if (*end_param != '\0')
+               RTE_ETHDEV_LOG(NOTICE,
+                       "Extra parameters passed to ethdev telemetry command, ignoring");
+
+       if (!rte_eth_dev_is_valid_port(port_id))
+               return -EINVAL;
+
+       eth_dev = &rte_eth_devices[port_id];
+       if (!eth_dev)
+               return -EINVAL;
+
+       rxq_state = rte_tel_data_alloc();
+       if (!rxq_state)
+               return -ENOMEM;
+
+       txq_state = rte_tel_data_alloc();
+       if (!txq_state)
+               return -ENOMEM;
+
+       rte_tel_data_start_dict(d);
+       rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
+       rte_tel_data_add_dict_int(d, "state", eth_dev->state);
+       rte_tel_data_add_dict_int(d, "nb_rx_queues",
+                       eth_dev->data->nb_rx_queues);
+       rte_tel_data_add_dict_int(d, "nb_tx_queues",
+                       eth_dev->data->nb_tx_queues);
+       rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
+       rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
+       rte_tel_data_add_dict_int(d, "rx_mbuf_size_min",
+                       eth_dev->data->min_rx_buf_size);
+       rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail",
+                       eth_dev->data->rx_mbuf_alloc_failed);
+       snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
+                        eth_dev->data->mac_addrs->addr_bytes[0],
+                        eth_dev->data->mac_addrs->addr_bytes[1],
+                        eth_dev->data->mac_addrs->addr_bytes[2],
+                        eth_dev->data->mac_addrs->addr_bytes[3],
+                        eth_dev->data->mac_addrs->addr_bytes[4],
+                        eth_dev->data->mac_addrs->addr_bytes[5]);
+       rte_tel_data_add_dict_string(d, "mac_addr", mac_addr);
+       rte_tel_data_add_dict_int(d, "promiscuous",
+                       eth_dev->data->promiscuous);
+       rte_tel_data_add_dict_int(d, "scattered_rx",
+                       eth_dev->data->scattered_rx);
+       rte_tel_data_add_dict_int(d, "all_multicast",
+                       eth_dev->data->all_multicast);
+       rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started);
+       rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro);
+       rte_tel_data_add_dict_int(d, "dev_configured",
+                       eth_dev->data->dev_configured);
+
+       rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL);
+       for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+               rte_tel_data_add_array_int(rxq_state,
+                               eth_dev->data->rx_queue_state[i]);
+
+       rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL);
+       for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+               rte_tel_data_add_array_int(txq_state,
+                               eth_dev->data->tx_queue_state[i]);
+
+       rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
+       rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
+       rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
+       rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags);
+       rte_tel_data_add_dict_int(d, "rx_offloads",
+                       eth_dev->data->dev_conf.rxmode.offloads);
+       rte_tel_data_add_dict_int(d, "tx_offloads",
+                       eth_dev->data->dev_conf.txmode.offloads);
+       rte_tel_data_add_dict_int(d, "ethdev_rss_hf",
+                       eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
+
+       return 0;
+}
+
 int
 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
                                  struct rte_hairpin_peer_info *cur_info,
@@ -6239,7 +6455,7 @@ rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)
 
        if (dev->data->dev_configured != 0) {
                RTE_ETHDEV_LOG(ERR,
-                       "The port (id=%"PRIu16") is already configured\n",
+                       "The port (ID=%"PRIu16") is already configured\n",
                        port_id);
                return -EBUSY;
        }
@@ -6267,4 +6483,6 @@ RTE_INIT(ethdev_init_telemetry)
        rte_telemetry_register_cmd("/ethdev/link_status",
                        eth_dev_handle_port_link_status,
                        "Returns the link status for a port. Parameters: int port_id");
+       rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
+                       "Returns the device info for a port. Parameters: int port_id");
 }