xref: /dpdk/examples/vm_power_manager/main.c (revision da4ac8e5991a05d06a1e009a83c232dd824eac77)
13998e2a0SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
38db653ffSAlan Carew  */
48db653ffSAlan Carew 
58db653ffSAlan Carew #include <stdio.h>
68db653ffSAlan Carew #include <string.h>
78db653ffSAlan Carew #include <stdint.h>
88db653ffSAlan Carew #include <sys/epoll.h>
98db653ffSAlan Carew #include <fcntl.h>
108db653ffSAlan Carew #include <unistd.h>
118db653ffSAlan Carew #include <stdlib.h>
128db653ffSAlan Carew #include <signal.h>
138db653ffSAlan Carew #include <errno.h>
148db653ffSAlan Carew 
158db653ffSAlan Carew #include <sys/queue.h>
168db653ffSAlan Carew 
178db653ffSAlan Carew #include <rte_common.h>
188db653ffSAlan Carew #include <rte_eal.h>
198db653ffSAlan Carew #include <rte_launch.h>
208db653ffSAlan Carew #include <rte_log.h>
218db653ffSAlan Carew #include <rte_per_lcore.h>
228db653ffSAlan Carew #include <rte_lcore.h>
2320c78ac9SDavid Hunt #include <rte_ethdev.h>
2420c78ac9SDavid Hunt #include <getopt.h>
2520c78ac9SDavid Hunt #include <rte_cycles.h>
268db653ffSAlan Carew #include <rte_debug.h>
278db653ffSAlan Carew 
288db653ffSAlan Carew #include "channel_manager.h"
298db653ffSAlan Carew #include "channel_monitor.h"
308db653ffSAlan Carew #include "power_manager.h"
318db653ffSAlan Carew #include "vm_power_cli.h"
32d42b1300SDavid Hunt #include "oob_monitor.h"
3399a968faSDavid Hunt #include "parse.h"
34c9a47791SDavid Hunt #include <rte_pmd_ixgbe.h>
35c9a47791SDavid Hunt #include <rte_pmd_i40e.h>
36c9a47791SDavid Hunt #include <rte_pmd_bnxt.h>
378db653ffSAlan Carew 
38867a6c66SKevin Laatz #define RX_RING_SIZE 1024
39867a6c66SKevin Laatz #define TX_RING_SIZE 1024
4020c78ac9SDavid Hunt 
4120c78ac9SDavid Hunt #define NUM_MBUFS 8191
4220c78ac9SDavid Hunt #define MBUF_CACHE_SIZE 250
4320c78ac9SDavid Hunt #define BURST_SIZE 32
4420c78ac9SDavid Hunt 
4520c78ac9SDavid Hunt static uint32_t enabled_port_mask;
4620c78ac9SDavid Hunt static volatile bool force_quit;
4720c78ac9SDavid Hunt 
4820c78ac9SDavid Hunt /****************/
4920c78ac9SDavid Hunt static const struct rte_eth_conf port_conf_default = {
50f21e3b88SShahaf Shuler 	.rxmode = {
51f21e3b88SShahaf Shuler 		.max_rx_pkt_len = ETHER_MAX_LEN,
52f21e3b88SShahaf Shuler 	},
5320c78ac9SDavid Hunt };
5420c78ac9SDavid Hunt 
5520c78ac9SDavid Hunt static inline int
5620c78ac9SDavid Hunt port_init(uint16_t port, struct rte_mempool *mbuf_pool)
5720c78ac9SDavid Hunt {
5820c78ac9SDavid Hunt 	struct rte_eth_conf port_conf = port_conf_default;
5920c78ac9SDavid Hunt 	const uint16_t rx_rings = 1, tx_rings = 1;
6020c78ac9SDavid Hunt 	int retval;
6120c78ac9SDavid Hunt 	uint16_t q;
62f21e3b88SShahaf Shuler 	struct rte_eth_dev_info dev_info;
63f21e3b88SShahaf Shuler 	struct rte_eth_txconf txq_conf;
6420c78ac9SDavid Hunt 
65a9dbe180SThomas Monjalon 	if (!rte_eth_dev_is_valid_port(port))
6620c78ac9SDavid Hunt 		return -1;
6720c78ac9SDavid Hunt 
68f21e3b88SShahaf Shuler 	rte_eth_dev_info_get(port, &dev_info);
69f21e3b88SShahaf Shuler 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
70f21e3b88SShahaf Shuler 		port_conf.txmode.offloads |=
71f21e3b88SShahaf Shuler 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
72f21e3b88SShahaf Shuler 
7320c78ac9SDavid Hunt 	/* Configure the Ethernet device. */
7420c78ac9SDavid Hunt 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
7520c78ac9SDavid Hunt 	if (retval != 0)
7620c78ac9SDavid Hunt 		return retval;
7720c78ac9SDavid Hunt 
7820c78ac9SDavid Hunt 	/* Allocate and set up 1 RX queue per Ethernet port. */
7920c78ac9SDavid Hunt 	for (q = 0; q < rx_rings; q++) {
8020c78ac9SDavid Hunt 		retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
8120c78ac9SDavid Hunt 				rte_eth_dev_socket_id(port), NULL, mbuf_pool);
8220c78ac9SDavid Hunt 		if (retval < 0)
8320c78ac9SDavid Hunt 			return retval;
8420c78ac9SDavid Hunt 	}
8520c78ac9SDavid Hunt 
86f21e3b88SShahaf Shuler 	txq_conf = dev_info.default_txconf;
87f21e3b88SShahaf Shuler 	txq_conf.offloads = port_conf.txmode.offloads;
8820c78ac9SDavid Hunt 	/* Allocate and set up 1 TX queue per Ethernet port. */
8920c78ac9SDavid Hunt 	for (q = 0; q < tx_rings; q++) {
9020c78ac9SDavid Hunt 		retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
91f21e3b88SShahaf Shuler 				rte_eth_dev_socket_id(port), &txq_conf);
9220c78ac9SDavid Hunt 		if (retval < 0)
9320c78ac9SDavid Hunt 			return retval;
9420c78ac9SDavid Hunt 	}
9520c78ac9SDavid Hunt 
9620c78ac9SDavid Hunt 	/* Start the Ethernet port. */
9720c78ac9SDavid Hunt 	retval = rte_eth_dev_start(port);
9820c78ac9SDavid Hunt 	if (retval < 0)
9920c78ac9SDavid Hunt 		return retval;
10020c78ac9SDavid Hunt 
10120c78ac9SDavid Hunt 	/* Display the port MAC address. */
10220c78ac9SDavid Hunt 	struct ether_addr addr;
10320c78ac9SDavid Hunt 	rte_eth_macaddr_get(port, &addr);
10420c78ac9SDavid Hunt 	printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
10520c78ac9SDavid Hunt 			   " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
10620c78ac9SDavid Hunt 			(unsigned int)port,
10720c78ac9SDavid Hunt 			addr.addr_bytes[0], addr.addr_bytes[1],
10820c78ac9SDavid Hunt 			addr.addr_bytes[2], addr.addr_bytes[3],
10920c78ac9SDavid Hunt 			addr.addr_bytes[4], addr.addr_bytes[5]);
11020c78ac9SDavid Hunt 
11120c78ac9SDavid Hunt 	/* Enable RX in promiscuous mode for the Ethernet device. */
11220c78ac9SDavid Hunt 	rte_eth_promiscuous_enable(port);
11320c78ac9SDavid Hunt 
11420c78ac9SDavid Hunt 
11520c78ac9SDavid Hunt 	return 0;
11620c78ac9SDavid Hunt }
11720c78ac9SDavid Hunt 
11820c78ac9SDavid Hunt static int
11920c78ac9SDavid Hunt parse_portmask(const char *portmask)
12020c78ac9SDavid Hunt {
12120c78ac9SDavid Hunt 	char *end = NULL;
12220c78ac9SDavid Hunt 	unsigned long pm;
12320c78ac9SDavid Hunt 
12420c78ac9SDavid Hunt 	/* parse hexadecimal string */
12520c78ac9SDavid Hunt 	pm = strtoul(portmask, &end, 16);
12620c78ac9SDavid Hunt 	if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
12720c78ac9SDavid Hunt 		return -1;
12820c78ac9SDavid Hunt 
12920c78ac9SDavid Hunt 	if (pm == 0)
13020c78ac9SDavid Hunt 		return -1;
13120c78ac9SDavid Hunt 
13220c78ac9SDavid Hunt 	return pm;
13320c78ac9SDavid Hunt }
13420c78ac9SDavid Hunt /* Parse the argument given in the command line of the application */
13520c78ac9SDavid Hunt static int
13620c78ac9SDavid Hunt parse_args(int argc, char **argv)
13720c78ac9SDavid Hunt {
13899a968faSDavid Hunt 	int opt, ret, cnt, i;
13920c78ac9SDavid Hunt 	char **argvopt;
14099a968faSDavid Hunt 	uint16_t *oob_enable;
14120c78ac9SDavid Hunt 	int option_index;
14220c78ac9SDavid Hunt 	char *prgname = argv[0];
14399a968faSDavid Hunt 	struct core_info *ci;
144711f43baSDavid Hunt 	float branch_ratio;
14520c78ac9SDavid Hunt 	static struct option lgopts[] = {
14620c78ac9SDavid Hunt 		{ "mac-updating", no_argument, 0, 1},
14720c78ac9SDavid Hunt 		{ "no-mac-updating", no_argument, 0, 0},
14899a968faSDavid Hunt 		{ "core-list", optional_argument, 0, 'l'},
1496e269577SDavid Hunt 		{ "port-list", optional_argument, 0, 'p'},
150711f43baSDavid Hunt 		{ "branch-ratio", optional_argument, 0, 'b'},
15120c78ac9SDavid Hunt 		{NULL, 0, 0, 0}
15220c78ac9SDavid Hunt 	};
15320c78ac9SDavid Hunt 	argvopt = argv;
15499a968faSDavid Hunt 	ci = get_core_info();
15520c78ac9SDavid Hunt 
156711f43baSDavid Hunt 	while ((opt = getopt_long(argc, argvopt, "l:p:q:T:b:",
15720c78ac9SDavid Hunt 				  lgopts, &option_index)) != EOF) {
15820c78ac9SDavid Hunt 
15920c78ac9SDavid Hunt 		switch (opt) {
16020c78ac9SDavid Hunt 		/* portmask */
16120c78ac9SDavid Hunt 		case 'p':
16220c78ac9SDavid Hunt 			enabled_port_mask = parse_portmask(optarg);
16320c78ac9SDavid Hunt 			if (enabled_port_mask == 0) {
16420c78ac9SDavid Hunt 				printf("invalid portmask\n");
16520c78ac9SDavid Hunt 				return -1;
16620c78ac9SDavid Hunt 			}
16720c78ac9SDavid Hunt 			break;
16899a968faSDavid Hunt 		case 'l':
16999a968faSDavid Hunt 			oob_enable = malloc(ci->core_count * sizeof(uint16_t));
17099a968faSDavid Hunt 			if (oob_enable == NULL) {
17199a968faSDavid Hunt 				printf("Error - Unable to allocate memory\n");
17299a968faSDavid Hunt 				return -1;
17399a968faSDavid Hunt 			}
17499a968faSDavid Hunt 			cnt = parse_set(optarg, oob_enable, ci->core_count);
17599a968faSDavid Hunt 			if (cnt < 0) {
17699a968faSDavid Hunt 				printf("Invalid core-list - [%s]\n",
17799a968faSDavid Hunt 						optarg);
178*da4ac8e5SDavid Hunt 				free(oob_enable);
17999a968faSDavid Hunt 				break;
18099a968faSDavid Hunt 			}
18199a968faSDavid Hunt 			for (i = 0; i < ci->core_count; i++) {
18299a968faSDavid Hunt 				if (oob_enable[i]) {
18399a968faSDavid Hunt 					printf("***Using core %d\n", i);
18499a968faSDavid Hunt 					ci->cd[i].oob_enabled = 1;
18599a968faSDavid Hunt 					ci->cd[i].global_enabled_cpus = 1;
18699a968faSDavid Hunt 				}
18799a968faSDavid Hunt 			}
18899a968faSDavid Hunt 			free(oob_enable);
18999a968faSDavid Hunt 			break;
190711f43baSDavid Hunt 		case 'b':
191711f43baSDavid Hunt 			branch_ratio = 0.0;
192711f43baSDavid Hunt 			if (strlen(optarg))
193711f43baSDavid Hunt 				branch_ratio = atof(optarg);
194711f43baSDavid Hunt 			if (branch_ratio <= 0.0) {
195711f43baSDavid Hunt 				printf("invalid branch ratio specified\n");
196711f43baSDavid Hunt 				return -1;
197711f43baSDavid Hunt 			}
198711f43baSDavid Hunt 			ci->branch_ratio_threshold = branch_ratio;
199711f43baSDavid Hunt 			printf("***Setting branch ratio to %f\n",
200711f43baSDavid Hunt 					branch_ratio);
201711f43baSDavid Hunt 			break;
20220c78ac9SDavid Hunt 		/* long options */
20320c78ac9SDavid Hunt 		case 0:
20420c78ac9SDavid Hunt 			break;
20520c78ac9SDavid Hunt 
20620c78ac9SDavid Hunt 		default:
20720c78ac9SDavid Hunt 			return -1;
20820c78ac9SDavid Hunt 		}
20920c78ac9SDavid Hunt 	}
21020c78ac9SDavid Hunt 
21120c78ac9SDavid Hunt 	if (optind >= 0)
21220c78ac9SDavid Hunt 		argv[optind-1] = prgname;
21320c78ac9SDavid Hunt 
21420c78ac9SDavid Hunt 	ret = optind-1;
21520c78ac9SDavid Hunt 	optind = 0; /* reset getopt lib */
21620c78ac9SDavid Hunt 	return ret;
21720c78ac9SDavid Hunt }
21820c78ac9SDavid Hunt 
21920c78ac9SDavid Hunt static void
2208728ccf3SThomas Monjalon check_all_ports_link_status(uint32_t port_mask)
22120c78ac9SDavid Hunt {
22220c78ac9SDavid Hunt #define CHECK_INTERVAL 100 /* 100ms */
22320c78ac9SDavid Hunt #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
22420c78ac9SDavid Hunt 	uint16_t portid, count, all_ports_up, print_flag = 0;
22520c78ac9SDavid Hunt 	struct rte_eth_link link;
22620c78ac9SDavid Hunt 
22720c78ac9SDavid Hunt 	printf("\nChecking link status");
22820c78ac9SDavid Hunt 	fflush(stdout);
22920c78ac9SDavid Hunt 	for (count = 0; count <= MAX_CHECK_TIME; count++) {
23020c78ac9SDavid Hunt 		if (force_quit)
23120c78ac9SDavid Hunt 			return;
23220c78ac9SDavid Hunt 		all_ports_up = 1;
2338728ccf3SThomas Monjalon 		RTE_ETH_FOREACH_DEV(portid) {
23420c78ac9SDavid Hunt 			if (force_quit)
23520c78ac9SDavid Hunt 				return;
23620c78ac9SDavid Hunt 			if ((port_mask & (1 << portid)) == 0)
23720c78ac9SDavid Hunt 				continue;
23820c78ac9SDavid Hunt 			memset(&link, 0, sizeof(link));
23920c78ac9SDavid Hunt 			rte_eth_link_get_nowait(portid, &link);
24020c78ac9SDavid Hunt 			/* print link status if flag set */
24120c78ac9SDavid Hunt 			if (print_flag == 1) {
24220c78ac9SDavid Hunt 				if (link.link_status)
24320c78ac9SDavid Hunt 					printf("Port %d Link Up - speed %u "
24420c78ac9SDavid Hunt 						"Mbps - %s\n", (uint16_t)portid,
24520c78ac9SDavid Hunt 						(unsigned int)link.link_speed,
24620c78ac9SDavid Hunt 				(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
24720c78ac9SDavid Hunt 					("full-duplex") : ("half-duplex\n"));
24820c78ac9SDavid Hunt 				else
24920c78ac9SDavid Hunt 					printf("Port %d Link Down\n",
25020c78ac9SDavid Hunt 						(uint16_t)portid);
25120c78ac9SDavid Hunt 				continue;
25220c78ac9SDavid Hunt 			}
25320c78ac9SDavid Hunt 		       /* clear all_ports_up flag if any link down */
25420c78ac9SDavid Hunt 			if (link.link_status == ETH_LINK_DOWN) {
25520c78ac9SDavid Hunt 				all_ports_up = 0;
25620c78ac9SDavid Hunt 				break;
25720c78ac9SDavid Hunt 			}
25820c78ac9SDavid Hunt 		}
25920c78ac9SDavid Hunt 		/* after finally printing all link status, get out */
26020c78ac9SDavid Hunt 		if (print_flag == 1)
26120c78ac9SDavid Hunt 			break;
26220c78ac9SDavid Hunt 
26320c78ac9SDavid Hunt 		if (all_ports_up == 0) {
26420c78ac9SDavid Hunt 			printf(".");
26520c78ac9SDavid Hunt 			fflush(stdout);
26620c78ac9SDavid Hunt 			rte_delay_ms(CHECK_INTERVAL);
26720c78ac9SDavid Hunt 		}
26820c78ac9SDavid Hunt 
26920c78ac9SDavid Hunt 		/* set the print_flag if all ports up or timeout */
27020c78ac9SDavid Hunt 		if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
27120c78ac9SDavid Hunt 			print_flag = 1;
27220c78ac9SDavid Hunt 			printf("done\n");
27320c78ac9SDavid Hunt 		}
27420c78ac9SDavid Hunt 	}
27520c78ac9SDavid Hunt }
2768db653ffSAlan Carew static int
2778db653ffSAlan Carew run_monitor(__attribute__((unused)) void *arg)
2788db653ffSAlan Carew {
2798db653ffSAlan Carew 	if (channel_monitor_init() < 0) {
2808db653ffSAlan Carew 		printf("Unable to initialize channel monitor\n");
2818db653ffSAlan Carew 		return -1;
2828db653ffSAlan Carew 	}
2838db653ffSAlan Carew 	run_channel_monitor();
2848db653ffSAlan Carew 	return 0;
2858db653ffSAlan Carew }
2868db653ffSAlan Carew 
287d42b1300SDavid Hunt static int
288d42b1300SDavid Hunt run_core_monitor(__attribute__((unused)) void *arg)
289d42b1300SDavid Hunt {
290d42b1300SDavid Hunt 	if (branch_monitor_init() < 0) {
291d42b1300SDavid Hunt 		printf("Unable to initialize core monitor\n");
292d42b1300SDavid Hunt 		return -1;
293d42b1300SDavid Hunt 	}
294d42b1300SDavid Hunt 	run_branch_monitor();
295d42b1300SDavid Hunt 	return 0;
296d42b1300SDavid Hunt }
297d42b1300SDavid Hunt 
2988db653ffSAlan Carew static void
2998db653ffSAlan Carew sig_handler(int signo)
3008db653ffSAlan Carew {
3018db653ffSAlan Carew 	printf("Received signal %d, exiting...\n", signo);
3028db653ffSAlan Carew 	channel_monitor_exit();
3038db653ffSAlan Carew 	channel_manager_exit();
3048db653ffSAlan Carew 	power_manager_exit();
3058db653ffSAlan Carew 
3068db653ffSAlan Carew }
3078db653ffSAlan Carew 
3088db653ffSAlan Carew int
30998a16481SDavid Marchand main(int argc, char **argv)
3108db653ffSAlan Carew {
3118db653ffSAlan Carew 	int ret;
3128db653ffSAlan Carew 	unsigned lcore_id;
31320c78ac9SDavid Hunt 	unsigned int nb_ports;
31420c78ac9SDavid Hunt 	struct rte_mempool *mbuf_pool;
31520c78ac9SDavid Hunt 	uint16_t portid;
316d42b1300SDavid Hunt 	struct core_info *ci;
31720c78ac9SDavid Hunt 
3188db653ffSAlan Carew 
31999a968faSDavid Hunt 	ret = core_info_init();
32099a968faSDavid Hunt 	if (ret < 0)
32199a968faSDavid Hunt 		rte_panic("Cannot allocate core info\n");
32299a968faSDavid Hunt 
323d42b1300SDavid Hunt 	ci = get_core_info();
324d42b1300SDavid Hunt 
3258db653ffSAlan Carew 	ret = rte_eal_init(argc, argv);
3268db653ffSAlan Carew 	if (ret < 0)
3278db653ffSAlan Carew 		rte_panic("Cannot init EAL\n");
3288db653ffSAlan Carew 
3298db653ffSAlan Carew 	signal(SIGINT, sig_handler);
3308db653ffSAlan Carew 	signal(SIGTERM, sig_handler);
3318db653ffSAlan Carew 
33220c78ac9SDavid Hunt 	argc -= ret;
33320c78ac9SDavid Hunt 	argv += ret;
33420c78ac9SDavid Hunt 
33520c78ac9SDavid Hunt 	/* parse application arguments (after the EAL ones) */
33620c78ac9SDavid Hunt 	ret = parse_args(argc, argv);
33720c78ac9SDavid Hunt 	if (ret < 0)
33820c78ac9SDavid Hunt 		rte_exit(EXIT_FAILURE, "Invalid arguments\n");
33920c78ac9SDavid Hunt 
340d9a42a69SThomas Monjalon 	nb_ports = rte_eth_dev_count_avail();
34120c78ac9SDavid Hunt 
342ace158c4SDavid Hunt 	if (nb_ports > 0) {
343ace158c4SDavid Hunt 		mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL",
344ace158c4SDavid Hunt 				NUM_MBUFS * nb_ports, MBUF_CACHE_SIZE, 0,
345ace158c4SDavid Hunt 				RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
34620c78ac9SDavid Hunt 
34720c78ac9SDavid Hunt 		if (mbuf_pool == NULL)
34820c78ac9SDavid Hunt 			rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
34920c78ac9SDavid Hunt 
35020c78ac9SDavid Hunt 		/* Initialize ports. */
3518728ccf3SThomas Monjalon 		RTE_ETH_FOREACH_DEV(portid) {
352c9a47791SDavid Hunt 			struct ether_addr eth;
353c9a47791SDavid Hunt 			int w, j;
354a032a081SDavid Coyle 			int ret;
355c9a47791SDavid Hunt 
35620c78ac9SDavid Hunt 			if ((enabled_port_mask & (1 << portid)) == 0)
35720c78ac9SDavid Hunt 				continue;
358c9a47791SDavid Hunt 
359c9a47791SDavid Hunt 			eth.addr_bytes[0] = 0xe0;
360c9a47791SDavid Hunt 			eth.addr_bytes[1] = 0xe0;
361c9a47791SDavid Hunt 			eth.addr_bytes[2] = 0xe0;
362c9a47791SDavid Hunt 			eth.addr_bytes[3] = 0xe0;
363c9a47791SDavid Hunt 			eth.addr_bytes[4] = portid + 0xf0;
364c9a47791SDavid Hunt 
36520c78ac9SDavid Hunt 			if (port_init(portid, mbuf_pool) != 0)
366ace158c4SDavid Hunt 				rte_exit(EXIT_FAILURE,
367ace158c4SDavid Hunt 					"Cannot init port %"PRIu8 "\n",
36820c78ac9SDavid Hunt 					portid);
369c9a47791SDavid Hunt 
370c9a47791SDavid Hunt 			for (w = 0; w < MAX_VFS; w++) {
371c9a47791SDavid Hunt 				eth.addr_bytes[5] = w + 0xf0;
372c9a47791SDavid Hunt 
373c9a47791SDavid Hunt 				ret = rte_pmd_ixgbe_set_vf_mac_addr(portid,
374c9a47791SDavid Hunt 							w, &eth);
375c9a47791SDavid Hunt 				if (ret == -ENOTSUP)
376ace158c4SDavid Hunt 					ret = rte_pmd_i40e_set_vf_mac_addr(
377ace158c4SDavid Hunt 							portid, w, &eth);
378c9a47791SDavid Hunt 				if (ret == -ENOTSUP)
379ace158c4SDavid Hunt 					ret = rte_pmd_bnxt_set_vf_mac_addr(
380ace158c4SDavid Hunt 							portid, w, &eth);
381c9a47791SDavid Hunt 
382c9a47791SDavid Hunt 				switch (ret) {
383c9a47791SDavid Hunt 				case 0:
384c9a47791SDavid Hunt 					printf("Port %d VF %d MAC: ",
385c9a47791SDavid Hunt 							portid, w);
386ace158c4SDavid Hunt 					for (j = 0; j < 5; j++) {
387ace158c4SDavid Hunt 						printf("%02x:",
388ace158c4SDavid Hunt 							eth.addr_bytes[j]);
389ace158c4SDavid Hunt 					}
390ace158c4SDavid Hunt 					printf("%02x\n", eth.addr_bytes[5]);
391ace158c4SDavid Hunt 					break;
392c9a47791SDavid Hunt 				}
393c9a47791SDavid Hunt 				printf("\n");
394c9a47791SDavid Hunt 				break;
395c9a47791SDavid Hunt 			}
396c9a47791SDavid Hunt 		}
39720c78ac9SDavid Hunt 	}
39820c78ac9SDavid Hunt 
399d42b1300SDavid Hunt 	check_all_ports_link_status(enabled_port_mask);
400d42b1300SDavid Hunt 
4018db653ffSAlan Carew 	lcore_id = rte_get_next_lcore(-1, 1, 0);
4028db653ffSAlan Carew 	if (lcore_id == RTE_MAX_LCORE) {
403d42b1300SDavid Hunt 		RTE_LOG(ERR, EAL, "A minimum of three cores are required to run "
4048db653ffSAlan Carew 				"application\n");
4058db653ffSAlan Carew 		return 0;
4068db653ffSAlan Carew 	}
407d42b1300SDavid Hunt 	printf("Running channel monitor on lcore id %d\n", lcore_id);
4088db653ffSAlan Carew 	rte_eal_remote_launch(run_monitor, NULL, lcore_id);
4098db653ffSAlan Carew 
410d42b1300SDavid Hunt 	lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
411d42b1300SDavid Hunt 	if (lcore_id == RTE_MAX_LCORE) {
412d42b1300SDavid Hunt 		RTE_LOG(ERR, EAL, "A minimum of three cores are required to run "
413d42b1300SDavid Hunt 				"application\n");
414d42b1300SDavid Hunt 		return 0;
415d42b1300SDavid Hunt 	}
4168db653ffSAlan Carew 	if (power_manager_init() < 0) {
4178db653ffSAlan Carew 		printf("Unable to initialize power manager\n");
4188db653ffSAlan Carew 		return -1;
4198db653ffSAlan Carew 	}
4208db653ffSAlan Carew 	if (channel_manager_init(CHANNEL_MGR_DEFAULT_HV_PATH) < 0) {
4218db653ffSAlan Carew 		printf("Unable to initialize channel manager\n");
4228db653ffSAlan Carew 		return -1;
4238db653ffSAlan Carew 	}
424d42b1300SDavid Hunt 
4253618326fSDavid Hunt 	add_host_channel();
4263618326fSDavid Hunt 
427d42b1300SDavid Hunt 	printf("Running core monitor on lcore id %d\n", lcore_id);
428d42b1300SDavid Hunt 	rte_eal_remote_launch(run_core_monitor, NULL, lcore_id);
429d42b1300SDavid Hunt 
4308db653ffSAlan Carew 	run_cli(NULL);
4318db653ffSAlan Carew 
432d42b1300SDavid Hunt 	branch_monitor_exit();
433d42b1300SDavid Hunt 
4348db653ffSAlan Carew 	rte_eal_mp_wait_lcore();
435d42b1300SDavid Hunt 
436d42b1300SDavid Hunt 	free(ci->cd);
437d42b1300SDavid Hunt 
4388db653ffSAlan Carew 	return 0;
4398db653ffSAlan Carew }
440