aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorJere Leppänen <jere.leppanen@nokia.com>2022-09-26 11:17:35 +0300
committerPetri Savolainen <petri.savolainen@nokia.com>2022-10-20 12:17:21 +0300
commitd46af42449b414efc04a95f0097eaf73299a56af (patch)
tree1420c3baff161bff3cbbce1552827714d17246ae /example
parentf63f981427de76276871222884f725b56df28308 (diff)
example: classifier: add parse layer option
Add option to set parse layer. Default is to parse all layers. Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'example')
-rw-r--r--example/classifier/odp_classifier.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index d5e097818..f64df711e 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -94,6 +94,7 @@ typedef struct {
int verbose;
int promisc_mode; /**< Promiscuous mode enabled */
int classifier_enable;
+ int parse_layer;
} appl_args_t;
enum packet_mode {
@@ -241,6 +242,7 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool)
odp_pktio_param_t pktio_param;
odp_pktin_queue_param_t pktin_param;
odp_pktio_capability_t capa;
+ odp_pktio_config_t cfg;
odp_pktio_param_init(&pktio_param);
pktio_param.in_mode = ODP_PKTIN_MODE_SCHED;
@@ -291,6 +293,13 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool)
odp_pktio_to_u64(pktio), dev,
odp_pktio_to_u64(pktio));
+ odp_pktio_config_init(&cfg);
+ cfg.parser.layer = appl_args_gbl->parse_layer;
+ if (odp_pktio_config(pktio, &cfg)) {
+ ODPH_ERR("failed to configure pktio %s\n", dev);
+ exit(EXIT_FAILURE);
+ }
+
return pktio;
}
@@ -1127,15 +1136,17 @@ static int parse_args(int argc, char *argv[], appl_args_t *appl_args)
{"verbose", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{"enable", required_argument, NULL, 'e'},
+ {"layer", required_argument, NULL, 'l'},
{NULL, 0, NULL, 0}
};
- static const char *shortopts = "+c:t:i:p:m:t:C:Pvhe:";
+ static const char *shortopts = "+c:t:i:p:m:t:C:Pvhe:l:";
appl_args->cpu_count = 1; /* Use one worker by default */
appl_args->verbose = 0;
appl_args->promisc_mode = 0;
appl_args->classifier_enable = 1;
+ appl_args->parse_layer = ODP_PROTO_LAYER_ALL;
while (ret == 0) {
opt = getopt_long(argc, argv, shortopts,
@@ -1199,6 +1210,9 @@ static int parse_args(int argc, char *argv[], appl_args_t *appl_args)
case 'e':
appl_args->classifier_enable = atoi(optarg);
break;
+ case 'l':
+ appl_args->parse_layer = atoi(optarg);
+ break;
default:
break;
}
@@ -1285,6 +1299,9 @@ static void usage(void)
" 1: Classifier is enabled\n"
" default: Classifier is enabled\n"
"\n"
+ " -l, --layer <layer> Parse packets up to and including this layer. See odp_proto_layer_t\n"
+ " default: ODP_PROTO_LAYER_ALL\n"
+ "\n"
" -C, --ci_pass <dst queue:count>\n"
" Minimum acceptable packet count for a CoS destination queue.\n"
" If the received packet count is smaller than this value,\n"