/*-
* BSD LICENSE
- *
+ *
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#include "test.h"
-#ifdef RTE_LIBRTE_KNI
#include <rte_string_fns.h>
#include <rte_mempool.h>
#include <rte_ethdev.h>
#define NB_MBUF 8192
#define MAX_PACKET_SZ 2048
-#define MBUF_SZ \
- (MAX_PACKET_SZ + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
+#define MBUF_DATA_SZ (MAX_PACKET_SZ + RTE_PKTMBUF_HEADROOM)
#define PKT_BURST_SZ 32
#define MEMPOOL_CACHE_SZ PKT_BURST_SZ
#define SOCKET 0
#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;
mp = rte_mempool_lookup("kni_mempool");
if (!mp)
- mp = rte_mempool_create("kni_mempool",
+ mp = rte_pktmbuf_pool_create("kni_mempool",
NB_MBUF,
- MBUF_SZ,
- MEMPOOL_CACHE_SZ,
- sizeof(struct rte_pktmbuf_pool_private),
- rte_pktmbuf_pool_init,
- NULL,
- rte_pktmbuf_init,
- NULL,
- SOCKET,
- 0);
+ MEMPOOL_CACHE_SZ, 0, MBUF_DATA_SZ,
+ SOCKET);
return mp;
}
kni_change_mtu(uint8_t port_id, unsigned new_mtu)
{
printf("Change MTU of port %d to %u\n", port_id, new_mtu);
- kni_pkt_mtu = new_mtu;
+ kni_pkt_mtu = new_mtu;
printf("Change MTU of port %d to %i successfully.\n",
port_id, kni_pkt_mtu);
return 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 -1;
}
test_kni_ctx = NULL;
-
+
/* test of releasing a released kni device */
if (rte_kni_release(kni) == 0) {
printf("should not release a released kni device\n");
printf("fail to release kni\n");
return -1;
}
-
+
return ret;
fail_kni:
if (rte_kni_release(kni) < 0) {
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);