Hi > -----Original Message----- > From: Ye, Xiaolong > Sent: Tuesday, June 4, 2019 16:49 > To: Li, Xiaoyun <xiaoyun...@intel.com> > Cc: Wu, Jingjing <jingjing...@intel.com>; Wiles, Keith > <keith.wi...@intel.com>; > Liang, Cunming <cunming.li...@intel.com>; Maslekar, Omkar > <omkar.masle...@intel.com>; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 4/6] examples/ntb: enable an example for ntb > > [snip] > > >--- > >+ > >+int > >+main(int argc, char **argv) > >+{ > >+ int ret, i; > >+ > >+ signal(SIGINT, signal_handler); > >+ signal(SIGTERM, signal_handler); > >+ > >+ ret = rte_eal_init(argc, argv); > >+ if (ret < 0) > >+ rte_exit(EXIT_FAILURE, "Error with EAL initialization.\n"); > >+ > >+ /* Find 1st ntb rawdev. */ > >+ for (i = 0; i < RTE_RAWDEV_MAX_DEVS; i++) > >+ if (rte_rawdevs[i].driver_name && > >+ (strncmp(rte_rawdevs[i].driver_name, "raw_ntb", 7) == 0) && > >+ (rte_rawdevs[i].attached == 1)) > >+ break; > > Can replace above code block with rawdev API rte_rawdev_get_dev_id. > In fact, I've considered this API. But this API uses name (device name) not driver name to identify device and it uses strcmp not strncmp. But I want the first device who driver is ''raw_ntb". The device name is set to "NTB:[bus]:[dev].[func]" which is specific to the device.
> Thanks, > Xiaolong > > >+ > >+ if (i == RTE_RAWDEV_MAX_DEVS) > >+ rte_exit(EXIT_FAILURE, "Cannot find any ntb device.\n"); > >+ > >+ dev_id = i; > >+ > >+ argc -= ret; > >+ argv += ret; > >+ > >+ ret = parse_args(argc, argv); > >+ if (ret < 0) > >+ rte_exit(EXIT_FAILURE, "Invalid arguments\n"); > >+ > >+ rte_rawdev_start(dev_id); > >+ > >+ if (interactive) { > >+ sleep(1); > >+ prompt(); > >+ } > >+ > >+ return 0; > >+} > >-- > >2.17.1 > >