vhost: checkout resubmit inflight information
[dpdk.git] / lib / librte_ethdev / rte_ethdev.c
index 933d71e..750bc9d 100644 (file)
@@ -166,6 +166,25 @@ static const struct {
 
 #undef RTE_TX_OFFLOAD_BIT2STR
 
+static const struct {
+       uint64_t option;
+       const char *name;
+} rte_burst_option_names[] = {
+       { RTE_ETH_BURST_SCALAR, "Scalar" },
+       { RTE_ETH_BURST_VECTOR, "Vector" },
+
+       { RTE_ETH_BURST_ALTIVEC, "AltiVec" },
+       { RTE_ETH_BURST_NEON, "Neon" },
+       { RTE_ETH_BURST_SSE, "SSE" },
+       { RTE_ETH_BURST_AVX2, "AVX2" },
+       { RTE_ETH_BURST_AVX512, "AVX512" },
+
+       { RTE_ETH_BURST_SCATTERED, "Scattered" },
+       { RTE_ETH_BURST_BULK_ALLOC, "Bulk Alloc" },
+       { RTE_ETH_BURST_SIMPLE, "Simple" },
+       { RTE_ETH_BURST_PER_QUEUE, "Per Queue" },
+};
+
 /**
  * The user application callback description.
  *
@@ -687,10 +706,11 @@ rte_eth_dev_owner_unset(const uint16_t port_id, const uint64_t owner_id)
        return ret;
 }
 
-void
+int
 rte_eth_dev_owner_delete(const uint64_t owner_id)
 {
        uint16_t port_id;
+       int ret = 0;
 
        rte_eth_dev_shared_data_prepare();
 
@@ -708,9 +728,12 @@ rte_eth_dev_owner_delete(const uint64_t owner_id)
                RTE_ETHDEV_LOG(ERR,
                               "Invalid owner id=%016"PRIx64"\n",
                               owner_id);
+               ret = -EINVAL;
        }
 
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+       return ret;
 }
 
 int
@@ -1418,10 +1441,31 @@ rte_eth_dev_config_restore(struct rte_eth_dev *dev,
        }
 
        /* replay all multicast configuration */
-       if (rte_eth_allmulticast_get(port_id) == 1)
-               rte_eth_allmulticast_enable(port_id);
-       else if (rte_eth_allmulticast_get(port_id) == 0)
-               rte_eth_allmulticast_disable(port_id);
+       /*
+        * use callbacks directly since we don't need port_id check and
+        * would like to bypass the same value set
+        */
+       if (rte_eth_allmulticast_get(port_id) == 1 &&
+           *dev->dev_ops->allmulticast_enable != NULL) {
+               ret = eth_err(port_id,
+                             (*dev->dev_ops->allmulticast_enable)(dev));
+               if (ret != 0 && ret != -ENOTSUP) {
+                       RTE_ETHDEV_LOG(ERR,
+                               "Failed to enable allmulticast mode for device (port %u): %s\n",
+                               port_id, rte_strerror(-ret));
+                       return ret;
+               }
+       } else if (rte_eth_allmulticast_get(port_id) == 0 &&
+                  *dev->dev_ops->allmulticast_disable != NULL) {
+               ret = eth_err(port_id,
+                             (*dev->dev_ops->allmulticast_disable)(dev));
+               if (ret != 0 && ret != -ENOTSUP) {
+                       RTE_ETHDEV_LOG(ERR,
+                               "Failed to disable allmulticast mode for device (port %u): %s\n",
+                               port_id, rte_strerror(-ret));
+                       return ret;
+               }
+       }
 
        return 0;
 }
@@ -1947,30 +1991,44 @@ rte_eth_promiscuous_get(uint16_t port_id)
        return dev->data->promiscuous;
 }
 
-void
+int
 rte_eth_allmulticast_enable(uint16_t port_id)
 {
        struct rte_eth_dev *dev;
+       int diag;
 
-       RTE_ETH_VALID_PORTID_OR_RET(port_id);
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
 
-       RTE_FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
-       (*dev->dev_ops->allmulticast_enable)(dev);
-       dev->data->all_multicast = 1;
+       if (dev->data->all_multicast == 1)
+               return 0;
+
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_enable, -ENOTSUP);
+       diag = (*dev->dev_ops->allmulticast_enable)(dev);
+       dev->data->all_multicast = (diag == 0) ? 1 : 0;
+
+       return eth_err(port_id, diag);
 }
 
