Defined single queue configuration to be the default for pktin and pktout queues. Passing NULL into config functions result default configuration. This simplifies greatly single queue configuration.
Signed-off-by: Petri Savolainen <[email protected]> --- include/odp/api/spec/packet_io.h | 33 +++++++++++++++++++++------------ platform/linux-generic/odp_packet_io.c | 14 ++++++++++---- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h index 699b3c8..7714f5f 100644 --- a/include/odp/api/spec/packet_io.h +++ b/include/odp/api/spec/packet_io.h @@ -162,7 +162,7 @@ typedef struct odp_pktin_queue_param_t { * require input hashing or classifier setup. Hash_proto is ignored * when hash_enable is zero or num_queues is one. This value must be * between 1 and interface capability. Queue type is defined by the - * input mode. */ + * input mode. The default value is 1. */ unsigned num_queues; /** Queue parameters for creating input queues in ODP_PKTIN_MODE_QUEUE @@ -186,7 +186,7 @@ typedef struct odp_pktout_queue_param_t { odp_pktio_op_mode_t op_mode; /** Number of output queues to be created. The value must be between - * 1 and interface capability */ + * 1 and interface capability. The default value is 1. */ unsigned num_queues; } odp_pktout_queue_param_t; @@ -269,14 +269,18 @@ int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa); * * Setup a number of packet input queues and configure those. The maximum number * of queues is platform dependent and can be queried with - * odp_pktio_capability(). Queue handles for input queues can be requested with - * odp_pktin_queue() or odp_pktin_event_queue() after this call. All - * requested queues are setup on success, no queues are setup on failure. - * Each call reconfigures input queues and may invalidate all previous queue - * handles. + * odp_pktio_capability(). Use odp_pktin_queue_param_init() to initialize + * parameters into their default values. Default values are also used when + * 'param' pointer is NULL. + * + * Queue handles for input queues can be requested with odp_pktin_queue() or + * odp_pktin_event_queue() after this call. All requested queues are setup on + * success, no queues are setup on failure. Each call reconfigures input queues + * and may invalidate all previous queue handles. * * @param pktio Packet IO handle - * @param param Packet input queue configuration parameters + * @param param Packet input queue configuration parameters. Uses defaults + * when NULL. * * @retval 0 on success * @retval <0 on failure @@ -291,12 +295,17 @@ int odp_pktin_queue_config(odp_pktio_t pktio, * * Setup a number of packet output queues and configure those. The maximum * number of queues is platform dependent and can be queried with - * odp_pktio_capability(). All requested queues are setup on success, no - * queues are setup on failure. Each call reconfigures output queues and may - * invalidate all previous queue handles. + * odp_pktio_capability(). Use odp_pktout_queue_param_init() to initialize + * parameters into their default values. Default values are also used when + * 'param' pointer is NULL. + * + * All requested queues are setup on success, no queues are setup on failure. + * Each call reconfigures output queues and may invalidate all previous queue + * handles. * * @param pktio Packet IO handle - * @param param Packet output queue configuration parameters + * @param param Packet output queue configuration parameters. Uses defaults + * when NULL. * * @retval 0 on success * @retval <0 on failure diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 12e65f2..7c3bd18 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -868,12 +868,16 @@ void odp_pktin_queue_param_init(odp_pktin_queue_param_t *param) { memset(param, 0, sizeof(odp_pktin_queue_param_t)); param->op_mode = ODP_PKTIO_OP_MT; + param->num_queues = 1; + /* no need to choose queue type since pktin mode defines it */ + odp_queue_param_init(¶m->queue_param); } void odp_pktout_queue_param_init(odp_pktout_queue_param_t *param) { memset(param, 0, sizeof(odp_pktout_queue_param_t)); param->op_mode = ODP_PKTIO_OP_MT; + param->num_queues = 1; } int odp_pktio_info(odp_pktio_t id, odp_pktio_info_t *info) @@ -1062,10 +1066,11 @@ int odp_pktin_queue_config(odp_pktio_t pktio, unsigned num_queues; unsigned i; odp_queue_t queue; + odp_pktin_queue_param_t default_param; if (param == NULL) { - ODP_DBG("no parameters\n"); - return -1; + odp_pktin_queue_param_init(&default_param); + param = &default_param; } entry = get_pktio_entry(pktio); @@ -1167,10 +1172,11 @@ int odp_pktout_queue_config(odp_pktio_t pktio, odp_pktio_capability_t capa; unsigned num_queues; unsigned i; + odp_pktout_queue_param_t default_param; if (param == NULL) { - ODP_DBG("no parameters\n"); - return -1; + odp_pktout_queue_param_init(&default_param); + param = &default_param; } entry = get_pktio_entry(pktio); -- 2.7.1 _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
