summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/prox_port_cfg.c
diff options
context:
space:
mode:
authorXavier Simonart <xavier.simonart@intel.com>2020-03-24 00:31:13 +0100
committerXavier Simonart <xavier.simonart@intel.com>2020-05-29 23:40:28 +0200
commitc61fccde40dc6bb4a6ecd21c9d6dc8969df33400 (patch)
treeacdf0a31a6d1eea0e97f3ef6d1b70f4b97bc0dc0 /VNFs/DPPD-PROX/prox_port_cfg.c
parent4359ac786cc49d0ce20f745def415d46fbba177d (diff)
Added support for secondary process & virtual devices
A virtual device can be created adding the following option on the eal field within the eal options section: --vdev=net_ring0 This will cause a new (virtual) dpdk port to be created. Such a device can then be used in a primary process as other DPDK devices i.e. a [port x] section must be defined in the configuration file For a secondary process, there is no need to add --vdev, but, of course --proc-type=secondary (or --proc-type=auto) must be set within the eal field. There are two ways to use such a virtual device in a secondary process 1) Using the DPDK port number. Note however that the DPDK port number of virtual devices in the secondary process might not start from 0 and might hence have to be guessed e.g. if using 2 virtual devices in primary process (--vdev=net_ring0 --vdev=net_ring1) the port_id will be 0 and 1 in primary process and 2 & 3 in secondary process. 2) Using the port name, as defined in --vdev in the primary process. In this way, no [port] section must be defined, and the virtual port names are directly used within the "rx port" and "tx port" configuration e.g.: rx port=net_ring0 tx port=net_ring1 Limitations =========== There seems to be a PROX leak causing DPDK port id to increase when restarting the secondary process (causing the secondary process configuration through port id more difficult). As the primary process configures the port (including the number of rx and tx queues) based on its config file, the secondary process can't setup its own queues. Simple configurations (such as using gen or lat in primary, and swap in secondary) work as PROX allocates a RX queue even in gen mode and a TX queue even in lat mode. Better configuration/support for secondary process should be designed. The use of dpdk port names is only supported by PROX within "rx port" and "tx port". It is not supported by other configuration fields such as "tx ports from routing table". The use of dpdk port names in "rx port" and "tx port" is limited to only 1 port. Change-Id: Iaa606625da471403713a21df79d3ded4bb91b91e Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/prox_port_cfg.c')
-rw-r--r--VNFs/DPPD-PROX/prox_port_cfg.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/VNFs/DPPD-PROX/prox_port_cfg.c b/VNFs/DPPD-PROX/prox_port_cfg.c
index 2abf4d58..098d973b 100644
--- a/VNFs/DPPD-PROX/prox_port_cfg.c
+++ b/VNFs/DPPD-PROX/prox_port_cfg.c
@@ -47,6 +47,7 @@
#include "rte_ethdev.h"
struct prox_port_cfg prox_port_cfg[PROX_MAX_PORTS];
+
rte_atomic32_t lsc;
int prox_nb_active_ports(void)
@@ -271,17 +272,33 @@ void init_rte_dev(int use_dummy_devices)
nb_ports = PROX_MAX_PORTS;
}
- port_id_max = nb_ports - 1;
+ port_id_max = -1;
+ uint16_t id;
+ RTE_ETH_FOREACH_DEV(id) {
+ char name[256];
+ rte_eth_dev_get_name_by_port(id, name);
+ plog_info("\tFound DPDK port id %u %s\n", id, name);
+ if (id >= PROX_MAX_PORTS) {
+ plog_warn("\tWarning: I can deal with at most %u ports."
+ " Please update PROX_MAX_PORTS and recompile.\n", PROX_MAX_PORTS);
+ } else {
+ prox_port_cfg[id].available = 1;
+ if (id > port_id_max)
+ port_id_max = id;
+ }
+ }
port_id_last = prox_last_port_active();
PROX_PANIC(port_id_last > port_id_max,
"\tError: invalid port(s) specified, last port index active: %d (max index is %d)\n",
port_id_last, port_id_max);
/* Assign ports to PROX interfaces & Read max RX/TX queues per port */
- for (uint8_t port_id = 0; port_id < nb_ports; ++port_id) {
+ for (uint8_t port_id = 0; port_id <= port_id_last; ++port_id) {
/* skip ports that are not enabled */
if (!prox_port_cfg[port_id].active) {
continue;
+ } else if (prox_port_cfg[port_id].available == 0) {
+ PROX_PANIC(1, "port %u enabled but not available\n", port_id);
}
plog_info("\tGetting info for rte dev %u\n", port_id);
rte_eth_dev_info_get(port_id, &dev_info);
@@ -813,6 +830,12 @@ static void init_port(struct prox_port_cfg *port_cfg)
void init_port_all(void)
{
+ enum rte_proc_type_t proc_type;
+ proc_type = rte_eal_process_type();
+ if (proc_type == RTE_PROC_SECONDARY) {
+ plog_info("\tSkipping port initialization as secondary process\n");
+ return;
+ }
uint8_t max_port_idx = prox_last_port_active() + 1;
for (uint8_t portid = 0; portid < max_port_idx; ++portid) {
@@ -831,6 +854,7 @@ void close_ports_atexit(void)
if (!prox_port_cfg[portid].active) {
continue;
}
+ plog_info("Closing port %u\n", portid);
rte_eth_dev_close(portid);
}
}
@@ -838,6 +862,7 @@ void close_ports_atexit(void)
void init_port_addr(void)
{
struct prox_port_cfg *port_cfg;
+ enum rte_proc_type_t proc_type;
int rc;
for (uint8_t port_id = 0; port_id < PROX_MAX_PORTS; ++port_id) {
@@ -854,9 +879,13 @@ void init_port_addr(void)
prox_rte_eth_random_addr(port_cfg->eth_addr.addr_bytes);
break;
case PROX_PORT_MAC_SET:
- plog_info("Setting MAC to "MAC_BYTES_FMT"\n", MAC_BYTES(port_cfg->eth_addr.addr_bytes));
- if ((rc = rte_eth_dev_default_mac_addr_set(port_id, &port_cfg->eth_addr)) != 0)
- plog_warn("port %u: failed to set mac address. Error = %d\n", port_id, rc);
+ proc_type = rte_eal_process_type();
+ if (proc_type == RTE_PROC_SECONDARY) {
+ plog_warn("\tport %u: unable to change port mac address as secondary process\n", port_id);
+ } else if ((rc = rte_eth_dev_default_mac_addr_set(port_id, &port_cfg->eth_addr)) != 0)
+ plog_warn("\tport %u: failed to set mac address. Error = %d\n", port_id, rc);
+ else
+ plog_info("Setting MAC to "MAC_BYTES_FMT"\n", MAC_BYTES(port_cfg->eth_addr.addr_bytes));
break;
}
}