devargs: remove incorrect experimental tags
[dpdk.git] / lib / librte_ethdev / rte_ethdev.c
index 243beb4..8ac3016 100644 (file)
@@ -339,6 +339,15 @@ rte_eth_find_next(uint16_t port_id)
        return port_id;
 }
 
+/*
+ * Macro to iterate over all valid ports for internal usage.
+ * Note: RTE_ETH_FOREACH_DEV is different because filtering owned ports.
+ */
+#define RTE_ETH_FOREACH_VALID_DEV(port_id) \
+       for (port_id = rte_eth_find_next(0); \
+            port_id < RTE_MAX_ETHPORTS; \
+            port_id = rte_eth_find_next(port_id + 1))
+
 uint16_t
 rte_eth_find_next_of(uint16_t port_id, const struct rte_device *parent)
 {
@@ -491,7 +500,7 @@ rte_eth_dev_allocate(const char *name)
        eth_dev = eth_dev_get(port_id);
        strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name));
        eth_dev->data->port_id = port_id;
-       eth_dev->data->mtu = ETHER_MTU;
+       eth_dev->data->mtu = RTE_ETHER_MTU;
 
 unlock:
        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
@@ -584,13 +593,10 @@ rte_eth_is_valid_owner_id(uint64_t owner_id)
 uint64_t
 rte_eth_find_next_owned_by(uint16_t port_id, const uint64_t owner_id)
 {
+       port_id = rte_eth_find_next(port_id);
        while (port_id < RTE_MAX_ETHPORTS &&
-              (rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED ||
-              rte_eth_devices[port_id].data->owner.id != owner_id))
-               port_id++;
-
-       if (port_id >= RTE_MAX_ETHPORTS)
-               return RTE_MAX_ETHPORTS;
+                       rte_eth_devices[port_id].data->owner.id != owner_id)
+               port_id = rte_eth_find_next(port_id + 1);
 
        return port_id;
 }
@@ -763,14 +769,13 @@ rte_eth_dev_count_avail(void)
        return count;
 }
 
-uint16_t __rte_experimental
+uint16_t
 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++;
+       RTE_ETH_FOREACH_VALID_DEV(port)
+               count++;
 
        return count;
 }
@@ -804,13 +809,11 @@ rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)
                return -EINVAL;
        }
 
-       for (pid = 0; pid < RTE_MAX_ETHPORTS; pid++) {
-               if (rte_eth_devices[pid].state != RTE_ETH_DEV_UNUSED &&
-                   !strcmp(name, rte_eth_dev_shared_data->data[pid].name)) {
+       RTE_ETH_FOREACH_VALID_DEV(pid)
+               if (!strcmp(name, rte_eth_dev_shared_data->data[pid].name)) {
                        *port_id = pid;
                        return 0;
                }
-       }
 
        return -ENODEV;
 }
@@ -1221,20 +1224,20 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
                                dev_info.max_rx_pktlen);
                        ret = -EINVAL;
                        goto rollback;
-               } else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
+               } 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)ETHER_MIN_LEN);
+                               (unsigned int)RTE_ETHER_MIN_LEN);
                        ret = -EINVAL;
                        goto rollback;
                }
        } else {
-               if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN ||
-                       dev_conf->rxmode.max_rx_pkt_len > ETHER_MAX_LEN)
+               if (dev_conf->rxmode.max_rx_pkt_len < RTE_ETHER_MIN_LEN ||
+                       dev_conf->rxmode.max_rx_pkt_len > RTE_ETHER_MAX_LEN)
                        /* Use default value */
                        dev->data->dev_conf.rxmode.max_rx_pkt_len =
-                                                       ETHER_MAX_LEN;
+                                                       RTE_ETHER_MAX_LEN;
        }
 
        /* Any requested offloading must be within its device capabilities */
@@ -1343,7 +1346,7 @@ static void
 rte_eth_dev_mac_restore(struct rte_eth_dev *dev,
                        struct rte_eth_dev_info *dev_info)
 {
-       struct ether_addr *addr;
+       struct rte_ether_addr *addr;
        uint16_t i;
        uint32_t pool = 0;
        uint64_t pool_mask;
@@ -1360,7 +1363,7 @@ rte_eth_dev_mac_restore(struct rte_eth_dev *dev,
                        addr = &dev->data->mac_addrs[i];
 
                        /* skip zero address */
-                       if (is_zero_ether_addr(addr))
+                       if (rte_is_zero_ether_addr(addr))
                                continue;
 
                        pool = 0;
@@ -1576,6 +1579,11 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
                return -EINVAL;
        }
 
+       if (mp == NULL) {
+               RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n");
+               return -EINVAL;
+       }
+
        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);
 
@@ -2540,6 +2548,8 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
                .nb_max = UINT16_MAX,
                .nb_min = 0,
                .nb_align = 1,
+               .nb_seg_max = UINT16_MAX,
+               .nb_mtu_seg_max = UINT16_MAX,
        };
 
        RTE_ETH_VALID_PORTID_OR_RET(port_id);
@@ -2549,7 +2559,7 @@ 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 = ETHER_MIN_MTU;
+       dev_info->min_mtu = RTE_ETHER_MIN_MTU;
        dev_info->max_mtu = UINT16_MAX;
 
        RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
@@ -2588,13 +2598,13 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
 }
 
 void
-rte_eth_macaddr_get(uint16_t port_id, struct ether_addr *mac_addr)
+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);
        dev = &rte_eth_devices[port_id];
-       ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
+       rte_ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
 }
 
 
@@ -3075,7 +3085,7 @@ rte_eth_led_off(uint16_t port_id)
  * an empty spot.
  */
 static int
