/** * Print to console all available DPDK ports. Used by the -l switch */ void listDpdkPorts() { CoreMask coreMaskToUse = getCoreMaskForAllMachineCores(); // initialize DPDK if (!DpdkDeviceList::initDpdk(coreMaskToUse, DEFAULT_MBUF_POOL_SIZE)) { EXIT_WITH_ERROR("couldn't initialize DPDK"); } printf("DPDK port list:\n"); // go over all available DPDK devices and print info for each one vector<DpdkDevice*> deviceList = DpdkDeviceList::getInstance().getDpdkDeviceList(); for (vector<DpdkDevice*>::iterator iter = deviceList.begin(); iter != deviceList.end(); iter++) { DpdkDevice* dev = *iter; printf(" Port #%d: MAC address='%s'; PCI address='%s'; PMD='%s'\n", dev->getDeviceId(), dev->getMacAddress().toString().c_str(), dev->getPciAddress().toString().c_str(), dev->getPMDName().c_str()); } }
bool DpdkDeviceList::initDpdkDevices(uint32_t mBufPoolSizePerDevice) { if (!m_IsDpdkInitialized) { LOG_ERROR("DPDK is not initialized!! Please call DpdkDeviceList::initDpdk(coreMask, mBufPoolSizePerDevice) before start using DPDK devices"); return false; } if (m_IsInitialized) return true; int numOfPorts = rte_eth_dev_count(); if (numOfPorts <= 0) { LOG_ERROR("Zero DPDK ports are initialized. Something went wrong while initializing DPDK"); return false; } LOG_DEBUG("Found %d DPDK ports. Constructing DpdkDevice for each one", numOfPorts); // Initialize a DpdkDevice per port for (int i = 0; i < numOfPorts; i++) { DpdkDevice* newDevice = new DpdkDevice(i, mBufPoolSizePerDevice); LOG_DEBUG("DpdkDevice #%d: Name='%s', PCI-slot='%s', PMD='%s', MAC Addr='%s'", i, newDevice->getDeviceName().c_str(), newDevice->getPciAddress().toString().c_str(), newDevice->getPMDName().c_str(), newDevice->getMacAddress().toString().c_str()); m_DpdkDeviceList.push_back(newDevice); } m_IsInitialized = true; return true; }