Message ID | 1450258133-3375-3-git-send-email-bala.manoharan@linaro.org |
---|---|
State | New |
Headers | show |
Hi, Bala Just pay attention, see below. On 16.12.15 11:28, Balasubramanian Manoharan wrote: > Replaces odp_cos_create() function with odp_cls_cos_create() function > > Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> > --- > test/validation/classification/classification.h | 1 + > .../classification/odp_classification_basic.c | 137 +++++++- > .../classification/odp_classification_common.c | 15 +- > .../classification/odp_classification_test_pmr.c | 386 +++++++++++++-------- > .../classification/odp_classification_tests.c | 207 ++++------- > .../classification/odp_classification_testsuites.h | 3 +- > 6 files changed, 453 insertions(+), 296 deletions(-) > > diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h > index 6a7e8a5..e3fc081 100644 > --- a/test/validation/classification/classification.h > +++ b/test/validation/classification/classification.h > @@ -59,6 +59,7 @@ void classification_test_destroy_cos(void); > void classification_test_create_pmr_match(void); > void classification_test_destroy_pmr(void); > void classification_test_cos_set_queue(void); > +void classification_test_cos_set_pool(void); > void classification_test_cos_set_drop(void); > void classification_test_pmr_match_set_create(void); > void classification_test_pmr_match_set_destroy(void); > diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c > index 20c157f..f0b7a42 100644 > --- a/test/validation/classification/odp_classification_basic.c > +++ b/test/validation/classification/odp_classification_basic.c > @@ -13,26 +13,60 @@ > void classification_test_create_cos(void) > { > odp_cos_t cos; > - char name[ODP_COS_NAME_LEN]; > - sprintf(name, "ClassOfService"); > - cos = odp_cos_create(name); > - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > + odp_cls_cos_param_t cls_param; > + odp_pool_t pool; > + odp_queue_t queue; > + char cosname[ODP_COS_NAME_LEN]; > + > + pool = pool_create("cls_basic_pool"); > + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > + > + queue = queue_create("cls_basic_queue", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > + sprintf(cosname, "ClassOfService"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + > + cos = odp_cls_cos_create(cosname, &cls_param); > CU_ASSERT(odp_cos_to_u64(cos) != odp_cos_to_u64(ODP_COS_INVALID)); > odp_cos_destroy(cos); > + odp_pool_destroy(pool); > + odp_queue_destroy(queue); > } > > void classification_test_destroy_cos(void) > { > odp_cos_t cos; > char name[ODP_COS_NAME_LEN]; > + odp_pool_t pool; > + odp_queue_t queue; > + odp_cls_cos_param_t cls_param; > int retval; > + > + pool = pool_create("cls_basic_pool"); > + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > + > + queue = queue_create("cls_basic_queue", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > sprintf(name, "ClassOfService"); > - cos = odp_cos_create(name); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + > + cos = odp_cls_cos_create(name, &cls_param); > CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > retval = odp_cos_destroy(cos); > CU_ASSERT(retval == 0); > retval = odp_cos_destroy(ODP_COS_INVALID); > CU_ASSERT(retval < 0); > + > + odp_pool_destroy(pool); > + odp_queue_destroy(queue); > } > > void classification_test_create_pmr_match(void) > @@ -82,35 +116,101 @@ void classification_test_cos_set_queue(void) > { > int retval; > char cosname[ODP_COS_NAME_LEN]; > - char queuename[ODP_QUEUE_NAME_LEN]; > - odp_queue_param_t qparam; > + odp_cls_cos_param_t cls_param; > + odp_pool_t pool; > + odp_queue_t queue; > odp_queue_t queue_cos; > odp_cos_t cos_queue; > + odp_queue_t recvqueue; > + > + pool = pool_create("cls_basic_pool"); > + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > + > + queue = queue_create("cls_basic_queue", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > sprintf(cosname, "CoSQueue"); > - cos_queue = odp_cos_create(cosname); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_queue = odp_cls_cos_create(cosname, &cls_param); > CU_ASSERT_FATAL(cos_queue != ODP_COS_INVALID); > > - odp_queue_param_init(&qparam); > - qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; > - qparam.sched.sync = ODP_SCHED_SYNC_NONE; > - qparam.sched.group = ODP_SCHED_GROUP_ALL; > - sprintf(queuename, "%s", "QueueCoS"); > + queue_cos = queue_create("QueueCoS", true); > + CU_ASSERT_FATAL(queue_cos != ODP_QUEUE_INVALID); > > - queue_cos = odp_queue_create(queuename, > - ODP_QUEUE_TYPE_SCHED, &qparam); > retval = odp_cos_queue_set(cos_queue, queue_cos); > CU_ASSERT(retval == 0); > + recvqueue = odp_cos_queue(cos_queue); > + CU_ASSERT(recvqueue == queue_cos); > + > odp_cos_destroy(cos_queue); > odp_queue_destroy(queue_cos); > + odp_queue_destroy(queue); > + odp_pool_destroy(pool); > +} > + > +void classification_test_cos_set_pool(void) > +{ > + int retval; > + char cosname[ODP_COS_NAME_LEN]; > + odp_cls_cos_param_t cls_param; > + odp_pool_t pool; > + odp_queue_t queue; > + odp_pool_t cos_pool; > + odp_cos_t cos; > + odp_pool_t recvpool; > + > + pool = pool_create("cls_basic_pool"); > + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > + > + queue = queue_create("cls_basic_queue", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > + sprintf(cosname, "CoSQueue"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > + > + cos_pool = pool_create("PoolCoS"); > + CU_ASSERT_FATAL(cos_pool != ODP_POOL_INVALID); > + > + retval = odp_cls_cos_pool_set(cos, cos_pool); > + CU_ASSERT(retval == 0); > + recvpool = odp_cls_cos_pool(cos); > + CU_ASSERT(recvpool == cos_pool); > + > + odp_cos_destroy(cos); > + odp_queue_destroy(queue); > + odp_pool_destroy(pool); > + odp_pool_destroy(cos_pool); > } > > void classification_test_cos_set_drop(void) > { > int retval; > char cosname[ODP_COS_NAME_LEN]; > - sprintf(cosname, "CoSDrop"); > odp_cos_t cos_drop; > - cos_drop = odp_cos_create(cosname); > + odp_queue_t queue; > + odp_pool_t pool; > + odp_cls_cos_param_t cls_param; > + > + pool = pool_create("cls_basic_pool"); > + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > + > + queue = queue_create("cls_basic_queue", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > + sprintf(cosname, "CoSDrop"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_drop = odp_cls_cos_create(cosname, &cls_param); > CU_ASSERT_FATAL(cos_drop != ODP_COS_INVALID); > > retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_POOL); > @@ -118,6 +218,8 @@ void classification_test_cos_set_drop(void) > retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_NEVER); > CU_ASSERT(retval == 0); > odp_cos_destroy(cos_drop); > + odp_pool_destroy(pool); > + odp_queue_destroy(queue); > } > > void classification_test_pmr_match_set_create(void) > @@ -177,6 +279,7 @@ odp_testinfo_t classification_suite_basic[] = { > ODP_TEST_INFO(classification_test_destroy_pmr), > ODP_TEST_INFO(classification_test_cos_set_queue), > ODP_TEST_INFO(classification_test_cos_set_drop), > + ODP_TEST_INFO(classification_test_cos_set_pool), > ODP_TEST_INFO(classification_test_pmr_match_set_create), > ODP_TEST_INFO(classification_test_pmr_match_set_destroy), > ODP_TEST_INFO_NULL, > diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c > index a56c017..afcea45 100644 > --- a/test/validation/classification/odp_classification_common.c > +++ b/test/validation/classification/odp_classification_common.c > @@ -154,7 +154,7 @@ odp_packet_t receive_packet(odp_queue_t *queue, uint64_t ns) > return odp_packet_from_event(ev); > } > > -odp_queue_t queue_create(char *queuename, bool sched) > +odp_queue_t queue_create(const char *queuename, bool sched) > { > odp_queue_t queue; > odp_queue_param_t qparam; > @@ -177,6 +177,19 @@ odp_queue_t queue_create(char *queuename, bool sched) > return queue; > } > > +odp_pool_t pool_create(const char *poolname) > +{ > + odp_pool_param_t param; > + > + odp_pool_param_init(¶m); > + param.pkt.seg_len = SHM_PKT_BUF_SIZE; > + param.pkt.len = SHM_PKT_BUF_SIZE; > + param.pkt.num = SHM_PKT_NUM_BUFS; > + param.type = ODP_POOL_PACKET; > + > + return odp_pool_create(poolname, ¶m); > +} > + > odp_packet_t create_packet(odp_pool_t pool, bool vlan, > odp_atomic_u32_t *seq, bool flag_udp) > { > diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c > index 120ddd2..2fb611b 100644 > --- a/test/validation/classification/odp_classification_test_pmr.c > +++ b/test/validation/classification/odp_classification_test_pmr.c > @@ -19,15 +19,7 @@ odp_atomic_u32_t seq; > > int classification_suite_pmr_init(void) > { > - odp_pool_param_t param; > - > - odp_pool_param_init(¶m); > - param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - param.pkt.len = SHM_PKT_BUF_SIZE; > - param.pkt.num = SHM_PKT_NUM_BUFS; > - param.type = ODP_POOL_PACKET; > - > - pkt_pool = odp_pool_create("classification_pmr_pool", ¶m); > + pkt_pool = pool_create("classification_pmr_pool"); > if (ODP_POOL_INVALID == pkt_pool) { > fprintf(stderr, "Packet pool creation failed.\n"); > return -1; > @@ -99,38 +91,27 @@ int create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype) > void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos, > odp_queue_t *queue, odp_pool_t *pool) > { > - odp_pool_param_t pool_param; > + odp_cls_cos_param_t cls_param; > odp_pool_t default_pool; > odp_cos_t default_cos; > odp_queue_t default_queue; > int retval; > char cosname[ODP_COS_NAME_LEN]; > - char poolname[ODP_POOL_NAME_LEN]; > - char queuename[ODP_QUEUE_NAME_LEN]; > > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > - sprintf(poolname, "%s", "DefaultPool"); > - > - default_pool = odp_pool_create(poolname, &pool_param); > + default_pool = pool_create("DefaultPool"); > CU_ASSERT(default_pool != ODP_POOL_INVALID); > > - sprintf(queuename, "DefaultQueue"); > - default_queue = queue_create(queuename, true); > + default_queue = queue_create("DefaultQueue", true); > CU_ASSERT(default_queue != ODP_QUEUE_INVALID); > > sprintf(cosname, "DefaultCos"); > - default_cos = odp_cos_create(cosname); > - CU_ASSERT(default_cos != ODP_COS_INVALID); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = default_pool; > + cls_param.queue = default_queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > > - retval = odp_cos_queue_set(default_cos, default_queue); > - CU_ASSERT(retval == 0); > - > - retval = odp_cls_cos_pool_set(default_cos, default_pool); > - CU_ASSERT(retval == 0); > + default_cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT(default_cos != ODP_COS_INVALID); > > retval = odp_pktio_default_cos_set(pktio, default_cos); > CU_ASSERT(retval == 0); > @@ -171,9 +152,7 @@ static void classification_test_pmr_term_tcp_dport(void) > odp_pmr_t pmr; > odp_cos_t cos; > char cosname[ODP_COS_NAME_LEN]; > - char queuename[ODP_QUEUE_NAME_LEN]; > - char poolname[ODP_POOL_NAME_LEN]; > - odp_pool_param_t pool_param; > + odp_cls_cos_param_t cls_param; > odp_pool_t pool; > odp_pool_t pool_recv; > odp_pmr_match_t match; > @@ -195,30 +174,21 @@ static void classification_test_pmr_term_tcp_dport(void) > pmr = odp_pmr_create(&match); > CU_ASSERT(pmr != ODP_PMR_INVAL); > > - sprintf(cosname, "tcp_dport"); > - cos = odp_cos_create(cosname); > - CU_ASSERT(cos != ODP_COS_INVALID); > - > - sprintf(queuename, "%s", "tcp_dport1"); > > - queue = queue_create(queuename, true); > + queue = queue_create("tcp_dport1", true); > CU_ASSERT(queue != ODP_QUEUE_INVALID); > > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > - sprintf(poolname, "%s", "tcp_dport1"); > - > - pool = odp_pool_create(poolname, &pool_param); > + pool = pool_create("tcp_dport1"); > CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos, pool); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "tcp_dport"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > > - retval = odp_cos_queue_set(cos, queue); > - CU_ASSERT(retval == 0); > + cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT(cos != ODP_COS_INVALID); > > retval = odp_pktio_pmr_cos(pmr, pktio, cos); > CU_ASSERT(retval == 0); > @@ -286,14 +256,12 @@ static void classification_test_pmr_term_tcp_sport(void) > odp_queue_t default_queue; > odp_cos_t default_cos; > odp_pool_t default_pool; > - odp_pool_param_t pool_param; > odp_pool_t pool; > odp_pool_t recvpool; > odp_pmr_t pmr; > odp_cos_t cos; > char cosname[ODP_COS_NAME_LEN]; > - char poolname[ODP_POOL_NAME_LEN]; > - char queuename[ODP_QUEUE_NAME_LEN]; > + odp_cls_cos_param_t cls_param; > odp_pmr_match_t match; > > val = CLS_DEFAULT_SPORT; > @@ -312,30 +280,20 @@ static void classification_test_pmr_term_tcp_sport(void) > pmr = odp_pmr_create(&match); > CU_ASSERT(pmr != ODP_PMR_INVAL); > > - sprintf(cosname, "tcp_sport"); > - cos = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > - > - sprintf(queuename, "%s", "tcp_sport"); > - > - queue = queue_create(queuename, true); > + queue = queue_create("tcp_sport", true); > CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > - sprintf(poolname, "%s", "tcp_sport"); > - > - pool = odp_pool_create(poolname, &pool_param); > + pool = pool_create("tcp_sport"); > CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos, pool); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "tcp_sport"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > > - retval = odp_cos_queue_set(cos, queue); > - CU_ASSERT(retval == 0); > + cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > > retval = odp_pktio_pmr_cos(pmr, pktio, cos); > CU_ASSERT(retval == 0); > @@ -403,13 +361,11 @@ static void classification_test_pmr_term_udp_dport(void) > odp_queue_t default_queue; > odp_cos_t default_cos; > odp_pool_t default_pool; > - odp_pool_param_t pool_param; > odp_pmr_t pmr; > odp_cos_t cos; > char cosname[ODP_COS_NAME_LEN]; > - char poolname[ODP_POOL_NAME_LEN]; > - char queuename[ODP_QUEUE_NAME_LEN]; > odp_pmr_match_t match; > + odp_cls_cos_param_t cls_param; > > val = CLS_DEFAULT_DPORT; > mask = 0xffff; > @@ -427,30 +383,20 @@ static void classification_test_pmr_term_udp_dport(void) > pmr = odp_pmr_create(&match); > CU_ASSERT(pmr != ODP_PMR_INVAL); > > - sprintf(cosname, "udp_dport"); > - cos = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > - > - sprintf(queuename, "%s", "udp_dport"); > - > - queue = queue_create(queuename, true); > + queue = queue_create("udp_dport", true); > CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > > - retval = odp_cos_queue_set(cos, queue); > - CU_ASSERT(retval == 0); > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > - sprintf(poolname, "%s", "udp_dport"); > - > - pool = odp_pool_create(poolname, &pool_param); > + pool = pool_create("udp_dport"); > CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos, pool); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "udp_dport"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + > + cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > > retval = odp_pktio_pmr_cos(pmr, pktio, cos); > CU_ASSERT(retval == 0); > @@ -517,15 +463,13 @@ static void classification_test_pmr_term_udp_sport(void) > odp_queue_t default_queue; > odp_cos_t default_cos; > odp_pool_t default_pool; > - odp_pool_param_t pool_param; > odp_pool_t pool; > odp_pool_t recvpool; > odp_pmr_t pmr; > odp_cos_t cos; > char cosname[ODP_COS_NAME_LEN]; > - char poolname[ODP_POOL_NAME_LEN]; > - char queuename[ODP_QUEUE_NAME_LEN]; > odp_pmr_match_t match; > + odp_cls_cos_param_t cls_param; > > val = CLS_DEFAULT_SPORT; > mask = 0xffff; > @@ -543,30 +487,20 @@ static void classification_test_pmr_term_udp_sport(void) > pmr = odp_pmr_create(&match); > CU_ASSERT(pmr != ODP_PMR_INVAL); > > - sprintf(cosname, "udp_sport"); > - cos = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > - > - sprintf(queuename, "%s", "udp_sport"); > - > - queue = queue_create(queuename, true); > + queue = queue_create("udp_sport", true); > CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > > - retval = odp_cos_queue_set(cos, queue); > - CU_ASSERT(retval == 0); > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > - sprintf(poolname, "%s", "udp_sport"); > - > - pool = odp_pool_create(poolname, &pool_param); > + pool = pool_create("udp_sport"); > CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos, pool); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "udp_sport"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + > + cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > > retval = odp_pktio_pmr_cos(pmr, pktio, cos); > CU_ASSERT(retval == 0); > @@ -635,10 +569,8 @@ static void classification_test_pmr_term_ipproto(void) > odp_pool_t recvpool; > odp_pmr_t pmr; > odp_cos_t cos; > - odp_pool_param_t pool_param; > char cosname[ODP_COS_NAME_LEN]; > - char poolname[ODP_POOL_NAME_LEN]; > - char queuename[ODP_QUEUE_NAME_LEN]; > + odp_cls_cos_param_t cls_param; > odp_pmr_match_t match; > > val = ODPH_IPPROTO_UDP; > @@ -657,29 +589,124 @@ static void classification_test_pmr_term_ipproto(void) > pmr = odp_pmr_create(&match); > CU_ASSERT(pmr != ODP_PMR_INVAL); > > + queue = queue_create("ipproto", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > + pool = pool_create("ipproto"); > + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > + > sprintf(cosname, "ipproto"); > - cos = odp_cos_create(cosname); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + > + cos = odp_cls_cos_create(cosname, &cls_param); > CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > > - sprintf(queuename, "%s", "ipproto"); > + retval = odp_pktio_pmr_cos(pmr, pktio, cos); > + CU_ASSERT(retval == 0); > > - queue = queue_create(queuename, true); > - CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + configure_default_cos(pktio, &default_cos, > + &default_queue, &default_pool); > + pkt = create_packet(pkt_pool, false, &seq, true); > + seqno = cls_pkt_get_seq(pkt); > + CU_ASSERT(seqno != TEST_SEQ_INVALID); > + > + enqueue_pktio_interface(pkt, pktio); > + > + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); here has to be time of scheduler, ns should be converted to with odp_schedule_wait_time() first Maybe here is reason to check if the function is used correctly in other places. > + CU_ASSERT(pkt != ODP_PACKET_INVALID); > + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); > + recvpool = odp_packet_pool(pkt); > + CU_ASSERT(recvpool == pool); > + CU_ASSERT(retqueue == queue); > + odp_packet_free(pkt); > + > + /* Other packets delivered to default queue */ > + pkt = create_packet(pkt_pool, false, &seq, false); > + seqno = cls_pkt_get_seq(pkt); > + CU_ASSERT(seqno != TEST_SEQ_INVALID); > + > + enqueue_pktio_interface(pkt, pktio); > + > + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); here has to be time of scheduler, ns should be converted to with odp_schedule_wait_time() first > + CU_ASSERT(pkt != ODP_PACKET_INVALID); > + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); > + recvpool = odp_packet_pool(pkt); > + CU_ASSERT(recvpool == default_pool); > + CU_ASSERT(retqueue == default_queue); > + > + odp_cos_destroy(cos); > + odp_cos_destroy(default_cos); > + odp_pmr_destroy(pmr); > + odp_packet_free(pkt); > + destroy_inq(pktio); > + odp_pool_destroy(default_pool); > + odp_pool_destroy(pool); > + odp_queue_destroy(queue); > + odp_queue_destroy(default_queue); > + odp_pktio_close(pktio); > +} > + > +static void classification_test_pmr_pool_set(void) > +{ > + odp_packet_t pkt; > + uint32_t seqno; > + uint8_t val; > + uint8_t mask; > + int retval; > + odp_pktio_t pktio; > + odp_queue_t queue; > + odp_queue_t retqueue; > + odp_queue_t default_queue; > + odp_cos_t default_cos; > + odp_pool_t default_pool; > + odp_pool_t pool; > + odp_pool_t pool_new; > + odp_pool_t recvpool; > + odp_pmr_t pmr; > + odp_cos_t cos; > + char cosname[ODP_COS_NAME_LEN]; > + odp_cls_cos_param_t cls_param; > + odp_pmr_match_t match; > > - retval = odp_cos_queue_set(cos, queue); > + val = ODPH_IPPROTO_UDP; > + mask = 0xff; > + seqno = 0; > + > + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); > + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); > CU_ASSERT(retval == 0); > > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > - sprintf(poolname, "%s", "ipproto"); > + match.term = ODP_PMR_IPPROTO; > + match.val = &val; > + match.mask = &mask; > + match.val_sz = sizeof(val); > + > + pmr = odp_pmr_create(&match); > + CU_ASSERT(pmr != ODP_PMR_INVAL); > > - pool = odp_pool_create(poolname, &pool_param); > + queue = queue_create("ipproto1", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > + pool = pool_create("ipproto1"); > CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos, pool); > + sprintf(cosname, "ipproto1"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + > + cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > + > + pool_new = pool_create("ipproto2"); > + CU_ASSERT_FATAL(pool_new != ODP_POOL_INVALID); > + > + /* new pool is set on CoS */ > + retval = odp_cls_cos_pool_set(cos, pool_new); > CU_ASSERT(retval == 0); > > retval = odp_pktio_pmr_cos(pmr, pktio, cos); > @@ -697,12 +724,89 @@ static void classification_test_pmr_term_ipproto(void) > CU_ASSERT(pkt != ODP_PACKET_INVALID); > CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); > recvpool = odp_packet_pool(pkt); > - CU_ASSERT(recvpool == pool); > + CU_ASSERT(recvpool == pool_new); > CU_ASSERT(retqueue == queue); > odp_packet_free(pkt); > > - /* Other packets delivered to default queue */ > - pkt = create_packet(pkt_pool, false, &seq, false); > + odp_cos_destroy(cos); > + odp_cos_destroy(default_cos); > + odp_pmr_destroy(pmr); > + odp_packet_free(pkt); > + destroy_inq(pktio); > + odp_pool_destroy(default_pool); > + odp_pool_destroy(pool); > + odp_pool_destroy(pool_new); > + odp_queue_destroy(queue); > + odp_queue_destroy(default_queue); > + odp_pktio_close(pktio); > +} > + > +static void classification_test_pmr_queue_set(void) > +{ > + odp_packet_t pkt; > + uint32_t seqno; > + uint8_t val; > + uint8_t mask; > + int retval; > + odp_pktio_t pktio; > + odp_queue_t queue; > + odp_queue_t retqueue; > + odp_queue_t default_queue; > + odp_cos_t default_cos; > + odp_pool_t default_pool; > + odp_pool_t pool; > + odp_queue_t queue_new; > + odp_pool_t recvpool; > + odp_pmr_t pmr; > + odp_cos_t cos; > + char cosname[ODP_COS_NAME_LEN]; > + odp_cls_cos_param_t cls_param; > + odp_pmr_match_t match; > + > + val = ODPH_IPPROTO_UDP; > + mask = 0xff; > + seqno = 0; > + > + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); > + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); > + CU_ASSERT(retval == 0); > + > + match.term = ODP_PMR_IPPROTO; > + match.val = &val; > + match.mask = &mask; > + match.val_sz = sizeof(val); > + > + pmr = odp_pmr_create(&match); > + CU_ASSERT(pmr != ODP_PMR_INVAL); > + > + queue = queue_create("ipproto1", true); > + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); > + > + pool = pool_create("ipproto1"); > + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > + > + sprintf(cosname, "ipproto1"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + > + cos = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); > + > + queue_new = queue_create("ipproto2", true); > + CU_ASSERT_FATAL(queue_new != ODP_QUEUE_INVALID); > + > + /* new queue is set on CoS */ > + retval = odp_cos_queue_set(cos, queue_new); > + CU_ASSERT(retval == 0); > + > + retval = odp_pktio_pmr_cos(pmr, pktio, cos); > + CU_ASSERT(retval == 0); > + > + configure_default_cos(pktio, &default_cos, > + &default_queue, &default_pool); > + pkt = create_packet(pkt_pool, false, &seq, true); > seqno = cls_pkt_get_seq(pkt); > CU_ASSERT(seqno != TEST_SEQ_INVALID); > > @@ -712,8 +816,9 @@ static void classification_test_pmr_term_ipproto(void) > CU_ASSERT(pkt != ODP_PACKET_INVALID); > CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); > recvpool = odp_packet_pool(pkt); > - CU_ASSERT(recvpool == default_pool); > - CU_ASSERT(retqueue == default_queue); > + CU_ASSERT(recvpool == pool); > + CU_ASSERT(retqueue == queue_new); > + odp_packet_free(pkt); > > odp_cos_destroy(cos); > odp_cos_destroy(default_cos); > @@ -722,6 +827,7 @@ static void classification_test_pmr_term_ipproto(void) > destroy_inq(pktio); > odp_pool_destroy(default_pool); > odp_pool_destroy(pool); > + odp_queue_destroy(queue_new); > odp_queue_destroy(queue); > odp_queue_destroy(default_queue); > odp_pktio_close(pktio); > @@ -733,5 +839,7 @@ odp_testinfo_t classification_suite_pmr[] = { > ODP_TEST_INFO(classification_test_pmr_term_udp_dport), > ODP_TEST_INFO(classification_test_pmr_term_udp_sport), > ODP_TEST_INFO(classification_test_pmr_term_ipproto), > + ODP_TEST_INFO(classification_test_pmr_pool_set), > + ODP_TEST_INFO(classification_test_pmr_queue_set), > ODP_TEST_INFO_NULL, > }; > diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c > index b64d841..99242d0 100644 > --- a/test/validation/classification/odp_classification_tests.c > +++ b/test/validation/classification/odp_classification_tests.c > @@ -25,7 +25,6 @@ odp_atomic_u32_t seq; > > int classification_suite_init(void) > { > - odp_pool_param_t param; > odp_queue_t inq_def; > odp_queue_param_t qparam; > char queuename[ODP_QUEUE_NAME_LEN]; > @@ -33,13 +32,7 @@ int classification_suite_init(void) > int ret; > odp_pktio_param_t pktio_param; > > - odp_pool_param_init(¶m); > - param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - param.pkt.len = SHM_PKT_BUF_SIZE; > - param.pkt.num = SHM_PKT_NUM_BUFS; > - param.type = ODP_POOL_PACKET; > - > - pool_default = odp_pool_create("classification_pool", ¶m); > + pool_default = pool_create("classification_pool"); > if (ODP_POOL_INVALID == pool_default) { > fprintf(stderr, "Packet pool creation failed.\n"); > return -1; > @@ -55,6 +48,7 @@ int classification_suite_init(void) > fprintf(stderr, "unable to destroy pool.\n"); > return -1; > } > + > odp_queue_param_init(&qparam); > qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; > qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; > @@ -136,16 +130,13 @@ void configure_cls_pmr_chain(void) > int retval; > char cosname[ODP_QUEUE_NAME_LEN]; > odp_queue_param_t qparam; > - odp_pool_param_t pool_param; > + odp_cls_cos_param_t cls_param; > char queuename[ODP_QUEUE_NAME_LEN]; > char poolname[ODP_POOL_NAME_LEN]; > uint32_t addr; > uint32_t mask; > odp_pmr_match_t match; > > - sprintf(cosname, "SrcCos"); > - cos_list[CLS_PMR_CHAIN_SRC] = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_SRC] != ODP_COS_INVALID); > > odp_queue_param_init(&qparam); > qparam.sched.prio = ODP_SCHED_PRIO_NORMAL; > @@ -160,27 +151,18 @@ void configure_cls_pmr_chain(void) > > CU_ASSERT_FATAL(queue_list[CLS_PMR_CHAIN_SRC] != ODP_QUEUE_INVALID); > > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > sprintf(poolname, "%s", "SrcPool"); > - > - pool_list[CLS_PMR_CHAIN_SRC] = odp_pool_create(poolname, &pool_param); > + pool_list[CLS_PMR_CHAIN_SRC] = pool_create(poolname); > CU_ASSERT_FATAL(pool_list[CLS_PMR_CHAIN_SRC] != ODP_POOL_INVALID); > > - retval = odp_cos_queue_set(cos_list[CLS_PMR_CHAIN_SRC], > - queue_list[CLS_PMR_CHAIN_SRC]); > - CU_ASSERT(retval == 0); > - > - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_CHAIN_SRC], > - pool_list[CLS_PMR_CHAIN_SRC]); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "SrcCos"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool_list[CLS_PMR_CHAIN_SRC]; > + cls_param.queue = queue_list[CLS_PMR_CHAIN_SRC]; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_list[CLS_PMR_CHAIN_SRC] = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_SRC] != ODP_COS_INVALID); > > - sprintf(cosname, "DstCos"); > - cos_list[CLS_PMR_CHAIN_DST] = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_DST] != ODP_COS_INVALID); > > odp_queue_param_init(&qparam); > qparam.sched.prio = ODP_SCHED_PRIO_NORMAL; > @@ -193,23 +175,17 @@ void configure_cls_pmr_chain(void) > &qparam); > CU_ASSERT_FATAL(queue_list[CLS_PMR_CHAIN_DST] != ODP_QUEUE_INVALID); > > - retval = odp_cos_queue_set(cos_list[CLS_PMR_CHAIN_DST], > - queue_list[CLS_PMR_CHAIN_DST]); > - CU_ASSERT(retval == 0); > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > sprintf(poolname, "%s", "DstPool"); > - > - pool_list[CLS_PMR_CHAIN_DST] = odp_pool_create(poolname, &pool_param); > + pool_list[CLS_PMR_CHAIN_DST] = pool_create(poolname); > CU_ASSERT_FATAL(pool_list[CLS_PMR_CHAIN_DST] != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_CHAIN_DST], > - pool_list[CLS_PMR_CHAIN_DST]); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "DstCos"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool_list[CLS_PMR_CHAIN_DST]; > + cls_param.queue = queue_list[CLS_PMR_CHAIN_DST]; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_list[CLS_PMR_CHAIN_DST] = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_DST] != ODP_COS_INVALID); > > parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask); > match.term = ODP_PMR_SIP_ADDR; > @@ -296,15 +272,11 @@ void configure_pktio_default_cos(void) > { > int retval; > odp_queue_param_t qparam; > - odp_pool_param_t pool_param; > + odp_cls_cos_param_t cls_param; > char cosname[ODP_COS_NAME_LEN]; > char queuename[ODP_QUEUE_NAME_LEN]; > char poolname[ODP_POOL_NAME_LEN]; > > - sprintf(cosname, "DefaultCoS"); > - cos_list[CLS_DEFAULT] = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos_list[CLS_DEFAULT] != ODP_COS_INVALID); > - > odp_queue_param_init(&qparam); > qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; > qparam.sched.sync = ODP_SCHED_SYNC_NONE; > @@ -314,23 +286,17 @@ void configure_pktio_default_cos(void) > ODP_QUEUE_TYPE_SCHED, &qparam); > CU_ASSERT_FATAL(queue_list[CLS_DEFAULT] != ODP_QUEUE_INVALID); > > - retval = odp_cos_queue_set(cos_list[CLS_DEFAULT], > - queue_list[CLS_DEFAULT]); > - CU_ASSERT(retval == 0); > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > sprintf(poolname, "DefaultPool"); > - > - pool_list[CLS_DEFAULT] = odp_pool_create(poolname, &pool_param); > + pool_list[CLS_DEFAULT] = pool_create(poolname); > CU_ASSERT_FATAL(pool_list[CLS_DEFAULT] != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos_list[CLS_DEFAULT], > - pool_list[CLS_DEFAULT]); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "DefaultCoS"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool_list[CLS_DEFAULT]; > + cls_param.queue = queue_list[CLS_DEFAULT]; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_list[CLS_DEFAULT] = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos_list[CLS_DEFAULT] != ODP_COS_INVALID); > > retval = odp_pktio_default_cos_set(pktio_loop, cos_list[CLS_DEFAULT]); > CU_ASSERT(retval == 0); > @@ -364,7 +330,7 @@ void configure_pktio_error_cos(void) > { > int retval; > odp_queue_param_t qparam; > - odp_pool_param_t pool_param; > + odp_cls_cos_param_t cls_param; > char queuename[ODP_QUEUE_NAME_LEN]; > char cosname[ODP_COS_NAME_LEN]; > char poolname[ODP_POOL_NAME_LEN]; > @@ -380,26 +346,17 @@ void configure_pktio_error_cos(void) > &qparam); > CU_ASSERT_FATAL(queue_list[CLS_ERROR] != ODP_QUEUE_INVALID); > > - sprintf(cosname, "%s", "ErrorCos"); > - cos_list[CLS_ERROR] = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos_list[CLS_ERROR] != ODP_COS_INVALID); > - > - retval = odp_cos_queue_set(cos_list[CLS_ERROR], queue_list[CLS_ERROR]); > - CU_ASSERT(retval == 0); > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > sprintf(poolname, "ErrorPool"); > - > - pool_list[CLS_ERROR] = odp_pool_create(poolname, &pool_param); > + pool_list[CLS_ERROR] = pool_create(poolname); > CU_ASSERT_FATAL(pool_list[CLS_ERROR] != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos_list[CLS_ERROR], > - pool_list[CLS_ERROR]); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "%s", "ErrorCos"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool_list[CLS_ERROR]; > + cls_param.queue = queue_list[CLS_ERROR]; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_list[CLS_ERROR] = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos_list[CLS_ERROR] != ODP_COS_INVALID); > > retval = odp_pktio_error_cos_set(pktio_loop, cos_list[CLS_ERROR]); > CU_ASSERT(retval == 0); > @@ -471,14 +428,7 @@ void configure_cos_with_l2_priority(void) > int retval; > int i; > odp_queue_param_t qparam; > - odp_pool_param_t pool_param; > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > - > + odp_cls_cos_param_t cls_param; > > /** Initialize scalar variable qos_tbl **/ > for (i = 0; i < CLS_L2_QOS_MAX; i++) > @@ -489,32 +439,31 @@ void configure_cos_with_l2_priority(void) > qparam.sched.group = ODP_SCHED_GROUP_ALL; > for (i = 0; i < num_qos; i++) { > qparam.sched.prio = ODP_SCHED_PRIO_LOWEST - i; > - sprintf(cosname, "%s_%d", "L2_Cos", i); > - cos_tbl[i] = odp_cos_create(cosname); > - if (cos_tbl[i] == ODP_COS_INVALID) > - break; > - > - cos_list[CLS_L2_QOS_0 + i] = cos_tbl[i]; > sprintf(queuename, "%s_%d", "L2_Queue", i); > queue_tbl[i] = odp_queue_create(queuename, ODP_QUEUE_TYPE_SCHED, > &qparam); > CU_ASSERT_FATAL(queue_tbl[i] != ODP_QUEUE_INVALID); > queue_list[CLS_L2_QOS_0 + i] = queue_tbl[i]; > > - retval = odp_cos_queue_set(cos_tbl[i], queue_tbl[i]); > - CU_ASSERT(retval == 0); > - > sprintf(poolname, "%s_%d", "L2_Pool", i); > - pool = odp_pool_create(poolname, &pool_param); > + pool = pool_create(poolname); > CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); > pool_list[CLS_L2_QOS_0 + i] = pool; > - retval = odp_cls_cos_pool_set(cos_tbl[i], pool); > - CU_ASSERT(retval == 0); > > + sprintf(cosname, "%s_%d", "L2_Cos", i); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool; > + cls_param.queue = queue_tbl[i]; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_tbl[i] = odp_cls_cos_create(cosname, &cls_param); > + if (cos_tbl[i] == ODP_COS_INVALID) > + break; > + > + cos_list[CLS_L2_QOS_0 + i] = cos_tbl[i]; > qos_tbl[i] = i; > } > /* count 'i' is passed instead of num_qos to handle the rare scenario > - if the odp_cos_create() failed in the middle*/ > + if the odp_cls_cos_create() failed in the middle*/ > retval = odp_cos_with_l2_priority(pktio_loop, i, qos_tbl, cos_tbl); > CU_ASSERT(retval == 0); > } > @@ -554,10 +503,10 @@ void configure_pmr_cos(void) > int retval; > odp_pmr_match_t match; > odp_queue_param_t qparam; > + odp_cls_cos_param_t cls_param; > char cosname[ODP_COS_NAME_LEN]; > char queuename[ODP_QUEUE_NAME_LEN]; > char poolname[ODP_POOL_NAME_LEN]; > - odp_pool_param_t pool_param; > > val = CLS_PMR_SPORT; > mask = 0xffff; > @@ -569,10 +518,6 @@ void configure_pmr_cos(void) > pmr_list[CLS_PMR] = odp_pmr_create(&match); > CU_ASSERT(pmr_list[CLS_PMR] != ODP_PMR_INVAL); > > - sprintf(cosname, "PMR_CoS"); > - cos_list[CLS_PMR] = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos_list[CLS_PMR] != ODP_COS_INVALID); > - > odp_queue_param_init(&qparam); > qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; > qparam.sched.sync = ODP_SCHED_SYNC_NONE; > @@ -584,22 +529,17 @@ void configure_pmr_cos(void) > &qparam); > CU_ASSERT_FATAL(queue_list[CLS_PMR] != ODP_QUEUE_INVALID); > > - retval = odp_cos_queue_set(cos_list[CLS_PMR], > - queue_list[CLS_PMR]); > - CU_ASSERT(retval == 0); > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > sprintf(poolname, "PMR_Pool"); > - > - pool_list[CLS_PMR] = odp_pool_create(poolname, &pool_param); > + pool_list[CLS_PMR] = pool_create(poolname); > CU_ASSERT_FATAL(pool_list[CLS_PMR] != ODP_POOL_INVALID); > > - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR], pool_list[CLS_PMR]); > - CU_ASSERT(retval == 0); > + sprintf(cosname, "PMR_CoS"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool_list[CLS_PMR]; > + cls_param.queue = queue_list[CLS_PMR]; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_list[CLS_PMR] = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos_list[CLS_PMR] != ODP_COS_INVALID); > > retval = odp_pktio_pmr_cos(pmr_list[CLS_PMR], pktio_loop, > cos_list[CLS_PMR]); > @@ -637,10 +577,10 @@ void configure_pktio_pmr_match_set_cos(void) > uint16_t maskport; > int num_terms = 2; /* one pmr for each L3 and L4 */ > odp_queue_param_t qparam; > + odp_cls_cos_param_t cls_param; > char cosname[ODP_COS_NAME_LEN]; > char queuename[ODP_QUEUE_NAME_LEN]; > char poolname[ODP_POOL_NAME_LEN]; > - odp_pool_param_t pool_param; > uint32_t addr = 0; > uint32_t mask; > > @@ -661,10 +601,6 @@ void configure_pktio_pmr_match_set_cos(void) > retval = odp_pmr_match_set_create(num_terms, pmr_terms, &pmr_set); > CU_ASSERT(retval > 0); > > - sprintf(cosname, "cos_pmr_set"); > - cos_list[CLS_PMR_SET] = odp_cos_create(cosname); > - CU_ASSERT_FATAL(cos_list[CLS_PMR_SET] != ODP_COS_INVALID); > - > odp_queue_param_init(&qparam); > qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; > qparam.sched.sync = ODP_SCHED_SYNC_NONE; > @@ -676,22 +612,17 @@ void configure_pktio_pmr_match_set_cos(void) > &qparam); > CU_ASSERT_FATAL(queue_list[CLS_PMR_SET] != ODP_QUEUE_INVALID); > > - retval = odp_cos_queue_set(cos_list[CLS_PMR_SET], > - queue_list[CLS_PMR_SET]); > - CU_ASSERT(retval == 0); > - > - odp_pool_param_init(&pool_param); > - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.len = SHM_PKT_BUF_SIZE; > - pool_param.pkt.num = SHM_PKT_NUM_BUFS; > - pool_param.type = ODP_POOL_PACKET; > sprintf(poolname, "cos_pmr_set_pool"); > - > - pool_list[CLS_PMR_SET] = odp_pool_create(poolname, &pool_param); > + pool_list[CLS_PMR_SET] = pool_create(poolname); > CU_ASSERT_FATAL(pool_list[CLS_PMR_SET] != ODP_POOL_INVALID); > - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_SET], > - pool_list[CLS_PMR_SET]); > - CU_ASSERT(retval == 0); > + > + sprintf(cosname, "cos_pmr_set"); > + odp_cls_cos_param_init(&cls_param); > + cls_param.pool = pool_list[CLS_PMR_SET]; > + cls_param.queue = queue_list[CLS_PMR_SET]; > + cls_param.drop_policy = ODP_COS_DROP_POOL; > + cos_list[CLS_PMR_SET] = odp_cls_cos_create(cosname, &cls_param); > + CU_ASSERT_FATAL(cos_list[CLS_PMR_SET] != ODP_COS_INVALID); > > retval = odp_pktio_pmr_match_set_cos(pmr_set, pktio_loop, > cos_list[CLS_PMR_SET]); > diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h > index a09067c..02828e1 100644 > --- a/test/validation/classification/odp_classification_testsuites.h > +++ b/test/validation/classification/odp_classification_testsuites.h > @@ -31,7 +31,8 @@ void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos, > int parse_ipv4_string(const char *ipaddress, uint32_t *addr, uint32_t *mask); > void enqueue_pktio_interface(odp_packet_t pkt, odp_pktio_t pktio); > odp_packet_t receive_packet(odp_queue_t *queue, uint64_t ns); > -odp_queue_t queue_create(char *queuename, bool sched); > +odp_pool_t pool_create(const char *poolname); > +odp_queue_t queue_create(const char *queuename, bool sched); > void configure_pktio_default_cos(void); > void test_pktio_default_cos(void); > void configure_pktio_error_cos(void); >
..... >> + >> + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); > here has to be time of scheduler, ns should be converted to with odp_schedule_wait_time() first > Maybe here is reason to check if the function is used correctly in other places. > Here probably should be one more patch that corrects receive_packet() instead "ns" the "wait" word should be used in order to not confuse user. It can be converted inside of receive_packet of course, but in this case the modes like ODP_SCHED_WAIT and ODP_SCHED_NO_WAIT cannot be used. So better to correct usage of this function and rename ns to wait inside.
I will correct this as a separate patch. Regards, Bala On 17 December 2015 at 15:48, Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> wrote: > ..... > >>> + >>> + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); >> >> here has to be time of scheduler, ns should be converted to with >> odp_schedule_wait_time() first >> Maybe here is reason to check if the function is used correctly in other >> places. >> > > Here probably should be one more patch that corrects receive_packet() > instead "ns" the "wait" word should be used in order to not confuse user. > > It can be converted inside of receive_packet of course, but in this case > the modes like ODP_SCHED_WAIT and ODP_SCHED_NO_WAIT cannot be used. > > So better to correct usage of this function and rename ns to wait inside.
diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h index 6a7e8a5..e3fc081 100644 --- a/test/validation/classification/classification.h +++ b/test/validation/classification/classification.h @@ -59,6 +59,7 @@ void classification_test_destroy_cos(void); void classification_test_create_pmr_match(void); void classification_test_destroy_pmr(void); void classification_test_cos_set_queue(void); +void classification_test_cos_set_pool(void); void classification_test_cos_set_drop(void); void classification_test_pmr_match_set_create(void); void classification_test_pmr_match_set_destroy(void); diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c index 20c157f..f0b7a42 100644 --- a/test/validation/classification/odp_classification_basic.c +++ b/test/validation/classification/odp_classification_basic.c @@ -13,26 +13,60 @@ void classification_test_create_cos(void) { odp_cos_t cos; - char name[ODP_COS_NAME_LEN]; - sprintf(name, "ClassOfService"); - cos = odp_cos_create(name); - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + odp_cls_cos_param_t cls_param; + odp_pool_t pool; + odp_queue_t queue; + char cosname[ODP_COS_NAME_LEN]; + + pool = pool_create("cls_basic_pool"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + queue = queue_create("cls_basic_queue", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + sprintf(cosname, "ClassOfService"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT(odp_cos_to_u64(cos) != odp_cos_to_u64(ODP_COS_INVALID)); odp_cos_destroy(cos); + odp_pool_destroy(pool); + odp_queue_destroy(queue); } void classification_test_destroy_cos(void) { odp_cos_t cos; char name[ODP_COS_NAME_LEN]; + odp_pool_t pool; + odp_queue_t queue; + odp_cls_cos_param_t cls_param; int retval; + + pool = pool_create("cls_basic_pool"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + queue = queue_create("cls_basic_queue", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + sprintf(name, "ClassOfService"); - cos = odp_cos_create(name); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(name, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); retval = odp_cos_destroy(cos); CU_ASSERT(retval == 0); retval = odp_cos_destroy(ODP_COS_INVALID); CU_ASSERT(retval < 0); + + odp_pool_destroy(pool); + odp_queue_destroy(queue); } void classification_test_create_pmr_match(void) @@ -82,35 +116,101 @@ void classification_test_cos_set_queue(void) { int retval; char cosname[ODP_COS_NAME_LEN]; - char queuename[ODP_QUEUE_NAME_LEN]; - odp_queue_param_t qparam; + odp_cls_cos_param_t cls_param; + odp_pool_t pool; + odp_queue_t queue; odp_queue_t queue_cos; odp_cos_t cos_queue; + odp_queue_t recvqueue; + + pool = pool_create("cls_basic_pool"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + queue = queue_create("cls_basic_queue", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + sprintf(cosname, "CoSQueue"); - cos_queue = odp_cos_create(cosname); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_queue = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos_queue != ODP_COS_INVALID); - odp_queue_param_init(&qparam); - qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; - qparam.sched.sync = ODP_SCHED_SYNC_NONE; - qparam.sched.group = ODP_SCHED_GROUP_ALL; - sprintf(queuename, "%s", "QueueCoS"); + queue_cos = queue_create("QueueCoS", true); + CU_ASSERT_FATAL(queue_cos != ODP_QUEUE_INVALID); - queue_cos = odp_queue_create(queuename, - ODP_QUEUE_TYPE_SCHED, &qparam); retval = odp_cos_queue_set(cos_queue, queue_cos); CU_ASSERT(retval == 0); + recvqueue = odp_cos_queue(cos_queue); + CU_ASSERT(recvqueue == queue_cos); + odp_cos_destroy(cos_queue); odp_queue_destroy(queue_cos); + odp_queue_destroy(queue); + odp_pool_destroy(pool); +} + +void classification_test_cos_set_pool(void) +{ + int retval; + char cosname[ODP_COS_NAME_LEN]; + odp_cls_cos_param_t cls_param; + odp_pool_t pool; + odp_queue_t queue; + odp_pool_t cos_pool; + odp_cos_t cos; + odp_pool_t recvpool; + + pool = pool_create("cls_basic_pool"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + queue = queue_create("cls_basic_queue", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + sprintf(cosname, "CoSQueue"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + cos_pool = pool_create("PoolCoS"); + CU_ASSERT_FATAL(cos_pool != ODP_POOL_INVALID); + + retval = odp_cls_cos_pool_set(cos, cos_pool); + CU_ASSERT(retval == 0); + recvpool = odp_cls_cos_pool(cos); + CU_ASSERT(recvpool == cos_pool); + + odp_cos_destroy(cos); + odp_queue_destroy(queue); + odp_pool_destroy(pool); + odp_pool_destroy(cos_pool); } void classification_test_cos_set_drop(void) { int retval; char cosname[ODP_COS_NAME_LEN]; - sprintf(cosname, "CoSDrop"); odp_cos_t cos_drop; - cos_drop = odp_cos_create(cosname); + odp_queue_t queue; + odp_pool_t pool; + odp_cls_cos_param_t cls_param; + + pool = pool_create("cls_basic_pool"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + queue = queue_create("cls_basic_queue", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + sprintf(cosname, "CoSDrop"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_drop = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos_drop != ODP_COS_INVALID); retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_POOL); @@ -118,6 +218,8 @@ void classification_test_cos_set_drop(void) retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_NEVER); CU_ASSERT(retval == 0); odp_cos_destroy(cos_drop); + odp_pool_destroy(pool); + odp_queue_destroy(queue); } void classification_test_pmr_match_set_create(void) @@ -177,6 +279,7 @@ odp_testinfo_t classification_suite_basic[] = { ODP_TEST_INFO(classification_test_destroy_pmr), ODP_TEST_INFO(classification_test_cos_set_queue), ODP_TEST_INFO(classification_test_cos_set_drop), + ODP_TEST_INFO(classification_test_cos_set_pool), ODP_TEST_INFO(classification_test_pmr_match_set_create), ODP_TEST_INFO(classification_test_pmr_match_set_destroy), ODP_TEST_INFO_NULL, diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index a56c017..afcea45 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -154,7 +154,7 @@ odp_packet_t receive_packet(odp_queue_t *queue, uint64_t ns) return odp_packet_from_event(ev); } -odp_queue_t queue_create(char *queuename, bool sched) +odp_queue_t queue_create(const char *queuename, bool sched) { odp_queue_t queue; odp_queue_param_t qparam; @@ -177,6 +177,19 @@ odp_queue_t queue_create(char *queuename, bool sched) return queue; } +odp_pool_t pool_create(const char *poolname) +{ + odp_pool_param_t param; + + odp_pool_param_init(¶m); + param.pkt.seg_len = SHM_PKT_BUF_SIZE; + param.pkt.len = SHM_PKT_BUF_SIZE; + param.pkt.num = SHM_PKT_NUM_BUFS; + param.type = ODP_POOL_PACKET; + + return odp_pool_create(poolname, ¶m); +} + odp_packet_t create_packet(odp_pool_t pool, bool vlan, odp_atomic_u32_t *seq, bool flag_udp) { diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c index 120ddd2..2fb611b 100644 --- a/test/validation/classification/odp_classification_test_pmr.c +++ b/test/validation/classification/odp_classification_test_pmr.c @@ -19,15 +19,7 @@ odp_atomic_u32_t seq; int classification_suite_pmr_init(void) { - odp_pool_param_t param; - - odp_pool_param_init(¶m); - param.pkt.seg_len = SHM_PKT_BUF_SIZE; - param.pkt.len = SHM_PKT_BUF_SIZE; - param.pkt.num = SHM_PKT_NUM_BUFS; - param.type = ODP_POOL_PACKET; - - pkt_pool = odp_pool_create("classification_pmr_pool", ¶m); + pkt_pool = pool_create("classification_pmr_pool"); if (ODP_POOL_INVALID == pkt_pool) { fprintf(stderr, "Packet pool creation failed.\n"); return -1; @@ -99,38 +91,27 @@ int create_default_inq(odp_pktio_t pktio, odp_queue_type_t qtype) void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos, odp_queue_t *queue, odp_pool_t *pool) { - odp_pool_param_t pool_param; + odp_cls_cos_param_t cls_param; odp_pool_t default_pool; odp_cos_t default_cos; odp_queue_t default_queue; int retval; char cosname[ODP_COS_NAME_LEN]; - char poolname[ODP_POOL_NAME_LEN]; - char queuename[ODP_QUEUE_NAME_LEN]; - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; - sprintf(poolname, "%s", "DefaultPool"); - - default_pool = odp_pool_create(poolname, &pool_param); + default_pool = pool_create("DefaultPool"); CU_ASSERT(default_pool != ODP_POOL_INVALID); - sprintf(queuename, "DefaultQueue"); - default_queue = queue_create(queuename, true); + default_queue = queue_create("DefaultQueue", true); CU_ASSERT(default_queue != ODP_QUEUE_INVALID); sprintf(cosname, "DefaultCos"); - default_cos = odp_cos_create(cosname); - CU_ASSERT(default_cos != ODP_COS_INVALID); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = default_pool; + cls_param.queue = default_queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; - retval = odp_cos_queue_set(default_cos, default_queue); - CU_ASSERT(retval == 0); - - retval = odp_cls_cos_pool_set(default_cos, default_pool); - CU_ASSERT(retval == 0); + default_cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT(default_cos != ODP_COS_INVALID); retval = odp_pktio_default_cos_set(pktio, default_cos); CU_ASSERT(retval == 0); @@ -171,9 +152,7 @@ static void classification_test_pmr_term_tcp_dport(void) odp_pmr_t pmr; odp_cos_t cos; char cosname[ODP_COS_NAME_LEN]; - char queuename[ODP_QUEUE_NAME_LEN]; - char poolname[ODP_POOL_NAME_LEN]; - odp_pool_param_t pool_param; + odp_cls_cos_param_t cls_param; odp_pool_t pool; odp_pool_t pool_recv; odp_pmr_match_t match; @@ -195,30 +174,21 @@ static void classification_test_pmr_term_tcp_dport(void) pmr = odp_pmr_create(&match); CU_ASSERT(pmr != ODP_PMR_INVAL); - sprintf(cosname, "tcp_dport"); - cos = odp_cos_create(cosname); - CU_ASSERT(cos != ODP_COS_INVALID); - - sprintf(queuename, "%s", "tcp_dport1"); - queue = queue_create(queuename, true); + queue = queue_create("tcp_dport1", true); CU_ASSERT(queue != ODP_QUEUE_INVALID); - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; - sprintf(poolname, "%s", "tcp_dport1"); - - pool = odp_pool_create(poolname, &pool_param); + pool = pool_create("tcp_dport1"); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos, pool); - CU_ASSERT(retval == 0); + sprintf(cosname, "tcp_dport"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; - retval = odp_cos_queue_set(cos, queue); - CU_ASSERT(retval == 0); + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT(cos != ODP_COS_INVALID); retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); @@ -286,14 +256,12 @@ static void classification_test_pmr_term_tcp_sport(void) odp_queue_t default_queue; odp_cos_t default_cos; odp_pool_t default_pool; - odp_pool_param_t pool_param; odp_pool_t pool; odp_pool_t recvpool; odp_pmr_t pmr; odp_cos_t cos; char cosname[ODP_COS_NAME_LEN]; - char poolname[ODP_POOL_NAME_LEN]; - char queuename[ODP_QUEUE_NAME_LEN]; + odp_cls_cos_param_t cls_param; odp_pmr_match_t match; val = CLS_DEFAULT_SPORT; @@ -312,30 +280,20 @@ static void classification_test_pmr_term_tcp_sport(void) pmr = odp_pmr_create(&match); CU_ASSERT(pmr != ODP_PMR_INVAL); - sprintf(cosname, "tcp_sport"); - cos = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - - sprintf(queuename, "%s", "tcp_sport"); - - queue = queue_create(queuename, true); + queue = queue_create("tcp_sport", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; - sprintf(poolname, "%s", "tcp_sport"); - - pool = odp_pool_create(poolname, &pool_param); + pool = pool_create("tcp_sport"); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos, pool); - CU_ASSERT(retval == 0); + sprintf(cosname, "tcp_sport"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; - retval = odp_cos_queue_set(cos, queue); - CU_ASSERT(retval == 0); + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); @@ -403,13 +361,11 @@ static void classification_test_pmr_term_udp_dport(void) odp_queue_t default_queue; odp_cos_t default_cos; odp_pool_t default_pool; - odp_pool_param_t pool_param; odp_pmr_t pmr; odp_cos_t cos; char cosname[ODP_COS_NAME_LEN]; - char poolname[ODP_POOL_NAME_LEN]; - char queuename[ODP_QUEUE_NAME_LEN]; odp_pmr_match_t match; + odp_cls_cos_param_t cls_param; val = CLS_DEFAULT_DPORT; mask = 0xffff; @@ -427,30 +383,20 @@ static void classification_test_pmr_term_udp_dport(void) pmr = odp_pmr_create(&match); CU_ASSERT(pmr != ODP_PMR_INVAL); - sprintf(cosname, "udp_dport"); - cos = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - - sprintf(queuename, "%s", "udp_dport"); - - queue = queue_create(queuename, true); + queue = queue_create("udp_dport", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); - retval = odp_cos_queue_set(cos, queue); - CU_ASSERT(retval == 0); - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; - sprintf(poolname, "%s", "udp_dport"); - - pool = odp_pool_create(poolname, &pool_param); + pool = pool_create("udp_dport"); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos, pool); - CU_ASSERT(retval == 0); + sprintf(cosname, "udp_dport"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); @@ -517,15 +463,13 @@ static void classification_test_pmr_term_udp_sport(void) odp_queue_t default_queue; odp_cos_t default_cos; odp_pool_t default_pool; - odp_pool_param_t pool_param; odp_pool_t pool; odp_pool_t recvpool; odp_pmr_t pmr; odp_cos_t cos; char cosname[ODP_COS_NAME_LEN]; - char poolname[ODP_POOL_NAME_LEN]; - char queuename[ODP_QUEUE_NAME_LEN]; odp_pmr_match_t match; + odp_cls_cos_param_t cls_param; val = CLS_DEFAULT_SPORT; mask = 0xffff; @@ -543,30 +487,20 @@ static void classification_test_pmr_term_udp_sport(void) pmr = odp_pmr_create(&match); CU_ASSERT(pmr != ODP_PMR_INVAL); - sprintf(cosname, "udp_sport"); - cos = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - - sprintf(queuename, "%s", "udp_sport"); - - queue = queue_create(queuename, true); + queue = queue_create("udp_sport", true); CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); - retval = odp_cos_queue_set(cos, queue); - CU_ASSERT(retval == 0); - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; - sprintf(poolname, "%s", "udp_sport"); - - pool = odp_pool_create(poolname, &pool_param); + pool = pool_create("udp_sport"); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos, pool); - CU_ASSERT(retval == 0); + sprintf(cosname, "udp_sport"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); retval = odp_pktio_pmr_cos(pmr, pktio, cos); CU_ASSERT(retval == 0); @@ -635,10 +569,8 @@ static void classification_test_pmr_term_ipproto(void) odp_pool_t recvpool; odp_pmr_t pmr; odp_cos_t cos; - odp_pool_param_t pool_param; char cosname[ODP_COS_NAME_LEN]; - char poolname[ODP_POOL_NAME_LEN]; - char queuename[ODP_QUEUE_NAME_LEN]; + odp_cls_cos_param_t cls_param; odp_pmr_match_t match; val = ODPH_IPPROTO_UDP; @@ -657,29 +589,124 @@ static void classification_test_pmr_term_ipproto(void) pmr = odp_pmr_create(&match); CU_ASSERT(pmr != ODP_PMR_INVAL); + queue = queue_create("ipproto", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("ipproto"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + sprintf(cosname, "ipproto"); - cos = odp_cos_create(cosname); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos != ODP_COS_INVALID); - sprintf(queuename, "%s", "ipproto"); + retval = odp_pktio_pmr_cos(pmr, pktio, cos); + CU_ASSERT(retval == 0); - queue = queue_create(queuename, true); - CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, true); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); + CU_ASSERT(retqueue == queue); + odp_packet_free(pkt); + + /* Other packets delivered to default queue */ + pkt = create_packet(pkt_pool, false, &seq, false); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); + CU_ASSERT(retqueue == default_queue); + + odp_cos_destroy(cos); + odp_cos_destroy(default_cos); + odp_pmr_destroy(pmr); + odp_packet_free(pkt); + destroy_inq(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); + odp_queue_destroy(queue); + odp_queue_destroy(default_queue); + odp_pktio_close(pktio); +} + +static void classification_test_pmr_pool_set(void) +{ + odp_packet_t pkt; + uint32_t seqno; + uint8_t val; + uint8_t mask; + int retval; + odp_pktio_t pktio; + odp_queue_t queue; + odp_queue_t retqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_t pool; + odp_pool_t pool_new; + odp_pool_t recvpool; + odp_pmr_t pmr; + odp_cos_t cos; + char cosname[ODP_COS_NAME_LEN]; + odp_cls_cos_param_t cls_param; + odp_pmr_match_t match; - retval = odp_cos_queue_set(cos, queue); + val = ODPH_IPPROTO_UDP; + mask = 0xff; + seqno = 0; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); CU_ASSERT(retval == 0); - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; - sprintf(poolname, "%s", "ipproto"); + match.term = ODP_PMR_IPPROTO; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_pmr_create(&match); + CU_ASSERT(pmr != ODP_PMR_INVAL); - pool = odp_pool_create(poolname, &pool_param); + queue = queue_create("ipproto1", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("ipproto1"); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos, pool); + sprintf(cosname, "ipproto1"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + pool_new = pool_create("ipproto2"); + CU_ASSERT_FATAL(pool_new != ODP_POOL_INVALID); + + /* new pool is set on CoS */ + retval = odp_cls_cos_pool_set(cos, pool_new); CU_ASSERT(retval == 0); retval = odp_pktio_pmr_cos(pmr, pktio, cos); @@ -697,12 +724,89 @@ static void classification_test_pmr_term_ipproto(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); recvpool = odp_packet_pool(pkt); - CU_ASSERT(recvpool == pool); + CU_ASSERT(recvpool == pool_new); CU_ASSERT(retqueue == queue); odp_packet_free(pkt); - /* Other packets delivered to default queue */ - pkt = create_packet(pkt_pool, false, &seq, false); + odp_cos_destroy(cos); + odp_cos_destroy(default_cos); + odp_pmr_destroy(pmr); + odp_packet_free(pkt); + destroy_inq(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); + odp_pool_destroy(pool_new); + odp_queue_destroy(queue); + odp_queue_destroy(default_queue); + odp_pktio_close(pktio); +} + +static void classification_test_pmr_queue_set(void) +{ + odp_packet_t pkt; + uint32_t seqno; + uint8_t val; + uint8_t mask; + int retval; + odp_pktio_t pktio; + odp_queue_t queue; + odp_queue_t retqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_t pool; + odp_queue_t queue_new; + odp_pool_t recvpool; + odp_pmr_t pmr; + odp_cos_t cos; + char cosname[ODP_COS_NAME_LEN]; + odp_cls_cos_param_t cls_param; + odp_pmr_match_t match; + + val = ODPH_IPPROTO_UDP; + mask = 0xff; + seqno = 0; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED); + retval = create_default_inq(pktio, ODP_QUEUE_TYPE_SCHED); + CU_ASSERT(retval == 0); + + match.term = ODP_PMR_IPPROTO; + match.val = &val; + match.mask = &mask; + match.val_sz = sizeof(val); + + pmr = odp_pmr_create(&match); + CU_ASSERT(pmr != ODP_PMR_INVAL); + + queue = queue_create("ipproto1", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("ipproto1"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + sprintf(cosname, "ipproto1"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + queue_new = queue_create("ipproto2", true); + CU_ASSERT_FATAL(queue_new != ODP_QUEUE_INVALID); + + /* new queue is set on CoS */ + retval = odp_cos_queue_set(cos, queue_new); + CU_ASSERT(retval == 0); + + retval = odp_pktio_pmr_cos(pmr, pktio, cos); + CU_ASSERT(retval == 0); + + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + pkt = create_packet(pkt_pool, false, &seq, true); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); @@ -712,8 +816,9 @@ static void classification_test_pmr_term_ipproto(void) CU_ASSERT(pkt != ODP_PACKET_INVALID); CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); recvpool = odp_packet_pool(pkt); - CU_ASSERT(recvpool == default_pool); - CU_ASSERT(retqueue == default_queue); + CU_ASSERT(recvpool == pool); + CU_ASSERT(retqueue == queue_new); + odp_packet_free(pkt); odp_cos_destroy(cos); odp_cos_destroy(default_cos); @@ -722,6 +827,7 @@ static void classification_test_pmr_term_ipproto(void) destroy_inq(pktio); odp_pool_destroy(default_pool); odp_pool_destroy(pool); + odp_queue_destroy(queue_new); odp_queue_destroy(queue); odp_queue_destroy(default_queue); odp_pktio_close(pktio); @@ -733,5 +839,7 @@ odp_testinfo_t classification_suite_pmr[] = { ODP_TEST_INFO(classification_test_pmr_term_udp_dport), ODP_TEST_INFO(classification_test_pmr_term_udp_sport), ODP_TEST_INFO(classification_test_pmr_term_ipproto), + ODP_TEST_INFO(classification_test_pmr_pool_set), + ODP_TEST_INFO(classification_test_pmr_queue_set), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index b64d841..99242d0 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -25,7 +25,6 @@ odp_atomic_u32_t seq; int classification_suite_init(void) { - odp_pool_param_t param; odp_queue_t inq_def; odp_queue_param_t qparam; char queuename[ODP_QUEUE_NAME_LEN]; @@ -33,13 +32,7 @@ int classification_suite_init(void) int ret; odp_pktio_param_t pktio_param; - odp_pool_param_init(¶m); - param.pkt.seg_len = SHM_PKT_BUF_SIZE; - param.pkt.len = SHM_PKT_BUF_SIZE; - param.pkt.num = SHM_PKT_NUM_BUFS; - param.type = ODP_POOL_PACKET; - - pool_default = odp_pool_create("classification_pool", ¶m); + pool_default = pool_create("classification_pool"); if (ODP_POOL_INVALID == pool_default) { fprintf(stderr, "Packet pool creation failed.\n"); return -1; @@ -55,6 +48,7 @@ int classification_suite_init(void) fprintf(stderr, "unable to destroy pool.\n"); return -1; } + odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; @@ -136,16 +130,13 @@ void configure_cls_pmr_chain(void) int retval; char cosname[ODP_QUEUE_NAME_LEN]; odp_queue_param_t qparam; - odp_pool_param_t pool_param; + odp_cls_cos_param_t cls_param; char queuename[ODP_QUEUE_NAME_LEN]; char poolname[ODP_POOL_NAME_LEN]; uint32_t addr; uint32_t mask; odp_pmr_match_t match; - sprintf(cosname, "SrcCos"); - cos_list[CLS_PMR_CHAIN_SRC] = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_SRC] != ODP_COS_INVALID); odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_NORMAL; @@ -160,27 +151,18 @@ void configure_cls_pmr_chain(void) CU_ASSERT_FATAL(queue_list[CLS_PMR_CHAIN_SRC] != ODP_QUEUE_INVALID); - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; sprintf(poolname, "%s", "SrcPool"); - - pool_list[CLS_PMR_CHAIN_SRC] = odp_pool_create(poolname, &pool_param); + pool_list[CLS_PMR_CHAIN_SRC] = pool_create(poolname); CU_ASSERT_FATAL(pool_list[CLS_PMR_CHAIN_SRC] != ODP_POOL_INVALID); - retval = odp_cos_queue_set(cos_list[CLS_PMR_CHAIN_SRC], - queue_list[CLS_PMR_CHAIN_SRC]); - CU_ASSERT(retval == 0); - - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_CHAIN_SRC], - pool_list[CLS_PMR_CHAIN_SRC]); - CU_ASSERT(retval == 0); + sprintf(cosname, "SrcCos"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool_list[CLS_PMR_CHAIN_SRC]; + cls_param.queue = queue_list[CLS_PMR_CHAIN_SRC]; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_list[CLS_PMR_CHAIN_SRC] = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_SRC] != ODP_COS_INVALID); - sprintf(cosname, "DstCos"); - cos_list[CLS_PMR_CHAIN_DST] = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_DST] != ODP_COS_INVALID); odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_NORMAL; @@ -193,23 +175,17 @@ void configure_cls_pmr_chain(void) &qparam); CU_ASSERT_FATAL(queue_list[CLS_PMR_CHAIN_DST] != ODP_QUEUE_INVALID); - retval = odp_cos_queue_set(cos_list[CLS_PMR_CHAIN_DST], - queue_list[CLS_PMR_CHAIN_DST]); - CU_ASSERT(retval == 0); - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; sprintf(poolname, "%s", "DstPool"); - - pool_list[CLS_PMR_CHAIN_DST] = odp_pool_create(poolname, &pool_param); + pool_list[CLS_PMR_CHAIN_DST] = pool_create(poolname); CU_ASSERT_FATAL(pool_list[CLS_PMR_CHAIN_DST] != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_CHAIN_DST], - pool_list[CLS_PMR_CHAIN_DST]); - CU_ASSERT(retval == 0); + sprintf(cosname, "DstCos"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool_list[CLS_PMR_CHAIN_DST]; + cls_param.queue = queue_list[CLS_PMR_CHAIN_DST]; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_list[CLS_PMR_CHAIN_DST] = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_DST] != ODP_COS_INVALID); parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask); match.term = ODP_PMR_SIP_ADDR; @@ -296,15 +272,11 @@ void configure_pktio_default_cos(void) { int retval; odp_queue_param_t qparam; - odp_pool_param_t pool_param; + odp_cls_cos_param_t cls_param; char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; char poolname[ODP_POOL_NAME_LEN]; - sprintf(cosname, "DefaultCoS"); - cos_list[CLS_DEFAULT] = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos_list[CLS_DEFAULT] != ODP_COS_INVALID); - odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_NONE; @@ -314,23 +286,17 @@ void configure_pktio_default_cos(void) ODP_QUEUE_TYPE_SCHED, &qparam); CU_ASSERT_FATAL(queue_list[CLS_DEFAULT] != ODP_QUEUE_INVALID); - retval = odp_cos_queue_set(cos_list[CLS_DEFAULT], - queue_list[CLS_DEFAULT]); - CU_ASSERT(retval == 0); - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; sprintf(poolname, "DefaultPool"); - - pool_list[CLS_DEFAULT] = odp_pool_create(poolname, &pool_param); + pool_list[CLS_DEFAULT] = pool_create(poolname); CU_ASSERT_FATAL(pool_list[CLS_DEFAULT] != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos_list[CLS_DEFAULT], - pool_list[CLS_DEFAULT]); - CU_ASSERT(retval == 0); + sprintf(cosname, "DefaultCoS"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool_list[CLS_DEFAULT]; + cls_param.queue = queue_list[CLS_DEFAULT]; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_list[CLS_DEFAULT] = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos_list[CLS_DEFAULT] != ODP_COS_INVALID); retval = odp_pktio_default_cos_set(pktio_loop, cos_list[CLS_DEFAULT]); CU_ASSERT(retval == 0); @@ -364,7 +330,7 @@ void configure_pktio_error_cos(void) { int retval; odp_queue_param_t qparam; - odp_pool_param_t pool_param; + odp_cls_cos_param_t cls_param; char queuename[ODP_QUEUE_NAME_LEN]; char cosname[ODP_COS_NAME_LEN]; char poolname[ODP_POOL_NAME_LEN]; @@ -380,26 +346,17 @@ void configure_pktio_error_cos(void) &qparam); CU_ASSERT_FATAL(queue_list[CLS_ERROR] != ODP_QUEUE_INVALID); - sprintf(cosname, "%s", "ErrorCos"); - cos_list[CLS_ERROR] = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos_list[CLS_ERROR] != ODP_COS_INVALID); - - retval = odp_cos_queue_set(cos_list[CLS_ERROR], queue_list[CLS_ERROR]); - CU_ASSERT(retval == 0); - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; sprintf(poolname, "ErrorPool"); - - pool_list[CLS_ERROR] = odp_pool_create(poolname, &pool_param); + pool_list[CLS_ERROR] = pool_create(poolname); CU_ASSERT_FATAL(pool_list[CLS_ERROR] != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos_list[CLS_ERROR], - pool_list[CLS_ERROR]); - CU_ASSERT(retval == 0); + sprintf(cosname, "%s", "ErrorCos"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool_list[CLS_ERROR]; + cls_param.queue = queue_list[CLS_ERROR]; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_list[CLS_ERROR] = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos_list[CLS_ERROR] != ODP_COS_INVALID); retval = odp_pktio_error_cos_set(pktio_loop, cos_list[CLS_ERROR]); CU_ASSERT(retval == 0); @@ -471,14 +428,7 @@ void configure_cos_with_l2_priority(void) int retval; int i; odp_queue_param_t qparam; - odp_pool_param_t pool_param; - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; - + odp_cls_cos_param_t cls_param; /** Initialize scalar variable qos_tbl **/ for (i = 0; i < CLS_L2_QOS_MAX; i++) @@ -489,32 +439,31 @@ void configure_cos_with_l2_priority(void) qparam.sched.group = ODP_SCHED_GROUP_ALL; for (i = 0; i < num_qos; i++) { qparam.sched.prio = ODP_SCHED_PRIO_LOWEST - i; - sprintf(cosname, "%s_%d", "L2_Cos", i); - cos_tbl[i] = odp_cos_create(cosname); - if (cos_tbl[i] == ODP_COS_INVALID) - break; - - cos_list[CLS_L2_QOS_0 + i] = cos_tbl[i]; sprintf(queuename, "%s_%d", "L2_Queue", i); queue_tbl[i] = odp_queue_create(queuename, ODP_QUEUE_TYPE_SCHED, &qparam); CU_ASSERT_FATAL(queue_tbl[i] != ODP_QUEUE_INVALID); queue_list[CLS_L2_QOS_0 + i] = queue_tbl[i]; - retval = odp_cos_queue_set(cos_tbl[i], queue_tbl[i]); - CU_ASSERT(retval == 0); - sprintf(poolname, "%s_%d", "L2_Pool", i); - pool = odp_pool_create(poolname, &pool_param); + pool = pool_create(poolname); CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); pool_list[CLS_L2_QOS_0 + i] = pool; - retval = odp_cls_cos_pool_set(cos_tbl[i], pool); - CU_ASSERT(retval == 0); + sprintf(cosname, "%s_%d", "L2_Cos", i); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue_tbl[i]; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_tbl[i] = odp_cls_cos_create(cosname, &cls_param); + if (cos_tbl[i] == ODP_COS_INVALID) + break; + + cos_list[CLS_L2_QOS_0 + i] = cos_tbl[i]; qos_tbl[i] = i; } /* count 'i' is passed instead of num_qos to handle the rare scenario - if the odp_cos_create() failed in the middle*/ + if the odp_cls_cos_create() failed in the middle*/ retval = odp_cos_with_l2_priority(pktio_loop, i, qos_tbl, cos_tbl); CU_ASSERT(retval == 0); } @@ -554,10 +503,10 @@ void configure_pmr_cos(void) int retval; odp_pmr_match_t match; odp_queue_param_t qparam; + odp_cls_cos_param_t cls_param; char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; char poolname[ODP_POOL_NAME_LEN]; - odp_pool_param_t pool_param; val = CLS_PMR_SPORT; mask = 0xffff; @@ -569,10 +518,6 @@ void configure_pmr_cos(void) pmr_list[CLS_PMR] = odp_pmr_create(&match); CU_ASSERT(pmr_list[CLS_PMR] != ODP_PMR_INVAL); - sprintf(cosname, "PMR_CoS"); - cos_list[CLS_PMR] = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos_list[CLS_PMR] != ODP_COS_INVALID); - odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; qparam.sched.sync = ODP_SCHED_SYNC_NONE; @@ -584,22 +529,17 @@ void configure_pmr_cos(void) &qparam); CU_ASSERT_FATAL(queue_list[CLS_PMR] != ODP_QUEUE_INVALID); - retval = odp_cos_queue_set(cos_list[CLS_PMR], - queue_list[CLS_PMR]); - CU_ASSERT(retval == 0); - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; sprintf(poolname, "PMR_Pool"); - - pool_list[CLS_PMR] = odp_pool_create(poolname, &pool_param); + pool_list[CLS_PMR] = pool_create(poolname); CU_ASSERT_FATAL(pool_list[CLS_PMR] != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR], pool_list[CLS_PMR]); - CU_ASSERT(retval == 0); + sprintf(cosname, "PMR_CoS"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool_list[CLS_PMR]; + cls_param.queue = queue_list[CLS_PMR]; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_list[CLS_PMR] = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos_list[CLS_PMR] != ODP_COS_INVALID); retval = odp_pktio_pmr_cos(pmr_list[CLS_PMR], pktio_loop, cos_list[CLS_PMR]); @@ -637,10 +577,10 @@ void configure_pktio_pmr_match_set_cos(void) uint16_t maskport; int num_terms = 2; /* one pmr for each L3 and L4 */ odp_queue_param_t qparam; + odp_cls_cos_param_t cls_param; char cosname[ODP_COS_NAME_LEN]; char queuename[ODP_QUEUE_NAME_LEN]; char poolname[ODP_POOL_NAME_LEN]; - odp_pool_param_t pool_param; uint32_t addr = 0; uint32_t mask; @@ -661,10 +601,6 @@ void configure_pktio_pmr_match_set_cos(void) retval = odp_pmr_match_set_create(num_terms, pmr_terms, &pmr_set); CU_ASSERT(retval > 0); - sprintf(cosname, "cos_pmr_set"); - cos_list[CLS_PMR_SET] = odp_cos_create(cosname); - CU_ASSERT_FATAL(cos_list[CLS_PMR_SET] != ODP_COS_INVALID); - odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_HIGHEST; qparam.sched.sync = ODP_SCHED_SYNC_NONE; @@ -676,22 +612,17 @@ void configure_pktio_pmr_match_set_cos(void) &qparam); CU_ASSERT_FATAL(queue_list[CLS_PMR_SET] != ODP_QUEUE_INVALID); - retval = odp_cos_queue_set(cos_list[CLS_PMR_SET], - queue_list[CLS_PMR_SET]); - CU_ASSERT(retval == 0); - - odp_pool_param_init(&pool_param); - pool_param.pkt.seg_len = SHM_PKT_BUF_SIZE; - pool_param.pkt.len = SHM_PKT_BUF_SIZE; - pool_param.pkt.num = SHM_PKT_NUM_BUFS; - pool_param.type = ODP_POOL_PACKET; sprintf(poolname, "cos_pmr_set_pool"); - - pool_list[CLS_PMR_SET] = odp_pool_create(poolname, &pool_param); + pool_list[CLS_PMR_SET] = pool_create(poolname); CU_ASSERT_FATAL(pool_list[CLS_PMR_SET] != ODP_POOL_INVALID); - retval = odp_cls_cos_pool_set(cos_list[CLS_PMR_SET], - pool_list[CLS_PMR_SET]); - CU_ASSERT(retval == 0); + + sprintf(cosname, "cos_pmr_set"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool_list[CLS_PMR_SET]; + cls_param.queue = queue_list[CLS_PMR_SET]; + cls_param.drop_policy = ODP_COS_DROP_POOL; + cos_list[CLS_PMR_SET] = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos_list[CLS_PMR_SET] != ODP_COS_INVALID); retval = odp_pktio_pmr_match_set_cos(pmr_set, pktio_loop, cos_list[CLS_PMR_SET]); diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index a09067c..02828e1 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -31,7 +31,8 @@ void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos, int parse_ipv4_string(const char *ipaddress, uint32_t *addr, uint32_t *mask); void enqueue_pktio_interface(odp_packet_t pkt, odp_pktio_t pktio); odp_packet_t receive_packet(odp_queue_t *queue, uint64_t ns); -odp_queue_t queue_create(char *queuename, bool sched); +odp_pool_t pool_create(const char *poolname); +odp_queue_t queue_create(const char *queuename, bool sched); void configure_pktio_default_cos(void); void test_pktio_default_cos(void); void configure_pktio_error_cos(void);
Replaces odp_cos_create() function with odp_cls_cos_create() function Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> --- test/validation/classification/classification.h | 1 + .../classification/odp_classification_basic.c | 137 +++++++- .../classification/odp_classification_common.c | 15 +- .../classification/odp_classification_test_pmr.c | 386 +++++++++++++-------- .../classification/odp_classification_tests.c | 207 ++++------- .../classification/odp_classification_testsuites.h | 3 +- 6 files changed, 453 insertions(+), 296 deletions(-)