#include "rte_eth_ring.h"
#include <rte_mbuf.h>
-#include <rte_ethdev_driver.h>
+#include <ethdev_driver.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_string_fns.h>
#define ETH_RING_ACTION_CREATE "CREATE"
#define ETH_RING_ACTION_ATTACH "ATTACH"
#define ETH_RING_INTERNAL_ARG "internal"
+#define ETH_RING_INTERNAL_ARG_MAX_LEN 19 /* "0x..16chars..\0" */
static const char *valid_arguments[] = {
ETH_RING_NUMA_NODE_ACTION_ARG,
};
static struct rte_eth_link pmd_link = {
- .link_speed = ETH_SPEED_NUM_10G,
- .link_duplex = ETH_LINK_FULL_DUPLEX,
- .link_status = ETH_LINK_DOWN,
- .link_autoneg = ETH_LINK_FIXED,
+ .link_speed = RTE_ETH_SPEED_NUM_10G,
+ .link_duplex = RTE_ETH_LINK_FULL_DUPLEX,
+ .link_status = RTE_ETH_LINK_DOWN,
+ .link_autoneg = RTE_ETH_LINK_FIXED,
};
-RTE_LOG_REGISTER(eth_ring_logtype, pmd.net.ring, NOTICE);
+RTE_LOG_REGISTER_DEFAULT(eth_ring_logtype, NOTICE);
#define PMD_LOG(level, fmt, args...) \
rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
static int
eth_dev_start(struct rte_eth_dev *dev)
{
- dev->data->dev_link.link_status = ETH_LINK_UP;
+ dev->data->dev_link.link_status = RTE_ETH_LINK_UP;
return 0;
}
-static void
+static int
eth_dev_stop(struct rte_eth_dev *dev)
{
- dev->data->dev_link.link_status = ETH_LINK_DOWN;
+ dev->data->dev_started = 0;
+ dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
+ return 0;
}
static int
eth_dev_set_link_down(struct rte_eth_dev *dev)
{
- dev->data->dev_link.link_status = ETH_LINK_DOWN;
+ dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
return 0;
}
static int
eth_dev_set_link_up(struct rte_eth_dev *dev)
{
- dev->data->dev_link.link_status = ETH_LINK_UP;
+ dev->data->dev_link.link_status = RTE_ETH_LINK_UP;
return 0;
}
dev_info->max_mac_addrs = 1;
dev_info->max_rx_pktlen = (uint32_t)-1;
dev_info->max_rx_queues = (uint16_t)internals->max_rx_queues;
- dev_info->rx_offload_capa = DEV_RX_OFFLOAD_SCATTER;
- dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MULTI_SEGS;
+ dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_SCATTER;
+ dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
dev_info->max_tx_queues = (uint16_t)internals->max_tx_queues;
dev_info->min_rx_bufsize = 0;
return 0;
}
-static void
-eth_queue_release(void *q __rte_unused) { ; }
+static int
+eth_promiscuous_enable(struct rte_eth_dev *dev __rte_unused)
+{
+ return 0;
+}
+
+static int
+eth_promiscuous_disable(struct rte_eth_dev *dev __rte_unused)
+{
+ return 0;
+}
+
+static int
+eth_allmulticast_enable(struct rte_eth_dev *dev __rte_unused)
+{
+ return 0;
+}
+
+static int
+eth_allmulticast_disable(struct rte_eth_dev *dev __rte_unused)
+{
+ return 0;
+}
+
static int
eth_link_update(struct rte_eth_dev *dev __rte_unused,
int wait_to_complete __rte_unused) { return 0; }
struct pmd_internals *internals = NULL;
struct ring_queue *r = NULL;
uint16_t i;
+ int ret;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- eth_dev_stop(dev);
+ ret = eth_dev_stop(dev);
internals = dev->data->dev_private;
if (internals->action == DEV_CREATE) {
/* mac_addrs must not be freed alone because part of dev_private */
dev->data->mac_addrs = NULL;
- return 0;
+ return ret;
}
static const struct eth_dev_ops ops = {
.dev_infos_get = eth_dev_info,
.rx_queue_setup = eth_rx_queue_setup,
.tx_queue_setup = eth_tx_queue_setup,
- .rx_queue_release = eth_queue_release,
- .tx_queue_release = eth_queue_release,
.link_update = eth_link_update,
.stats_get = eth_stats_get,
.stats_reset = eth_stats_reset,
.mac_addr_remove = eth_mac_addr_remove,
.mac_addr_add = eth_mac_addr_add,
+ .promiscuous_enable = eth_promiscuous_enable,
+ .promiscuous_disable = eth_promiscuous_disable,
+ .allmulticast_enable = eth_allmulticast_enable,
+ .allmulticast_disable = eth_allmulticast_disable,
};
static int
data->mac_addrs = &internals->address;
data->promiscuous = 1;
data->all_multicast = 1;
+ data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
eth_dev->dev_ops = &ops;
data->numa_node = numa_node;
{
struct ring_internal_args **internal_args = data;
void *args;
+ int ret, n;
+
+ /* make sure 'value' is valid pointer length */
+ if (strnlen(value, ETH_RING_INTERNAL_ARG_MAX_LEN) >=
+ ETH_RING_INTERNAL_ARG_MAX_LEN) {
+ PMD_LOG(ERR, "Error parsing internal args, argument is too long");
+ return -1;
+ }
+
+ ret = sscanf(value, "%p%n", &args, &n);
+ if (ret == 0 || (size_t)n != strlen(value)) {
+ PMD_LOG(ERR, "Error parsing internal args");
- sscanf(value, "%p", &args);
+ return -1;
+ }
*internal_args = args;
PMD_LOG(INFO, "Initializing pmd_ring for %s", name);
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ eth_dev = rte_eth_dev_attach_secondary(name);
+ if (!eth_dev) {
+ PMD_LOG(ERR, "Failed to probe %s", name);
+ return -1;
+ }
+ eth_dev->dev_ops = &ops;
+ eth_dev->device = &dev->device;
+
+ eth_dev->rx_pkt_burst = eth_ring_rx;
+ eth_dev->tx_pkt_burst = eth_ring_tx;
+
+ rte_eth_dev_probing_finish(eth_dev);
+
+ return 0;
+ }
+
if (params == NULL || params[0] == '\0') {
ret = eth_dev_ring_create(name, dev, rte_socket_id(), DEV_CREATE,
ð_dev);
if (!kvlist) {
PMD_LOG(INFO,
- "Ignoring unsupported parameters when creatingrings-backed ethernet device");
+ "Ignoring unsupported parameters when creating rings-backed ethernet device");
ret = eth_dev_ring_create(name, dev, rte_socket_id(),
DEV_CREATE, ð_dev);
if (ret == -1) {