-get_mac_addr_index(uint16_t port_id, const struct ether_addr *addr)
+get_mac_addr_index(uint16_t port_id, const struct rte_ether_addr *addr)
 {
        struct rte_eth_dev_info dev_info;
        struct rte_eth_dev *dev = &rte_eth_devices[port_id];
@@ -3085,16 +3095,17 @@ get_mac_addr_index(uint16_t port_id, const struct ether_addr *addr)
        rte_eth_dev_info_get(port_id, &dev_info);
 
        for (i = 0; i < dev_info.max_mac_addrs; i++)
-               if (memcmp(addr, &dev->data->mac_addrs[i], ETHER_ADDR_LEN) == 0)
+               if (memcmp(addr, &dev->data->mac_addrs[i],
+                               RTE_ETHER_ADDR_LEN) == 0)
                        return i;
 
        return -1;
 }
 
-static const struct ether_addr null_mac_addr;
+static const struct rte_ether_addr null_mac_addr;
 
 int
-rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *addr,
+rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
                        uint32_t pool)
 {
        struct rte_eth_dev *dev;
@@ -3106,7 +3117,7 @@ rte_eth_dev_mac_addr_add(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_add, -ENOTSUP);
 
-       if (is_zero_ether_addr(addr)) {
+       if (rte_is_zero_ether_addr(addr)) {
                RTE_ETHDEV_LOG(ERR, "Port %u: Cannot add NULL MAC address\n",
                        port_id);
                return -EINVAL;
@@ -3137,7 +3148,7 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *addr,
 
        if (ret == 0) {
                /* Update address in NIC data structure */
-               ether_addr_copy(addr, &dev->data->mac_addrs[index]);
+               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);
@@ -3147,7 +3158,7 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct ether_addr *addr,
 }
 
 int
-rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *addr)
+rte_eth_dev_mac_addr_remove(uint16_t port_id, struct rte_ether_addr *addr)
 {
        struct rte_eth_dev *dev;
        int index;
@@ -3169,7 +3180,7 @@ rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *addr)
        (*dev->dev_ops->mac_addr_remove)(dev, index);
 
        /* Update address in NIC data structure */
-       ether_addr_copy(&null_mac_addr, &dev->data->mac_addrs[index]);
+       rte_ether_addr_copy(&null_mac_addr, &dev->data->mac_addrs[index]);
 
        /* reset pool bitmap */
        dev->data->mac_pool_sel[index] = 0;
@@ -3178,14 +3189,14 @@ rte_eth_dev_mac_addr_remove(uint16_t port_id, struct ether_addr *addr)
 }
 
 int
-rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
+rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
 {
        struct rte_eth_dev *dev;
        int ret;
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
-       if (!is_valid_assigned_ether_addr(addr))
+       if (!rte_is_valid_assigned_ether_addr(addr))
                return -EINVAL;
 
        dev = &rte_eth_devices[port_id];
@@ -3196,7 +3207,7 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
                return ret;
 
        /* Update default address in NIC data structure */
-       ether_addr_copy(addr, &dev->data->mac_addrs[0]);
+       rte_ether_addr_copy(addr, &dev->data->mac_addrs[0]);
 
        return 0;
 }
@@ -3207,7 +3218,7 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
  * an empty spot.
  */
 static int
-get_hash_mac_addr_index(uint16_t port_id, const struct ether_addr *addr)
+get_hash_mac_addr_index(uint16_t port_id, const struct rte_ether_addr *addr)
 {
        struct rte_eth_dev_info dev_info;
        struct rte_eth_dev *dev = &rte_eth_devices[port_id];
@@ -3219,14 +3230,14 @@ get_hash_mac_addr_index(uint16_t port_id, const struct ether_addr *addr)
 
        for (i = 0; i < dev_info.max_hash_mac_addrs; i++)
                if (memcmp(addr, &dev->data->hash_mac_addrs[i],
-                       ETHER_ADDR_LEN) == 0)
+                       RTE_ETHER_ADDR_LEN) == 0)
                        return i;
 
        return -1;
 }
 
 int
-rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
+rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
                                uint8_t on)
 {
        int index;
@@ -3236,7 +3247,7 @@ rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
        dev = &rte_eth_devices[port_id];
-       if (is_zero_ether_addr(addr)) {
+       if (rte_is_zero_ether_addr(addr)) {
                RTE_ETHDEV_LOG(ERR, "Port %u: Cannot add NULL MAC address\n",
                        port_id);
                return -EINVAL;
@@ -3268,10 +3279,10 @@ rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct ether_addr *addr,
        if (ret == 0) {
                /* Update address in NIC data structure */
                if (on)
-                       ether_addr_copy(addr,
+                       rte_ether_addr_copy(addr,
                                        &dev->data->hash_mac_addrs[index]);
                else
-                       ether_addr_copy(&null_mac_addr,
+                       rte_ether_addr_copy(&null_mac_addr,
                                        &dev->data->hash_mac_addrs[index]);
        }
 
@@ -4063,7 +4074,7 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 
 int
 rte_eth_dev_set_mc_addr_list(uint16_t port_id,
-                            struct ether_addr *mc_addr_set,
+                            struct rte_ether_addr *mc_addr_set,
                             uint32_t nb_mc_addr)
 {
        struct rte_eth_dev *dev;
@@ -4167,6 +4178,18 @@ rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *timestamp)
                                                                timestamp));
 }
 
+int
+rte_eth_read_clock(uint16_t port_id, uint64_t *clock)
+{
+       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->read_clock, -ENOTSUP);
+       return eth_err(port_id, (*dev->dev_ops->read_clock)(dev, clock));
+}
+
 int
 rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info)
 {