diff mbox

[API-NEXT,PATCHv2,5/5] example: classifier: add odp_cls_cos_pool_set() api

Message ID 1448273572-27435-5-git-send-email-bala.manoharan@linaro.org
State New
Headers show

Commit Message

Balasubramanian Manoharan Nov. 23, 2015, 10:12 a.m. UTC
Adds packet pool to CoS using odp_cls_cos_pool_set() api.

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
 example/classifier/odp_classifier.c | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

Comments

Ivan Khoronzhuk Nov. 30, 2015, 9:29 a.m. UTC | #1
On 23.11.15 12:12, Balasubramanian Manoharan wrote:
> Adds packet pool to CoS using odp_cls_cos_pool_set() api.
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
>   example/classifier/odp_classifier.c | 37 ++++++++++++++++++++++++++++++-------
>   1 file changed, 30 insertions(+), 7 deletions(-)
>
> diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
> index 365c748..fb9f407 100644
> --- a/example/classifier/odp_classifier.c
> +++ b/example/classifier/odp_classifier.c
> @@ -85,8 +85,12 @@ static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned len);
>   static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
>   static void print_info(char *progname, appl_args_t *appl_args);
>   static void usage(char *progname);
> -static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args);
> -static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args);
> +static void configure_cos_queue(odp_pktio_t pktio,
Seems function name doesn't correspond to the actual things it does now.

> +				appl_args_t *args,
> +				odp_pool_t pool);
> +static void configure_default_queue(odp_pktio_t pktio,
> +				    appl_args_t *args,
> +				    odp_pool_t pool);
Seems function name doesn't correspond to the actual things it does now.

>   static int convert_str_to_pmr_enum(char *token, odp_pmr_term_e *term,
>   				   uint32_t *offset);
>   static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg);
> @@ -320,7 +324,6 @@ static void *pktio_receive_thread(void *arg)
>
>   		/* Swap Eth MACs and possibly IP-addrs before sending back */
>   		swap_pkt_addrs(&pkt, 1);
> -
>   		for (i = 0; i <  MAX_PMR_COUNT; i++) {
>   			stats = &appl->stats[i];
>   			if (queue == stats->queue)
> @@ -341,7 +344,9 @@ static void *pktio_receive_thread(void *arg)
>   	return NULL;
>   }
>
> -static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
> +static void configure_default_queue(odp_pktio_t pktio,
> +				    appl_args_t *args,
> +				    odp_pool_t pool)
>   {
>   	odp_queue_param_t qparam;
>   	odp_cos_t cos_default;
> @@ -365,6 +370,11 @@ static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
>   		exit(EXIT_FAILURE);
>   	}
>
> +	if (0 > odp_cls_cos_pool_set(cos_default, pool)) {
> +		EXAMPLE_ERR("odp_cls_cos_pool_set failed");
> +		exit(EXIT_FAILURE);
> +	}
> +
>   	if (0 > odp_pktio_default_cos_set(pktio, cos_default)) {
>   		EXAMPLE_ERR("odp_pktio_default_cos_set failed");
>   		exit(EXIT_FAILURE);
> @@ -379,7 +389,9 @@ static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
>   	args->policy_count++;
>   }
>
> -static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
> +static void configure_cos_queue(odp_pktio_t pktio,
> +				appl_args_t *args,
> +				odp_pool_t pool)
>   {
>   	char cos_name[ODP_COS_NAME_LEN];
>   	char queue_name[ODP_QUEUE_NAME_LEN];
> @@ -402,6 +414,7 @@ static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
>   		};
>
>   		stats->pmr = odp_pmr_create(&match);
> +		odp_queue_param_init(&qparam);
>   		qparam.sched.prio = i % odp_schedule_num_prio();
>   		qparam.sched.sync = ODP_SCHED_SYNC_NONE;
>   		qparam.sched.group = ODP_SCHED_GROUP_ALL;
> @@ -411,11 +424,21 @@ static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
>   		stats->queue = odp_queue_create(queue_name,
>   						 ODP_QUEUE_TYPE_SCHED,
>   						 &qparam);
> +		if (ODP_QUEUE_INVALID == stats->queue) {
> +			EXAMPLE_ERR("odp_queue_create failed");
> +			exit(EXIT_FAILURE);
> +		}
> +
>   		if (0 > odp_cos_queue_set(stats->cos, stats->queue)) {
>   			EXAMPLE_ERR("odp_cos_queue_set failed");
>   			exit(EXIT_FAILURE);
>   		}
>
> +		if (0 > odp_cls_cos_pool_set(stats->cos, pool)) {
> +			EXAMPLE_ERR("odp_cls_cos_pool_set failed");
> +			exit(EXIT_FAILURE);
> +		}
> +
>   		if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) {
>   			EXAMPLE_ERR("odp_pktio_pmr_cos failed");
>   			exit(EXIT_FAILURE);
> @@ -510,10 +533,10 @@ int main(int argc, char *argv[])
>   	/* create pktio per interface */
>   	pktio = create_pktio(args->if_name, pool);
>
> -	configure_cos_queue(pktio, args);
> +	configure_cos_queue(pktio, args, pool);
>
>   	/* configure default Cos and default queue */
> -	configure_default_queue(pktio, args);
> +	configure_default_queue(pktio, args, pool);
>
>   	if (odp_pktio_start(pktio)) {
>   		EXAMPLE_ERR("Error: unable to start pktio.\n");
>
diff mbox

Patch

diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index 365c748..fb9f407 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -85,8 +85,12 @@  static void swap_pkt_addrs(odp_packet_t pkt_tbl[], unsigned len);
 static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
 static void print_info(char *progname, appl_args_t *appl_args);
 static void usage(char *progname);
-static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args);
-static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args);
+static void configure_cos_queue(odp_pktio_t pktio,
+				appl_args_t *args,
+				odp_pool_t pool);
+static void configure_default_queue(odp_pktio_t pktio,
+				    appl_args_t *args,
+				    odp_pool_t pool);
 static int convert_str_to_pmr_enum(char *token, odp_pmr_term_e *term,
 				   uint32_t *offset);
 static int parse_pmr_policy(appl_args_t *appl_args, char *argv[], char *optarg);
