+ for (uint8_t port_id = 0; port_id < PROX_MAX_PORTS; ++port_id) {
+ if (!prox_port_cfg[port_id].active) {
+ continue;
+ }
+ struct prox_port_cfg* port_cfg = &prox_port_cfg[port_id];
+ if (port_cfg->vdev[0]) {
+#if (RTE_VERSION > RTE_VERSION_NUM(17,5,0,1))
+ char name[MAX_NAME_SIZE], tap[MAX_NAME_SIZE];
+ snprintf(tap, MAX_NAME_SIZE, "net_tap%d", port_id);
+ snprintf(name, MAX_NAME_SIZE, "iface=%s", port_cfg->vdev);
+ rc = rte_vdev_init(tap, name);
+#else
+ rc = eth_dev_null_create(tap, name, PROX_RTE_ETHER_MIN_LEN, 0);
+#endif
+ PROX_PANIC(rc != 0, "Unable to create device %s %s\n", "net tap", port_cfg->vdev);
+ int vdev_port_id = rte_eth_dev_count() - 1;
+ PROX_PANIC(vdev_port_id >= PROX_MAX_PORTS, "Too many port defined %d >= %d\n", vdev_port_id, PROX_MAX_PORTS);
+ plog_info("\tCreating device %s, port %d\n", port_cfg->vdev, vdev_port_id);
+ prox_port_cfg[vdev_port_id].active = 1;
+ prox_port_cfg[vdev_port_id].dpdk_mapping = port_id;
+ prox_port_cfg[vdev_port_id].n_txq = 1;
+
+ if (prox_port_cfg[port_id].vlan_tag) {
+ char command[1024];
+ snprintf(prox_port_cfg[vdev_port_id].name, MAX_NAME_SIZE, "%s_%d", port_cfg->vdev, prox_port_cfg[port_id].vlan_tag);
+ sprintf(command, "ip link add link %s name %s type vlan id %d", port_cfg->vdev, prox_port_cfg[vdev_port_id].name, prox_port_cfg[port_id].vlan_tag);
+ system(command);
+ plog_info("Running %s\n", command);
+ plog_info("Using vlan tag %d - added device %s\n", prox_port_cfg[port_id].vlan_tag, prox_port_cfg[vdev_port_id].name);
+ } else
+ strncpy(prox_port_cfg[vdev_port_id].name, port_cfg->vdev, MAX_NAME_SIZE);
+
+ prox_port_cfg[port_id].dpdk_mapping = vdev_port_id;
+ prox_port_cfg[vdev_port_id].ip = rte_be_to_cpu_32(prox_port_cfg[port_id].ip);
+ prox_port_cfg[port_id].ip = 0; // So only vdev has an IP associated
+ prox_port_cfg[vdev_port_id].type = prox_port_cfg[port_id].type;
+ if (prox_port_cfg[vdev_port_id].type == PROX_PORT_MAC_HW) {
+ // If DPDK port MAC set to HW, then make sure the vdev has the same MAC as DPDK port
+ prox_port_cfg[vdev_port_id].type = PROX_PORT_MAC_SET;
+ rte_eth_macaddr_get(port_id, &prox_port_cfg[vdev_port_id].eth_addr);
+ plog_info("\tDPDK port %d MAC address pre-configured to MAC from port %d: "MAC_BYTES_FMT"\n",
+ vdev_port_id, port_id, MAC_BYTES(prox_port_cfg[vdev_port_id].eth_addr.addr_bytes));
+ } else
+ memcpy(&prox_port_cfg[vdev_port_id].eth_addr, &prox_port_cfg[port_id].eth_addr, sizeof(prox_port_cfg[port_id].eth_addr));
+ }
+ }
+ nb_ports = prox_rte_eth_dev_count_avail();