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"); 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); }
static odp_cos_t build_cos_w_queue(const char *name) { odp_cos_t cos; odp_queue_t queue_cos; odp_queue_param_t qparam; odp_cls_cos_param_t cos_param; odp_queue_param_init(&qparam); qparam.type = ODP_QUEUE_TYPE_SCHED; qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_ALL; queue_cos = odp_queue_create(name, &qparam); if (queue_cos == ODP_QUEUE_INVALID) { OFP_ERR("Failed to create queue\n"); return ODP_COS_INVALID; } odp_cls_cos_param_init(&cos_param); cos_param.queue = queue_cos; cos_param.pool = odp_pool_lookup(SHM_PKT_POOL_NAME); cos = odp_cls_cos_create(name, &cos_param); if (cos == ODP_COS_INVALID) { OFP_ERR("Failed to create COS"); odp_cos_destroy(cos); odp_queue_destroy(queue_cos); return ODP_COS_INVALID; } return cos; }
void classification_test_cos_set_drop(void) { int retval; char cosname[ODP_COS_NAME_LEN]; odp_cos_t cos_drop; 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); CU_ASSERT(retval == 0); 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); }
static odp_cos_t build_cos_set_queue(const char *name, odp_queue_t queue_cos) { odp_cos_t cos; odp_cls_cos_param_t cos_param; odp_cls_cos_param_init(&cos_param); cos_param.queue = queue_cos; cos_param.pool = odp_pool_lookup(SHM_PKT_POOL_NAME); cos = odp_cls_cos_create(name, &cos_param); if (cos == ODP_COS_INVALID) { OFP_ERR("Failed to create COS"); return ODP_COS_INVALID; } return cos; }