[dpdk-dev] [PATCH 5/7] test/eventdev: unit and functional tests
Jerin Jacob
jerin.jacob at caviumnetworks.com
Wed Nov 23 04:32:46 CET 2016
On Wed, Nov 16, 2016 at 06:00:05PM +0000, Harry van Haaren wrote:
> This commit adds basic unit and functional tests for the eventdev
> API. The test code is added in this commit, but not yet enabled until
> the next commit.
>
> Signed-off-by: Gage Eads <gage.eads at intel.com>
> Signed-off-by: David Hunt <david.hunt at intel.com>
> Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
> ---
A few comments on portability and usage perspective. See below,
> +#include <rte_eal.h>
> +#include <rte_per_lcore.h>
> +#include <rte_lcore.h>
> +#include <rte_debug.h>
> +#include <rte_ethdev.h>
> +#include <rte_cycles.h>
> +
> +#include <rte_eventdev.h>
> +#include "test.h"
> +
> +
> +static inline int
> +create_ports(struct test *t, int num_ports)
> +{
> + int i;
> + static const struct rte_event_port_conf conf = {
> + .dequeue_queue_depth = 32,
> + .enqueue_queue_depth = 64,
> + };
Check the max supported through info get first.
> +
> + for (i = 0; i < num_ports; i++) {
> + if (rte_event_port_setup(t->ev, i, &conf) < 0) {
> + printf("Error setting up port %d\n", i);
> + return -1;
> + }
> + t->port[i] = i;
> + }
> +
> + return 0;
> +}
> +
> +
> +static int
> +run_prio_packet_test(struct test *t)
Run per event enqueue priority test if the platform supports
RTE_EVENT_DEV_CAP_EVENT_QOS
> +{
> + int err;
> + const uint32_t MAGIC_SEQN[] = {4711, 1234};
> + const uint32_t PRIORITY[] = {3, 0};
> + unsigned i;
> + for(i = 0; i < RTE_DIM(MAGIC_SEQN); i++) {
> + /* generate pkt and enqueue */
> + struct rte_event ev;
> + struct rte_mbuf *arp = rte_gen_arp(0, t->mbuf_pool);
> + if (!arp) {
> + printf("%d: gen of pkt failed\n", __LINE__);
> + return -1;
> + }
> + arp->seqn = MAGIC_SEQN[i];
For me, it make sense to don't touch any field in mbuf to make eventdev
model works. use private field to store test specific data
> +
> + ev = (struct rte_event){
> + .priority = PRIORITY[i],
> + .operation = RTE_EVENT_OP_NEW,
> + .queue_id = t->qid[0],
> + .mbuf = arp
> + };
> + err = rte_event_enqueue(t->ev, t->port[0], &ev, 0);
> + if (err < 0) {
> + printf("%d: error failed to enqueue\n", __LINE__);
> + return -1;
> + }
> + }
> +
> + rte_event_schedule(t->ev);
> +
> + struct rte_event_dev_stats stats;
> + err = rte_event_dev_stats_get(t->ev, &stats);
> + if (err) {
> + printf("%d: error failed to get stats\n", __LINE__);
> + return -1;
> + }
> +
> + if (stats.port_rx_pkts[t->port[0]] != 2) {
> + printf("%d: error stats incorrect for directed port\n", __LINE__);
> + rte_event_dev_dump(stdout, t->ev);
> + return -1;
> + }
rely on stats for functional verification may not work in all the
implementation. makes sense to have more concrete functional
verification without stats
> +
> + struct rte_event ev, ev2;
> + uint32_t deq_pkts;
> + deq_pkts = rte_event_dequeue(t->ev, t->port[0], &ev, 0);
> + if (deq_pkts != 1) {
> + printf("%d: error failed to deq\n", __LINE__);
> + rte_event_dev_dump(stdout, t->ev);
> + return -1;
> + }
> + if(ev.mbuf->seqn != MAGIC_SEQN[1]) {
> + printf("%d: first packet out not highest priority\n", __LINE__);
> + rte_event_dev_dump(stdout, t->ev);
> + return -1;
> + }
> + rte_pktmbuf_free(ev.mbuf);
> +
> +
> +static int
> +test_overload_trip(struct test *t)
overload tests wont fail in ddr backed systems.(ddr backed system will
mimic infinite size queue to application). So testing against failure
may not work at all in some implementation
> +{
> + int err;
> +
> + /* Create instance with 3 directed QIDs going to 3 ports */
> + if (init(t, 1, 1) < 0 ||
> + create_ports(t, 1) < 0 ||
> + create_atomic_qids(t, 1) < 0)
> + return -1;
> +
More information about the dev
mailing list