#include "test.h"
-#ifdef RTE_LIBRTE_KNI
#include <rte_string_fns.h>
#include <rte_mempool.h>
#include <rte_ethdev.h>
#define IFCONFIG "/sbin/ifconfig "
#define TEST_KNI_PORT "test_kni_port"
-
+#define KNI_TEST_MAX_PORTS 4
/* The threshold number of mbufs to be transmitted or received. */
#define KNI_NUM_MBUF_THRESHOLD 100
static int kni_pkt_mtu = 0;
rte_eth_dev_info_get(port_id, &info);
conf.addr = info.pci_dev->addr;
conf.id = info.pci_dev->id;
- rte_snprintf(conf.name, sizeof(conf.name), TEST_KNI_PORT);
+ snprintf(conf.name, sizeof(conf.name), TEST_KNI_PORT);
/* core id 1 configured for kernel thread */
conf.core_id = 1;
return ret;
}
-int
+static int
test_kni(void)
{
int ret = -1;
struct rte_eth_dev_info info;
struct rte_kni_ops ops;
+ /* Initialize KNI subsytem */
+ rte_kni_init(KNI_TEST_MAX_PORTS);
+
if (test_kni_allocate_lcores() < 0) {
printf("No enough lcores for kni processing\n");
return -1;
printf("fail to create mempool for kni\n");
return -1;
}
- ret = rte_eal_pci_probe();
- if (ret < 0) {
- printf("fail to probe PCI devices\n");
- return -1;
- }
nb_ports = rte_eth_dev_count();
if (nb_ports == 0) {
/* test of getting KNI device with an invalid string name */
memset(&conf, 0, sizeof(conf));
- rte_snprintf(conf.name, sizeof(conf.name), "testing");
+ snprintf(conf.name, sizeof(conf.name), "testing");
kni = rte_kni_get(conf.name);
if (kni) {
ret = -1;
return ret;
}
-#else /* RTE_LIBRTE_KNI */
-
-int
-test_kni(void)
-{
- printf("The KNI library is not included in this build\n");
- return 0;
-}
-
-#endif /* RTE_LIBRTE_KNI */
+static struct test_command kni_cmd = {
+ .command = "kni_autotest",
+ .callback = test_kni,
+};
+REGISTER_TEST_COMMAND(kni_cmd);