-void
+int
 rte_eth_allmulticast_disable(uint16_t port_id)
 {
        struct rte_eth_dev *dev;
+       int diag;
 
-       RTE_ETH_VALID_PORTID_OR_RET(port_id);
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
 
-       RTE_FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
+       if (dev->data->all_multicast == 0)
+               return 0;
+
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->allmulticast_disable, -ENOTSUP);
        dev->data->all_multicast = 0;
-       (*dev->dev_ops->allmulticast_disable)(dev);
+       diag = (*dev->dev_ops->allmulticast_disable)(dev);
+       if (diag != 0)
+               dev->data->all_multicast = 1;
+
+       return eth_err(port_id, diag);
 }
 
 int
@@ -1984,40 +2042,44 @@ rte_eth_allmulticast_get(uint16_t port_id)
        return dev->data->all_multicast;
 }
 
-void
+int
 rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
 {
        struct rte_eth_dev *dev;
 
-       RTE_ETH_VALID_PORTID_OR_RET(port_id);
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
 
        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);
+               RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
                (*dev->dev_ops->link_update)(dev, 1);
                *eth_link = dev->data->dev_link;
        }
+
+       return 0;
 }
 
-void
+int
 rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
 {
        struct rte_eth_dev *dev;
 
-       RTE_ETH_VALID_PORTID_OR_RET(port_id);
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
 
        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);
+               RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
                (*dev->dev_ops->link_update)(dev, 0);
                *eth_link = dev->data->dev_link;
        }
+
+       return 0;
 }
 
 int
@@ -2039,12 +2101,16 @@ int
 rte_eth_stats_reset(uint16_t port_id)
 {
        struct rte_eth_dev *dev;
+       int ret;
 
        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->stats_reset, -ENOTSUP);
-       (*dev->dev_ops->stats_reset)(dev);
+       ret = (*dev->dev_ops->stats_reset)(dev);
+       if (ret != 0)
+               return eth_err(port_id, ret);
+
        dev->data->rx_mbuf_alloc_failed = 0;
 
        return 0;
@@ -2529,10 +2595,8 @@ rte_eth_xstats_reset(uint16_t port_id)
        dev = &rte_eth_devices[port_id];
 
        /* implemented by the driver */
-       if (dev->dev_ops->xstats_reset != NULL) {
-               (*dev->dev_ops->xstats_reset)(dev);
-               return 0;
-       }
+       if (dev->dev_ops->xstats_reset != NULL)
+               return eth_err(port_id, (*dev->dev_ops->xstats_reset)(dev));
 
        /* fallback to default */
        return rte_eth_stats_reset(port_id);
@@ -2665,14 +2729,16 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
        return j;
 }
 
-void
+int
 rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr)
 {
        struct rte_eth_dev *dev;
 
-       RTE_ETH_VALID_PORTID_OR_RET(port_id);
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
        rte_ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
+
+       return 0;
 }
 
 
@@ -2889,7 +2955,7 @@ rte_eth_dev_get_vlan_offload(uint16_t port_id)
                ret |= ETH_VLAN_EXTEND_OFFLOAD;
 
        if (*dev_offloads & DEV_RX_OFFLOAD_QINQ_STRIP)
-               ret |= DEV_RX_OFFLOAD_QINQ_STRIP;
+               ret |= ETH_QINQ_STRIP_OFFLOAD;
 
        return ret;
 }
@@ -4163,6 +4229,70 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
        return 0;
 }
 
+int
+rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
+                         struct rte_eth_burst_mode *mode)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       if (mode == NULL)
+               return -EINVAL;
+
+       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);
+               return -EINVAL;
+       }
+
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_burst_mode_get, -ENOTSUP);
+       memset(mode, 0, sizeof(*mode));
+       return eth_err(port_id,
+                      dev->dev_ops->rx_burst_mode_get(dev, queue_id, mode));
+}
+
+int
+rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
+                         struct rte_eth_burst_mode *mode)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       if (mode == NULL)
+               return -EINVAL;
+
+       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);
+               return -EINVAL;
+       }
+
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_burst_mode_get, -ENOTSUP);
+       memset(mode, 0, sizeof(*mode));
+       return eth_err(port_id,
+                      dev->dev_ops->tx_burst_mode_get(dev, queue_id, mode));
+}
+
+const char *
+rte_eth_burst_mode_option_name(uint64_t option)
+{
+       const char *name = "";
+       unsigned int i;
+
+       for (i = 0; i < RTE_DIM(rte_burst_option_names); ++i) {
+               if (option == rte_burst_option_names[i].option) {
+                       name = rte_burst_option_names[i].name;
+                       break;
+               }
+       }
+
+       return name;
+}
+
 int
 rte_eth_dev_set_mc_addr_list(uint16_t port_id,
                             struct rte_ether_addr *mc_addr_set,