cryptodev: add asymmetric session user data API
[dpdk.git] / examples / l2fwd-event / main.c
index 1db89f2..dcc72f3 100644 (file)
@@ -25,6 +25,9 @@ l2fwd_event_usage(const char *prgname)
               "  --eventq-sched: Event queue schedule type, ordered, atomic or parallel.\n"
               "                  Default: atomic\n"
               "                  Valid only if --mode=eventdev\n"
+              "  --event-vector:  Enable event vectorization.\n"
+              "  --event-vector-size: Max vector size if event vectorization is enabled.\n"
+              "  --event-vector-tmo: Max timeout to form vector in nanoseconds if event vectorization is enabled\n"
               "  --config: Configure forwarding port pair mapping\n"
               "            Default: alternate port pairs\n\n",
               prgname);
@@ -175,6 +178,9 @@ static const char short_options[] =
 #define CMD_LINE_OPT_MODE "mode"
 #define CMD_LINE_OPT_EVENTQ_SCHED "eventq-sched"
 #define CMD_LINE_OPT_PORT_PAIR_CONF "config"
+#define CMD_LINE_OPT_ENABLE_VECTOR "event-vector"
+#define CMD_LINE_OPT_VECTOR_SIZE "event-vector-size"
+#define CMD_LINE_OPT_VECTOR_TMO_NS "event-vector-tmo"
 
 enum {
        /* long options mapped to a short option */
@@ -186,6 +192,9 @@ enum {
        CMD_LINE_OPT_MODE_NUM,
        CMD_LINE_OPT_EVENTQ_SCHED_NUM,
        CMD_LINE_OPT_PORT_PAIR_CONF_NUM,
+       CMD_LINE_OPT_ENABLE_VECTOR_NUM,
+       CMD_LINE_OPT_VECTOR_SIZE_NUM,
+       CMD_LINE_OPT_VECTOR_TMO_NS_NUM
 };
 
 /* Parse the argument given in the command line of the application */
@@ -202,6 +211,12 @@ l2fwd_event_parse_args(int argc, char **argv, struct l2fwd_resources *rsrc)
                                                CMD_LINE_OPT_EVENTQ_SCHED_NUM},
                { CMD_LINE_OPT_PORT_PAIR_CONF, required_argument, NULL,
                                        CMD_LINE_OPT_PORT_PAIR_CONF_NUM},
+               {CMD_LINE_OPT_ENABLE_VECTOR, no_argument, NULL,
+                                       CMD_LINE_OPT_ENABLE_VECTOR_NUM},
+               {CMD_LINE_OPT_VECTOR_SIZE, required_argument, NULL,
+                                       CMD_LINE_OPT_VECTOR_SIZE_NUM},
+               {CMD_LINE_OPT_VECTOR_TMO_NS, required_argument, NULL,
+                                       CMD_LINE_OPT_VECTOR_TMO_NS_NUM},
                {NULL, 0, 0, 0}
        };
        int opt, ret, timer_secs;
@@ -270,6 +285,16 @@ l2fwd_event_parse_args(int argc, char **argv, struct l2fwd_resources *rsrc)
                                return -1;
                        }
                        break;
+               case CMD_LINE_OPT_ENABLE_VECTOR_NUM:
+                       printf("event vectorization is enabled\n");
+                       rsrc->evt_vec.enabled = 1;
+                       break;
+               case CMD_LINE_OPT_VECTOR_SIZE_NUM:
+                       rsrc->evt_vec.size = strtol(optarg, NULL, 10);
+                       break;
+               case CMD_LINE_OPT_VECTOR_TMO_NS_NUM:
+                       rsrc->evt_vec.timeout_ns = strtoull(optarg, NULL, 10);
+                       break;
 
                /* long options */
                case 0:
@@ -283,6 +308,18 @@ l2fwd_event_parse_args(int argc, char **argv, struct l2fwd_resources *rsrc)
 
        rsrc->mac_updating = mac_updating;
 
+       if (rsrc->evt_vec.enabled && !rsrc->evt_vec.size) {
+               rsrc->evt_vec.size = VECTOR_SIZE_DEFAULT;
+               printf("vector size set to default (%" PRIu16 ")\n",
+                      rsrc->evt_vec.size);
+       }
+
+       if (rsrc->evt_vec.enabled && !rsrc->evt_vec.timeout_ns) {
+               rsrc->evt_vec.timeout_ns = VECTOR_TMO_NS_DEFAULT;
+               printf("vector timeout set to default (%" PRIu64 " ns)\n",
+                      rsrc->evt_vec.timeout_ns);
+       }
+
        if (optind >= 0)
                argv[optind-1] = prgname;
 
@@ -395,7 +432,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
-                       if (link.link_status == ETH_LINK_DOWN) {
+                       if (link.link_status == RTE_ETH_LINK_DOWN) {
                                all_ports_up = 0;
                                break;
                        }
@@ -636,6 +673,17 @@ main(int argc, char **argv)
                rte_panic("Cannot init mbuf pool\n");
        /* >8 End of creation of mbuf pool. */
 
+       if (rsrc->evt_vec.enabled) {
+               unsigned int nb_vec, vec_size;
+
+               vec_size = rsrc->evt_vec.size;
+               nb_vec = (nb_mbufs + vec_size - 1) / vec_size;
+               rsrc->evt_vec_pool = rte_event_vector_pool_create(
+                       "vector_pool", nb_vec, 0, vec_size, rte_socket_id());
+               if (rsrc->evt_vec_pool == NULL)
+                       rte_panic("Cannot init event vector pool\n");
+       }
+
        nb_ports_available = l2fwd_event_init_ports(rsrc);
        if (!nb_ports_available)
                rte_panic("All available ports are disabled. Please set portmask.\n");