diff options
author | Xavier Simonart <xavier.simonart@intel.com> | 2020-09-22 12:42:06 +0200 |
---|---|---|
committer | Xavier Simonart <xavier.simonart@intel.com> | 2020-10-16 14:32:53 +0200 |
commit | f9b0da859a9f2a6556f0437d5cff42a0648dcab2 (patch) | |
tree | 3b48c310d87547912a2f0fa3e17c34b0e9a594df /VNFs | |
parent | 0d1b97e647224d3d977186523d45555bc819f42a (diff) |
Report failure when tap port is not mapped to real dpdk port.
When using "vdev=" in port section, a tap device and an additional dpdk
port are created. In most cases, we still want to use a real DPDK device
(i.e. bound to an interface such as virtio or a PF or a VF).
PROX will now report by default an error when the used [port] is not a
DPDK bound device.
An additional parameter "virtual=yes" can be added in the port section
in case one want to disable this error checking (e.g. specify additional
parameter for the vdev device).
This patch also fixes a potential endianess issue when configuring IP
addresses.
Change-Id: Iffdd9552308be3b77cfe2067630647acac2c01fe
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs')
-rw-r--r-- | VNFs/DPPD-PROX/handle_master.c | 2 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/prox_args.c | 7 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/prox_port_cfg.c | 16 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/prox_port_cfg.h | 1 |
4 files changed, 20 insertions, 6 deletions
diff --git a/VNFs/DPPD-PROX/handle_master.c b/VNFs/DPPD-PROX/handle_master.c index b55db77e..ddaab521 100644 --- a/VNFs/DPPD-PROX/handle_master.c +++ b/VNFs/DPPD-PROX/handle_master.c @@ -169,7 +169,7 @@ void master_init_vdev(struct task_base *tbase, uint8_t port_id, uint8_t core_id, src.sin_family = AF_INET; src.sin_port = rte_cpu_to_be_16(PROX_PSEUDO_PKT_PORT); for (int vlan_id = 0; vlan_id < prox_port_cfg[vdev_port].n_vlans; vlan_id++) { - src.sin_addr.s_addr = prox_port_cfg[vdev_port].ip_addr[vlan_id].ip; + src.sin_addr.s_addr = rte_be_to_cpu_32(prox_port_cfg[vdev_port].ip_addr[vlan_id].ip); int fd = socket(AF_INET, SOCK_DGRAM, 0); PROX_PANIC(fd < 0, "Failed to open socket(AF_INET, SOCK_DGRAM, 0)\n"); prox_port_cfg[vdev_port].fds[vlan_id] = fd; diff --git a/VNFs/DPPD-PROX/prox_args.c b/VNFs/DPPD-PROX/prox_args.c index d6c1639d..aa87100a 100644 --- a/VNFs/DPPD-PROX/prox_args.c +++ b/VNFs/DPPD-PROX/prox_args.c @@ -582,6 +582,13 @@ static int get_port_cfg(unsigned sindex, char *str, void *data) } return 0; } + else if (STR_EQ(str, "virtual")) { + uint32_t val; + if (parse_bool(&val, pkey)) { + return -1; + } + cfg->virtual = val; + } else if (STR_EQ(str, "vdev")) { prox_strncpy(cfg->vdev, pkey, MAX_NAME_SIZE); } diff --git a/VNFs/DPPD-PROX/prox_port_cfg.c b/VNFs/DPPD-PROX/prox_port_cfg.c index 859c4372..60809f1d 100644 --- a/VNFs/DPPD-PROX/prox_port_cfg.c +++ b/VNFs/DPPD-PROX/prox_port_cfg.c @@ -173,13 +173,14 @@ static inline uint32_t get_netmask(uint8_t prefix) return rte_cpu_to_be_32(~((1 << (32 - prefix)) - 1)); } -static void set_ip_address(char *devname, uint32_t *ip, uint8_t prefix) +static void set_ip_address(char *devname, uint32_t ip, uint8_t prefix) { struct ifreq ifreq; struct sockaddr_in in_addr; int fd, rc; uint32_t netmask = get_netmask(prefix); plog_info("Setting netmask to %x\n", netmask); + uint32_t ip_cpu = rte_be_to_cpu_32(ip); fd = socket(AF_INET, SOCK_DGRAM, 0); @@ -187,12 +188,12 @@ static void set_ip_address(char *devname, uint32_t *ip, uint8_t prefix) memset(&in_addr, 0, sizeof(struct sockaddr_in)); in_addr.sin_family = AF_INET; - in_addr.sin_addr = *(struct in_addr *)ip; + in_addr.sin_addr = *(struct in_addr *)&ip_cpu; strncpy(ifreq.ifr_name, devname, IFNAMSIZ); ifreq.ifr_addr = *(struct sockaddr *)&in_addr; rc = ioctl(fd, SIOCSIFADDR, &ifreq); - PROX_PANIC(rc < 0, "Failed to set IP address %x on device %s: error = %d (%s)\n", *ip, devname, errno, strerror(errno)); + PROX_PANIC(rc < 0, "Failed to set IP address %x on device %s: error = %d (%s)\n", ip_cpu, devname, errno, strerror(errno)); in_addr.sin_addr = *(struct in_addr *)&netmask; ifreq.ifr_netmask = *(struct sockaddr *)&in_addr; @@ -210,6 +211,11 @@ void init_rte_dev(int use_dummy_devices) const struct rte_pci_device *pci_dev; for (uint8_t port_id = 0; port_id < PROX_MAX_PORTS; ++port_id) { + if (prox_port_cfg[port_id].active && (prox_port_cfg[port_id].virtual == 0) && (port_id >= prox_rte_eth_dev_count_avail())) { + PROX_PANIC(1, "port %u used but only %u available\n", port_id, prox_rte_eth_dev_count_avail()); + } + } + for (uint8_t port_id = 0; port_id < PROX_MAX_PORTS; ++port_id) { if (!prox_port_cfg[port_id].active) { continue; } @@ -257,7 +263,7 @@ void init_rte_dev(int use_dummy_devices) prox_port_cfg[port_id].dpdk_mapping = vdev_port_id; uint32_t i = 0; while ((i < PROX_MAX_VLAN_TAGS) && (prox_port_cfg[port_id].ip_addr[i].ip)) { - prox_port_cfg[vdev_port_id].ip_addr[i].ip = rte_be_to_cpu_32(prox_port_cfg[port_id].ip_addr[i].ip); + prox_port_cfg[vdev_port_id].ip_addr[i].ip = prox_port_cfg[port_id].ip_addr[i].ip; prox_port_cfg[vdev_port_id].ip_addr[i].prefix = prox_port_cfg[port_id].ip_addr[i].prefix; i++; } @@ -824,7 +830,7 @@ static void init_port(struct prox_port_cfg *port_cfg) if (prox_port_cfg[port_id].is_vdev) { for (int vlan_id = 0; vlan_id < prox_port_cfg[port_id].n_vlans; vlan_id++) { - set_ip_address(prox_port_cfg[port_id].names[vlan_id], &prox_port_cfg[port_id].ip_addr[vlan_id].ip, prox_port_cfg[port_id].ip_addr[vlan_id].prefix); + set_ip_address(prox_port_cfg[port_id].names[vlan_id], prox_port_cfg[port_id].ip_addr[vlan_id].ip, prox_port_cfg[port_id].ip_addr[vlan_id].prefix); } } /* Getting link status can be done without waiting if Link diff --git a/VNFs/DPPD-PROX/prox_port_cfg.h b/VNFs/DPPD-PROX/prox_port_cfg.h index 738ce86a..50359202 100644 --- a/VNFs/DPPD-PROX/prox_port_cfg.h +++ b/VNFs/DPPD-PROX/prox_port_cfg.h @@ -88,6 +88,7 @@ struct prox_port_cfg { int fds[PROX_MAX_VLAN_TAGS]; uint32_t vlan_tags[PROX_MAX_VLAN_TAGS]; uint8_t is_vdev; + uint8_t virtual; uint8_t all_rx_queues; uint16_t n_vlans; }; |