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)
{
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);
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;
}
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;
}
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;
}
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 */
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;
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;
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);
.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);
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);
}
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);
}
* 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];
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;
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;
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);
}
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;
(*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;
}
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];
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;
}
* 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];
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;
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;
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]);
}
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;
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)
{