From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1A86F1B1E3 for ; Thu, 7 Jun 2018 16:39:52 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 07:39:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="62111496" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by fmsmga001.fm.intel.com with ESMTP; 07 Jun 2018 07:39:51 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com Date: Thu, 7 Jun 2018 08:37:00 +0100 Message-Id: <20180607073705.32895-2-david.hunt@intel.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180607073705.32895-1-david.hunt@intel.com> References: <20180607073705.32895-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v1 1/6] examples/vm_power: add check for port count X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2018 14:39:53 -0000 If we don't pass any ports to the app, we don't need to create any mempools, and we don't need to init any ports. Signed-off-by: David Hunt --- examples/vm_power_manager/main.c | 81 +++++++++++++++++--------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index c9805a461..043b374bc 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -280,51 +280,56 @@ main(int argc, char **argv) nb_ports = rte_eth_dev_count_avail(); - mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUFS * nb_ports, - MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); + if (nb_ports > 0) { + mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", + NUM_MBUFS * nb_ports, MBUF_CACHE_SIZE, 0, + RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); - if (mbuf_pool == NULL) - rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); + if (mbuf_pool == NULL) + rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); - /* Initialize ports. */ - RTE_ETH_FOREACH_DEV(portid) { - struct ether_addr eth; - int w, j; - int ret; + /* Initialize ports. */ + RTE_ETH_FOREACH_DEV(portid) { + struct ether_addr eth; + int w, j; + int ret; - if ((enabled_port_mask & (1 << portid)) == 0) - continue; + if ((enabled_port_mask & (1 << portid)) == 0) + continue; - eth.addr_bytes[0] = 0xe0; - eth.addr_bytes[1] = 0xe0; - eth.addr_bytes[2] = 0xe0; - eth.addr_bytes[3] = 0xe0; - eth.addr_bytes[4] = portid + 0xf0; + eth.addr_bytes[0] = 0xe0; + eth.addr_bytes[1] = 0xe0; + eth.addr_bytes[2] = 0xe0; + eth.addr_bytes[3] = 0xe0; + eth.addr_bytes[4] = portid + 0xf0; - if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8 "\n", + if (port_init(portid, mbuf_pool) != 0) + rte_exit(EXIT_FAILURE, + "Cannot init port %"PRIu8 "\n", portid); - for (w = 0; w < MAX_VFS; w++) { - eth.addr_bytes[5] = w + 0xf0; - - ret = rte_pmd_ixgbe_set_vf_mac_addr(portid, - w, ð); - if (ret == -ENOTSUP) - ret = rte_pmd_i40e_set_vf_mac_addr(portid, - w, ð); - if (ret == -ENOTSUP) - ret = rte_pmd_bnxt_set_vf_mac_addr(portid, - w, ð); - - switch (ret) { - case 0: - printf("Port %d VF %d MAC: ", - portid, w); - for (j = 0; j < 6; j++) { - printf("%02x", eth.addr_bytes[j]); - if (j < 5) - printf(":"); + for (w = 0; w < MAX_VFS; w++) { + eth.addr_bytes[5] = w + 0xf0; + + ret = rte_pmd_ixgbe_set_vf_mac_addr(portid, + w, ð); + if (ret == -ENOTSUP) + ret = rte_pmd_i40e_set_vf_mac_addr( + portid, w, ð); + if (ret == -ENOTSUP) + ret = rte_pmd_bnxt_set_vf_mac_addr( + portid, w, ð); + + switch (ret) { + case 0: + printf("Port %d VF %d MAC: ", + portid, w); + for (j = 0; j < 5; j++) { + printf("%02x:", + eth.addr_bytes[j]); + } + printf("%02x\n", eth.addr_bytes[5]); + break; } printf("\n"); break; -- 2.17.0