X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fevent%2Fsw%2Fsw_evdev_selftest.c;h=d53e903129cb9ada6c22e6f8bd1b8fd14c0f3165;hb=dac12650eb1a5f9cb89f0da8355c6ce002f1e88d;hp=d00d5de613d7d2a5cd702964a2bfce117a9d1628;hpb=1638261a69b906eb56b871549bf4a64676d82d9f;p=dpdk.git diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c index d00d5de613..d53e903129 100644 --- a/drivers/event/sw/sw_evdev_selftest.c +++ b/drivers/event/sw/sw_evdev_selftest.c @@ -40,6 +40,16 @@ struct test { uint32_t service_id; }; +typedef uint8_t counter_dynfield_t; +static int counter_dynfield_offset = -1; + +static inline counter_dynfield_t * +counter_field(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, \ + counter_dynfield_offset, counter_dynfield_t *); +} + static struct rte_event release_ev; static inline struct rte_mbuf * @@ -172,7 +182,6 @@ create_ports(struct test *t, int num_ports) .new_event_threshold = 1024, .dequeue_depth = 32, .enqueue_depth = 64, - .disable_implicit_release = 0, }; if (num_ports > MAX_PORTS) return -1; @@ -376,7 +385,7 @@ run_prio_packet_test(struct test *t) printf("%d: gen of pkt failed\n", __LINE__); return -1; } - arp->seqn = MAGIC_SEQN[i]; + *rte_event_pmd_selftest_seqn(arp) = MAGIC_SEQN[i]; ev = (struct rte_event){ .priority = PRIORITY[i], @@ -385,7 +394,7 @@ run_prio_packet_test(struct test *t) .mbuf = arp }; err = rte_event_enqueue_burst(evdev, t->port[0], &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: error failed to enqueue\n", __LINE__); return -1; } @@ -415,7 +424,7 @@ run_prio_packet_test(struct test *t) rte_event_dev_dump(evdev, stdout); return -1; } - if (ev.mbuf->seqn != MAGIC_SEQN[1]) { + if (*rte_event_pmd_selftest_seqn(ev.mbuf) != MAGIC_SEQN[1]) { printf("%d: first packet out not highest priority\n", __LINE__); rte_event_dev_dump(evdev, stdout); @@ -429,7 +438,7 @@ run_prio_packet_test(struct test *t) rte_event_dev_dump(evdev, stdout); return -1; } - if (ev2.mbuf->seqn != MAGIC_SEQN[0]) { + if (*rte_event_pmd_selftest_seqn(ev2.mbuf) != MAGIC_SEQN[0]) { printf("%d: second packet out not lower priority\n", __LINE__); rte_event_dev_dump(evdev, stdout); @@ -473,11 +482,11 @@ test_single_directed_packet(struct test *t) } const uint32_t MAGIC_SEQN = 4711; - arp->seqn = MAGIC_SEQN; + *rte_event_pmd_selftest_seqn(arp) = MAGIC_SEQN; /* generate pkt and enqueue */ err = rte_event_enqueue_burst(evdev, rx_enq, &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: error failed to enqueue\n", __LINE__); return -1; } @@ -512,7 +521,7 @@ test_single_directed_packet(struct test *t) return -1; } - if (ev.mbuf->seqn != MAGIC_SEQN) { + if (*rte_event_pmd_selftest_seqn(ev.mbuf) != MAGIC_SEQN) { printf("%d: error magic sequence number not dequeued\n", __LINE__); return -1; @@ -546,7 +555,7 @@ test_directed_forward_credits(struct test *t) for (i = 0; i < 1000; i++) { err = rte_event_enqueue_burst(evdev, 0, &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: error failed to enqueue\n", __LINE__); return -1; } @@ -707,7 +716,7 @@ burst_packets(struct test *t) }; /* generate pkt and enqueue */ err = rte_event_enqueue_burst(evdev, t->port[rx_port], &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -795,7 +804,7 @@ abuse_inflights(struct test *t) /* Enqueue op only */ err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &release_ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -864,15 +873,15 @@ xstats_tests(struct test *t) int ret = rte_event_dev_xstats_names_get(evdev, RTE_EVENT_DEV_XSTATS_DEVICE, 0, xstats_names, ids, XSTATS_MAX); - if (ret != 6) { - printf("%d: expected 6 stats, got return %d\n", __LINE__, ret); + if (ret != 8) { + printf("%d: expected 8 stats, got return %d\n", __LINE__, ret); return -1; } ret = rte_event_dev_xstats_get(evdev, RTE_EVENT_DEV_XSTATS_DEVICE, 0, ids, values, ret); - if (ret != 6) { - printf("%d: expected 6 stats, got return %d\n", __LINE__, ret); + if (ret != 8) { + printf("%d: expected 8 stats, got return %d\n", __LINE__, ret); return -1; } @@ -930,7 +939,7 @@ xstats_tests(struct test *t) ev.op = RTE_EVENT_OP_NEW; ev.mbuf = arp; ev.flow_id = 7; - arp->seqn = i; + *rte_event_pmd_selftest_seqn(arp) = i; int err = rte_event_enqueue_burst(evdev, t->port[0], &ev, 1); if (err != 1) { @@ -950,7 +959,7 @@ xstats_tests(struct test *t) ret = rte_event_dev_xstats_get(evdev, RTE_EVENT_DEV_XSTATS_DEVICE, 0, ids, values, num_stats); - static const uint64_t expected[] = {3, 3, 0, 1, 0, 0}; + static const uint64_t expected[] = {3, 3, 0, 1, 0, 0, 4, 1}; for (i = 0; (signed int)i < ret; i++) { if (expected[i] != values[i]) { printf( @@ -966,7 +975,7 @@ xstats_tests(struct test *t) 0, NULL, 0); /* ensure reset statistics are zero-ed */ - static const uint64_t expected_zero[] = {0, 0, 0, 0, 0, 0}; + static const uint64_t expected_zero[] = {0, 0, 0, 0, 0, 0, 0, 0}; ret = rte_event_dev_xstats_get(evdev, RTE_EVENT_DEV_XSTATS_DEVICE, 0, ids, values, num_stats); @@ -1227,7 +1236,6 @@ port_reconfig_credits(struct test *t) .new_event_threshold = 128, .dequeue_depth = 32, .enqueue_depth = 64, - .disable_implicit_release = 0, }; if (rte_event_port_setup(evdev, 0, &port_conf) < 0) { printf("%d Error setting up port\n", __LINE__); @@ -1317,7 +1325,6 @@ port_single_lb_reconfig(struct test *t) .new_event_threshold = 128, .dequeue_depth = 32, .enqueue_depth = 64, - .disable_implicit_release = 0, }; if (rte_event_port_setup(evdev, 0, &port_conf) < 0) { printf("%d Error setting up port\n", __LINE__); @@ -1453,7 +1460,7 @@ xstats_id_reset_tests(struct test *t) for (i = 0; i < XSTATS_MAX; i++) ids[i] = i; -#define NUM_DEV_STATS 6 +#define NUM_DEV_STATS 8 /* Device names / values */ int num_stats = rte_event_dev_xstats_names_get(evdev, RTE_EVENT_DEV_XSTATS_DEVICE, @@ -1483,7 +1490,7 @@ xstats_id_reset_tests(struct test *t) ev.queue_id = t->qid[i]; ev.op = RTE_EVENT_OP_NEW; ev.mbuf = arp; - arp->seqn = i; + *rte_event_pmd_selftest_seqn(arp) = i; int err = rte_event_enqueue_burst(evdev, t->port[0], &ev, 1); if (err != 1) { @@ -1497,8 +1504,10 @@ xstats_id_reset_tests(struct test *t) static const char * const dev_names[] = { "dev_rx", "dev_tx", "dev_drop", "dev_sched_calls", "dev_sched_no_iq_enq", "dev_sched_no_cq_enq", + "dev_sched_last_iter_bitmask", + "dev_sched_progress_last_iter" }; - uint64_t dev_expected[] = {NPKTS, NPKTS, 0, 1, 0, 0}; + uint64_t dev_expected[] = {NPKTS, NPKTS, 0, 1, 0, 0, 4, 1}; for (i = 0; (int)i < ret; i++) { unsigned int id; uint64_t val = rte_event_dev_xstats_by_name_get(evdev, @@ -1511,8 +1520,8 @@ xstats_id_reset_tests(struct test *t) } if (val != dev_expected[i]) { printf("%d: %s value incorrect, expected %" - PRIu64" got %d\n", __LINE__, dev_names[i], - dev_expected[i], id); + PRIu64" got %"PRIu64"\n", __LINE__, + dev_names[i], dev_expected[i], val); goto fail; } /* reset to zero */ @@ -1535,11 +1544,11 @@ xstats_id_reset_tests(struct test *t) } }; -/* 48 is stat offset from start of the devices whole xstats. +/* 49 is stat offset from start of the devices whole xstats. * This WILL break every time we add a statistic to a port * or the device, but there is no other way to test */ -#define PORT_OFF 48 +#define PORT_OFF 50 /* num stats for the tested port. CQ size adds more stats to a port */ #define NUM_PORT_STATS 21 /* the port to test. */ @@ -1663,7 +1672,7 @@ xstats_id_reset_tests(struct test *t) /* queue offset from start of the devices whole xstats. * This will break every time we add a statistic to a device/port/queue */ -#define QUEUE_OFF 90 +#define QUEUE_OFF 92 const uint32_t queue = 0; num_stats = rte_event_dev_xstats_names_get(evdev, RTE_EVENT_DEV_XSTATS_QUEUE, queue, @@ -1871,7 +1880,7 @@ qid_priorities(struct test *t) ev.queue_id = t->qid[i]; ev.op = RTE_EVENT_OP_NEW; ev.mbuf = arp; - arp->seqn = i; + *rte_event_pmd_selftest_seqn(arp) = i; int err = rte_event_enqueue_burst(evdev, t->port[0], &ev, 1); if (err != 1) { @@ -1892,7 +1901,7 @@ qid_priorities(struct test *t) return -1; } for (i = 0; i < 3; i++) { - if (ev[i].mbuf->seqn != 2-i) { + if (*rte_event_pmd_selftest_seqn(ev[i].mbuf) != 2-i) { printf( "%d: qid priority test: seqn %d incorrectly prioritized\n", __LINE__, i); @@ -2026,7 +2035,7 @@ load_balancing(struct test *t) }; /* generate pkt and enqueue */ err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -2125,7 +2134,7 @@ load_balancing_history(struct test *t) } arp->hash.rss = flows1[i]; err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -2175,7 +2184,7 @@ load_balancing_history(struct test *t) arp->hash.rss = flows2[i]; err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -2285,7 +2294,7 @@ invalid_qid(struct test *t) }; /* generate pkt and enqueue */ err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -2369,10 +2378,10 @@ single_packet(struct test *t) ev.mbuf = arp; ev.queue_id = 0; ev.flow_id = 3; - arp->seqn = MAGIC_SEQN; + *rte_event_pmd_selftest_seqn(arp) = MAGIC_SEQN; err = rte_event_enqueue_burst(evdev, t->port[rx_enq], &ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -2409,14 +2418,14 @@ single_packet(struct test *t) } err = test_event_dev_stats_get(evdev, &stats); - if (ev.mbuf->seqn != MAGIC_SEQN) { + if (*rte_event_pmd_selftest_seqn(ev.mbuf) != MAGIC_SEQN) { printf("%d: magic sequence number not dequeued\n", __LINE__); return -1; } rte_pktmbuf_free(ev.mbuf); err = rte_event_enqueue_burst(evdev, t->port[wrk_enq], &release_ev, 1); - if (err < 0) { + if (err != 1) { printf("%d: Failed to enqueue\n", __LINE__); return -1; } @@ -2682,7 +2691,7 @@ parallel_basic(struct test *t, int check_order) ev.queue_id = t->qid[0]; ev.op = RTE_EVENT_OP_NEW; ev.mbuf = mbufs[i]; - mbufs[i]->seqn = MAGIC_SEQN + i; + *rte_event_pmd_selftest_seqn(mbufs[i]) = MAGIC_SEQN + i; /* generate pkt and enqueue */ err = rte_event_enqueue_burst(evdev, t->port[rx_port], &ev, 1); @@ -2737,10 +2746,12 @@ parallel_basic(struct test *t, int check_order) /* Check to see if the sequence numbers are in expected order */ if (check_order) { for (j = 0 ; j < deq_pkts ; j++) { - if (deq_ev[j].mbuf->seqn != MAGIC_SEQN + j) { - printf( - "%d: Incorrect sequence number(%d) from port %d\n", - __LINE__, mbufs_out[j]->seqn, tx_port); + if (*rte_event_pmd_selftest_seqn(deq_ev[j].mbuf) != + MAGIC_SEQN + j) { + printf("%d: Incorrect sequence number(%d) from port %d\n", + __LINE__, + *rte_event_pmd_selftest_seqn(mbufs_out[j]), + tx_port); return -1; } } @@ -2990,8 +3001,8 @@ worker_loopback_worker_fn(void *arg) } ev[i].queue_id = 0; - ev[i].mbuf->udata64++; - if (ev[i].mbuf->udata64 != 16) { + (*counter_field(ev[i].mbuf))++; + if (*counter_field(ev[i].mbuf) != 16) { ev[i].op = RTE_EVENT_OP_FORWARD; enqd = rte_event_enqueue_burst(evdev, port, &ev[i], 1); @@ -3031,7 +3042,7 @@ worker_loopback_producer_fn(void *arg) m = rte_pktmbuf_alloc(t->mbuf_pool); } while (m == NULL); - m->udata64 = 0; + *counter_field(m) = 0; struct rte_event ev = { .op = RTE_EVENT_OP_NEW, @@ -3064,6 +3075,18 @@ worker_loopback(struct test *t, uint8_t disable_implicit_release) int err; int w_lcore, p_lcore; + static const struct rte_mbuf_dynfield counter_dynfield_desc = { + .name = "rte_event_sw_dynfield_selftest_counter", + .size = sizeof(counter_dynfield_t), + .align = __alignof__(counter_dynfield_t), + }; + counter_dynfield_offset = + rte_mbuf_dynfield_register(&counter_dynfield_desc); + if (counter_dynfield_offset < 0) { + printf("Error registering mbuf field\n"); + return -rte_errno; + } + if (init(t, 8, 2) < 0 || create_atomic_qids(t, 8) < 0) { printf("%d: Error initializing device\n", __LINE__); @@ -3079,7 +3102,8 @@ worker_loopback(struct test *t, uint8_t disable_implicit_release) * only be initialized once - and this needs to be set for multiple runs */ conf.new_event_threshold = 512; - conf.disable_implicit_release = disable_implicit_release; + conf.event_port_cfg = disable_implicit_release ? + RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL : 0; if (rte_event_port_setup(evdev, 0, &conf) < 0) { printf("Error setting up RX port\n"); @@ -3108,7 +3132,7 @@ worker_loopback(struct test *t, uint8_t disable_implicit_release) p_lcore = rte_get_next_lcore( /* start core */ -1, - /* skip master */ 1, + /* skip main */ 1, /* wrap */ 0); w_lcore = rte_get_next_lcore(p_lcore, 1, 0);