@@ -320,7 +324,6 @@  static void *pktio_receive_thread(void *arg)
 
 		/* Swap Eth MACs and possibly IP-addrs before sending back */
 		swap_pkt_addrs(&pkt, 1);
-
 		for (i = 0; i <  MAX_PMR_COUNT; i++) {
 			stats = &appl->stats[i];
 			if (queue == stats->queue)
@@ -341,7 +344,9 @@  static void *pktio_receive_thread(void *arg)
 	return NULL;
 }
 
-static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
+static void configure_default_queue(odp_pktio_t pktio,
+				    appl_args_t *args,
+				    odp_pool_t pool)
 {
 	odp_queue_param_t qparam;
 	odp_cos_t cos_default;
@@ -365,6 +370,11 @@  static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
 		exit(EXIT_FAILURE);
 	}
 
+	if (0 > odp_cls_cos_pool_set(cos_default, pool)) {
+		EXAMPLE_ERR("odp_cls_cos_pool_set failed");
+		exit(EXIT_FAILURE);
+	}
+
 	if (0 > odp_pktio_default_cos_set(pktio, cos_default)) {
 		EXAMPLE_ERR("odp_pktio_default_cos_set failed");
 		exit(EXIT_FAILURE);
@@ -379,7 +389,9 @@  static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
 	args->policy_count++;
 }
 
-static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
+static void configure_cos_queue(odp_pktio_t pktio,
+				appl_args_t *args,
+				odp_pool_t pool)
 {
 	char cos_name[ODP_COS_NAME_LEN];
 	char queue_name[ODP_QUEUE_NAME_LEN];
@@ -402,6 +414,7 @@  static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
 		};
 
 		stats->pmr = odp_pmr_create(&match);
+		odp_queue_param_init(&qparam);
 		qparam.sched.prio = i % odp_schedule_num_prio();
 		qparam.sched.sync = ODP_SCHED_SYNC_NONE;
 		qparam.sched.group = ODP_SCHED_GROUP_ALL;
@@ -411,11 +424,21 @@  static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
 		stats->queue = odp_queue_create(queue_name,
 						 ODP_QUEUE_TYPE_SCHED,
 						 &qparam);
+		if (ODP_QUEUE_INVALID == stats->queue) {
+			EXAMPLE_ERR("odp_queue_create failed");
+			exit(EXIT_FAILURE);
+		}
+
 		if (0 > odp_cos_queue_set(stats->cos, stats->queue)) {
 			EXAMPLE_ERR("odp_cos_queue_set failed");
 			exit(EXIT_FAILURE);
 		}
 
+		if (0 > odp_cls_cos_pool_set(stats->cos, pool)) {
+			EXAMPLE_ERR("odp_cls_cos_pool_set failed");
+			exit(EXIT_FAILURE);
+		}
+
 		if (0 > odp_pktio_pmr_cos(stats->pmr, pktio, stats->cos)) {
 			EXAMPLE_ERR("odp_pktio_pmr_cos failed");
 			exit(EXIT_FAILURE);
@@ -510,10 +533,10 @@  int main(int argc, char *argv[])
 	/* create pktio per interface */
 	pktio = create_pktio(args->if_name, pool);
 
-	configure_cos_queue(pktio, args);
+	configure_cos_queue(pktio, args, pool);
 
 	/* configure default Cos and default queue */
-	configure_default_queue(pktio, args);
+	configure_default_queue(pktio, args, pool);
 
 	if (odp_pktio_start(pktio)) {
 		EXAMPLE_ERR("Error: unable to start pktio.\n");