LCOV - code coverage report
Current view: top level - app/test-eventdev - evt_options.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 218 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 46 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017 Cavium, Inc
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdio.h>
       6                 :            : #include <stdlib.h>
       7                 :            : #include <string.h>
       8                 :            : #include <inttypes.h>
       9                 :            : #include <getopt.h>
      10                 :            : 
      11                 :            : #include <rte_string_fns.h>
      12                 :            : #include <rte_common.h>
      13                 :            : #include <rte_eventdev.h>
      14                 :            : #include <rte_lcore.h>
      15                 :            : 
      16                 :            : #include "evt_options.h"
      17                 :            : #include "evt_test.h"
      18                 :            : #include "parser.h"
      19                 :            : 
      20                 :            : void
      21                 :          0 : evt_options_default(struct evt_options *opt)
      22                 :            : {
      23                 :            :         memset(opt, 0, sizeof(*opt));
      24                 :          0 :         opt->verbose_level = 1; /* Enable minimal prints */
      25                 :            :         opt->dev_id = 0;
      26                 :          0 :         strncpy(opt->test_name, "order_queue", EVT_TEST_NAME_MAX_LEN);
      27                 :          0 :         opt->nb_flows = 1024;
      28                 :          0 :         opt->socket_id = SOCKET_ID_ANY;
      29                 :          0 :         opt->pool_sz = 16 * 1024;
      30                 :            :         opt->prod_enq_burst_sz = 0;
      31                 :          0 :         opt->wkr_deq_dep = 16;
      32                 :          0 :         opt->nb_pkts = (1ULL << 26); /* do ~64M packets */
      33                 :          0 :         opt->nb_timers = 1E8;
      34                 :          0 :         opt->nb_timer_adptrs = 1;
      35                 :          0 :         opt->timer_tick_nsec = 1E3; /* 1000ns ~ 1us */
      36                 :          0 :         opt->max_tmo_nsec = 1E5;  /* 100000ns ~100us */
      37                 :          0 :         opt->expiry_nsec = 1E4;   /* 10000ns ~10us */
      38                 :          0 :         opt->prod_type = EVT_PROD_TYPE_SYNT;
      39                 :          0 :         opt->eth_queues = 1;
      40                 :          0 :         opt->vector_size = 64;
      41                 :          0 :         opt->vector_tmo_nsec = 100E3;
      42                 :          0 :         opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
      43                 :          0 :         opt->crypto_cipher_alg = RTE_CRYPTO_CIPHER_NULL;
      44                 :            :         opt->crypto_cipher_key_sz = 0;
      45                 :          0 : }
      46                 :            : 
      47                 :            : typedef int (*option_parser_t)(struct evt_options *opt,
      48                 :            :                 const char *arg);
      49                 :            : 
      50                 :            : struct long_opt_parser {
      51                 :            :         const char *lgopt_name;
      52                 :            :         option_parser_t parser_fn;
      53                 :            : };
      54                 :            : 
      55                 :            : static int
      56                 :          0 : evt_parse_nb_flows(struct evt_options *opt, const char *arg)
      57                 :            : {
      58                 :            :         int ret;
      59                 :            : 
      60                 :          0 :         ret = parser_read_uint32(&(opt->nb_flows), arg);
      61                 :            : 
      62                 :          0 :         return ret;
      63                 :            : }
      64                 :            : 
      65                 :            : static int
      66                 :          0 : evt_parse_dev_id(struct evt_options *opt, const char *arg)
      67                 :            : {
      68                 :            :         int ret;
      69                 :            : 
      70                 :          0 :         ret = parser_read_uint8(&(opt->dev_id), arg);
      71                 :            : 
      72                 :          0 :         return ret;
      73                 :            : }
      74                 :            : 
      75                 :            : static int
      76                 :          0 : evt_parse_verbose(struct evt_options *opt, const char *arg __rte_unused)
      77                 :            : {
      78                 :          0 :         opt->verbose_level = atoi(arg);
      79                 :          0 :         return 0;
      80                 :            : }
      81                 :            : 
      82                 :            : static int
      83                 :          0 : evt_parse_fwd_latency(struct evt_options *opt, const char *arg __rte_unused)
      84                 :            : {
      85                 :          0 :         opt->fwd_latency = 1;
      86                 :          0 :         return 0;
      87                 :            : }
      88                 :            : 
      89                 :            : static int
      90                 :          0 : evt_parse_queue_priority(struct evt_options *opt, const char *arg __rte_unused)
      91                 :            : {
      92                 :          0 :         opt->q_priority = 1;
      93                 :          0 :         return 0;
      94                 :            : }
      95                 :            : 
      96                 :            : static int
      97                 :          0 : evt_parse_deq_tmo_nsec(struct evt_options *opt, const char *arg)
      98                 :            : {
      99                 :            :         int ret;
     100                 :            : 
     101                 :          0 :         ret = parser_read_uint32(&(opt->deq_tmo_nsec), arg);
     102                 :            : 
     103                 :          0 :         return ret;
     104                 :            : }
     105                 :            : 
     106                 :            : static int
     107                 :          0 : evt_parse_eth_prod_type(struct evt_options *opt, const char *arg __rte_unused)
     108                 :            : {
     109                 :          0 :         opt->prod_type = EVT_PROD_TYPE_ETH_RX_ADPTR;
     110                 :          0 :         return 0;
     111                 :            : }
     112                 :            : 
     113                 :            : static int
     114                 :          0 : evt_parse_tx_first(struct evt_options *opt, const char *arg __rte_unused)
     115                 :            : {
     116                 :            :         int ret;
     117                 :            : 
     118                 :          0 :         ret = parser_read_uint32(&(opt->tx_first), arg);
     119                 :            : 
     120                 :          0 :         return ret;
     121                 :            : }
     122                 :            : 
     123                 :            : static int
     124                 :          0 : evt_parse_tx_pkt_sz(struct evt_options *opt, const char *arg __rte_unused)
     125                 :            : {
     126                 :            :         int ret;
     127                 :            : 
     128                 :          0 :         ret = parser_read_uint16(&(opt->tx_pkt_sz), arg);
     129                 :            : 
     130                 :          0 :         return ret;
     131                 :            : }
     132                 :            : 
     133                 :            : static int
     134                 :          0 : evt_parse_preschedule(struct evt_options *opt, const char *arg __rte_unused)
     135                 :            : {
     136                 :            :         int ret;
     137                 :            : 
     138                 :          0 :         ret = parser_read_uint8(&(opt->preschedule), arg);
     139                 :          0 :         opt->preschedule_opted = 1;
     140                 :            : 
     141                 :          0 :         return ret;
     142                 :            : }
     143                 :            : 
     144                 :            : static int
     145                 :          0 : evt_parse_timer_prod_type(struct evt_options *opt, const char *arg __rte_unused)
     146                 :            : {
     147                 :          0 :         opt->prod_type = EVT_PROD_TYPE_EVENT_TIMER_ADPTR;
     148                 :          0 :         return 0;
     149                 :            : }
     150                 :            : 
     151                 :            : static int
     152                 :          0 : evt_parse_timer_prod_type_burst(struct evt_options *opt,
     153                 :            :                 const char *arg __rte_unused)
     154                 :            : {
     155                 :          0 :         opt->prod_type = EVT_PROD_TYPE_EVENT_TIMER_ADPTR;
     156                 :          0 :         opt->timdev_use_burst = 1;
     157                 :          0 :         return 0;
     158                 :            : }
     159                 :            : 
     160                 :            : static int
     161                 :          0 : evt_parse_dma_prod_type(struct evt_options *opt,
     162                 :            :                            const char *arg __rte_unused)
     163                 :            : {
     164                 :          0 :         opt->prod_type = EVT_PROD_TYPE_EVENT_DMA_ADPTR;
     165                 :            : 
     166                 :            :         /* Only Forward mode is supported for DMA adapter. */
     167                 :          0 :         opt->dma_adptr_mode = RTE_EVENT_DMA_ADAPTER_OP_FORWARD;
     168                 :            : 
     169                 :          0 :         return 0;
     170                 :            : }
     171                 :            : 
     172                 :            : static int
     173                 :          0 : evt_parse_dma_adptr_mode(struct evt_options *opt, const char *arg)
     174                 :            : {
     175                 :            :         uint8_t mode;
     176                 :            :         int ret;
     177                 :            : 
     178                 :          0 :         ret = parser_read_uint8(&mode, arg);
     179                 :          0 :         if (mode != RTE_EVENT_DMA_ADAPTER_OP_FORWARD) {
     180                 :          0 :                 RTE_LOG(ERR, USER1, "DMA adapter is supported in forward mode only\n");
     181                 :          0 :                 return -EINVAL;
     182                 :            :         }
     183                 :            : 
     184                 :          0 :         opt->dma_adptr_mode = RTE_EVENT_DMA_ADAPTER_OP_FORWARD;
     185                 :            : 
     186                 :          0 :         return ret;
     187                 :            : }
     188                 :            : 
     189                 :            : 
     190                 :            : static int
     191                 :          0 : evt_parse_crypto_prod_type(struct evt_options *opt,
     192                 :            :                            const char *arg __rte_unused)
     193                 :            : {
     194                 :          0 :         opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
     195                 :          0 :         return 0;
     196                 :            : }
     197                 :            : 
     198                 :            : static int
     199                 :          0 : evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
     200                 :            : {
     201                 :            :         uint8_t mode;
     202                 :            :         int ret;
     203                 :            : 
     204                 :          0 :         ret = parser_read_uint8(&mode, arg);
     205                 :          0 :         opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
     206                 :            :                                         RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
     207                 :          0 :         return ret;
     208                 :            : }
     209                 :            : 
     210                 :            : static int
     211                 :          0 : evt_parse_crypto_op_type(struct evt_options *opt, const char *arg)
     212                 :            : {
     213                 :            :         uint8_t op_type;
     214                 :            :         int ret;
     215                 :            : 
     216                 :          0 :         ret = parser_read_uint8(&op_type, arg);
     217                 :          0 :         opt->crypto_op_type = op_type ? RTE_CRYPTO_OP_TYPE_ASYMMETRIC :
     218                 :            :                                         RTE_CRYPTO_OP_TYPE_SYMMETRIC;
     219                 :          0 :         return ret;
     220                 :            : }
     221                 :            : 
     222                 :            : static bool
     223                 :            : cipher_alg_is_bit_mode(enum rte_crypto_cipher_algorithm alg)
     224                 :            : {
     225                 :            :         return (alg == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
     226                 :          0 :                 alg == RTE_CRYPTO_CIPHER_ZUC_EEA3 ||
     227                 :            :                 alg == RTE_CRYPTO_CIPHER_KASUMI_F8);
     228                 :            : }
     229                 :            : 
     230                 :            : static int
     231                 :          0 : evt_parse_crypto_cipher_alg(struct evt_options *opt, const char *arg)
     232                 :            : {
     233                 :            :         enum rte_crypto_cipher_algorithm cipher_alg;
     234                 :            : 
     235                 :          0 :         if (rte_cryptodev_get_cipher_algo_enum(&cipher_alg, arg) < 0) {
     236                 :          0 :                 RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
     237                 :          0 :                 return -1;
     238                 :            :         }
     239                 :            : 
     240                 :          0 :         opt->crypto_cipher_alg = cipher_alg;
     241                 :          0 :         opt->crypto_cipher_bit_mode = cipher_alg_is_bit_mode(cipher_alg);
     242                 :            : 
     243                 :          0 :         return 0;
     244                 :            : }
     245                 :            : 
     246                 :            : static int
     247                 :          0 : evt_parse_crypto_cipher_key(struct evt_options *opt, const char *arg)
     248                 :            : {
     249                 :          0 :         opt->crypto_cipher_key_sz = EVT_CRYPTO_MAX_KEY_SIZE;
     250                 :          0 :         if (parse_hex_string(arg, opt->crypto_cipher_key,
     251                 :            :                              (uint32_t *)&opt->crypto_cipher_key_sz)) {
     252                 :          0 :                 RTE_LOG(ERR, USER1, "Invalid cipher key specified\n");
     253                 :          0 :                 return -1;
     254                 :            :         }
     255                 :            : 
     256                 :            :         return 0;
     257                 :            : }
     258                 :            : 
     259                 :            : static int
     260                 :          0 : evt_parse_crypto_cipher_iv_sz(struct evt_options *opt, const char *arg)
     261                 :            : {
     262                 :            :         uint16_t iv_sz;
     263                 :            :         int ret;
     264                 :            : 
     265                 :          0 :         ret = parser_read_uint16(&(iv_sz), arg);
     266                 :          0 :         if (iv_sz > EVT_CRYPTO_MAX_IV_SIZE) {
     267                 :          0 :                 RTE_LOG(ERR, USER1,
     268                 :            :                         "Unsupported cipher IV length [%d] specified\n",
     269                 :            :                         iv_sz);
     270                 :          0 :                 return -1;
     271                 :            :         }
     272                 :            : 
     273                 :          0 :         opt->crypto_cipher_iv_sz = iv_sz;
     274                 :          0 :         return ret;
     275                 :            : }
     276                 :            : 
     277                 :            : static int
     278                 :          0 : evt_parse_test_name(struct evt_options *opt, const char *arg)
     279                 :            : {
     280                 :          0 :         strlcpy(opt->test_name, arg, EVT_TEST_NAME_MAX_LEN);
     281                 :          0 :         return 0;
     282                 :            : }
     283                 :            : 
     284                 :            : static int
     285                 :          0 : evt_parse_socket_id(struct evt_options *opt, const char *arg)
     286                 :            : {
     287                 :          0 :         opt->socket_id = atoi(arg);
     288                 :          0 :         return 0;
     289                 :            : }
     290                 :            : 
     291                 :            : static int
     292                 :          0 : evt_parse_wkr_deq_dep(struct evt_options *opt, const char *arg)
     293                 :            : {
     294                 :            :         int ret;
     295                 :            : 
     296                 :          0 :         ret = parser_read_uint16(&(opt->wkr_deq_dep), arg);
     297                 :          0 :         return ret;
     298                 :            : }
     299                 :            : 
     300                 :            : static int
     301                 :          0 : evt_parse_nb_pkts(struct evt_options *opt, const char *arg)
     302                 :            : {
     303                 :            :         int ret;
     304                 :            : 
     305                 :          0 :         ret = parser_read_uint64(&(opt->nb_pkts), arg);
     306                 :            : 
     307                 :          0 :         return ret;
     308                 :            : }
     309                 :            : 
     310                 :            : static int
     311                 :          0 : evt_parse_nb_timers(struct evt_options *opt, const char *arg)
     312                 :            : {
     313                 :            :         int ret;
     314                 :            : 
     315                 :          0 :         ret = parser_read_uint64(&(opt->nb_timers), arg);
     316                 :            : 
     317                 :          0 :         return ret;
     318                 :            : }
     319                 :            : 
     320                 :            : static int
     321                 :          0 : evt_parse_timer_tick_nsec(struct evt_options *opt, const char *arg)
     322                 :            : {
     323                 :            :         int ret;
     324                 :            : 
     325                 :          0 :         ret = parser_read_uint64(&(opt->timer_tick_nsec), arg);
     326                 :            : 
     327                 :          0 :         return ret;
     328                 :            : }
     329                 :            : 
     330                 :            : static int
     331                 :          0 : evt_parse_max_tmo_nsec(struct evt_options *opt, const char *arg)
     332                 :            : {
     333                 :            :         int ret;
     334                 :            : 
     335                 :          0 :         ret = parser_read_uint64(&(opt->max_tmo_nsec), arg);
     336                 :            : 
     337                 :          0 :         return ret;
     338                 :            : }
     339                 :            : 
     340                 :            : static int
     341                 :          0 : evt_parse_expiry_nsec(struct evt_options *opt, const char *arg)
     342                 :            : {
     343                 :            :         int ret;
     344                 :            : 
     345                 :          0 :         ret = parser_read_uint64(&(opt->expiry_nsec), arg);
     346                 :            : 
     347                 :          0 :         return ret;
     348                 :            : }
     349                 :            : 
     350                 :            : static int
     351                 :          0 : evt_parse_nb_timer_adptrs(struct evt_options *opt, const char *arg)
     352                 :            : {
     353                 :            :         int ret;
     354                 :            : 
     355                 :          0 :         ret = parser_read_uint8(&(opt->nb_timer_adptrs), arg);
     356                 :          0 :         if (opt->nb_timer_adptrs <= 0) {
     357                 :          0 :                 evt_err("Number of timer adapters cannot be <= 0");
     358                 :          0 :                 return -EINVAL;
     359                 :            :         }
     360                 :            : 
     361                 :            :         return ret;
     362                 :            : }
     363                 :            : 
     364                 :            : static int
     365                 :          0 : evt_parse_pool_sz(struct evt_options *opt, const char *arg)
     366                 :            : {
     367                 :          0 :         opt->pool_sz = atoi(arg);
     368                 :            : 
     369                 :          0 :         return 0;
     370                 :            : }
     371                 :            : 
     372                 :            : static int
     373                 :          0 : evt_parse_plcores(struct evt_options *opt, const char *corelist)
     374                 :            : {
     375                 :            :         int ret;
     376                 :            : 
     377                 :          0 :         ret = parse_lcores_list(opt->plcores, RTE_MAX_LCORE, corelist);
     378                 :          0 :         if (ret == -E2BIG)
     379                 :          0 :                 evt_err("duplicate lcores in plcores");
     380                 :            : 
     381                 :          0 :         return ret;
     382                 :            : }
     383                 :            : 
     384                 :            : static int
     385                 :          0 : evt_parse_work_lcores(struct evt_options *opt, const char *corelist)
     386                 :            : {
     387                 :            :         int ret;
     388                 :            : 
     389                 :          0 :         ret = parse_lcores_list(opt->wlcores, RTE_MAX_LCORE, corelist);
     390                 :          0 :         if (ret == -E2BIG)
     391                 :          0 :                 evt_err("duplicate lcores in wlcores");
     392                 :            : 
     393                 :          0 :         return ret;
     394                 :            : }
     395                 :            : 
     396                 :            : static int
     397                 :          0 : evt_parse_mbuf_sz(struct evt_options *opt, const char *arg)
     398                 :            : {
     399                 :            :         int ret;
     400                 :            : 
     401                 :          0 :         ret = parser_read_uint16(&(opt->mbuf_sz), arg);
     402                 :            : 
     403                 :          0 :         return ret;
     404                 :            : }
     405                 :            : 
     406                 :            : static int
     407                 :          0 : evt_parse_max_pkt_sz(struct evt_options *opt, const char *arg)
     408                 :            : {
     409                 :            :         int ret;
     410                 :            : 
     411                 :          0 :         ret = parser_read_uint32(&(opt->max_pkt_sz), arg);
     412                 :            : 
     413                 :          0 :         return ret;
     414                 :            : }
     415                 :            : 
     416                 :            : static int
     417                 :          0 : evt_parse_ena_vector(struct evt_options *opt, const char *arg __rte_unused)
     418                 :            : {
     419                 :          0 :         opt->ena_vector = 1;
     420                 :          0 :         return 0;
     421                 :            : }
     422                 :            : 
     423                 :            : static int
     424                 :          0 : evt_parse_vector_size(struct evt_options *opt, const char *arg)
     425                 :            : {
     426                 :            :         int ret;
     427                 :            : 
     428                 :          0 :         ret = parser_read_uint16(&(opt->vector_size), arg);
     429                 :            : 
     430                 :          0 :         return ret;
     431                 :            : }
     432                 :            : 
     433                 :            : static int
     434                 :          0 : evt_parse_vector_tmo_ns(struct evt_options *opt, const char *arg)
     435                 :            : {
     436                 :            :         int ret;
     437                 :            : 
     438                 :          0 :         ret = parser_read_uint64(&(opt->vector_tmo_nsec), arg);
     439                 :            : 
     440                 :          0 :         return ret;
     441                 :            : }
     442                 :            : 
     443                 :            : static int
     444                 :          0 : evt_parse_eth_queues(struct evt_options *opt, const char *arg)
     445                 :            : {
     446                 :            :         int ret;
     447                 :            : 
     448                 :          0 :         ret = parser_read_uint16(&(opt->eth_queues), arg);
     449                 :            : 
     450                 :          0 :         return ret;
     451                 :            : }
     452                 :            : 
     453                 :            : static int
     454                 :          0 : evt_parse_per_port_pool(struct evt_options *opt, const char *arg __rte_unused)
     455                 :            : {
     456                 :          0 :         opt->per_port_pool = 1;
     457                 :          0 :         return 0;
     458                 :            : }
     459                 :            : 
     460                 :            : static int
     461                 :          0 : evt_parse_prod_enq_burst_sz(struct evt_options *opt, const char *arg)
     462                 :            : {
     463                 :            :         int ret;
     464                 :            : 
     465                 :          0 :         ret = parser_read_uint32(&(opt->prod_enq_burst_sz), arg);
     466                 :            : 
     467                 :          0 :         return ret;
     468                 :            : }
     469                 :            : 
     470                 :            : static void
     471                 :          0 : usage(char *program)
     472                 :            : {
     473                 :            :         printf("usage : %s [EAL options] -- [application options]\n", program);
     474                 :            :         printf("application options:\n");
     475                 :            :         printf("\t--verbose          : verbose level\n"
     476                 :            :                 "\t--dev              : device id of the event device\n"
     477                 :            :                 "\t--test             : name of the test application to run\n"
     478                 :            :                 "\t--socket_id        : socket_id of application resources\n"
     479                 :            :                 "\t--pool_sz          : pool size of the mempool\n"
     480                 :            :                 "\t--plcores          : list of lcore ids for producers\n"
     481                 :            :                 "\t--wlcores          : list of lcore ids for workers\n"
     482                 :            :                 "\t--stlist           : list of scheduled types of the stages\n"
     483                 :            :                 "\t--nb_flows         : number of flows to produce\n"
     484                 :            :                 "\t--nb_pkts          : number of packets to produce\n"
     485                 :            :                 "\t--worker_deq_depth : dequeue depth of the worker\n"
     486                 :            :                 "\t--fwd_latency      : perform fwd_latency measurement\n"
     487                 :            :                 "\t--queue_priority   : enable queue priority\n"
     488                 :            :                 "\t--deq_tmo_nsec     : global dequeue timeout\n"
     489                 :            :                 "\t--prod_type_ethdev : use ethernet device as producer.\n"
     490                 :            :                 "\t--prod_type_dmadev : use dma device as producer.\n"
     491                 :            :                 "\t--prod_type_cryptodev : use crypto device as producer.\n"
     492                 :            :                 "\t--prod_type_timerdev : use event timer device as producer.\n"
     493                 :            :                 "\t                     expiry_nsec would be the timeout\n"
     494                 :            :                 "\t                     in ns.\n"
     495                 :            :                 "\t--prod_type_timerdev_burst : use timer device as producer\n"
     496                 :            :                 "\t                             burst mode.\n"
     497                 :            :                 "\t--nb_timers        : number of timers to arm.\n"
     498                 :            :                 "\t--nb_timer_adptrs  : number of timer adapters to use.\n"
     499                 :            :                 "\t--timer_tick_nsec  : timer tick interval in ns.\n"
     500                 :            :                 "\t--max_tmo_nsec     : max timeout interval in ns.\n"
     501                 :            :                 "\t--expiry_nsec      : event timer expiry ns.\n"
     502                 :            :                 "\t--dma_adptr_mode   : 1 for OP_FORWARD mode (default).\n"
     503                 :            :                 "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
     504                 :            :                 "\t                      1 for OP_FORWARD mode.\n"
     505                 :            :                 "\t--crypto_op_type   : 0 for SYM ops (default) and\n"
     506                 :            :                 "\t                     1 for ASYM ops.\n"
     507                 :            :                 "\t--crypto_cipher_alg : cipher algorithm to be used\n"
     508                 :            :                 "\t                      default algorithm is NULL.\n"
     509                 :            :                 "\t--crypto_cipher_key : key for the cipher algorithm selected\n"
     510                 :            :                 "\t--crypto_cipher_iv_sz : IV size for the cipher algorithm\n"
     511                 :            :                 "\t                        selected\n"
     512                 :            :                 "\t--mbuf_sz          : packet mbuf size.\n"
     513                 :            :                 "\t--max_pkt_sz       : max packet size.\n"
     514                 :            :                 "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
     515                 :            :                 "\t--nb_eth_queues    : number of ethernet Rx queues.\n"
     516                 :            :                 "\t--enable_vector    : enable event vectorization.\n"
     517                 :            :                 "\t--vector_size      : Max vector size.\n"
     518                 :            :                 "\t--vector_tmo_ns    : Max vector timeout in nanoseconds\n"
     519                 :            :                 "\t--per_port_pool    : Configure unique pool per ethdev port\n"
     520                 :            :                 "\t--tx_first         : Transmit given number of packets\n"
     521                 :            :                 "                       across all the ethernet devices before\n"
     522                 :            :                 "                       event workers start.\n"
     523                 :            :                 "\t--tx_pkt_sz        : Packet size to use with Tx first."
     524                 :            :                 "\t--preschedule      : Pre-schedule type to use.\n"
     525                 :            :                 "                       0 - disable pre-schedule\n"
     526                 :            :                 "                       1 - pre-schedule\n"
     527                 :            :                 "                       2 - pre-schedule adaptive (Default)\n"
     528                 :            :                 );
     529                 :            :         printf("available tests:\n");
     530                 :          0 :         evt_test_dump_names();
     531                 :          0 : }
     532                 :            : 
     533                 :            : static int
     534                 :          0 : evt_parse_sched_type_list(struct evt_options *opt, const char *arg)
     535                 :            : {
     536                 :            :         char c;
     537                 :            :         int i = 0, j = -1;
     538                 :            : 
     539                 :          0 :         for (i = 0; i < EVT_MAX_STAGES; i++)
     540                 :          0 :                 opt->sched_type_list[i] = (uint8_t)-1;
     541                 :            : 
     542                 :            :         i = 0;
     543                 :            : 
     544                 :            :         do {
     545                 :          0 :                 c = arg[++j];
     546                 :            : 
     547                 :          0 :                 switch (c) {
     548                 :          0 :                 case 'o':
     549                 :            :                 case 'O':
     550                 :          0 :                         opt->sched_type_list[i++] = RTE_SCHED_TYPE_ORDERED;
     551                 :          0 :                         break;
     552                 :          0 :                 case 'a':
     553                 :            :                 case 'A':
     554                 :          0 :                         opt->sched_type_list[i++] = RTE_SCHED_TYPE_ATOMIC;
     555                 :          0 :                         break;
     556                 :          0 :                 case 'p':
     557                 :            :                 case 'P':
     558                 :          0 :                         opt->sched_type_list[i++] = RTE_SCHED_TYPE_PARALLEL;
     559                 :          0 :                         break;
     560                 :            :                 case ',':
     561                 :            :                         break;
     562                 :          0 :                 default:
     563                 :          0 :                         if (c != '\0') {
     564                 :          0 :                                 evt_err("invalid sched_type %c", c);
     565                 :          0 :                                 return -EINVAL;
     566                 :            :                         }
     567                 :            :                 }
     568                 :          0 :         } while (c != '\0');
     569                 :            : 
     570                 :          0 :         opt->nb_stages = i;
     571                 :          0 :         return 0;
     572                 :            : }
     573                 :            : 
     574                 :            : static struct option lgopts[] = {
     575                 :            :         { EVT_NB_FLOWS,            1, 0, 0 },
     576                 :            :         { EVT_DEVICE,              1, 0, 0 },
     577                 :            :         { EVT_VERBOSE,             1, 0, 0 },
     578                 :            :         { EVT_TEST,                1, 0, 0 },
     579                 :            :         { EVT_PROD_LCORES,         1, 0, 0 },
     580                 :            :         { EVT_WORK_LCORES,         1, 0, 0 },
     581                 :            :         { EVT_SOCKET_ID,           1, 0, 0 },
     582                 :            :         { EVT_POOL_SZ,             1, 0, 0 },
     583                 :            :         { EVT_NB_PKTS,             1, 0, 0 },
     584                 :            :         { EVT_WKR_DEQ_DEP,         1, 0, 0 },
     585                 :            :         { EVT_SCHED_TYPE_LIST,     1, 0, 0 },
     586                 :            :         { EVT_FWD_LATENCY,         0, 0, 0 },
     587                 :            :         { EVT_QUEUE_PRIORITY,      0, 0, 0 },
     588                 :            :         { EVT_DEQ_TMO_NSEC,        1, 0, 0 },
     589                 :            :         { EVT_PROD_ETHDEV,         0, 0, 0 },
     590                 :            :         { EVT_PROD_DMADEV,         0, 0, 0 },
     591                 :            :         { EVT_PROD_CRYPTODEV,      0, 0, 0 },
     592                 :            :         { EVT_PROD_TIMERDEV,       0, 0, 0 },
     593                 :            :         { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
     594                 :            :         { EVT_DMA_ADPTR_MODE,      1, 0, 0 },
     595                 :            :         { EVT_CRYPTO_ADPTR_MODE,   1, 0, 0 },
     596                 :            :         { EVT_CRYPTO_OP_TYPE,      1, 0, 0 },
     597                 :            :         { EVT_CRYPTO_CIPHER_ALG,   1, 0, 0 },
     598                 :            :         { EVT_CRYPTO_CIPHER_KEY,   1, 0, 0 },
     599                 :            :         { EVT_CRYPTO_CIPHER_IV_SZ, 1, 0, 0 },
     600                 :            :         { EVT_NB_TIMERS,           1, 0, 0 },
     601                 :            :         { EVT_NB_TIMER_ADPTRS,     1, 0, 0 },
     602                 :            :         { EVT_TIMER_TICK_NSEC,     1, 0, 0 },
     603                 :            :         { EVT_MAX_TMO_NSEC,        1, 0, 0 },
     604                 :            :         { EVT_EXPIRY_NSEC,         1, 0, 0 },
     605                 :            :         { EVT_MBUF_SZ,             1, 0, 0 },
     606                 :            :         { EVT_MAX_PKT_SZ,          1, 0, 0 },
     607                 :            :         { EVT_PROD_ENQ_BURST_SZ,   1, 0, 0 },
     608                 :            :         { EVT_NB_ETH_QUEUES,       1, 0, 0 },
     609                 :            :         { EVT_ENA_VECTOR,          0, 0, 0 },
     610                 :            :         { EVT_VECTOR_SZ,           1, 0, 0 },
     611                 :            :         { EVT_VECTOR_TMO,          1, 0, 0 },
     612                 :            :         { EVT_PER_PORT_POOL,       0, 0, 0 },
     613                 :            :         { EVT_HELP,                0, 0, 0 },
     614                 :            :         { EVT_TX_FIRST,            1, 0, 0 },
     615                 :            :         { EVT_TX_PKT_SZ,           1, 0, 0 },
     616                 :            :         { EVT_PRESCHEDULE,         1, 0, 0 },
     617                 :            :         { NULL,                    0, 0, 0 }
     618                 :            : };
     619                 :            : 
     620                 :            : static int
     621                 :          0 : evt_opts_parse_long(int opt_idx, struct evt_options *opt)
     622                 :            : {
     623                 :            :         unsigned int i;
     624                 :            : 
     625                 :          0 :         struct long_opt_parser parsermap[] = {
     626                 :            :                 { EVT_NB_FLOWS, evt_parse_nb_flows},
     627                 :            :                 { EVT_DEVICE, evt_parse_dev_id},
     628                 :            :                 { EVT_VERBOSE, evt_parse_verbose},
     629                 :            :                 { EVT_TEST, evt_parse_test_name},
     630                 :            :                 { EVT_PROD_LCORES, evt_parse_plcores},
     631                 :            :                 { EVT_WORK_LCORES, evt_parse_work_lcores},
     632                 :            :                 { EVT_SOCKET_ID, evt_parse_socket_id},
     633                 :            :                 { EVT_POOL_SZ, evt_parse_pool_sz},
     634                 :            :                 { EVT_NB_PKTS, evt_parse_nb_pkts},
     635                 :            :                 { EVT_WKR_DEQ_DEP, evt_parse_wkr_deq_dep},
     636                 :            :                 { EVT_SCHED_TYPE_LIST, evt_parse_sched_type_list},
     637                 :            :                 { EVT_FWD_LATENCY, evt_parse_fwd_latency},
     638                 :            :                 { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
     639                 :            :                 { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
     640                 :            :                 { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
     641                 :            :                 { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
     642                 :            :                 { EVT_PROD_DMADEV, evt_parse_dma_prod_type},
     643                 :            :                 { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
     644                 :            :                 { EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
     645                 :            :                 { EVT_DMA_ADPTR_MODE, evt_parse_dma_adptr_mode},
     646                 :            :                 { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
     647                 :            :                 { EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type},
     648                 :            :                 { EVT_CRYPTO_CIPHER_ALG, evt_parse_crypto_cipher_alg},
     649                 :            :                 { EVT_CRYPTO_CIPHER_KEY, evt_parse_crypto_cipher_key},
     650                 :            :                 { EVT_CRYPTO_CIPHER_IV_SZ, evt_parse_crypto_cipher_iv_sz},
     651                 :            :                 { EVT_NB_TIMERS, evt_parse_nb_timers},
     652                 :            :                 { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
     653                 :            :                 { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
     654                 :            :                 { EVT_MAX_TMO_NSEC, evt_parse_max_tmo_nsec},
     655                 :            :                 { EVT_EXPIRY_NSEC, evt_parse_expiry_nsec},
     656                 :            :                 { EVT_MBUF_SZ, evt_parse_mbuf_sz},
     657                 :            :                 { EVT_MAX_PKT_SZ, evt_parse_max_pkt_sz},
     658                 :            :                 { EVT_PROD_ENQ_BURST_SZ, evt_parse_prod_enq_burst_sz},
     659                 :            :                 { EVT_NB_ETH_QUEUES, evt_parse_eth_queues},
     660                 :            :                 { EVT_ENA_VECTOR, evt_parse_ena_vector},
     661                 :            :                 { EVT_VECTOR_SZ, evt_parse_vector_size},
     662                 :            :                 { EVT_VECTOR_TMO, evt_parse_vector_tmo_ns},
     663                 :            :                 { EVT_PER_PORT_POOL, evt_parse_per_port_pool},
     664                 :            :                 { EVT_TX_FIRST, evt_parse_tx_first},
     665                 :            :                 { EVT_TX_PKT_SZ, evt_parse_tx_pkt_sz},
     666                 :            :                 { EVT_PRESCHEDULE, evt_parse_preschedule},
     667                 :            :         };
     668                 :            : 
     669                 :          0 :         for (i = 0; i < RTE_DIM(parsermap); i++) {
     670                 :          0 :                 if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name,
     671                 :            :                                 strlen(lgopts[opt_idx].name)) == 0)
     672                 :          0 :                         return parsermap[i].parser_fn(opt, optarg);
     673                 :            :         }
     674                 :            : 
     675                 :            :         return -EINVAL;
     676                 :            : }
     677                 :            : 
     678                 :            : int
     679                 :          0 : evt_options_parse(struct evt_options *opt, int argc, char **argv)
     680                 :            : {
     681                 :            :         int opts, retval, opt_idx;
     682                 :            : 
     683                 :          0 :         while ((opts = getopt_long(argc, argv, "", lgopts, &opt_idx)) != EOF) {
     684                 :          0 :                 switch (opts) {
     685                 :          0 :                 case 0: /* long options */
     686                 :          0 :                         if (!strcmp(lgopts[opt_idx].name, "help")) {
     687                 :          0 :                                 usage(argv[0]);
     688                 :          0 :                                 exit(EXIT_SUCCESS);
     689                 :            :                         }
     690                 :            : 
     691                 :          0 :                         retval = evt_opts_parse_long(opt_idx, opt);
     692                 :          0 :                         if (retval != 0)
     693                 :          0 :                                 return retval;
     694                 :            :                         break;
     695                 :            :                 default:
     696                 :            :                         return -EINVAL;
     697                 :            :                 }
     698                 :            :         }
     699                 :            :         return 0;
     700                 :            : }
     701                 :            : 
     702                 :            : void
     703                 :          0 : evt_options_dump(struct evt_options *opt)
     704                 :            : {
     705                 :            :         int lcore_id;
     706                 :            :         struct rte_event_dev_info dev_info;
     707                 :            : 
     708                 :          0 :         rte_event_dev_info_get(opt->dev_id, &dev_info);
     709                 :          0 :         evt_dump("driver", "%s", dev_info.driver_name);
     710                 :          0 :         evt_dump("test", "%s", opt->test_name);
     711                 :          0 :         evt_dump("dev", "%d", opt->dev_id);
     712                 :          0 :         evt_dump("verbose_level", "%d", opt->verbose_level);
     713                 :          0 :         evt_dump("socket_id", "%d", opt->socket_id);
     714                 :          0 :         evt_dump("pool_sz", "%d", opt->pool_sz);
     715                 :          0 :         evt_dump("main lcore", "%d", rte_get_main_lcore());
     716                 :          0 :         evt_dump("nb_pkts", "%"PRIu64, opt->nb_pkts);
     717                 :          0 :         evt_dump("nb_timers", "%"PRIu64, opt->nb_timers);
     718                 :            :         evt_dump_begin("available lcores");
     719                 :          0 :         RTE_LCORE_FOREACH(lcore_id)
     720                 :            :                 printf("%d ", lcore_id);
     721                 :            :         evt_dump_end;
     722                 :            :         evt_dump_nb_flows(opt);
     723                 :            :         evt_dump_worker_dequeue_depth(opt);
     724                 :          0 : }

Generated by: LCOV version 1.14