Skip to contentSkip to conversation

add eventmode to ipsec-secgw

PATCH Superseded Anoob Joseph 5 participants 147 messages Dec 8, 2019 – Apr 12, 2020 Arm/Amlogic Meson SoC support Page 3 of 3

lore
Share & tools
lore
#116 lore raw

Re: [dpdk-dev] [EXT] RE: [PATCH v4 12/15] examples/ipsec-secgw: add app mode worker

In reply to Akhil Goyal

Hi Akhil,

Please see my answer below.

Thanks,
Lukasz

Quoted 88 lines · Akhil Goyal
Quoted 46 lines

Hi Lukasz,

Quoted 4 lines
Quoted 2 lines

Is it not possible to use the existing functions for finding routes, checking

packet types and checking security policies.

Quoted 1 line

It will be very difficult to manage two separate functions for same work. I

can

Quoted 6 lines

see that the pkt->data_offs

Quoted 1 line

Are not required to be updated in the inline case, but can we split the existing

functions in two so that they can be

Quoted 3 lines

Called in the appropriate cases.

As you have said in the cover note as well to add lookaside protocol support.

I

Quoted 11 lines

also tried adding it, and it will get very

Quoted 2 lines

Difficult to manage separate functions for separate code paths.

[Lukasz] This was also Konstantin's comment during review of one of previous revisions.
The prepare_one_packet() and prepare_tx_pkt() do much more than we need and for performance reasons
we crafted new functions. For example, process_ipsec_get_pkt_type function returns nlp and whether
packet type is plain or IPsec. That's all. Prepare_one_packet() process packets

in

Quoted 2 lines

chunks and does much more -
it adjusts mbuf and packet length then it demultiplex packets into plain and

IPsec

Quoted 4 lines

flows and finally does
inline checks. This is similar for update_mac_addrs() vs prepare_tx_pkt() and check_sp() vs inbound_sp_sa()
that prepare_tx_pkt() and inbound_sp_sa() do more that we need in event

mode.

Quoted 2 lines

I understand your concern from the perspective of code maintenance but on

the

Quoted 4 lines

other hand we are concerned with performance.
The current code is not optimized to support multiple mode processing introduced with rte_security. We can work on a common routines once we have other modes also added, so that we can come up with

a

Quoted 2 lines

better solution than what we have today.

Quoted 10 lines

Yes that is correct, but we should split the existing functions so that the part which is common
In both mode should stay common and we do not have duplicate code in the app.

I believe we should take care of this when we add lookaside cases. We shall remove all duplicate
Code. Ideally it should be part of this patchset. But we can postpone it to the lookaside case addition.

I believe the route(4/6)_pkts and route(4/6)_pkt can be made uniform quite easily. Now you can call either send_single_pkt() or rte_event_eth_tx_adapter_enqueue() from the caller of route4_pkts.
I don’t think this will impact the performance at all.
Instead of having 3 for loops, now there will be only 2 and nothing else is getting changed for anybody. In fact we can reduce 1 more, if we can call send pkts from inside the route4_pkts. I think that can also be done, but it may increase the lookup duration as there may be cache miss. But that need to be experimented. What say??

static inline void
route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint32_t *hop[],
uint8_t nb_pkts)

{
        uint32_t dst_ip;
        uint16_t i, offset;

        if (nb_pkts == 0)
                return;

        /* Need to do an LPM lookup for non-inline packets. Inline packets will
         * have port ID in the SA
         */

        for (i = 0; i < nb_pkts; i++) {
                if (!(pkts[i]->ol_flags & PKT_TX_SEC_OFFLOAD)) {
                        /* Security offload not enabled. So an LPM lookup is
                         * required to get the hop
                         */
                        offset = offsetof(struct ip, ip_dst);
                        dst_ip = *rte_pktmbuf_mtod_offset(pkts[i],
                                        uint32_t *, offset);
Quoted 9 lines
                        dst_ip = rte_be_to_cpu_32(dst_ip);
                        if (rte_lpm_lookup((struct rte_lpm *)rt_ctx, dst_ip, hop[i]))
                                rte_pktmbuf_free(pkts[i]);
                } else {
                        *hop[i] = get_hop_for_offload_pkt(pkts[i], 0);
                }
        }
}

[Lukasz] Thank you for your suggestion. Looking at the proposed change I have major concern related
to performance. Current rout4_pkts uses rte_lpm_lookup_bulk() which can benefit from SIMD instructions. Replacing it with rte_lpm_lookup might introduce substantial performance degradation. I will start experimenting with processing functions (routing packets, checking packet type, checking sp policies) to make them as much common as possible between poll and event modes. As agreed the plan is to make processing functions common with the addition of lookaside event mode. In the meantime I will send V5 event mode patches which address your other comments.

#117 lore raw

PATCH v4 13/15 examples/ipsec-secgw: make number of buffers dynamic

In reply to Lukasz Bartosik

Make number of buffers in a pool nb_mbuf_in_pool dependent on number of ports, cores and crypto queues. Add command line option -s which when used overrides dynamic calculation of number of buffers in a pool.

---
 examples/ipsec-secgw/ipsec-secgw.c | 71 ++++++++++++++++++++++++++++++++------
 1 file changed, 60 insertions(+), 11 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +60 -11
index c98620e..341e7b4 100644
@@ -60,8 +60,6 @@ volatile bool force_quit;
 
 #define MEMPOOL_CACHE_SIZE 256
 
-#define NB_MBUF	(32000)
-
 #define CDEV_QUEUE_DESC 2048
 #define CDEV_MAP_ENTRIES 16384
 #define CDEV_MP_NB_OBJS 1024
@@ -164,6 +162,7 @@ static int32_t promiscuous_on = 1;
 static int32_t numa_on = 1; /**< NUMA is enabled by default. */
 static uint32_t nb_lcores;
 static uint32_t single_sa;
+static uint32_t nb_bufs_in_pool;
 
 /*
  * RX/TX HW offload capabilities to enable/use on ethernet ports.
@@ -1274,6 +1273,7 @@ print_usage(const char *prgname)
 		" [-e]"
 		" [-a]"
 		" [-c]"
+		" [-s NUMBER_OF_MBUFS_IN_PKT_POOL]"
 		" -f CONFIG_FILE"
 		" --config (port,queue,lcore)[,(port,queue,lcore)]"
 		" [--single-sa SAIDX]"
@@ -1297,6 +1297,9 @@ print_usage(const char *prgname)
 		"  -a enables SA SQN atomic behaviour\n"
 		"  -c specifies inbound SAD cache size,\n"
 		"     zero value disables the cache (default value: 128)\n"
+		"  -s number of mbufs in packet pool, if not specified number\n"
+		"     of mbufs will be calculated based on number of cores,\n"
+		"     ports and crypto queues\n"
 		"  -f CONFIG_FILE: Configuration file\n"
 		"  --config (port,queue,lcore): Rx queue configuration\n"
 		"  --single-sa SAIDX: In poll mode use single SA index for\n"
@@ -1496,7 +1499,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf)
 
 	argvopt = argv;
 
-	while ((opt = getopt_long(argc, argvopt, "aelp:Pu:f:j:w:c:",
+	while ((opt = getopt_long(argc, argvopt, "aelp:Pu:f:j:w:c:s:",
 				lgopts, &option_index)) != EOF) {
 
 		switch (opt) {
@@ -1530,6 +1533,19 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf)
 			cfgfile = optarg;
 			f_present = 1;
 			break;
+
+		case 's':
+			ret = parse_decimal(optarg);
+			if (ret < 0) {
+				printf("Invalid number of buffers in a pool: "
+					"%s\n", optarg);
+				print_usage(prgname);
+				return -1;
+			}
+
+			nb_bufs_in_pool = ret;
+			break;
+
 		case 'j':
 			ret = parse_decimal(optarg);
 			if (ret < RTE_MBUF_DEFAULT_BUF_SIZE ||
@@ -1902,12 +1918,12 @@ check_cryptodev_mask(uint8_t cdev_id)
 	return -1;
 }
 
-static int32_t
+static uint16_t
 cryptodevs_init(void)
 {
 	struct rte_cryptodev_config dev_conf;
 	struct rte_cryptodev_qp_conf qp_conf;
-	uint16_t idx, max_nb_qps, qp, i;
+	uint16_t idx, max_nb_qps, qp, total_nb_qps, i;
 	int16_t cdev_id;
 	struct rte_hash_parameters params = { 0 };
 
@@ -1935,6 +1951,7 @@ cryptodevs_init(void)
 	printf("lcore/cryptodev/qp mappings:\n");
 
 	idx = 0;
+	total_nb_qps = 0;
 	for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
 		struct rte_cryptodev_info cdev_info;
 
@@ -1968,6 +1985,7 @@ cryptodevs_init(void)
 		if (qp == 0)
 			continue;
 
+		total_nb_qps += qp;
 		dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
 		dev_conf.nb_queue_pairs = qp;
 		dev_conf.ff_disable = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO;
@@ -2000,7 +2018,7 @@ cryptodevs_init(void)
 
 	printf("\n");
 
-	return 0;
+	return total_nb_qps;
 }
 
 static void
@@ -2630,20 +2648,36 @@ inline_sessions_free(struct sa_ctx *sa_ctx)
 	}
 }
 
+static uint32_t
+calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq,
+		uint32_t nb_txq)
+{
+	return RTE_MAX((nb_rxq * nb_rxd +
+			nb_ports * nb_lcores * MAX_PKT_BURST +
+			nb_ports * nb_txq * nb_txd +
+			nb_lcores * MEMPOOL_CACHE_SIZE +
+			nb_crypto_qp * CDEV_QUEUE_DESC +
+			nb_lcores * frag_tbl_sz *
+			FRAG_TBL_BUCKET_ENTRIES),
+		       8192U);
+}
+
 int32_t
 main(int32_t argc, char **argv)
 {
 	int32_t ret;
-	uint32_t lcore_id;
+	uint32_t lcore_id, nb_txq, nb_rxq = 0;
 	uint32_t cdev_id;
 	uint32_t i;
 	uint8_t socket_id;
-	uint16_t portid;
+	uint16_t portid, nb_crypto_qp, nb_ports = 0;
 	uint64_t req_rx_offloads[RTE_MAX_ETHPORTS];
 	uint64_t req_tx_offloads[RTE_MAX_ETHPORTS];
 	struct eh_conf *eh_conf = NULL;
 	size_t sess_sz;
 
+	nb_bufs_in_pool = 0;
+
 	/* init EAL */
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
@@ -2692,6 +2726,22 @@ main(int32_t argc, char **argv)
 
 	sess_sz = max_session_size();
 
+	nb_crypto_qp = cryptodevs_init();
+
+	if (nb_bufs_in_pool == 0) {
+		RTE_ETH_FOREACH_DEV(portid) {
+			if ((enabled_port_mask & (1 << portid)) == 0)
+				continue;
+			nb_ports++;
+			nb_rxq += get_port_nb_rx_queues(portid);
+		}
+
+		nb_txq = nb_lcores;
+
+		nb_bufs_in_pool = calculate_nb_mbufs(nb_ports, nb_crypto_qp,
+						nb_rxq, nb_txq);
+	}
+
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
 		if (rte_lcore_is_enabled(lcore_id) == 0)
 			continue;
@@ -2705,11 +2755,12 @@ main(int32_t argc, char **argv)
 		if (socket_ctx[socket_id].mbuf_pool)
 			continue;
 
-		pool_init(&socket_ctx[socket_id], socket_id, NB_MBUF);
+		pool_init(&socket_ctx[socket_id], socket_id, nb_bufs_in_pool);
 		session_pool_init(&socket_ctx[socket_id], socket_id, sess_sz);
 		session_priv_pool_init(&socket_ctx[socket_id], socket_id,
 			sess_sz);
 	}
+	printf("Number of mbufs in packet pool %d\n", nb_bufs_in_pool);
 
 	RTE_ETH_FOREACH_DEV(portid) {
 		if ((enabled_port_mask & (1 << portid)) == 0)
@@ -2721,8 +2772,6 @@ main(int32_t argc, char **argv)
 				req_tx_offloads[portid]);
 	}
 
-	cryptodevs_init();
-
 	/*
 	 * Set the enabled port mask in helper config for use by helper
 	 * sub-system. This will be used while initializing devices using
Signature · 1 line
2.7.4
#118 lore raw

PATCH v4 14/15 doc: add event mode support to ipsec-secgw

In reply to Lukasz Bartosik

Document addition of event mode support
to ipsec-secgw application.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst | 138 ++++++++++++++++++++++++++-----
 1 file changed, 117 insertions(+), 21 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +117 -21
index 5ec9b1e..fddd88c 100644
@@ -1,5 +1,6 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2016-2017 Intel Corporation.
+    Copyright (C) 2020 Marvell International Ltd.
 
 IPsec Security Gateway Sample Application
 =========================================
@@ -61,6 +62,44 @@ The Path for the IPsec Outbound traffic is:
 *  Routing.
 *  Write packet to port.
 
+The application supports two modes of operation: poll mode and event mode.
+
+* In the poll mode a core receives packets from statically configured list
+  of eth ports and eth ports' queues.
+
+* In the event mode a core receives packets as events. After packet processing
+  is done core submits them back as events to an event device. This enables
+  multicore scaling and HW assisted scheduling by making use of the event device
+  capabilities. The event mode configuration is predefined. All packets reaching
+  given eth port will arrive at the same event queue. All event queues are mapped
+  to all event ports. This allows all cores to receive traffic from all ports.
+  Since the underlying event device might have varying capabilities, the worker
+  threads can be drafted differently to maximize performance. For example, if an
+  event device - eth device pair has Tx internal port, then application can call
+  rte_event_eth_tx_adapter_enqueue() instead of regular rte_event_enqueue_burst().
+  So a thread which assumes that the device pair has internal port will not be the
+  right solution for another pair. The infrastructure added for the event mode aims
+  to help application to have multiple worker threads by maximizing performance from
+  every type of event device without affecting existing paths/use cases. The worker
+  to be used will be determined by the operating conditions and the underlying device
+  capabilities. **Currently the application provides non-burst, internal port worker
+  threads and supports inline protocol only.** It also provides infrastructure for
+  non-internal port however does not define any worker threads.
+
+Additionally the event mode introduces two submodes of processing packets:
+
+* Driver submode: This submode has bare minimum changes in the application to support
+  IPsec. There are no lookups, no routing done in the application. And for inline
+  protocol use case, the worker thread resembles l2fwd worker thread as the IPsec
+  processing is done entirely in HW. This mode can be used to benchmark the raw
+  performance of the HW. The driver submode is selected with --single-sa option
+  (used also by poll mode). When --single-sa option is used in conjution with event
+  mode then index passed to --single-sa is ignored.
+
+* App submode: This submode has all the features currently implemented with the
+  application (non librte_ipsec path). All the lookups, routing follows existing
+  methods and report numbers that can be compared against regular poll mode
+  benchmark numbers.
 
 Constraints
 -----------
@@ -94,13 +133,18 @@ The application has a number of command line options::
                         -p PORTMASK -P -u PORTMASK -j FRAMESIZE
                         -l -w REPLAY_WINOW_SIZE -e -a
                         -c SAD_CACHE_SIZE
+                        -s NUMBER_OF_MBUFS_IN_PACKET_POOL
+                        -f CONFIG_FILE_PATH
                         --config (port,queue,lcore)[,(port,queue,lcore]
                         --single-sa SAIDX
+                        --cryptodev_mask MASK
+                        --transfer-mode MODE
+                        --event-schedule-type TYPE
                         --rxoffload MASK
                         --txoffload MASK
-                        --mtu MTU
                         --reassemble NUM
-                        -f CONFIG_FILE_PATH
+                        --mtu MTU
+                        --frag-ttl FRAG_TTL_NS
 
 Where:
 
@@ -138,12 +182,38 @@ Where:
     Zero value disables cache.
     Default value: 128.
 
-*   ``--config (port,queue,lcore)[,(port,queue,lcore)]``: determines which queues
-    from which ports are mapped to which cores.
+*   ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs
+    will be calculated based on number of cores, eth ports and crypto queues.
+
+*   ``-f CONFIG_FILE_PATH``: the full path of text-based file containing all
+    configuration items for running the application (See Configuration file
+    syntax section below). ``-f CONFIG_FILE_PATH`` **must** be specified.
+    **ONLY** the UNIX format configuration file is accepted.
+
+*   ``--config (port,queue,lcore)[,(port,queue,lcore)]``: in poll mode determines
+    which queues from which ports are mapped to which cores. In event mode this
+    is required for eth ports initialization only. Afterwards packets are dynamically
+    scheduled to cores by HW.
+
+*   ``--single-sa SAIDX``: in poll mode use a single SA for outbound traffic,
+    bypassing the SP on both Inbound and Outbound. This option is meant for
+    debugging/performance purposes. In event mode selects driver submode, SA index
+    value is ignored.
 
-*   ``--single-sa SAIDX``: use a single SA for outbound traffic, bypassing the SP
-    on both Inbound and Outbound. This option is meant for debugging/performance
-    purposes.
+*   ``--cryptodev_mask MASK``: hexadecimal bitmask of the crypto devices
+    to configure.
+
+*   ``--transfer-mode MODE``: sets operating mode of the application
+    "poll"  : packet transfer via polling (default)
+    "event" : Packet transfer via event device
+
+*   ``--event-schedule-type TYPE``: queue schedule type, applies only when
+    --transfer-mode is set to event.
+    "ordered"  : Ordered (default)
+    "atomic"   : Atomic
+    "parallel" : Parallel
+    When --event-schedule-type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event
+    device will ensure the ordering. Ordering will be lost when tried in PARALLEL.
 
 *   ``--rxoffload MASK``: RX HW offload capabilities to enable/use on this port
     (bitmask of DEV_RX_OFFLOAD_* values). It is an optional parameter and
@@ -155,6 +225,10 @@ Where:
     allows user to disable some of the TX HW offload capabilities.
     By default all HW TX offloads are enabled.
 
+*   ``--reassemble NUM``: max number of entries in reassemble fragment table.
+    Zero value disables reassembly functionality.
+    Default value: 0.
+
 *   ``--mtu MTU``: MTU value (in bytes) on all attached ethernet ports.
     Outgoing packets with length bigger then MTU will be fragmented.
     Incoming packets with length bigger then MTU will be discarded.
@@ -167,26 +241,17 @@ Where:
     Should be lower for low number of reassembly buckets.
     Valid values: from 1 ns to 10 s. Default value: 10000000 (10 s).
 
-*   ``--reassemble NUM``: max number of entries in reassemble fragment table.
-    Zero value disables reassembly functionality.
-    Default value: 0.
-
-*   ``-f CONFIG_FILE_PATH``: the full path of text-based file containing all
-    configuration items for running the application (See Configuration file
-    syntax section below). ``-f CONFIG_FILE_PATH`` **must** be specified.
-    **ONLY** the UNIX format configuration file is accepted.
-
 
 The mapping of lcores to port/queues is similar to other l3fwd applications.
 
-For example, given the following command line::
+For example, given the following command line to run application in poll mode::
 
     ./build/ipsec-secgw -l 20,21 -n 4 --socket-mem 0,2048       \
-           --vdev "crypto_null" -- -p 0xf -P -u 0x3      \
+           --vdev "crypto_null" -- -p 0xf -P -u 0x3             \
            --config="(0,0,20),(1,0,20),(2,0,21),(3,0,21)"       \
-           -f /path/to/config_file                              \
+           -f /path/to/config_file --transfer-mode poll         \
 
-where each options means:
+where each option means:
 
 *   The ``-l`` option enables cores 20 and 21.
 
@@ -200,7 +265,7 @@ where each options means:
 
 *   The ``-P`` option enables promiscuous mode.
 
-*   The ``-u`` option sets ports 1 and 2 as unprotected, leaving 2 and 3 as protected.
+*   The ``-u`` option sets ports 0 and 1 as unprotected, leaving 2 and 3 as protected.
 
 *   The ``--config`` option enables one queue per port with the following mapping:
 
@@ -228,6 +293,37 @@ where each options means:
     **note** the parser only accepts UNIX format text file. Other formats
     such as DOS/MAC format will cause a parse error.
 
+*   The ``--transfer-mode`` option selects poll mode for processing packets.
+
+Similarly for example, given the following command line to run application in
+event app mode::
+
+    ./build/ipsec-secgw -c 0x3 -- -P -p 0x3 -u 0x1       \
+           --config "(1,0,0),(0,0,1)"                    \
+           -f /path/to/config_file --transfer-mode event \
+           --event-schedule-type parallel                \
+
+where each option means:
+
+*   The ``-c`` option selects cores 0 and 1 to run on.
+
+*   The ``-P`` option enables promiscuous mode.
+
+*   The ``-p`` option enables ports (detected) 0 and 1.
+
+*   The ``-u`` option sets ports 0 as unprotected, leaving 1 as protected.
+
+*   The ``--config`` option provides configuration for eth ports initialization
+    only. Afterwards packets are dynamically scheduled to cores by HW.
+
+*   The ``-f /path/to/config_file`` option has the same behavior as in poll
+    mode example.
+
+*   The ``--transfer-mode`` option selects event mode for processing packets.
+
+*   The ``--event-schedule-type`` option selects parallel ordering of event queues.
+
+
 Refer to the *DPDK Getting Started Guide* for general information on running
 applications and the Environment Abstraction Layer (EAL) options.
 
Signature · 1 line
2.7.4
#119 lore raw

PATCH v4 15/15 examples/ipsec-secgw: reserve crypto queues in event mode

In reply to Lukasz Bartosik

Reserve minimum number of crypto queues equal to number of ports. This is to fulfill inline protocol offload requirements.

---
 examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +12 -2
index 341e7b4..982d00b 100644
@@ -1919,7 +1919,7 @@ check_cryptodev_mask(uint8_t cdev_id)
 }
 
 static uint16_t
-cryptodevs_init(void)
+cryptodevs_init(uint16_t req_queue_num)
 {
 	struct rte_cryptodev_config dev_conf;
 	struct rte_cryptodev_qp_conf qp_conf;
@@ -1982,6 +1982,7 @@ cryptodevs_init(void)
 			i++;
 		}
 
+		qp = RTE_MIN(max_nb_qps, RTE_MAX(req_queue_num, qp));
 		if (qp == 0)
 			continue;
 
@@ -2726,7 +2727,16 @@ main(int32_t argc, char **argv)
 
 	sess_sz = max_session_size();
 
-	nb_crypto_qp = cryptodevs_init();
+	/*
+	 * In event mode request minimum number of crypto queues
+	 * to be reserved equal to number of ports.
+	 */
+	if (eh_conf->mode == EH_PKT_TRANSFER_MODE_EVENT)
+		nb_crypto_qp = rte_eth_dev_count_avail();
+	else
+		nb_crypto_qp = 0;
+
+	nb_crypto_qp = cryptodevs_init(nb_crypto_qp);
 
 	if (nb_bufs_in_pool == 0) {
 		RTE_ETH_FOREACH_DEV(portid) {
Signature · 1 line
2.7.4
#120 lore raw
In reply to Lukasz Bartosik

Hi Konstantin, Akhil,

Do you have any further comments on this series?

Regarding the config parameter change which was discussed in the last submission, we have deferred it and went back to Konstantin's suggestion of updating qp only for our case. Hope now you can Ack the series.

Thanks,
Anoob

Quoted 221 lines

-----Original Message-----
From: Lukasz Bartosik <[email protected]>
Sent: Thursday, February 20, 2020 1:32 PM
To: Akhil Goyal <[email protected]>; Radu Nicolau <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Ankur Dwivedi <[email protected]>; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; Konstantin Ananyev <[email protected]>; [email protected]
Subject: [PATCH v4 00/15] add eventmode to ipsec-secgw

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize performance. This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports.
When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in PARALLEL.

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 --config "(1,0,0),(0,0,0)" -f aes-gcm.cfg -- transfer-mode event --event-schedule-type parallel

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 --config "(1,0,0),(0,0,0)" -f aes-gcm.cfg -- transfer-mode event --event-schedule-type parallel --single-sa 0

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads added.

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth ports in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static keyword from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(), check_sp()
and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES"
in one line
instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port() and eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec- secgw.h,
remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

 doc/guides/sample_app_ug/ipsec_secgw.rst |  138 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812
++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  463 ++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  638 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   35 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3464 insertions(+), 129 deletions(-)  create mode 100644
examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h

--
2.7.4

#121 lore raw
In reply to Lukasz Bartosik

Hi Anoob/Lukasz,

Quoted 61 lines

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize performance. This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports. When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device
will ensure the ordering. Ordering would be lost when tried in PARALLEL.

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Quoted 9 lines

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 --config "(1,0,0),(0,0,0)" -f aes-gcm.cfg -- transfer-mode event --event-schedule-type parallel

What is the need of adding the port queue core mapping in case of event.
In case of event, all queues are given to eventdev and there is no need for specifying such specific mapping. In l3fwd also this was not done.

Quoted 142 lines

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 --config "(1,0,0),(0,0,0)" -f aes-gcm.cfg -- transfer-mode event --event-schedule-type parallel --single-sa 0

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec
protocol mode is supported by the worker threads added.

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth ports in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static keyword from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(), check_sp() and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES"
in one line
instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port() and eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec- secgw.h,
remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

 doc/guides/sample_app_ug/ipsec_secgw.rst |  138 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812
++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  463 ++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  638 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   35 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3464 insertions(+), 129 deletions(-)
 create mode 100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h

--
2.7.4

#122 lore raw

Hi Akhil,

Please see my answer below.

Thanks,
Lukasz

Quoted 76 lines · Akhil Goyal

External Email

----------------------------------------------------------------------
Hi Anoob/Lukasz,

Quoted 61 lines

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize performance. This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports. When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device
will ensure the ordering. Ordering would be lost when tried in PARALLEL.

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Quoted 9 lines

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 --config "(1,0,0),(0,0,0)" -f aes-gcm.cfg -- transfer-mode event --event-schedule-type parallel

Quoted 3 lines

What is the need of adding the port queue core mapping in case of event.
In case of event, all queues are given to eventdev and there is no need for specifying such specific mapping. In l3fwd also this was not done.

[Lukasz] You are right port,queue,core mapping is not needed in case of event mode. I will remove --config option from being used in event mode. Number of ports to be initialized will be derived from the port mask and nb_rx_queues per port will be set to 1.

Quoted 143 lines
Quoted 142 lines

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 --config "(1,0,0),(0,0,0)" -f aes-gcm.cfg -- transfer-mode event --event-schedule-type parallel --single-sa 0

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec
protocol mode is supported by the worker threads added.

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth ports in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static keyword from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(), check_sp() and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES"
in one line
instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port() and eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec- secgw.h,
remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

 doc/guides/sample_app_ug/ipsec_secgw.rst |  138 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812
++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  463 ++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  638 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   35 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3464 insertions(+), 129 deletions(-)
 create mode 100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h

--
2.7.4

#123 lore raw

v5 cover add eventmode to ipsec-secgw

In reply to Lukasz Bartosik

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize performance. This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports. When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in PARALLEL.

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel --single-sa 0

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads added.

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Changes in v5:
* Rename function check_params() to check_poll_mode_params() and check_eh_conf() to check_event_mode_params() in order to make it clear what is their purpose.
* Forbid usage of --config option in event mode.
* Replace magic numbers on return with enum values in process_ipsec_ev_inbound() and process_ipsec_ev_outbound() functions.
* Add session_priv_pool for both inbound and outbound configuration in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Add check of event type in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Update description of --config option in both ipsec-secgw help and documentation.

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth ports in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static keyword from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(), check_sp() and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES" in one line instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port() and eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec-secgw.h, remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

 doc/guides/sample_app_ug/ipsec_secgw.rst |  135 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812 ++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  506 +++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  649 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   41 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3516 insertions(+), 134 deletions(-)
 create mode 100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h
Signature · 1 line
2.7.4
#124 lore raw

PATCH v5 1/15 examples/ipsec-secgw: add default rte flow for inline Rx

From: Ankur Dwivedi <[email protected]>

The default flow created would enable security processing on all ESP packets. If the default flow is created, SA based rte_flow creation would be skipped.

---
 examples/ipsec-secgw/ipsec-secgw.c | 61 +++++++++++++++++++++++++++++++++-----
 examples/ipsec-secgw/ipsec.c       |  5 +++-
 examples/ipsec-secgw/ipsec.h       |  6 ++++
 3 files changed, 63 insertions(+), 9 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +53 -8
index 4799bc9..e1ee7c3 100644
@@ -129,6 +129,8 @@ struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
 	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x49, 0x9e, 0xdd) }
 };
 
+struct flow_info flow_info_tbl[RTE_MAX_ETHPORTS];
+
 #define CMD_LINE_OPT_CONFIG		"config"
 #define CMD_LINE_OPT_SINGLE_SA		"single-sa"
 #define CMD_LINE_OPT_CRYPTODEV_MASK	"cryptodev_mask"
@@ -2432,6 +2434,48 @@ reassemble_init(void)
 	return rc;
 }
 
+static void
+create_default_ipsec_flow(uint16_t port_id, uint64_t rx_offloads)
+{
+	struct rte_flow_action action[2];
+	struct rte_flow_item pattern[2];
+	struct rte_flow_attr attr = {0};
+	struct rte_flow_error err;
+	struct rte_flow *flow;
+	int ret;
+
+	if (!(rx_offloads & DEV_RX_OFFLOAD_SECURITY))
+		return;
+
+	/* Add the default rte_flow to enable SECURITY for all ESP packets */
+
+	pattern[0].type = RTE_FLOW_ITEM_TYPE_ESP;
+	pattern[0].spec = NULL;
+	pattern[0].mask = NULL;
+	pattern[0].last = NULL;
+	pattern[1].type = RTE_FLOW_ITEM_TYPE_END;
+
+	action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY;
+	action[0].conf = NULL;
+	action[1].type = RTE_FLOW_ACTION_TYPE_END;
+	action[1].conf = NULL;
+
+	attr.ingress = 1;
+
+	ret = rte_flow_validate(port_id, &attr, pattern, action, &err);
+	if (ret)
+		return;
+
+	flow = rte_flow_create(port_id, &attr, pattern, action, &err);
+	if (flow == NULL)
+		return;
+
+	flow_info_tbl[port_id].rx_def_flow = flow;
+	RTE_LOG(INFO, IPSEC,
+		"Created default flow enabling SECURITY for all ESP traffic on port %d\n",
+		port_id);
+}
+
 int32_t
 main(int32_t argc, char **argv)
 {
@@ -2440,7 +2484,8 @@ main(int32_t argc, char **argv)
 	uint32_t i;
 	uint8_t socket_id;
 	uint16_t portid;
-	uint64_t req_rx_offloads, req_tx_offloads;
+	uint64_t req_rx_offloads[RTE_MAX_ETHPORTS];
+	uint64_t req_tx_offloads[RTE_MAX_ETHPORTS];
 	size_t sess_sz;
 
 	/* init EAL */
@@ -2502,8 +2547,10 @@ main(int32_t argc, char **argv)
 		if ((enabled_port_mask & (1 << portid)) == 0)
 			continue;
 
-		sa_check_offloads(portid, &req_rx_offloads, &req_tx_offloads);
-		port_init(portid, req_rx_offloads, req_tx_offloads);
+		sa_check_offloads(portid, &req_rx_offloads[portid],
+				&req_tx_offloads[portid]);
+		port_init(portid, req_rx_offloads[portid],
+				req_tx_offloads[portid]);
 	}
 
 	cryptodevs_init();
@@ -2513,11 +2560,9 @@ main(int32_t argc, char **argv)
 		if ((enabled_port_mask & (1 << portid)) == 0)
 			continue;
 
-		/*
-		 * Start device
-		 * note: device must be started before a flow rule
-		 * can be installed.
-		 */
+		/* Create flow before starting the device */
+		create_default_ipsec_flow(portid, req_rx_offloads[portid]);
+
 		ret = rte_eth_dev_start(portid);
 		if (ret < 0)
 			rte_exit(EXIT_FAILURE, "rte_eth_dev_start: "
examples/ipsec-secgw/ipsec.c +4 -1
index 6e81207..d406571 100644
@@ -275,6 +275,10 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			unsigned int i;
 			unsigned int j;
 
+			/* Don't create flow if default flow is created */
+			if (flow_info_tbl[sa->portid].rx_def_flow)
+				return 0;
+
 			ret = rte_eth_dev_info_get(sa->portid, &dev_info);
 			if (ret != 0) {
 				RTE_LOG(ERR, IPSEC,
@@ -410,7 +414,6 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 		ips->security.ol_flags = sec_cap->ol_flags;
 		ips->security.ctx = sec_ctx;
 	}
-	sa->cdev_id_qp = 0;
 
 	return 0;
 }
examples/ipsec-secgw/ipsec.h +6 -0
index 4f2fd61..8f5d382 100644
@@ -87,6 +87,12 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+struct flow_info {
+	struct rte_flow *rx_def_flow;
+};
+
+extern struct flow_info flow_info_tbl[RTE_MAX_ETHPORTS];
+
 enum {
 	IPSEC_SESSION_PRIMARY = 0,
 	IPSEC_SESSION_FALLBACK = 1,
Signature · 1 line
2.7.4
#125 lore raw

PATCH v5 2/15 examples/ipsec-secgw: add framework for eventmode helper

In reply to Lukasz Bartosik

From: Anoob Joseph <[email protected]>

Add framework for eventmode helper. Event mode involves initialization of multiple devices like eventdev, ethdev and etc. Add routines to initialize and uninitialize event device. Generate a default config for event device if it is not specified in the configuration. Currently event helper supports single event device only.

---
 examples/ipsec-secgw/Makefile       |   1 +
 examples/ipsec-secgw/event_helper.c | 320 ++++++++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h | 107 ++++++++++++
 examples/ipsec-secgw/meson.build    |   4 +-
 4 files changed, 430 insertions(+), 2 deletions(-)
 create mode 100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
examples/ipsec-secgw/Makefile +1 -0
index ad83d79..66d05d4 100644
@@ -16,6 +16,7 @@ SRCS-y += sad.c
 SRCS-y += rt.c
 SRCS-y += ipsec_process.c
 SRCS-y += ipsec-secgw.c
+SRCS-y += event_helper.c
 
 CFLAGS += -gdwarf-2
 
examples/ipsec-secgw/event_helper.c new file +320 -0

320 lines not on this page · raw message

examples/ipsec-secgw/event_helper.h new file +107 -0

107 lines not on this page · raw message

examples/ipsec-secgw/meson.build +2 -2
index 6bd5b78..2415d47 100644
@@ -6,9 +6,9 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
-deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec']
+deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev']
 allow_experimental_apis = true
 sources = files(
-	'esp.c', 'ipsec.c', 'ipsec_process.c', 'ipsec-secgw.c',
+	'esp.c', 'event_helper.c', 'ipsec.c', 'ipsec_process.c', 'ipsec-secgw.c',
 	'parser.c', 'rt.c', 'sa.c', 'sad.c', 'sp4.c', 'sp6.c'
 )
Signature · 1 line
2.7.4
#126 lore raw

PATCH v5 3/15 examples/ipsec-secgw: add eventdev port-lcore link

In reply to Lukasz Bartosik

From: Anoob Joseph <[email protected]>

Add event device port-lcore link and specify which event queues should be connected to the event port. Generate a default config for event port-lcore links if it is not specified in the configuration. This routine will check the number of available ports and then create links according to the number of cores available. This patch also adds a new entry in the eventmode conf to denote that all queues are to be linked with every port. This enables one core to receive packets from all ethernet ports.

---
 examples/ipsec-secgw/event_helper.c | 126 ++++++++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h |  33 ++++++++++
 2 files changed, 159 insertions(+)
examples/ipsec-secgw/event_helper.c +126 -0
index 0c38474..c90249f 100644
@@ -1,11 +1,33 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright (C) 2020 Marvell International Ltd.
  */
+#include <rte_bitmap.h>
 #include <rte_ethdev.h>
 #include <rte_eventdev.h>
+#include <rte_malloc.h>
 
 #include "event_helper.h"
 
+static inline unsigned int
+eh_get_next_active_core(struct eventmode_conf *em_conf, unsigned int prev_core)
+{
+	unsigned int next_core;
+
+	/* Get next active core skipping cores reserved as eth cores */
+	do {
+		/* Get the next core */
+		next_core = rte_get_next_lcore(prev_core, 0, 0);
+
+		/* Check if we have reached max lcores */
+		if (next_core == RTE_MAX_LCORE)
+			return next_core;
+
+		prev_core = next_core;
+	} while (rte_bitmap_get(em_conf->eth_core_mask, next_core));
+
+	return next_core;
+}
+
 static int
 eh_set_default_conf_eventdev(struct eventmode_conf *em_conf)
 {
@@ -77,6 +99,71 @@ eh_set_default_conf_eventdev(struct eventmode_conf *em_conf)
 }
 
 static int
+eh_set_default_conf_link(struct eventmode_conf *em_conf)
+{
+	struct eventdev_params *eventdev_config;
+	struct eh_event_link_info *link;
+	unsigned int lcore_id = -1;
+	int i, link_index;
+
+	/*
+	 * Create a 1:1 mapping from event ports to cores. If the number
+	 * of event ports is lesser than the cores, some cores won't
+	 * execute worker. If there are more event ports, then some ports
+	 * won't be used.
+	 *
+	 */
+
+	/*
+	 * The event queue-port mapping is done according to the link. Since
+	 * we are falling back to the default link config, enabling
+	 * "all_ev_queue_to_ev_port" mode flag. This will map all queues
+	 * to the port.
+	 */
+	em_conf->ext_params.all_ev_queue_to_ev_port = 1;
+
+	/* Get first event dev conf */
+	eventdev_config = &(em_conf->eventdev_config[0]);
+
+	/* Loop through the ports */
+	for (i = 0; i < eventdev_config->nb_eventport; i++) {
+
+		/* Get next active core id */
+		lcore_id = eh_get_next_active_core(em_conf,
+				lcore_id);
+
+		if (lcore_id == RTE_MAX_LCORE) {
+			/* Reached max cores */
+			return 0;
+		}
+
+		/* Save the current combination as one link */
+
+		/* Get the index */
+		link_index = em_conf->nb_link;
+
+		/* Get the corresponding link */
+		link = &(em_conf->link[link_index]);
+
+		/* Save link */
+		link->eventdev_id = eventdev_config->eventdev_id;
+		link->event_port_id = i;
+		link->lcore_id = lcore_id;
+
+		/*
+		 * Don't set eventq_id as by default all queues
+		 * need to be mapped to the port, which is controlled
+		 * by the operating mode.
+		 */
+
+		/* Update number of links */
+		em_conf->nb_link++;
+	}
+
+	return 0;
+}
+
+static int
 eh_validate_conf(struct eventmode_conf *em_conf)
 {
 	int ret;
@@ -91,6 +178,16 @@ eh_validate_conf(struct eventmode_conf *em_conf)
 			return ret;
 	}
 
+	/*
+	 * Check if links are specified. Else generate a default config for
+	 * the event ports used.
+	 */
+	if (em_conf->nb_link == 0) {
+		ret = eh_set_default_conf_link(em_conf);
+		if (ret != 0)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -102,6 +199,8 @@ eh_initialize_eventdev(struct eventmode_conf *em_conf)
 	struct rte_event_dev_config eventdev_conf;
 	struct eventdev_params *eventdev_config;
 	int nb_eventdev = em_conf->nb_eventdev;
+	struct eh_event_link_info *link;
+	uint8_t *queue = NULL;
 	uint8_t eventdev_id;
 	int nb_eventqueue;
 	uint8_t i, j;
@@ -199,6 +298,33 @@ eh_initialize_eventdev(struct eventmode_conf *em_conf)
 		}
 	}
 
+	/* Make event queue - event port link */
+	for (j = 0; j <  em_conf->nb_link; j++) {
+
+		/* Get link info */
+		link = &(em_conf->link[j]);
+
+		/* Get event dev ID */
+		eventdev_id = link->eventdev_id;
+
+		/*
+		 * If "all_ev_queue_to_ev_port" params flag is selected, all
+		 * queues need to be mapped to the port.
+		 */
+		if (em_conf->ext_params.all_ev_queue_to_ev_port)
+			queue = NULL;
+		else
+			queue = &(link->eventq_id);
+
+		/* Link queue to port */
+		ret = rte_event_port_link(eventdev_id, link->event_port_id,
+				queue, NULL, 1);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to link event port %d", ret);
+			return ret;
+		}
+	}
+
 	/* Start event devices */
 	for (i = 0; i < nb_eventdev; i++) {
 
examples/ipsec-secgw/event_helper.h +33 -0
index 040f977..c8afc84 100644
@@ -16,6 +16,13 @@
 /* Max event devices supported */
 #define EVENT_MODE_MAX_EVENT_DEVS RTE_EVENT_MAX_DEVS
 
+/* Max event queues supported per event device */
+#define EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV RTE_EVENT_MAX_QUEUES_PER_DEV
+
+/* Max event-lcore links */
+#define EVENT_MODE_MAX_LCORE_LINKS \
+	(EVENT_MODE_MAX_EVENT_DEVS * EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV)
+
 /**
  * Packet transfer mode of the application
  */
@@ -32,17 +39,43 @@ struct eventdev_params {
 	uint8_t ev_queue_mode;
 };
 
+/**
+ * Event-lcore link configuration
+ */
+struct eh_event_link_info {
+	uint8_t eventdev_id;
+		/**< Event device ID */
+	uint8_t event_port_id;
+		/**< Event port ID */
+	uint8_t eventq_id;
+		/**< Event queue to be linked to the port */
+	uint8_t lcore_id;
+		/**< Lcore to be polling on this port */
+};
+
 /* Eventmode conf data */
 struct eventmode_conf {
 	int nb_eventdev;
 		/**< No of event devs */
 	struct eventdev_params eventdev_config[EVENT_MODE_MAX_EVENT_DEVS];
 		/**< Per event dev conf */
+	uint8_t nb_link;
+		/**< No of links */
+	struct eh_event_link_info
+		link[EVENT_MODE_MAX_LCORE_LINKS];
+		/**< Per link conf */
+	struct rte_bitmap *eth_core_mask;
+		/**< Core mask of cores to be used for software Rx and Tx */
 	union {
 		RTE_STD_C11
 		struct {
 			uint64_t sched_type			: 2;
 		/**< Schedule type */
+			uint64_t all_ev_queue_to_ev_port	: 1;
+		/**<
+		 * When enabled, all event queues need to be mapped to
+		 * each event port
+		 */
 		};
 		uint64_t u64;
 	} ext_params;
Signature · 1 line
2.7.4
#127 lore raw

PATCH v5 4/15 examples/ipsec-secgw: add Rx adapter support

In reply to Lukasz Bartosik

From: Anoob Joseph <[email protected]>

Add Rx adapter support. The event helper init routine will initialize the Rx adapter according to the configuration. If Rx adapter config is not present it will generate a default config. If there are enough event queues available it will map eth ports and event queues 1:1 (one eth port will be connected to one event queue). Otherwise it will map all eth ports to one event queue.

---
 examples/ipsec-secgw/event_helper.c | 273 +++++++++++++++++++++++++++++++++++-
 examples/ipsec-secgw/event_helper.h |  29 ++++
 2 files changed, 301 insertions(+), 1 deletion(-)
examples/ipsec-secgw/event_helper.c +272 -1
index c90249f..2653e86 100644
@@ -4,10 +4,58 @@
 #include <rte_bitmap.h>
 #include <rte_ethdev.h>
 #include <rte_eventdev.h>
+#include <rte_event_eth_rx_adapter.h>
 #include <rte_malloc.h>
+#include <stdbool.h>
 
 #include "event_helper.h"
 
+static int
+eh_get_enabled_cores(struct rte_bitmap *eth_core_mask)
+{
+	int i, count = 0;
+
+	RTE_LCORE_FOREACH(i) {
+		/* Check if this core is enabled in core mask*/
+		if (rte_bitmap_get(eth_core_mask, i)) {
+			/* Found enabled core */
+			count++;
+		}
+	}
+	return count;
+}
+
+static inline unsigned int
+eh_get_next_eth_core(struct eventmode_conf *em_conf)
+{
+	static unsigned int prev_core = -1;
+	unsigned int next_core;
+
+	/*
+	 * Make sure we have at least one eth core running, else the following
+	 * logic would lead to an infinite loop.
+	 */
+	if (eh_get_enabled_cores(em_conf->eth_core_mask) == 0) {
+		EH_LOG_ERR("No enabled eth core found");
+		return RTE_MAX_LCORE;
+	}
+
+	/* Only some cores are marked as eth cores, skip others */
+	do {
+		/* Get the next core */
+		next_core = rte_get_next_lcore(prev_core, 0, 1);
+
+		/* Check if we have reached max lcores */
+		if (next_core == RTE_MAX_LCORE)
+			return next_core;
+
+		/* Update prev_core */
+		prev_core = next_core;
+	} while (!(rte_bitmap_get(em_conf->eth_core_mask, next_core)));
+
+	return next_core;
+}
+
 static inline unsigned int
 eh_get_next_active_core(struct eventmode_conf *em_conf, unsigned int prev_core)
 {
@@ -164,6 +212,82 @@ eh_set_default_conf_link(struct eventmode_conf *em_conf)
 }
 
 static int
+eh_set_default_conf_rx_adapter(struct eventmode_conf *em_conf)
+{
+	struct rx_adapter_connection_info *conn;
+	struct eventdev_params *eventdev_config;
+	struct rx_adapter_conf *adapter;
+	bool single_ev_queue = false;
+	int eventdev_id;
+	int nb_eth_dev;
+	int adapter_id;
+	int conn_id;
+	int i;
+
+	/* Create one adapter with eth queues mapped to event queue(s) */
+
+	if (em_conf->nb_eventdev == 0) {
+		EH_LOG_ERR("No event devs registered");
+		return -EINVAL;
+	}
+
+	/* Get the number of eth devs */
+	nb_eth_dev = rte_eth_dev_count_avail();
+
+	/* Use the first event dev */
+	eventdev_config = &(em_conf->eventdev_config[0]);
+
+	/* Get eventdev ID */
+	eventdev_id = eventdev_config->eventdev_id;
+	adapter_id = 0;
+
+	/* Get adapter conf */
+	adapter = &(em_conf->rx_adapter[adapter_id]);
+
+	/* Set adapter conf */
+	adapter->eventdev_id = eventdev_id;
+	adapter->adapter_id = adapter_id;
+	adapter->rx_core_id = eh_get_next_eth_core(em_conf);
+
+	/*
+	 * Map all queues of eth device (port) to an event queue. If there
+	 * are more event queues than eth ports then create 1:1 mapping.
+	 * Otherwise map all eth ports to a single event queue.
+	 */
+	if (nb_eth_dev > eventdev_config->nb_eventqueue)
+		single_ev_queue = true;
+
+	for (i = 0; i < nb_eth_dev; i++) {
+
+		/* Use only the ports enabled */
+		if ((em_conf->eth_portmask & (1 << i)) == 0)
+			continue;
+
+		/* Get the connection id */
+		conn_id = adapter->nb_connections;
+
+		/* Get the connection */
+		conn = &(adapter->conn[conn_id]);
+
+		/* Set mapping between eth ports & event queues*/
+		conn->ethdev_id = i;
+		conn->eventq_id = single_ev_queue ? 0 : i;
+
+		/* Add all eth queues eth port to event queue */
+		conn->ethdev_rx_qid = -1;
+
+		/* Update no of connections */
+		adapter->nb_connections++;
+
+	}
+
+	/* We have setup one adapter */
+	em_conf->nb_rx_adapter = 1;
+
+	return 0;
+}
+
+static int
 eh_validate_conf(struct eventmode_conf *em_conf)
 {
 	int ret;
@@ -188,6 +312,16 @@ eh_validate_conf(struct eventmode_conf *em_conf)
 			return ret;
 	}
 
+	/*
+	 * Check if rx adapters are specified. Else generate a default config
+	 * with one rx adapter and all eth queues - event queue mapped.
+	 */
+	if (em_conf->nb_rx_adapter == 0) {
+		ret = eh_set_default_conf_rx_adapter(em_conf);
+		if (ret != 0)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -341,6 +475,104 @@ eh_initialize_eventdev(struct eventmode_conf *em_conf)
 	return 0;
 }
 
+static int
+eh_rx_adapter_configure(struct eventmode_conf *em_conf,
+		struct rx_adapter_conf *adapter)
+{
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+	struct rte_event_dev_info evdev_default_conf = {0};
+	struct rte_event_port_conf port_conf = {0};
+	struct rx_adapter_connection_info *conn;
+	uint8_t eventdev_id;
+	uint32_t service_id;
+	int ret;
+	int j;
+
+	/* Get event dev ID */
+	eventdev_id = adapter->eventdev_id;
+
+	/* Get default configuration of event dev */
+	ret = rte_event_dev_info_get(eventdev_id, &evdev_default_conf);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to get event dev info %d", ret);
+		return ret;
+	}
+
+	/* Setup port conf */
+	port_conf.new_event_threshold = 1200;
+	port_conf.dequeue_depth =
+			evdev_default_conf.max_event_port_dequeue_depth;
+	port_conf.enqueue_depth =
+			evdev_default_conf.max_event_port_enqueue_depth;
+
+	/* Create Rx adapter */
+	ret = rte_event_eth_rx_adapter_create(adapter->adapter_id,
+			adapter->eventdev_id, &port_conf);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to create rx adapter %d", ret);
+		return ret;
+	}
+
+	/* Setup various connections in the adapter */
+	for (j = 0; j < adapter->nb_connections; j++) {
+		/* Get connection */
+		conn = &(adapter->conn[j]);
+
+		/* Setup queue conf */
+		queue_conf.ev.queue_id = conn->eventq_id;
+		queue_conf.ev.sched_type = em_conf->ext_params.sched_type;
+		queue_conf.ev.event_type = RTE_EVENT_TYPE_ETHDEV;
+
+		/* Add queue to the adapter */
+		ret = rte_event_eth_rx_adapter_queue_add(adapter->adapter_id,
+				conn->ethdev_id, conn->ethdev_rx_qid,
+				&queue_conf);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to add eth queue to rx adapter %d",
+				   ret);
+			return ret;
+		}
+	}
+
+	/* Get the service ID used by rx adapter */
+	ret = rte_event_eth_rx_adapter_service_id_get(adapter->adapter_id,
+						      &service_id);
+	if (ret != -ESRCH && ret < 0) {
+		EH_LOG_ERR("Failed to get service id used by rx adapter %d",
+			   ret);
+		return ret;
+	}
+
+	rte_service_set_runstate_mapped_check(service_id, 0);
+
+	/* Start adapter */
+	ret = rte_event_eth_rx_adapter_start(adapter->adapter_id);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to start rx adapter %d", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int
+eh_initialize_rx_adapter(struct eventmode_conf *em_conf)
+{
+	struct rx_adapter_conf *adapter;
+	int i, ret;
+
+	/* Configure rx adapters */
+	for (i = 0; i < em_conf->nb_rx_adapter; i++) {
+		adapter = &(em_conf->rx_adapter[i]);
+		ret = eh_rx_adapter_configure(em_conf, adapter);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to configure rx adapter %d", ret);
+			return ret;
+		}
+	}
+	return 0;
+}
+
 int32_t
 eh_devs_init(struct eh_conf *conf)
 {
@@ -364,6 +596,9 @@ eh_devs_init(struct eh_conf *conf)
 	/* Get eventmode conf */
 	em_conf = conf->mode_params;
 
+	/* Eventmode conf would need eth portmask */
+	em_conf->eth_portmask = conf->eth_portmask;
+
 	/* Validate the requested config */
 	ret = eh_validate_conf(em_conf);
 	if (ret < 0) {
@@ -388,6 +623,13 @@ eh_devs_init(struct eh_conf *conf)
 		return ret;
 	}
 
+	/* Setup Rx adapter */
+	ret = eh_initialize_rx_adapter(em_conf);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to initialize rx adapter %d", ret);
+		return ret;
+	}
+
 	/* Start eth devices after setting up adapter */
 	RTE_ETH_FOREACH_DEV(port_id) {
 
@@ -410,8 +652,8 @@ int32_t
 eh_devs_uninit(struct eh_conf *conf)
 {
 	struct eventmode_conf *em_conf;
+	int ret, i, j;
 	uint16_t id;
-	int ret, i;
 
 	if (conf == NULL) {
 		EH_LOG_ERR("Invalid event helper configuration");
@@ -429,6 +671,35 @@ eh_devs_uninit(struct eh_conf *conf)
 	/* Get eventmode conf */
 	em_conf = conf->mode_params;
 
+	/* Stop and release rx adapters */
+	for (i = 0; i < em_conf->nb_rx_adapter; i++) {
+
+		id = em_conf->rx_adapter[i].adapter_id;
+		ret = rte_event_eth_rx_adapter_stop(id);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to stop rx adapter %d", ret);
+			return ret;
+		}
+
+		for (j = 0; j < em_conf->rx_adapter[i].nb_connections; j++) {
+
+			ret = rte_event_eth_rx_adapter_queue_del(id,
+				em_conf->rx_adapter[i].conn[j].ethdev_id, -1);
+			if (ret < 0) {
+				EH_LOG_ERR(
+				       "Failed to remove rx adapter queues %d",
+				       ret);
+				return ret;
+			}
+		}
+
+		ret = rte_event_eth_rx_adapter_free(id);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to free rx adapter %d", ret);
+			return ret;
+		}
+	}
+
 	/* Stop and release event devices */
 	for (i = 0; i < em_conf->nb_eventdev; i++) {
 
examples/ipsec-secgw/event_helper.h +29 -0
index c8afc84..00ce14e 100644
@@ -16,6 +16,12 @@
 /* Max event devices supported */
 #define EVENT_MODE_MAX_EVENT_DEVS RTE_EVENT_MAX_DEVS
 
+/* Max Rx adapters supported */
+#define EVENT_MODE_MAX_RX_ADAPTERS RTE_EVENT_MAX_DEVS
+
+/* Max Rx adapter connections */
+#define EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER 16
+
 /* Max event queues supported per event device */
 #define EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV RTE_EVENT_MAX_QUEUES_PER_DEV
 
@@ -53,12 +59,33 @@ struct eh_event_link_info {
 		/**< Lcore to be polling on this port */
 };
 
+/* Rx adapter connection info */
+struct rx_adapter_connection_info {
+	uint8_t ethdev_id;
+	uint8_t eventq_id;
+	int32_t ethdev_rx_qid;
+};
+
+/* Rx adapter conf */
+struct rx_adapter_conf {
+	int32_t eventdev_id;
+	int32_t adapter_id;
+	uint32_t rx_core_id;
+	uint8_t nb_connections;
+	struct rx_adapter_connection_info
+			conn[EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER];
+};
+
 /* Eventmode conf data */
 struct eventmode_conf {
 	int nb_eventdev;
 		/**< No of event devs */
 	struct eventdev_params eventdev_config[EVENT_MODE_MAX_EVENT_DEVS];
 		/**< Per event dev conf */
+	uint8_t nb_rx_adapter;
+		/**< No of Rx adapters */
+	struct rx_adapter_conf rx_adapter[EVENT_MODE_MAX_RX_ADAPTERS];
+		/**< Rx adapter conf */
 	uint8_t nb_link;
 		/**< No of links */
 	struct eh_event_link_info
@@ -66,6 +93,8 @@ struct eventmode_conf {
 		/**< Per link conf */
 	struct rte_bitmap *eth_core_mask;
 		/**< Core mask of cores to be used for software Rx and Tx */
+	uint32_t eth_portmask;
+		/**< Mask of the eth ports to be used */
 	union {
 		RTE_STD_C11
 		struct {
Signature · 1 line
2.7.4
#128 lore raw

PATCH v5 5/15 examples/ipsec-secgw: add Tx adapter support

In reply to Lukasz Bartosik

From: Anoob Joseph <[email protected]>

Add Tx adapter support. The event helper init routine will initialize the Tx adapter according to the configuration. If Tx adapter config is not present it will generate a default config.

---
 examples/ipsec-secgw/event_helper.c | 313 ++++++++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h |  48 ++++++
 2 files changed, 361 insertions(+)
examples/ipsec-secgw/event_helper.c +313 -0
index 2653e86..fca1e08 100644
@@ -5,6 +5,7 @@
 #include <rte_ethdev.h>
 #include <rte_eventdev.h>
 #include <rte_event_eth_rx_adapter.h>
+#include <rte_event_eth_tx_adapter.h>
 #include <rte_malloc.h>
 #include <stdbool.h>
 
@@ -76,6 +77,22 @@ eh_get_next_active_core(struct eventmode_conf *em_conf, unsigned int prev_core)
 	return next_core;
 }
 
+static struct eventdev_params *
+eh_get_eventdev_params(struct eventmode_conf *em_conf, uint8_t eventdev_id)
+{
+	int i;
+
+	for (i = 0; i < em_conf->nb_eventdev; i++) {
+		if (em_conf->eventdev_config[i].eventdev_id == eventdev_id)
+			break;
+	}
+
+	/* No match */
+	if (i == em_conf->nb_eventdev)
+		return NULL;
+
+	return &(em_conf->eventdev_config[i]);
+}
 static int
 eh_set_default_conf_eventdev(struct eventmode_conf *em_conf)
 {
@@ -288,6 +305,95 @@ eh_set_default_conf_rx_adapter(struct eventmode_conf *em_conf)
 }
 
 static int
+eh_set_default_conf_tx_adapter(struct eventmode_conf *em_conf)
+{
+	struct tx_adapter_connection_info *conn;
+	struct eventdev_params *eventdev_config;
+	struct tx_adapter_conf *tx_adapter;
+	int eventdev_id;
+	int adapter_id;
+	int nb_eth_dev;
+	int conn_id;
+	int i;
+
+	/*
+	 * Create one Tx adapter with all eth queues mapped to event queues
+	 * 1:1.
+	 */
+
+	if (em_conf->nb_eventdev == 0) {
+		EH_LOG_ERR("No event devs registered");
+		return -EINVAL;
+	}
+
+	/* Get the number of eth devs */
+	nb_eth_dev = rte_eth_dev_count_avail();
+
+	/* Use the first event dev */
+	eventdev_config = &(em_conf->eventdev_config[0]);
+
+	/* Get eventdev ID */
+	eventdev_id = eventdev_config->eventdev_id;
+	adapter_id = 0;
+
+	/* Get adapter conf */
+	tx_adapter = &(em_conf->tx_adapter[adapter_id]);
+
+	/* Set adapter conf */
+	tx_adapter->eventdev_id = eventdev_id;
+	tx_adapter->adapter_id = adapter_id;
+
+	/* TODO: Tx core is required only when internal port is not present */
+	tx_adapter->tx_core_id = eh_get_next_eth_core(em_conf);
+
+	/*
+	 * Application uses one event queue per adapter for submitting
+	 * packets for Tx. Reserve the last queue available and decrement
+	 * the total available event queues for this
+	 */
+
+	/* Queue numbers start at 0 */
+	tx_adapter->tx_ev_queue = eventdev_config->nb_eventqueue - 1;
+
+	/*
+	 * Map all Tx queues of the eth device (port) to the event device.
+	 */
+
+	/* Set defaults for connections */
+
+	/*
+	 * One eth device (port) is one connection. Map all Tx queues
+	 * of the device to the Tx adapter.
+	 */
+
+	for (i = 0; i < nb_eth_dev; i++) {
+
+		/* Use only the ports enabled */
+		if ((em_conf->eth_portmask & (1 << i)) == 0)
+			continue;
+
+		/* Get the connection id */
+		conn_id = tx_adapter->nb_connections;
+
+		/* Get the connection */
+		conn = &(tx_adapter->conn[conn_id]);
+
+		/* Add ethdev to connections */
+		conn->ethdev_id = i;
+
+		/* Add all eth tx queues to adapter */
+		conn->ethdev_tx_qid = -1;
+
+		/* Update no of connections */
+		tx_adapter->nb_connections++;
+	}
+
+	/* We have setup one adapter */
+	em_conf->nb_tx_adapter = 1;
+	return 0;
+}
+
+static int
 eh_validate_conf(struct eventmode_conf *em_conf)
 {
 	int ret;
@@ -322,6 +428,16 @@ eh_validate_conf(struct eventmode_conf *em_conf)
 			return ret;
 	}
 
+	/*
+	 * Check if tx adapters are specified. Else generate a default config
+	 * with one tx adapter.
+	 */
+	if (em_conf->nb_tx_adapter == 0) {
+		ret = eh_set_default_conf_tx_adapter(em_conf);
+		if (ret != 0)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -573,6 +689,133 @@ eh_initialize_rx_adapter(struct eventmode_conf *em_conf)
 	return 0;
 }
 
+static int
+eh_tx_adapter_configure(struct eventmode_conf *em_conf,
+		struct tx_adapter_conf *adapter)
+{
+	struct rte_event_dev_info evdev_default_conf = {0};
+	struct rte_event_port_conf port_conf = {0};
+	struct tx_adapter_connection_info *conn;
+	struct eventdev_params *eventdev_config;
+	uint8_t tx_port_id = 0;
+	uint8_t eventdev_id;
+	uint32_t service_id;
+	int ret, j;
+
+	/* Get event dev ID */
+	eventdev_id = adapter->eventdev_id;
+
+	/* Get event device conf */
+	eventdev_config = eh_get_eventdev_params(em_conf, eventdev_id);
+
+	/* Create Tx adapter */
+
+	/* Get default configuration of event dev */
+	ret = rte_event_dev_info_get(eventdev_id, &evdev_default_conf);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to get event dev info %d", ret);
+		return ret;
+	}
+
+	/* Setup port conf */
+	port_conf.new_event_threshold =
+			evdev_default_conf.max_num_events;
+	port_conf.dequeue_depth =
+			evdev_default_conf.max_event_port_dequeue_depth;
+	port_conf.enqueue_depth =
+			evdev_default_conf.max_event_port_enqueue_depth;
+
+	/* Create adapter */
+	ret = rte_event_eth_tx_adapter_create(adapter->adapter_id,
+			adapter->eventdev_id, &port_conf);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to create tx adapter %d", ret);
+		return ret;
+	}
+
+	/* Setup various connections in the adapter */
+	for (j = 0; j < adapter->nb_connections; j++) {
+
+		/* Get connection */
+		conn = &(adapter->conn[j]);
+
+		/* Add queue to the adapter */
+		ret = rte_event_eth_tx_adapter_queue_add(adapter->adapter_id,
+				conn->ethdev_id, conn->ethdev_tx_qid);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to add eth queue to tx adapter %d",
+				   ret);
+			return ret;
+		}
+	}
+
+	/* Setup Tx queue & port */
+
+	/* Get event port used by the adapter */
+	ret = rte_event_eth_tx_adapter_event_port_get(
+			adapter->adapter_id, &tx_port_id);
+	if (ret) {
+		EH_LOG_ERR("Failed to get tx adapter port id %d", ret);
+		return ret;
+	}
+
+	/*
+	 * Tx event queue is reserved for Tx adapter. Unlink this queue
+	 * from all other ports
+	 *
+	 */
+	for (j = 0; j < eventdev_config->nb_eventport; j++) {
+		rte_event_port_unlink(eventdev_id, j,
+				      &(adapter->tx_ev_queue), 1);
+	}
+
+	/* Link Tx event queue to Tx port */
+	ret = rte_event_port_link(eventdev_id, tx_port_id,
+			&(adapter->tx_ev_queue), NULL, 1);
+	if (ret != 1) {
+		EH_LOG_ERR("Failed to link event queue to port");
+		return ret;
+	}
+
+	/* Get the service ID used by Tx adapter */
+	ret = rte_event_eth_tx_adapter_service_id_get(adapter->adapter_id,
+						      &service_id);
+	if (ret != -ESRCH && ret < 0) {
+		EH_LOG_ERR("Failed to get service id used by tx adapter %d",
+			   ret);
+		return ret;
+	}
+
+	rte_service_set_runstate_mapped_check(service_id, 0);
+
+	/* Start adapter */
+	ret = rte_event_eth_tx_adapter_start(adapter->adapter_id);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to start tx adapter %d", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int
+eh_initialize_tx_adapter(struct eventmode_conf *em_conf)
+{
+	struct tx_adapter_conf *adapter;
+	int i, ret;
+
+	/* Configure Tx adapters */
+	for (i = 0; i < em_conf->nb_tx_adapter; i++) {
+		adapter = &(em_conf->tx_adapter[i]);
+		ret = eh_tx_adapter_configure(em_conf, adapter);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to configure tx adapter %d", ret);
+			return ret;
+		}
+	}
+	return 0;
+}
+
 int32_t
 eh_devs_init(struct eh_conf *conf)
 {
@@ -630,6 +873,13 @@ eh_devs_init(struct eh_conf *conf)
 		return ret;
 	}
 
+	/* Setup Tx adapter */
+	ret = eh_initialize_tx_adapter(em_conf);
+	if (ret < 0) {
+		EH_LOG_ERR("Failed to initialize tx adapter %d", ret);
+		return ret;
+	}
+
 	/* Start eth devices after setting up adapter */
 	RTE_ETH_FOREACH_DEV(port_id) {
 
@@ -713,5 +963,68 @@ eh_devs_uninit(struct eh_conf *conf)
 		}
 	}
 
+	/* Stop and release tx adapters */
+	for (i = 0; i < em_conf->nb_tx_adapter; i++) {
+
+		id = em_conf->tx_adapter[i].adapter_id;
+		ret = rte_event_eth_tx_adapter_stop(id);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to stop tx adapter %d", ret);
+			return ret;
+		}
+
+		for (j = 0; j < em_conf->tx_adapter[i].nb_connections; j++) {
+
+			ret = rte_event_eth_tx_adapter_queue_del(id,
+				em_conf->tx_adapter[i].conn[j].ethdev_id, -1);
+			if (ret < 0) {
+				EH_LOG_ERR(
+					"Failed to remove tx adapter queues %d",
+					ret);
+				return ret;
+			}
+		}
+
+		ret = rte_event_eth_tx_adapter_free(id);
+		if (ret < 0) {
+			EH_LOG_ERR("Failed to free tx adapter %d", ret);
+			return ret;
+		}
+	}
+
 	return 0;
 }
+
+uint8_t
+eh_get_tx_queue(struct eh_conf *conf, uint8_t eventdev_id)
+{
+	struct eventdev_params *eventdev_config;
+	struct eventmode_conf *em_conf;
+
+	if (conf == NULL) {
+		EH_LOG_ERR("Invalid event helper configuration");
+		return -EINVAL;
+	}
+
+	if (conf->mode_params == NULL) {
+		EH_LOG_ERR("Invalid event mode parameters");
+		return -EINVAL;
+	}
+
+	/* Get eventmode conf */
+	em_conf = conf->mode_params;
+
+	/* Get event device conf */
+	eventdev_config = eh_get_eventdev_params(em_conf, eventdev_id);
+
+	if (eventdev_config == NULL) {
+		EH_LOG_ERR("Failed to read eventdev config");
+		return -EINVAL;
+	}
+
+	/*
+	 * The last queue is reserved to be used as atomic queue for the
+	 * last stage (eth packet tx stage)
+	 */
+	return eventdev_config->nb_eventqueue - 1;
+}
examples/ipsec-secgw/event_helper.h +48 -0

79 lines not on this page · raw message

Signature · 1 line
2.7.4
#129 lore raw

PATCH v5 6/15 examples/ipsec-secgw: add routines to display config

In reply to Lukasz Bartosik

From: Anoob Joseph <[email protected]>

Add routines to display the eventmode configuration and provide an overview of the devices used.

---
 examples/ipsec-secgw/event_helper.c | 207 ++++++++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h |  14 +++
 2 files changed, 221 insertions(+)
examples/ipsec-secgw/event_helper.c +207 -0
index fca1e08..d09bf7d 100644
@@ -816,6 +816,210 @@ eh_initialize_tx_adapter(struct eventmode_conf *em_conf)
 	return 0;
 }
 
+static void
+eh_display_operating_mode(struct eventmode_conf *em_conf)
+{
+	char sched_types[][32] = {
+		"RTE_SCHED_TYPE_ORDERED",
+		"RTE_SCHED_TYPE_ATOMIC",
+		"RTE_SCHED_TYPE_PARALLEL",
+	};
+	EH_LOG_INFO("Operating mode:");
+
+	EH_LOG_INFO("\tScheduling type: \t%s",
+		sched_types[em_conf->ext_params.sched_type]);
+
+	EH_LOG_INFO("");
+}
+
+static void
+eh_display_event_dev_conf(struct eventmode_conf *em_conf)
+{
+	char queue_mode[][32] = {
+		"",
+		"ATQ (ALL TYPE QUEUE)",
+		"SINGLE LINK",
+	};
+	char print_buf[256] = { 0 };
+	int i;
+
+	EH_LOG_INFO("Event Device Configuration:");
+
+	for (i = 0; i < em_conf->nb_eventdev; i++) {
+		sprintf(print_buf,
+			"\tDev ID: %-2d \tQueues: %-2d \tPorts: %-2d",
+			em_conf->eventdev_config[i].eventdev_id,
+			em_conf->eventdev_config[i].nb_eventqueue,
+			em_conf->eventdev_config[i].nb_eventport);
+		sprintf(print_buf + strlen(print_buf),
+			"\tQueue mode: %s",
+			queue_mode[em_conf->eventdev_config[i].ev_queue_mode]);
+		EH_LOG_INFO("%s", print_buf);
+	}
+	EH_LOG_INFO("");
+}
+
+static void
+eh_display_rx_adapter_conf(struct eventmode_conf *em_conf)
+{
+	int nb_rx_adapter = em_conf->nb_rx_adapter;
+	struct rx_adapter_connection_info *conn;
+	struct rx_adapter_conf *adapter;
+	char print_buf[256] = { 0 };
+	int i, j;
+
+	EH_LOG_INFO("Rx adapters configured: %d", nb_rx_adapter);
+
+	for (i = 0; i < nb_rx_adapter; i++) {
+		adapter = &(em_conf->rx_adapter[i]);
+		EH_LOG_INFO(
+			"\tRx adaper ID: %-2d\tConnections: %-2d\tEvent dev ID: %-2d"
+			"\tRx core: %-2d",
+			adapter->adapter_id,
+			adapter->nb_connections,
+			adapter->eventdev_id,
+			adapter->rx_core_id);
+
+		for (j = 0; j < adapter->nb_connections; j++) {
+			conn = &(adapter->conn[j]);
+
+			sprintf(print_buf,
+				"\t\tEthdev ID: %-2d", conn->ethdev_id);
+
+			if (conn->ethdev_rx_qid == -1)
+				sprintf(print_buf + strlen(print_buf),
+					"\tEth rx queue: %-2s", "ALL");
+			else
+				sprintf(print_buf + strlen(print_buf),
+					"\tEth rx queue: %-2d",
+					conn->ethdev_rx_qid);
+
+			sprintf(print_buf + strlen(print_buf),
+				"\tEvent queue: %-2d", conn->eventq_id);
+			EH_LOG_INFO("%s", print_buf);
+		}
+	}
+	EH_LOG_INFO("");
+}
+
+static void
+eh_display_tx_adapter_conf(struct eventmode_conf *em_conf)
+{
+	int nb_tx_adapter = em_conf->nb_tx_adapter;
+	struct tx_adapter_connection_info *conn;
+	struct tx_adapter_conf *adapter;
+	char print_buf[256] = { 0 };
+	int i, j;
+
+	EH_LOG_INFO("Tx adapters configured: %d", nb_tx_adapter);
+
+	for (i = 0; i < nb_tx_adapter; i++) {
+		adapter = &(em_conf->tx_adapter[i]);
+		sprintf(print_buf,
+			"\tTx adapter ID: %-2d\tConnections: %-2d\tEvent dev ID: %-2d",
+			adapter->adapter_id,
+			adapter->nb_connections,
+			adapter->eventdev_id);
+		if (adapter->tx_core_id == (uint32_t)-1)
+			sprintf(print_buf + strlen(print_buf),
+				"\tTx core: %-2s", "[INTERNAL PORT]");
+		else if (adapter->tx_core_id == RTE_MAX_LCORE)
+			sprintf(print_buf + strlen(print_buf),
+				"\tTx core: %-2s", "[NONE]");
+		else
+			sprintf(print_buf + strlen(print_buf),
+				"\tTx core: %-2d,\tInput event queue: %-2d",
+				adapter->tx_core_id, adapter->tx_ev_queue);
+
+		EH_LOG_INFO("%s", print_buf);
+
+		for (j = 0; j < adapter->nb_connections; j++) {
+			conn = &(adapter->conn[j]);
+
+			sprintf(print_buf,
+				"\t\tEthdev ID: %-2d", conn->ethdev_id);
+
+			if (conn->ethdev_tx_qid == -1)
+				sprintf(print_buf + strlen(print_buf),
+					"\tEth tx queue: %-2s", "ALL");
+			else
+				sprintf(print_buf + strlen(print_buf),
+					"\tEth tx queue: %-2d",
+					conn->ethdev_tx_qid);
+			EH_LOG_INFO("%s", print_buf);
+		}
+	}
+	EH_LOG_INFO("");
+}
+
+static void
+eh_display_link_conf(struct eventmode_conf *em_conf)
+{
+	struct eh_event_link_info *link;
+	char print_buf[256] = { 0 };
+	int i;
+
+	EH_LOG_INFO("Links configured: %d", em_conf->nb_link);
+
+	for (i = 0; i < em_conf->nb_link; i++) {
+		link = &(em_conf->link[i]);
+
+		sprintf(print_buf,
+			"\tEvent dev ID: %-2d\tEvent port: %-2d",
+			link->eventdev_id,
+			link->event_port_id);
+
+		if (em_conf->ext_params.all_ev_queue_to_ev_port)
+			sprintf(print_buf + strlen(print_buf),
+				"Event queue: %-2s\t", "ALL");
+		else
+			sprintf(print_buf + strlen(print_buf),
+				"Event queue: %-2d\t", link->eventq_id);
+
+		sprintf(print_buf + strlen(print_buf),
+			"Lcore: %-2d", link->lcore_id);
+		EH_LOG_INFO("%s", print_buf);
+	}
+	EH_LOG_INFO("");
+}
+
+void
+eh_display_conf(struct eh_conf *conf)
+{
+	struct eventmode_conf *em_conf;
+
+	if (conf == NULL) {
+		EH_LOG_ERR("Invalid event helper configuration");
+		return;
+	}
+
+	if (conf->mode != EH_PKT_TRANSFER_MODE_EVENT)
+		return;
+
+	if (conf->mode_params == NULL) {
+		EH_LOG_ERR("Invalid event mode parameters");
+		return;
+	}
+
+	/* Get eventmode conf */
+	em_conf = (struct eventmode_conf *)(conf->mode_params);
+
+	/* Display user exposed operating modes */
+	eh_display_operating_mode(em_conf);
+
+	/* Display event device conf */
+	eh_display_event_dev_conf(em_conf);
+
+	/* Display Rx adapter conf */
+	eh_display_rx_adapter_conf(em_conf);
+
+	/* Display Tx adapter conf */
+	eh_display_tx_adapter_conf(em_conf);
+
+	/* Display event-lcore link */
+	eh_display_link_conf(em_conf);
+}
+
 int32_t
 eh_devs_init(struct eh_conf *conf)
 {
@@ -849,6 +1053,9 @@ eh_devs_init(struct eh_conf *conf)
 		return ret;
 	}
 
+	/* Display the current configuration */
+	eh_display_conf(conf);
+
 	/* Stop eth devices before setting up adapter */
 	RTE_ETH_FOREACH_DEV(port_id) {
 
examples/ipsec-secgw/event_helper.h +14 -0
index 913b172..8eb5e25 100644
@@ -13,6 +13,11 @@
 		RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
 			__func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,)))
 
+#define EH_LOG_INFO(...) \
+	RTE_LOG(INFO, EH, \
+		RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
+			__func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,)))
+
 /* Max event devices supported */
 #define EVENT_MODE_MAX_EVENT_DEVS RTE_EVENT_MAX_DEVS
 
@@ -214,4 +219,13 @@ eh_devs_uninit(struct eh_conf *conf);
 uint8_t
 eh_get_tx_queue(struct eh_conf *conf, uint8_t eventdev_id);
 
+/**
+ * Display event mode configuration
+ *
+ * @param conf
+ *   Event helper configuration
+ */
+void
+eh_display_conf(struct eh_conf *conf);
+
 #endif /* _EVENT_HELPER_H_ */
Signature · 1 line
2.7.4
#130 lore raw

PATCH v5 7/15 examples/ipsec-secgw: add routines to launch workers

In reply to Lukasz Bartosik

In eventmode workers can be drafted differently according to the capabilities of the underlying event device. The added functions will receive an array of such workers and probe the eventmode properties to choose the worker.

---
 examples/ipsec-secgw/event_helper.c | 336 ++++++++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h |  48 ++++++
 2 files changed, 384 insertions(+)
examples/ipsec-secgw/event_helper.c +336 -0
index d09bf7d..e3dfaf5 100644
@@ -11,6 +11,8 @@
 
 #include "event_helper.h"
 
+static volatile bool eth_core_running;
+
 static int
 eh_get_enabled_cores(struct rte_bitmap *eth_core_mask)
 {
@@ -93,6 +95,16 @@ eh_get_eventdev_params(struct eventmode_conf *em_conf, uint8_t eventdev_id)
 
 	return &(em_conf->eventdev_config[i]);
 }
+static inline bool
+eh_dev_has_burst_mode(uint8_t dev_id)
+{
+	struct rte_event_dev_info dev_info;
+
+	rte_event_dev_info_get(dev_id, &dev_info);
+	return (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) ?
+			true : false;
+}
+
 static int
 eh_set_default_conf_eventdev(struct eventmode_conf *em_conf)
 {
@@ -689,6 +701,257 @@ eh_initialize_rx_adapter(struct eventmode_conf *em_conf)
 	return 0;
 }
 
+static int32_t
+eh_start_worker_eth_core(struct eventmode_conf *conf, uint32_t lcore_id)
+{
+	uint32_t service_id[EVENT_MODE_MAX_ADAPTERS_PER_RX_CORE];
+	struct rx_adapter_conf *rx_adapter;
+	struct tx_adapter_conf *tx_adapter;
+	int service_count = 0;
+	int adapter_id;
+	int32_t ret;
+	int i;
+
+	EH_LOG_INFO("Entering eth_core processing on lcore %u", lcore_id);
+
+	/*
+	 * Parse adapter config to check which of all Rx adapters need
+	 * to be handled by this core.
+	 */
+	for (i = 0; i < conf->nb_rx_adapter; i++) {
+		/* Check if we have exceeded the max allowed */
+		if (service_count > EVENT_MODE_MAX_ADAPTERS_PER_RX_CORE) {
+			EH_LOG_ERR(
+			      "Exceeded the max allowed adapters per rx core");
+			break;
+		}
+
+		rx_adapter = &(conf->rx_adapter[i]);
+		if (rx_adapter->rx_core_id != lcore_id)
+			continue;
+
+		/* Adapter is handled by this core */
+		adapter_id = rx_adapter->adapter_id;
+
+		/* Get the service ID for the adapters */
+		ret = rte_event_eth_rx_adapter_service_id_get(adapter_id,
+				&(service_id[service_count]));
+
+		if (ret != -ESRCH && ret < 0) {
+			EH_LOG_ERR(
+				"Failed to get service id used by rx adapter");
+			return ret;
+		}
+
+		/* Update service count */
+		service_count++;
+	}
+
+	/*
+	 * Parse adapter config to see which of all Tx adapters need
+	 * to be handled by this core.
+	 */
+	for (i = 0; i < conf->nb_tx_adapter; i++) {
+		/* Check if we have exceeded the max allowed */
+		if (service_count > EVENT_MODE_MAX_ADAPTERS_PER_TX_CORE) {
+			EH_LOG_ERR(
+				"Exceeded the max allowed adapters per tx core");
+			break;
+		}
+
+		tx_adapter = &conf->tx_adapter[i];
+		if (tx_adapter->tx_core_id != lcore_id)
+			continue;
+
+		/* Adapter is handled by this core */
+		adapter_id = tx_adapter->adapter_id;
+
+		/* Get the service ID for the adapters */
+		ret = rte_event_eth_tx_adapter_service_id_get(adapter_id,
+				&(service_id[service_count]));
+
+		if (ret != -ESRCH && ret < 0) {
+			EH_LOG_ERR(
+				"Failed to get service id used by tx adapter");
+			return ret;
+		}
+
+		/* Update service count */
+		service_count++;
+	}
+
+	eth_core_running = true;
+
+	while (eth_core_running) {
+		for (i = 0; i < service_count; i++) {
+			/* Initiate adapter service */
+			rte_service_run_iter_on_app_lcore(service_id[i], 0);
+		}
+	}
+
+	return 0;
+}
+
+static int32_t
+eh_stop_worker_eth_core(void)
+{
+	if (eth_core_running) {
+		EH_LOG_INFO("Stopping eth cores");
+		eth_core_running = false;
+	}
+	return 0;
+}
+
+static struct eh_app_worker_params *
+eh_find_worker(uint32_t lcore_id, struct eh_conf *conf,
+		struct eh_app_worker_params *app_wrkrs, uint8_t nb_wrkr_param)
+{
+	struct eh_app_worker_params curr_conf = { {{0} }, NULL};
+	struct eh_event_link_info *link = NULL;
+	struct eh_app_worker_params *tmp_wrkr;
+	struct eventmode_conf *em_conf;
+	uint8_t eventdev_id;
+	int i;
+
+	/* Get eventmode config */
+	em_conf = conf->mode_params;
+
+	/*
+	 * Use event device from the first lcore-event link.
+	 *
+	 * Assumption: All lcore-event links tied to a core are using the
+	 * same event device. In other words, one core would be polling on
+	 * queues of a single event device only.
+	 */
+
+	/* Get a link for this lcore */
+	for (i = 0; i < em_conf->nb_link; i++) {
+		link = &(em_conf->link[i]);
+		if (link->lcore_id == lcore_id)
+			break;
+	}
+
+	if (link == NULL) {
+		EH_LOG_ERR("No valid link found for lcore %d", lcore_id);
+		return NULL;
+	}
+
+	/* Get event dev ID */
+	eventdev_id = link->eventdev_id;
+
+	/* Populate the curr_conf with the capabilities */
+
+	/* Check for burst mode */
+	if (eh_dev_has_burst_mode(eventdev_id))
+		curr_conf.cap.burst = EH_RX_TYPE_BURST;
+	else
+		curr_conf.cap.burst = EH_RX_TYPE_NON_BURST;
+
+	/* Parse the passed list and see if we have matching capabilities */
+
+	/* Initialize the pointer used to traverse the list */
+	tmp_wrkr = app_wrkrs;
+
+	for (i = 0; i < nb_wrkr_param; i++, tmp_wrkr++) {
+
+		/* Skip this if capabilities are not matching */
+		if (tmp_wrkr->cap.u64 != curr_conf.cap.u64)
+			continue;
+
+		/* If the checks pass, we have a match */
+		return tmp_wrkr;
+	}
+
+	return NULL;
+}
+
+static int
+eh_verify_match_worker(struct eh_app_worker_params *match_wrkr)
+{
+	/* Verify registered worker */
+	if (match_wrkr->worker_thread == NULL) {
+		EH_LOG_ERR("No worker registered");
+		return 0;
+	}
+
+	/* Success */
+	return 1;
+}
+
+static uint8_t
+eh_get_event_lcore_links(uint32_t lcore_id, struct eh_conf *conf,
+		struct eh_event_link_info **links)
+{
+	struct eh_event_link_info *link_cache;
+	struct eventmode_conf *em_conf = NULL;
+	struct eh_event_link_info *link;
+	uint8_t lcore_nb_link = 0;
+	size_t single_link_size;
+	size_t cache_size;
+	int index = 0;
+	int i;
+
+	if (conf == NULL || links == NULL) {
+		EH_LOG_ERR("Invalid args");
+		return -EINVAL;
+	}
+
+	/* Get eventmode conf */
+	em_conf = conf->mode_params;
+
+	if (em_conf == NULL) {
+		EH_LOG_ERR("Invalid event mode parameters");
+		return -EINVAL;
+	}
+
+	/* Get the number of links registered */
+	for (i = 0; i < em_conf->nb_link; i++) {
+
+		/* Get link */
+		link = &(em_conf->link[i]);
+
+		/* Check if we have link intended for this lcore */
+		if (link->lcore_id == lcore_id) {
+
+			/* Update the number of links for this core */
+			lcore_nb_link++;
+
+		}
+	}
+
+	/* Compute size of one entry to be copied */
+	single_link_size = sizeof(struct eh_event_link_info);
+
+	/* Compute size of the buffer required */
+	cache_size = lcore_nb_link * sizeof(struct eh_event_link_info);
+
+	/* Compute size of the buffer required */
+	link_cache = calloc(1, cache_size);
+
+	/* Get the number of links registered */
+	for (i = 0; i < em_conf->nb_link; i++) {
+
+		/* Get link */
+		link = &(em_conf->link[i]);
+
+		/* Check if we have link intended for this lcore */
+		if (link->lcore_id == lcore_id) {
+
+			/* Cache the link */
+			memcpy(&link_cache[index], link, single_link_size);
+
+			/* Update index */
+			index++;
+		}
+	}
+
+	/* Update the links for application to use the cached links */
+	*links = link_cache;
+
+	/* Return the number of cached links */
+	return lcore_nb_link;
+}
+
 static int
 eh_tx_adapter_configure(struct eventmode_conf *em_conf,
 		struct tx_adapter_conf *adapter)
@@ -1202,6 +1465,79 @@ eh_devs_uninit(struct eh_conf *conf)
 	return 0;
 }
 
+void
+eh_launch_worker(struct eh_conf *conf, struct eh_app_worker_params *app_wrkr,
+		uint8_t nb_wrkr_param)
+{
+	struct eh_app_worker_params *match_wrkr;
+	struct eh_event_link_info *links = NULL;
+	struct eventmode_conf *em_conf;
+	uint32_t lcore_id;
+	uint8_t nb_links;
+
+	if (conf == NULL) {
+		EH_LOG_ERR("Invalid event helper configuration");
+		return;
+	}
+
+	if (conf->mode_params == NULL) {
+		EH_LOG_ERR("Invalid event mode parameters");
+		return;
+	}
+
+	/* Get eventmode conf */
+	em_conf = conf->mode_params;
+
+	/* Get core ID */
+	lcore_id = rte_lcore_id();
+
+	/* Check if this is eth core */
+	if (rte_bitmap_get(em_conf->eth_core_mask, lcore_id)) {
+		eh_start_worker_eth_core(em_conf, lcore_id);
+		return;
+	}
+
+	if (app_wrkr == NULL || nb_wrkr_param == 0) {
+		EH_LOG_ERR("Invalid args");
+		return;
+	}
+
+	/*
+	 * This is a regular worker thread. The application registers
+	 * multiple workers with various capabilities. Run worker
+	 * based on the selected capabilities of the event
+	 * device configured.
+	 */
+
+	/* Get the first matching worker for the event device */
+	match_wrkr = eh_find_worker(lcore_id, conf, app_wrkr, nb_wrkr_param);
+	if (match_wrkr == NULL) {
+		EH_LOG_ERR("Failed to match worker registered for lcore %d",
+			   lcore_id);
+		goto clean_and_exit;
+	}
+
+	/* Verify sanity of the matched worker */
+	if (eh_verify_match_worker(match_wrkr) != 1) {
+		EH_LOG_ERR("Failed to validate the matched worker");
+		goto clean_and_exit;
+	}
+
+	/* Get worker links */
+	nb_links = eh_get_event_lcore_links(lcore_id, conf, &links);
+
+	/* Launch the worker thread */
+	match_wrkr->worker_thread(links, nb_links);
+
+	/* Free links info memory */
+	free(links);
+
+clean_and_exit:
+
+	/* Flag eth_cores to stop, if started */
+	eh_stop_worker_eth_core();
+}
+
 uint8_t
 eh_get_tx_queue(struct eh_conf *conf, uint8_t eventdev_id)
 {
examples/ipsec-secgw/event_helper.h +48 -0

70 lines not on this page · raw message

Signature · 1 line
2.7.4
#131 lore raw

PATCH v5 8/15 examples/ipsec-secgw: add support for internal ports

In reply to Lukasz Bartosik

Add support for Rx and Tx internal ports. When internal ports are available then a packet can be received from eth port and forwarded to event queue by HW without any software intervention. The same applies to Tx side where a packet sent to an event queue can by forwarded by HW to eth port without any software intervention.

---
 examples/ipsec-secgw/event_helper.c | 179 +++++++++++++++++++++++++++++++-----
 examples/ipsec-secgw/event_helper.h |  11 +++
 2 files changed, 167 insertions(+), 23 deletions(-)
examples/ipsec-secgw/event_helper.c +156 -23
index e3dfaf5..fe047ab 100644
@@ -95,6 +95,39 @@ eh_get_eventdev_params(struct eventmode_conf *em_conf, uint8_t eventdev_id)
 
 	return &(em_conf->eventdev_config[i]);
 }
+
+static inline bool
+eh_dev_has_rx_internal_port(uint8_t eventdev_id)
+{
+	bool flag = true;
+	int j;
+
+	RTE_ETH_FOREACH_DEV(j) {
+		uint32_t caps = 0;
+
+		rte_event_eth_rx_adapter_caps_get(eventdev_id, j, &caps);
+		if (!(caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT))
+			flag = false;
+	}
+	return flag;
+}
+
+static inline bool
+eh_dev_has_tx_internal_port(uint8_t eventdev_id)
+{
+	bool flag = true;
+	int j;
+
+	RTE_ETH_FOREACH_DEV(j) {
+		uint32_t caps = 0;
+
+		rte_event_eth_tx_adapter_caps_get(eventdev_id, j, &caps);
+		if (!(caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT))
+			flag = false;
+	}
+	return flag;
+}
+
 static inline bool
 eh_dev_has_burst_mode(uint8_t dev_id)
 {
@@ -175,6 +208,42 @@ eh_set_default_conf_eventdev(struct eventmode_conf *em_conf)
 	return 0;
 }
 
+static void
+eh_do_capability_check(struct eventmode_conf *em_conf)
+{
+	struct eventdev_params *eventdev_config;
+	int all_internal_ports = 1;
+	uint32_t eventdev_id;
+	int i;
+
+	for (i = 0; i < em_conf->nb_eventdev; i++) {
+
+		/* Get the event dev conf */
+		eventdev_config = &(em_conf->eventdev_config[i]);
+		eventdev_id = eventdev_config->eventdev_id;
+
+		/* Check if event device has internal port for Rx & Tx */
+		if (eh_dev_has_rx_internal_port(eventdev_id) &&
+		    eh_dev_has_tx_internal_port(eventdev_id)) {
+			eventdev_config->all_internal_ports = 1;
+		} else {
+			all_internal_ports = 0;
+		}
+	}
+
+	/*
+	 * If Rx & Tx internal ports are supported by all event devices then
+	 * eth cores won't be required. Override the eth core mask requested
+	 * and decrement number of event queues by one as it won't be needed
+	 * for Tx.
+	 */
+	if (all_internal_ports) {
+		rte_bitmap_reset(em_conf->eth_core_mask);
+		for (i = 0; i < em_conf->nb_eventdev; i++)
+			em_conf->eventdev_config[i].nb_eventqueue--;
+	}
+}
+
 static int
 eh_set_default_conf_link(struct eventmode_conf *em_conf)
 {
@@ -246,7 +315,10 @@ eh_set_default_conf_rx_adapter(struct eventmode_conf *em_conf)
 	struct rx_adapter_connection_info *conn;
 	struct eventdev_params *eventdev_config;
 	struct rx_adapter_conf *adapter;
+	bool rx_internal_port = true;
 	bool single_ev_queue = false;
+	int nb_eventqueue;
+	uint32_t caps = 0;
 	int eventdev_id;
 	int nb_eth_dev;
 	int adapter_id;
@@ -276,14 +348,21 @@ eh_set_default_conf_rx_adapter(struct eventmode_conf *em_conf)
 	/* Set adapter conf */
 	adapter->eventdev_id = eventdev_id;
 	adapter->adapter_id = adapter_id;
-	adapter->rx_core_id = eh_get_next_eth_core(em_conf);
+
+	/*
+	 * If event device does not have internal ports for passing
+	 * packets then reserved one queue for Tx path
+	 */
+	nb_eventqueue = eventdev_config->all_internal_ports ?
+			eventdev_config->nb_eventqueue :
+			eventdev_config->nb_eventqueue - 1;
 
 	/*
 	 * Map all queues of eth device (port) to an event queue. If there
 	 * are more event queues than eth ports then create 1:1 mapping.
 	 * Otherwise map all eth ports to a single event queue.
 	 */
-	if (nb_eth_dev > eventdev_config->nb_eventqueue)
+	if (nb_eth_dev > nb_eventqueue)
 		single_ev_queue = true;
 
 	for (i = 0; i < nb_eth_dev; i++) {
@@ -305,11 +384,24 @@ eh_set_default_conf_rx_adapter(struct eventmode_conf *em_conf)
 		/* Add all eth queues eth port to event queue */
 		conn->ethdev_rx_qid = -1;
 
+		/* Get Rx adapter capabilities */
+		rte_event_eth_rx_adapter_caps_get(eventdev_id, i, &caps);
+		if (!(caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT))
+			rx_internal_port = false;
+
 		/* Update no of connections */
 		adapter->nb_connections++;
 
 	}
 
+	if (rx_internal_port) {
+		/* Rx core is not required */
+		adapter->rx_core_id = -1;
+	} else {
+		/* Rx core is required */
+		adapter->rx_core_id = eh_get_next_eth_core(em_conf);
+	}
+
 	/* We have setup one adapter */
 	em_conf->nb_rx_adapter = 1;
 
@@ -322,6 +414,8 @@ eh_set_default_conf_tx_adapter(struct eventmode_conf *em_conf)
 	struct tx_adapter_connection_info *conn;
 	struct eventdev_params *eventdev_config;
 	struct tx_adapter_conf *tx_adapter;
+	bool tx_internal_port = true;
+	uint32_t caps = 0;
 	int eventdev_id;
 	int adapter_id;
 	int nb_eth_dev;
@@ -355,18 +449,6 @@ eh_set_default_conf_tx_adapter(struct eventmode_conf *em_conf)
 	tx_adapter->eventdev_id = eventdev_id;
 	tx_adapter->adapter_id = adapter_id;
 
-	/* TODO: Tx core is required only when internal port is not present */
-	tx_adapter->tx_core_id = eh_get_next_eth_core(em_conf);
-
-	/*
-	 * Application uses one event queue per adapter for submitting
-	 * packets for Tx. Reserve the last queue available and decrement
-	 * the total available event queues for this
-	 */
-
-	/* Queue numbers start at 0 */
-	tx_adapter->tx_ev_queue = eventdev_config->nb_eventqueue - 1;
-
 	/*
 	 * Map all Tx queues of the eth device (port) to the event device.
 	 */
@@ -396,10 +478,30 @@ eh_set_default_conf_tx_adapter(struct eventmode_conf *em_conf)
 		/* Add all eth tx queues to adapter */
 		conn->ethdev_tx_qid = -1;
 
+		/* Get Tx adapter capabilities */
+		rte_event_eth_tx_adapter_caps_get(eventdev_id, i, &caps);
+		if (!(caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT))
+			tx_internal_port = false;
+
 		/* Update no of connections */
 		tx_adapter->nb_connections++;
 	}
 
+	if (tx_internal_port) {
+		/* Tx core is not required */
+		tx_adapter->tx_core_id = -1;
+	} else {
+		/* Tx core is required */
+		tx_adapter->tx_core_id = eh_get_next_eth_core(em_conf);
+
+		/*
+		 * Use one event queue per adapter for submitting packets
+		 * for Tx. Reserving the last queue available
+		 */
+		/* Queue numbers start at 0 */
+		tx_adapter->tx_ev_queue = eventdev_config->nb_eventqueue - 1;
+	}
+
 	/* We have setup one adapter */
 	em_conf->nb_tx_adapter = 1;
 	return 0;
@@ -420,6 +522,9 @@ eh_validate_conf(struct eventmode_conf *em_conf)
 			return ret;
 	}
 
+	/* Perform capability check for the selected event devices */
+	eh_do_capability_check(em_conf);
+
 	/*
 	 * Check if links are specified. Else generate a default config for
 	 * the event ports used.
@@ -523,11 +628,13 @@ eh_initialize_eventdev(struct eventmode_conf *em_conf)
 					eventdev_config->ev_queue_mode;
 			/*
 			 * All queues need to be set with sched_type as
-			 * schedule type for the application stage. One queue
-			 * would be reserved for the final eth tx stage. This
-			 * will be an atomic queue.
+			 * schedule type for the application stage. One
+			 * queue would be reserved for the final eth tx
+			 * stage if event device does not have internal
+			 * ports. This will be an atomic queue.
 			 */
-			if (j == nb_eventqueue-1) {
+			if (!eventdev_config->all_internal_ports &&
+			    j == nb_eventqueue-1) {
 				eventq_conf.schedule_type =
 					RTE_SCHED_TYPE_ATOMIC;
 			} else {
@@ -841,6 +948,12 @@ eh_find_worker(uint32_t lcore_id, struct eh_conf *conf,
 
 	/* Populate the curr_conf with the capabilities */
 
+	/* Check for Tx internal port */
+	if (eh_dev_has_tx_internal_port(eventdev_id))
+		curr_conf.cap.tx_internal_port = EH_TX_TYPE_INTERNAL_PORT;
+	else
+		curr_conf.cap.tx_internal_port = EH_TX_TYPE_NO_INTERNAL_PORT;
+
 	/* Check for burst mode */
 	if (eh_dev_has_burst_mode(eventdev_id))
 		curr_conf.cap.burst = EH_RX_TYPE_BURST;
@@ -1012,6 +1125,16 @@ eh_tx_adapter_configure(struct eventmode_conf *em_conf,
 		}
 	}
 
+	/*
+	 * Check if Tx core is assigned. If Tx core is not assigned then
+	 * the adapter has internal port for submitting Tx packets and
+	 * Tx event queue & port setup is not required
+	 */
+	if (adapter->tx_core_id == (uint32_t) (-1)) {
+		/* Internal port is present */
+		goto skip_tx_queue_port_setup;
+	}
+
 	/* Setup Tx queue & port */
 
 	/* Get event port used by the adapter */
@@ -1051,6 +1174,7 @@ eh_tx_adapter_configure(struct eventmode_conf *em_conf,
 
 	rte_service_set_runstate_mapped_check(service_id, 0);
 
+skip_tx_queue_port_setup:
 	/* Start adapter */
 	ret = rte_event_eth_tx_adapter_start(adapter->adapter_id);
 	if (ret < 0) {
@@ -1135,13 +1259,22 @@ eh_display_rx_adapter_conf(struct eventmode_conf *em_conf)
 
 	for (i = 0; i < nb_rx_adapter; i++) {
 		adapter = &(em_conf->rx_adapter[i]);
-		EH_LOG_INFO(
-			"\tRx adaper ID: %-2d\tConnections: %-2d\tEvent dev ID: %-2d"
-			"\tRx core: %-2d",
+		sprintf(print_buf,
+			"\tRx adaper ID: %-2d\tConnections: %-2d\tEvent dev ID: %-2d",
 			adapter->adapter_id,
 			adapter->nb_connections,
-			adapter->eventdev_id,
-			adapter->rx_core_id);
+			adapter->eventdev_id);
+		if (adapter->rx_core_id == (uint32_t)-1)
+			sprintf(print_buf + strlen(print_buf),
+				"\tRx core: %-2s", "[INTERNAL PORT]");
+		else if (adapter->rx_core_id == RTE_MAX_LCORE)
+			sprintf(print_buf + strlen(print_buf),
+				"\tRx core: %-2s", "[NONE]");
+		else
+			sprintf(print_buf + strlen(print_buf),
+				"\tRx core: %-2d", adapter->rx_core_id);
+
+		EH_LOG_INFO("%s", print_buf);
 
 		for (j = 0; j < adapter->nb_connections; j++) {
 			conn = &(adapter->conn[j]);
examples/ipsec-secgw/event_helper.h +11 -0
index 9a4dfab..25c8563 100644
@@ -62,12 +62,21 @@ enum eh_rx_types {
 	EH_RX_TYPE_BURST
 };
 
+/**
+ * Event mode packet tx types
+ */
+enum eh_tx_types {
+	EH_TX_TYPE_INTERNAL_PORT = 0,
+	EH_TX_TYPE_NO_INTERNAL_PORT
+};
+
 /* Event dev params */
 struct eventdev_params {
 	uint8_t eventdev_id;
 	uint8_t nb_eventqueue;
 	uint8_t nb_eventport;
 	uint8_t ev_queue_mode;
+	uint8_t all_internal_ports;
 };
 
 /**
@@ -179,6 +188,8 @@ struct eh_app_worker_params {
 		struct {
 			uint64_t burst : 1;
 			/**< Specify status of rx type burst */
+			uint64_t tx_internal_port : 1;
+			/**< Specify whether tx internal port is available */
 		};
 		uint64_t u64;
 	} cap;
Signature · 1 line
2.7.4
#132 lore raw

PATCH v5 9/15 examples/ipsec-secgw: add event helper config init/uninit

In reply to Lukasz Bartosik

Add eventmode helper eh_conf_init and eh_conf_uninit functions which purpose is to initialize and unitialize eventmode helper configuration.

---
 examples/ipsec-secgw/event_helper.c | 103 ++++++++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h |  23 ++++++++
 2 files changed, 126 insertions(+)
examples/ipsec-secgw/event_helper.c +103 -0
index fe047ab..0854fc2 100644
@@ -1379,6 +1379,109 @@ eh_display_link_conf(struct eventmode_conf *em_conf)
 	EH_LOG_INFO("");
 }
 
+struct eh_conf *
+eh_conf_init(void)
+{
+	struct eventmode_conf *em_conf = NULL;
+	struct eh_conf *conf = NULL;
+	unsigned int eth_core_id;
+	void *bitmap = NULL;
+	uint32_t nb_bytes;
+
+	/* Allocate memory for config */
+	conf = calloc(1, sizeof(struct eh_conf));
+	if (conf == NULL) {
+		EH_LOG_ERR("Failed to allocate memory for eventmode helper "
+			   "config");
+		return NULL;
+	}
+
+	/* Set default conf */
+
+	/* Packet transfer mode: poll */
+	conf->mode = EH_PKT_TRANSFER_MODE_POLL;
+
+	/* Keep all ethernet ports enabled by default */
+	conf->eth_portmask = -1;
+
+	/* Allocate memory for event mode params */
+	conf->mode_params = calloc(1, sizeof(struct eventmode_conf));
+	if (conf->mode_params == NULL) {
+		EH_LOG_ERR("Failed to allocate memory for event mode params");
+		goto free_conf;
+	}
+
+	/* Get eventmode conf */
+	em_conf = conf->mode_params;
+
+	/* Allocate and initialize bitmap for eth cores */
+	nb_bytes = rte_bitmap_get_memory_footprint(RTE_MAX_LCORE);
+	if (!nb_bytes) {
+		EH_LOG_ERR("Failed to get bitmap footprint");
+		goto free_em_conf;
+	}
+
+	bitmap = rte_zmalloc("event-helper-ethcore-bitmap", nb_bytes,
+			     RTE_CACHE_LINE_SIZE);
+	if (!bitmap) {
+		EH_LOG_ERR("Failed to allocate memory for eth cores bitmap\n");
+		goto free_em_conf;
+	}
+
+	em_conf->eth_core_mask = rte_bitmap_init(RTE_MAX_LCORE, bitmap,
+						 nb_bytes);
+	if (!em_conf->eth_core_mask) {
+		EH_LOG_ERR("Failed to initialize bitmap");
+		goto free_bitmap;
+	}
+
+	/* Set schedule type as not set */
+	em_conf->ext_params.sched_type = SCHED_TYPE_NOT_SET;
+
+	/* Set two cores as eth cores for Rx & Tx */
+
+	/* Use first core other than master core as Rx core */
+	eth_core_id = rte_get_next_lcore(0,	/* curr core */
+					 1,	/* skip master core */
+					 0	/* wrap */);
+
+	rte_bitmap_set(em_conf->eth_core_mask, eth_core_id);
+
+	/* Use next core as Tx core */
+	eth_core_id = rte_get_next_lcore(eth_core_id,	/* curr core */
+					 1,		/* skip master core */
+					 0		/* wrap */);
+
+	rte_bitmap_set(em_conf->eth_core_mask, eth_core_id);
+
+	return conf;
+
+free_bitmap:
+	rte_free(bitmap);
+free_em_conf:
+	free(em_conf);
+free_conf:
+	free(conf);
+	return NULL;
+}
+
+void
+eh_conf_uninit(struct eh_conf *conf)
+{
+	struct eventmode_conf *em_conf = NULL;
+
+	if (!conf || !conf->mode_params)
+		return;
+
+	/* Get eventmode conf */
+	em_conf = conf->mode_params;
+
+	/* Free evenmode configuration memory */
+	rte_free(em_conf->eth_core_mask);
+	free(em_conf);
+	free(conf);
+}
+
 void
 eh_display_conf(struct eh_conf *conf)
 {
examples/ipsec-secgw/event_helper.h +23 -0
index 25c8563..e17cab1 100644
@@ -46,6 +46,9 @@
 /* Max adapters that one Tx core can handle */
 #define EVENT_MODE_MAX_ADAPTERS_PER_TX_CORE EVENT_MODE_MAX_TX_ADAPTERS
 
+/* Used to indicate that queue schedule type is not set */
+#define SCHED_TYPE_NOT_SET	3
+
 /**
  * Packet transfer mode of the application
  */
@@ -200,6 +203,26 @@ struct eh_app_worker_params {
 };
 
 /**
+ * Allocate memory for event helper configuration and initialize
+ * it with default values.
+ *
+ * @return
+ * - pointer to event helper configuration structure on success.
+ * - NULL on failure.
+ */
+struct eh_conf *
+eh_conf_init(void);
+
+/**
+ * Uninitialize event helper configuration and release its memory
+. *
+ * @param conf
+ *   Event helper configuration
+ */
+void
+eh_conf_uninit(struct eh_conf *conf);
+
+/**
  * Initialize event mode devices
  *
  * Application can call this function to get the event devices, eth devices
Signature · 1 line
2.7.4
#133 lore raw

PATCH v5 10/15 examples/ipsec-secgw: add eventmode to ipsec-secgw

In reply to Lukasz Bartosik

Add eventmode support to ipsec-secgw. With the aid of event helper configure and use the eventmode capabilities.

---
 examples/ipsec-secgw/event_helper.c |   3 +
 examples/ipsec-secgw/event_helper.h |  14 ++
 examples/ipsec-secgw/ipsec-secgw.c  | 301 +++++++++++++++++++++++++++++++++++-
 examples/ipsec-secgw/ipsec.h        |  24 +++
 examples/ipsec-secgw/sa.c           |  21 +--
 examples/ipsec-secgw/sad.h          |   5 -
 6 files changed, 340 insertions(+), 28 deletions(-)
examples/ipsec-secgw/event_helper.c +3 -0
index 0854fc2..076f1f2 100644
@@ -960,6 +960,8 @@ eh_find_worker(uint32_t lcore_id, struct eh_conf *conf,
 	else
 		curr_conf.cap.burst = EH_RX_TYPE_NON_BURST;
 
+	curr_conf.cap.ipsec_mode = conf->ipsec_mode;
+
 	/* Parse the passed list and see if we have matching capabilities */
 
 	/* Initialize the pointer used to traverse the list */
@@ -1400,6 +1402,7 @@ eh_conf_init(void)
 
 	/* Packet transfer mode: poll */
 	conf->mode = EH_PKT_TRANSFER_MODE_POLL;
+	conf->ipsec_mode = EH_IPSEC_MODE_TYPE_APP;
 
 	/* Keep all ethernet ports enabled by default */
 	conf->eth_portmask = -1;
examples/ipsec-secgw/event_helper.h +14 -0
index e17cab1..b65b343 100644
@@ -73,6 +73,14 @@ enum eh_tx_types {
 	EH_TX_TYPE_NO_INTERNAL_PORT
 };
 
+/**
+ * Event mode ipsec mode types
+ */
+enum eh_ipsec_mode_types {
+	EH_IPSEC_MODE_TYPE_APP = 0,
+	EH_IPSEC_MODE_TYPE_DRIVER
+};
+
 /* Event dev params */
 struct eventdev_params {
 	uint8_t eventdev_id;
@@ -182,6 +190,10 @@ struct eh_conf {
 		 */
 	void *mode_params;
 		/**< Mode specific parameters */
+
+		/** Application specific params */
+	enum eh_ipsec_mode_types ipsec_mode;
+		/**< Mode of ipsec run */
 };
 
 /* Workers registered by the application */
@@ -193,6 +205,8 @@ struct eh_app_worker_params {
 			/**< Specify status of rx type burst */
 			uint64_t tx_internal_port : 1;
 			/**< Specify whether tx internal port is available */
+			uint64_t ipsec_mode : 1;
+			/**< Specify ipsec processing level */
 		};
 		uint64_t u64;
 	} cap;
examples/ipsec-secgw/ipsec-secgw.c +295 -6

440 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +24 -0
index 8f5d382..ec3d60b 100644
@@ -159,6 +159,24 @@ struct ipsec_sa {
 	struct rte_security_session_conf sess_conf;
 } __rte_cache_aligned;
 
+struct ipsec_xf {
+	struct rte_crypto_sym_xform a;
+	struct rte_crypto_sym_xform b;
+};
+
+struct ipsec_sad {
+	struct rte_ipsec_sad *sad_v4;
+	struct rte_ipsec_sad *sad_v6;
+};
+
+struct sa_ctx {
+	void *satbl; /* pointer to array of rte_ipsec_sa objects*/
+	struct ipsec_sad sad;
+	struct ipsec_xf *xf;
+	uint32_t nb_sa;
+	struct ipsec_sa sa[];
+};
+
 struct ipsec_mbuf_metadata {
 	struct ipsec_sa *sa;
 	struct rte_crypto_op cop;
@@ -253,6 +271,12 @@ struct ipsec_traffic {
 	struct traffic_type ip6;
 };
 
+extern struct ipsec_sa *sa_out;
+extern uint32_t nb_sa_out;
+
+extern struct ipsec_sa *sa_in;
+extern uint32_t nb_sa_in;
+
 uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len);
examples/ipsec-secgw/sa.c +4 -17
index 4822d6b..0eb52d1 100644
@@ -135,14 +135,14 @@ const struct supported_aead_algo aead_algos[] = {
 
 #define SA_INIT_NB	128
 
-static struct ipsec_sa *sa_out;
+struct ipsec_sa *sa_out;
+uint32_t nb_sa_out;
 static uint32_t sa_out_sz;
-static uint32_t nb_sa_out;
 static struct ipsec_sa_cnt sa_out_cnt;
 
-static struct ipsec_sa *sa_in;
+struct ipsec_sa *sa_in;
+uint32_t nb_sa_in;
 static uint32_t sa_in_sz;
-static uint32_t nb_sa_in;
 static struct ipsec_sa_cnt sa_in_cnt;
 
 static const struct supported_cipher_algo *
@@ -826,19 +826,6 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound)
 	printf("\n");
 }
 
-struct ipsec_xf {
-	struct rte_crypto_sym_xform a;
-	struct rte_crypto_sym_xform b;
-};
-
-struct sa_ctx {
-	void *satbl; /* pointer to array of rte_ipsec_sa objects*/
-	struct ipsec_sad sad;
-	struct ipsec_xf *xf;
-	uint32_t nb_sa;
-	struct ipsec_sa sa[];
-};
-
 static struct sa_ctx *
 sa_create(const char *name, int32_t socket_id, uint32_t nb_sa)
 {
examples/ipsec-secgw/sad.h +0 -5
index 55712ba..473aaa9 100644
@@ -18,11 +18,6 @@ struct ipsec_sad_cache {
 
 RTE_DECLARE_PER_LCORE(struct ipsec_sad_cache, sad_cache);
 
-struct ipsec_sad {
-	struct rte_ipsec_sad *sad_v4;
-	struct rte_ipsec_sad *sad_v6;
-};
-
 int ipsec_sad_create(const char *name, struct ipsec_sad *sad,
 	int socket_id, struct ipsec_sa_cnt *sa_cnt);
 
Signature · 1 line
2.7.4
#134 lore raw

PATCH v5 11/15 examples/ipsec-secgw: add driver mode worker

In reply to Lukasz Bartosik

Add driver inbound and outbound worker thread for ipsec-secgw. In driver mode application does as little as possible. It simply forwards packets back to port from which traffic was received instructing HW to apply inline security processing using first outbound SA configured for a given port. If a port does not have SA configured outbound traffic on that port will be silently dropped. The aim of this mode is to measure HW capabilities. Driver mode is selected with single-sa option. The single-sa option accepts SA index however in event mode the SA index is ignored.

Example command to run ipsec-secgw in driver mode:
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128
-w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel --single-sa 0

---
 examples/ipsec-secgw/Makefile       |   1 +
 examples/ipsec-secgw/ipsec-secgw.c  |  34 +++---
 examples/ipsec-secgw/ipsec-secgw.h  |  25 +++++
 examples/ipsec-secgw/ipsec.h        |  11 ++
 examples/ipsec-secgw/ipsec_worker.c | 218 ++++++++++++++++++++++++++++++++++++
 examples/ipsec-secgw/meson.build    |   2 +-
 6 files changed, 272 insertions(+), 19 deletions(-)
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
examples/ipsec-secgw/Makefile +1 -0
index 66d05d4..c4a272a 100644
@@ -16,6 +16,7 @@ SRCS-y += sad.c
 SRCS-y += rt.c
 SRCS-y += ipsec_process.c
 SRCS-y += ipsec-secgw.c
+SRCS-y += ipsec_worker.c
 SRCS-y += event_helper.c
 
 CFLAGS += -gdwarf-2
examples/ipsec-secgw/ipsec-secgw.c +16 -18
index 0f692d7..9ad4be5 100644
@@ -71,8 +71,6 @@ volatile bool force_quit;
 
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
 
-#define NB_SOCKETS 4
-
 /* Configure how many packets ahead to prefetch, when reading packets */
 #define PREFETCH_OFFSET	3
 
@@ -80,8 +78,6 @@ volatile bool force_quit;
 
 #define MAX_LCORE_PARAMS 1024
 
-#define UNPROTECTED_PORT(port) (unprotected_port_mask & (1 << portid))
-
 /*
  * Configurable number of RX/TX ring descriptors
  */
@@ -188,15 +184,15 @@ static const struct option lgopts[] = {
 	{NULL, 0, 0, 0}
 };
 
+uint32_t unprotected_port_mask;
+uint32_t single_sa_idx;
 /* mask of enabled ports */
 static uint32_t enabled_port_mask;
 static uint64_t enabled_cryptodev_mask = UINT64_MAX;
-static uint32_t unprotected_port_mask;
 static int32_t promiscuous_on = 1;
 static int32_t numa_on = 1; /**< NUMA is enabled by default. */
 static uint32_t nb_lcores;
 static uint32_t single_sa;
-static uint32_t single_sa_idx;
 
 /*
  * RX/TX HW offload capabilities to enable/use on ethernet ports.
@@ -282,7 +278,7 @@ static struct rte_eth_conf port_conf = {
 	},
 };
 
-static struct socket_ctx socket_ctx[NB_SOCKETS];
+struct socket_ctx socket_ctx[NB_SOCKETS];
 
 /*
  * Determine is multi-segment support required:
@@ -1003,12 +999,12 @@ process_pkts(struct lcore_conf *qconf, struct rte_mbuf **pkts,
 	prepare_traffic(pkts, &traffic, nb_pkts);
 
 	if (unlikely(single_sa)) {
-		if (UNPROTECTED_PORT(portid))
+		if (is_unprotected_port(portid))
 			process_pkts_inbound_nosp(&qconf->inbound, &traffic);
 		else
 			process_pkts_outbound_nosp(&qconf->outbound, &traffic);
 	} else {
-		if (UNPROTECTED_PORT(portid))
+		if (is_unprotected_port(portid))
 			process_pkts_inbound(&qconf->inbound, &traffic);
 		else
 			process_pkts_outbound(&qconf->outbound, &traffic);
@@ -1119,8 +1115,8 @@ drain_outbound_crypto_queues(const struct lcore_conf *qconf,
 }
 
 /* main processing loop */
-static int32_t
-main_loop(__attribute__((unused)) void *dummy)
+void
+ipsec_poll_mode_worker(void)
 {
 	struct rte_mbuf *pkts[MAX_PKT_BURST];
 	uint32_t lcore_id;
@@ -1164,13 +1160,13 @@ main_loop(__attribute__((unused)) void *dummy)
 		RTE_LOG(ERR, IPSEC,
 			"SAD cache init on lcore %u, failed with code: %d\n",
 			lcore_id, rc);
-		return rc;
+		return;
 	}
 
 	if (qconf->nb_rx_queue == 0) {
 		RTE_LOG(DEBUG, IPSEC, "lcore %u has nothing to do\n",
 			lcore_id);
-		return 0;
+		return;
 	}
 
 	RTE_LOG(INFO, IPSEC, "entering main loop on lcore %u\n", lcore_id);
@@ -1183,7 +1179,7 @@ main_loop(__attribute__((unused)) void *dummy)
 			lcore_id, portid, queueid);
 	}
 
-	while (1) {
+	while (!force_quit) {
 		cur_tsc = rte_rdtsc();
 
 		/* TX queue buffer drain */
@@ -1207,7 +1203,7 @@ main_loop(__attribute__((unused)) void *dummy)
 				process_pkts(qconf, pkts, nb_rx, portid);
 
 			/* dequeue and process completed crypto-ops */
-			if (UNPROTECTED_PORT(portid))
+			if (is_unprotected_port(portid))
 				drain_inbound_crypto_queues(qconf,
 					&qconf->inbound);
 			else
@@ -1343,8 +1339,10 @@ print_usage(const char *prgname)
 		"                               In event mode this option is not used\n"
 		"                               as packets are dynamically scheduled\n"
 		"                               to cores by HW.\n"
-		"  --single-sa SAIDX: Use single SA index for outbound traffic,\n"
-		"                     bypassing the SP\n"
+		"  --single-sa SAIDX: In poll mode use single SA index for\n"
+		"                     outbound traffic, bypassing the SP\n"
+		"                     In event mode selects driver submode,\n"
+		"                     SA index value is ignored\n"
 		"  --cryptodev_mask MASK: Hexadecimal bitmask of the crypto\n"
 		"                         devices to configure\n"
 		"  --transfer-mode MODE\n"
@@ -2854,7 +2852,7 @@ main(int32_t argc, char **argv)
 	check_all_ports_link_status(enabled_port_mask);
 
 	/* launch per-lcore init on every lcore */
-	rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
+	rte_eal_mp_remote_launch(ipsec_launch_one_lcore, eh_conf, CALL_MASTER);
 	RTE_LCORE_FOREACH_SLAVE(lcore_id) {
 		if (rte_eal_wait_lcore(lcore_id) < 0)
 			return -1;
examples/ipsec-secgw/ipsec-secgw.h new file +25 -0
new file mode 100644
index 0000000..a07a920
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) 2020 Marvell International Ltd.
+ */
+#ifndef _IPSEC_SECGW_H_
+#define _IPSEC_SECGW_H_
+
+#include <stdbool.h>
+
+#define NB_SOCKETS 4
+
+/* Port mask to identify the unprotected ports */
+extern uint32_t unprotected_port_mask;
+
+/* Index of SA in single mode */
+extern uint32_t single_sa_idx;
+
+extern volatile bool force_quit;
+
+static inline uint8_t
+is_unprotected_port(uint16_t port_id)
+{
+	return unprotected_port_mask & (1 << port_id);
+}
+
+#endif /* _IPSEC_SECGW_H_ */
examples/ipsec-secgw/ipsec.h +11 -0
index ec3d60b..ad913bf 100644
@@ -13,6 +13,8 @@
 #include <rte_flow.h>
 #include <rte_ipsec.h>
 
+#include "ipsec-secgw.h"
+
 #define RTE_LOGTYPE_IPSEC       RTE_LOGTYPE_USER1
 #define RTE_LOGTYPE_IPSEC_ESP   RTE_LOGTYPE_USER2
 #define RTE_LOGTYPE_IPSEC_IPIP  RTE_LOGTYPE_USER3
@@ -271,6 +273,15 @@ struct ipsec_traffic {
 	struct traffic_type ip6;
 };
 
+/* Socket ctx */
+extern struct socket_ctx socket_ctx[NB_SOCKETS];
+
+void
+ipsec_poll_mode_worker(void);
+
+int
+ipsec_launch_one_lcore(void *args);
+
 extern struct ipsec_sa *sa_out;
 extern uint32_t nb_sa_out;
 
examples/ipsec-secgw/ipsec_worker.c new file +218 -0

218 lines not on this page · raw message

examples/ipsec-secgw/meson.build +1 -1
index 2415d47..f9ba2a2 100644
@@ -10,5 +10,5 @@ deps += ['security', 'lpm', 'acl', 'hash', 'ip_frag', 'ipsec', 'eventdev']
 allow_experimental_apis = true
 sources = files(
 	'esp.c', 'event_helper.c', 'ipsec.c', 'ipsec_process.c', 'ipsec-secgw.c',
-	'parser.c', 'rt.c', 'sa.c', 'sad.c', 'sp4.c', 'sp6.c'
+	'ipsec_worker.c', 'parser.c', 'rt.c', 'sa.c', 'sad.c', 'sp4.c', 'sp6.c'
 )
Signature · 1 line
2.7.4
#135 lore raw

PATCH v5 12/15 examples/ipsec-secgw: add app mode worker

In reply to Lukasz Bartosik

Add application inbound/outbound worker thread and IPsec application processing code for event mode.

Example ipsec-secgw command in app mode:
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128
-w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel

---
 examples/ipsec-secgw/ipsec-secgw.c  |  31 +--
 examples/ipsec-secgw/ipsec-secgw.h  |  63 ++++++
 examples/ipsec-secgw/ipsec.h        |  16 --
 examples/ipsec-secgw/ipsec_worker.c | 435 +++++++++++++++++++++++++++++++++++-
 examples/ipsec-secgw/ipsec_worker.h |  41 ++++
 5 files changed, 538 insertions(+), 48 deletions(-)
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h
examples/ipsec-secgw/ipsec-secgw.c +1 -30
index 9ad4be5..a03958d 100644
@@ -50,13 +50,12 @@
 
 #include "event_helper.h"
 #include "ipsec.h"
+#include "ipsec_worker.h"
 #include "parser.h"
 #include "sad.h"
 
 volatile bool force_quit;
 
-#define RTE_LOGTYPE_IPSEC RTE_LOGTYPE_USER1
-
 #define MAX_JUMBO_PKT_LEN  9600
 
 #define MEMPOOL_CACHE_SIZE 256
@@ -86,29 +85,6 @@ volatile bool force_quit;
 static uint16_t nb_rxd = IPSEC_SECGW_RX_DESC_DEFAULT;
 static uint16_t nb_txd = IPSEC_SECGW_TX_DESC_DEFAULT;
 
-#if RTE_BYTE_ORDER != RTE_LITTLE_ENDIAN
-#define __BYTES_TO_UINT64(a, b, c, d, e, f, g, h) \
-	(((uint64_t)((a) & 0xff) << 56) | \
-	((uint64_t)((b) & 0xff) << 48) | \
-	((uint64_t)((c) & 0xff) << 40) | \
-	((uint64_t)((d) & 0xff) << 32) | \
-	((uint64_t)((e) & 0xff) << 24) | \
-	((uint64_t)((f) & 0xff) << 16) | \
-	((uint64_t)((g) & 0xff) << 8)  | \
-	((uint64_t)(h) & 0xff))
-#else
-#define __BYTES_TO_UINT64(a, b, c, d, e, f, g, h) \
-	(((uint64_t)((h) & 0xff) << 56) | \
-	((uint64_t)((g) & 0xff) << 48) | \
-	((uint64_t)((f) & 0xff) << 40) | \
-	((uint64_t)((e) & 0xff) << 32) | \
-	((uint64_t)((d) & 0xff) << 24) | \
-	((uint64_t)((c) & 0xff) << 16) | \
-	((uint64_t)((b) & 0xff) << 8) | \
-	((uint64_t)(a) & 0xff))
-#endif
-#define ETHADDR(a, b, c, d, e, f) (__BYTES_TO_UINT64(a, b, c, d, e, f, 0, 0))
-
 #define ETHADDR_TO_UINT64(addr) __BYTES_TO_UINT64( \
 		(addr)->addr_bytes[0], (addr)->addr_bytes[1], \
 		(addr)->addr_bytes[2], (addr)->addr_bytes[3], \
@@ -120,11 +96,6 @@ static uint16_t nb_txd = IPSEC_SECGW_TX_DESC_DEFAULT;
 
 #define MTU_TO_FRAMELEN(x)	((x) + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
 
-/* port/source ethernet addr and destination ethernet addr */
-struct ethaddr_info {
-	uint64_t src, dst;
-};
-
 struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
 	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x7e, 0x94, 0x9a) },
 	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x22, 0xa1, 0xd9) },
examples/ipsec-secgw/ipsec-secgw.h +63 -0

69 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +0 -16
index ad913bf..f8f29f9 100644
@@ -15,11 +15,9 @@
 
 #include "ipsec-secgw.h"
 
-#define RTE_LOGTYPE_IPSEC       RTE_LOGTYPE_USER1
 #define RTE_LOGTYPE_IPSEC_ESP   RTE_LOGTYPE_USER2
 #define RTE_LOGTYPE_IPSEC_IPIP  RTE_LOGTYPE_USER3
 
-#define MAX_PKT_BURST 32
 #define MAX_INFLIGHT 128
 #define MAX_QP_PER_LCORE 256
 
@@ -259,20 +257,6 @@ struct cnt_blk {
 	uint32_t cnt;
 } __attribute__((packed));
 
-struct traffic_type {
-	const uint8_t *data[MAX_PKT_BURST * 2];
-	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	void *saptr[MAX_PKT_BURST * 2];
-	uint32_t res[MAX_PKT_BURST * 2];
-	uint32_t num;
-};
-
-struct ipsec_traffic {
-	struct traffic_type ipsec;
-	struct traffic_type ip4;
-	struct traffic_type ip6;
-};
-
 /* Socket ctx */
 extern struct socket_ctx socket_ctx[NB_SOCKETS];
 
examples/ipsec-secgw/ipsec_worker.c +433 -2

476 lines not on this page · raw message

examples/ipsec-secgw/ipsec_worker.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.7.4
#136 lore raw

PATCH v5 13/15 examples/ipsec-secgw: make number of buffers dynamic

In reply to Lukasz Bartosik

Make number of buffers in a pool nb_mbuf_in_pool dependent on number of ports, cores and crypto queues. Add command line option -s which when used overrides dynamic calculation of number of buffers in a pool.

---
 examples/ipsec-secgw/ipsec-secgw.c | 71 ++++++++++++++++++++++++++++++++------
 1 file changed, 60 insertions(+), 11 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +60 -11
index a03958d..5335c4c 100644
@@ -60,8 +60,6 @@ volatile bool force_quit;
 
 #define MEMPOOL_CACHE_SIZE 256
 
-#define NB_MBUF	(32000)
-
 #define CDEV_QUEUE_DESC 2048
 #define CDEV_MAP_ENTRIES 16384
 #define CDEV_MP_NB_OBJS 1024
@@ -164,6 +162,7 @@ static int32_t promiscuous_on = 1;
 static int32_t numa_on = 1; /**< NUMA is enabled by default. */
 static uint32_t nb_lcores;
 static uint32_t single_sa;
+static uint32_t nb_bufs_in_pool;
 
 /*
  * RX/TX HW offload capabilities to enable/use on ethernet ports.
@@ -1280,6 +1279,7 @@ print_usage(const char *prgname)
 		" [-e]"
 		" [-a]"
 		" [-c]"
+		" [-s NUMBER_OF_MBUFS_IN_PKT_POOL]"
 		" -f CONFIG_FILE"
 		" --config (port,queue,lcore)[,(port,queue,lcore)]"
 		" [--single-sa SAIDX]"
@@ -1303,6 +1303,9 @@ print_usage(const char *prgname)
 		"  -a enables SA SQN atomic behaviour\n"
 		"  -c specifies inbound SAD cache size,\n"
 		"     zero value disables the cache (default value: 128)\n"
+		"  -s number of mbufs in packet pool, if not specified number\n"
+		"     of mbufs will be calculated based on number of cores,\n"
+		"     ports and crypto queues\n"
 		"  -f CONFIG_FILE: Configuration file\n"
 		"  --config (port,queue,lcore): Rx queue configuration. In poll\n"
 		"                               mode determines which queues from\n"
@@ -1507,7 +1510,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf)
 
 	argvopt = argv;
 
-	while ((opt = getopt_long(argc, argvopt, "aelp:Pu:f:j:w:c:",
+	while ((opt = getopt_long(argc, argvopt, "aelp:Pu:f:j:w:c:s:",
 				lgopts, &option_index)) != EOF) {
 
 		switch (opt) {
@@ -1541,6 +1544,19 @@ parse_args(int32_t argc, char **argv, struct eh_conf *eh_conf)
 			cfgfile = optarg;
 			f_present = 1;
 			break;
+
+		case 's':
+			ret = parse_decimal(optarg);
+			if (ret < 0) {
+				printf("Invalid number of buffers in a pool: "
+					"%s\n", optarg);
+				print_usage(prgname);
+				return -1;
+			}
+
+			nb_bufs_in_pool = ret;
+			break;
+
 		case 'j':
 			ret = parse_decimal(optarg);
 			if (ret < RTE_MBUF_DEFAULT_BUF_SIZE ||
@@ -1913,12 +1929,12 @@ check_cryptodev_mask(uint8_t cdev_id)
 	return -1;
 }
 
-static int32_t
+static uint16_t
 cryptodevs_init(void)
 {
 	struct rte_cryptodev_config dev_conf;
 	struct rte_cryptodev_qp_conf qp_conf;
-	uint16_t idx, max_nb_qps, qp, i;
+	uint16_t idx, max_nb_qps, qp, total_nb_qps, i;
 	int16_t cdev_id;
 	struct rte_hash_parameters params = { 0 };
 
@@ -1946,6 +1962,7 @@ cryptodevs_init(void)
 	printf("lcore/cryptodev/qp mappings:\n");
 
 	idx = 0;
+	total_nb_qps = 0;
 	for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
 		struct rte_cryptodev_info cdev_info;
 
@@ -1979,6 +1996,7 @@ cryptodevs_init(void)
 		if (qp == 0)
 			continue;
 
+		total_nb_qps += qp;
 		dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
 		dev_conf.nb_queue_pairs = qp;
 		dev_conf.ff_disable = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO;
@@ -2011,7 +2029,7 @@ cryptodevs_init(void)
 
 	printf("\n");
 
-	return 0;
+	return total_nb_qps;
 }
 
 static void
@@ -2665,20 +2683,36 @@ inline_sessions_free(struct sa_ctx *sa_ctx)
 	}
 }
 
+static uint32_t
+calculate_nb_mbufs(uint16_t nb_ports, uint16_t nb_crypto_qp, uint32_t nb_rxq,
+		uint32_t nb_txq)
+{
+	return RTE_MAX((nb_rxq * nb_rxd +
+			nb_ports * nb_lcores * MAX_PKT_BURST +
+			nb_ports * nb_txq * nb_txd +
+			nb_lcores * MEMPOOL_CACHE_SIZE +
+			nb_crypto_qp * CDEV_QUEUE_DESC +
+			nb_lcores * frag_tbl_sz *
+			FRAG_TBL_BUCKET_ENTRIES),
+		       8192U);
+}
+
 int32_t
 main(int32_t argc, char **argv)
 {
 	int32_t ret;
-	uint32_t lcore_id;
+	uint32_t lcore_id, nb_txq, nb_rxq = 0;
 	uint32_t cdev_id;
 	uint32_t i;
 	uint8_t socket_id;
-	uint16_t portid;
+	uint16_t portid, nb_crypto_qp, nb_ports = 0;
 	uint64_t req_rx_offloads[RTE_MAX_ETHPORTS];
 	uint64_t req_tx_offloads[RTE_MAX_ETHPORTS];
 	struct eh_conf *eh_conf = NULL;
 	size_t sess_sz;
 
+	nb_bufs_in_pool = 0;
+
 	/* init EAL */
 	ret = rte_eal_init(argc, argv);
 	if (ret < 0)
@@ -2727,6 +2761,22 @@ main(int32_t argc, char **argv)
 
 	sess_sz = max_session_size();
 
+	nb_crypto_qp = cryptodevs_init();
+
+	if (nb_bufs_in_pool == 0) {
+		RTE_ETH_FOREACH_DEV(portid) {
+			if ((enabled_port_mask & (1 << portid)) == 0)
+				continue;
+			nb_ports++;
+			nb_rxq += get_port_nb_rx_queues(portid);
+		}
+
+		nb_txq = nb_lcores;
+
+		nb_bufs_in_pool = calculate_nb_mbufs(nb_ports, nb_crypto_qp,
+						nb_rxq, nb_txq);
+	}
+
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
 		if (rte_lcore_is_enabled(lcore_id) == 0)
 			continue;
@@ -2740,11 +2790,12 @@ main(int32_t argc, char **argv)
 		if (socket_ctx[socket_id].mbuf_pool)
 			continue;
 
-		pool_init(&socket_ctx[socket_id], socket_id, NB_MBUF);
+		pool_init(&socket_ctx[socket_id], socket_id, nb_bufs_in_pool);
 		session_pool_init(&socket_ctx[socket_id], socket_id, sess_sz);
 		session_priv_pool_init(&socket_ctx[socket_id], socket_id,
 			sess_sz);
 	}
+	printf("Number of mbufs in packet pool %d\n", nb_bufs_in_pool);
 
 	RTE_ETH_FOREACH_DEV(portid) {
 		if ((enabled_port_mask & (1 << portid)) == 0)
@@ -2756,8 +2807,6 @@ main(int32_t argc, char **argv)
 				req_tx_offloads[portid]);
 	}
 
-	cryptodevs_init();
-
 	/*
 	 * Set the enabled port mask in helper config for use by helper
 	 * sub-system. This will be used while initializing devices using
Signature · 1 line
2.7.4
#137 lore raw

PATCH v5 14/15 doc: add event mode support to ipsec-secgw

In reply to Lukasz Bartosik

Document addition of event mode support
to ipsec-secgw application.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst | 135 ++++++++++++++++++++++++++-----
 1 file changed, 113 insertions(+), 22 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +113 -22
index 5ec9b1e..038f593 100644
@@ -1,5 +1,6 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
     Copyright(c) 2016-2017 Intel Corporation.
+    Copyright (C) 2020 Marvell International Ltd.
 
 IPsec Security Gateway Sample Application
 =========================================
@@ -61,6 +62,44 @@ The Path for the IPsec Outbound traffic is:
 *  Routing.
 *  Write packet to port.
 
+The application supports two modes of operation: poll mode and event mode.
+
+* In the poll mode a core receives packets from statically configured list
+  of eth ports and eth ports' queues.
+
+* In the event mode a core receives packets as events. After packet processing
+  is done core submits them back as events to an event device. This enables
+  multicore scaling and HW assisted scheduling by making use of the event device
+  capabilities. The event mode configuration is predefined. All packets reaching
+  given eth port will arrive at the same event queue. All event queues are mapped
+  to all event ports. This allows all cores to receive traffic from all ports.
+  Since the underlying event device might have varying capabilities, the worker
+  threads can be drafted differently to maximize performance. For example, if an
+  event device - eth device pair has Tx internal port, then application can call
+  rte_event_eth_tx_adapter_enqueue() instead of regular rte_event_enqueue_burst().
+  So a thread which assumes that the device pair has internal port will not be the
+  right solution for another pair. The infrastructure added for the event mode aims
+  to help application to have multiple worker threads by maximizing performance from
+  every type of event device without affecting existing paths/use cases. The worker
+  to be used will be determined by the operating conditions and the underlying device
+  capabilities. **Currently the application provides non-burst, internal port worker
+  threads and supports inline protocol only.** It also provides infrastructure for
+  non-internal port however does not define any worker threads.
+
+Additionally the event mode introduces two submodes of processing packets:
+
+* Driver submode: This submode has bare minimum changes in the application to support
+  IPsec. There are no lookups, no routing done in the application. And for inline
+  protocol use case, the worker thread resembles l2fwd worker thread as the IPsec
+  processing is done entirely in HW. This mode can be used to benchmark the raw
+  performance of the HW. The driver submode is selected with --single-sa option
+  (used also by poll mode). When --single-sa option is used in conjution with event
+  mode then index passed to --single-sa is ignored.
+
+* App submode: This submode has all the features currently implemented with the
+  application (non librte_ipsec path). All the lookups, routing follows existing
+  methods and report numbers that can be compared against regular poll mode
+  benchmark numbers.
 
 Constraints
 -----------
@@ -94,13 +133,18 @@ The application has a number of command line options::
                         -p PORTMASK -P -u PORTMASK -j FRAMESIZE
                         -l -w REPLAY_WINOW_SIZE -e -a
                         -c SAD_CACHE_SIZE
-                        --config (port,queue,lcore)[,(port,queue,lcore]
+                        -s NUMBER_OF_MBUFS_IN_PACKET_POOL
+                        -f CONFIG_FILE_PATH
+                        --config (port,queue,lcore)[,(port,queue,lcore)]
                         --single-sa SAIDX
+                        --cryptodev_mask MASK
+                        --transfer-mode MODE
+                        --event-schedule-type TYPE
                         --rxoffload MASK
                         --txoffload MASK
-                        --mtu MTU
                         --reassemble NUM
-                        -f CONFIG_FILE_PATH
+                        --mtu MTU
+                        --frag-ttl FRAG_TTL_NS
 
 Where:
 
@@ -138,12 +182,37 @@ Where:
     Zero value disables cache.
     Default value: 128.
 
-*   ``--config (port,queue,lcore)[,(port,queue,lcore)]``: determines which queues
-    from which ports are mapped to which cores.
+*   ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs
+    will be calculated based on number of cores, eth ports and crypto queues.
+
+*   ``-f CONFIG_FILE_PATH``: the full path of text-based file containing all
+    configuration items for running the application (See Configuration file
+    syntax section below). ``-f CONFIG_FILE_PATH`` **must** be specified.
+    **ONLY** the UNIX format configuration file is accepted.
+
+*   ``--config (port,queue,lcore)[,(port,queue,lcore)]``: in poll mode determines
+    which queues from which ports are mapped to which cores. In event mode this
+    option is not used as packets are dynamically scheduled to cores by HW.
 
-*   ``--single-sa SAIDX``: use a single SA for outbound traffic, bypassing the SP
-    on both Inbound and Outbound. This option is meant for debugging/performance
-    purposes.
+*   ``--single-sa SAIDX``: in poll mode use a single SA for outbound traffic,
+    bypassing the SP on both Inbound and Outbound. This option is meant for
+    debugging/performance purposes. In event mode selects driver submode, SA index
+    value is ignored.
+
+*   ``--cryptodev_mask MASK``: hexadecimal bitmask of the crypto devices
+    to configure.
+
+*   ``--transfer-mode MODE``: sets operating mode of the application
+    "poll"  : packet transfer via polling (default)
+    "event" : Packet transfer via event device
+
+*   ``--event-schedule-type TYPE``: queue schedule type, applies only when
+    --transfer-mode is set to event.
+    "ordered"  : Ordered (default)
+    "atomic"   : Atomic
+    "parallel" : Parallel
+    When --event-schedule-type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event
+    device will ensure the ordering. Ordering will be lost when tried in PARALLEL.
 
 *   ``--rxoffload MASK``: RX HW offload capabilities to enable/use on this port
     (bitmask of DEV_RX_OFFLOAD_* values). It is an optional parameter and
@@ -155,6 +224,10 @@ Where:
     allows user to disable some of the TX HW offload capabilities.
     By default all HW TX offloads are enabled.
 
+*   ``--reassemble NUM``: max number of entries in reassemble fragment table.
+    Zero value disables reassembly functionality.
+    Default value: 0.
+
 *   ``--mtu MTU``: MTU value (in bytes) on all attached ethernet ports.
     Outgoing packets with length bigger then MTU will be fragmented.
     Incoming packets with length bigger then MTU will be discarded.
@@ -167,26 +240,17 @@ Where:
     Should be lower for low number of reassembly buckets.
     Valid values: from 1 ns to 10 s. Default value: 10000000 (10 s).
 
-*   ``--reassemble NUM``: max number of entries in reassemble fragment table.
-    Zero value disables reassembly functionality.
-    Default value: 0.
-
-*   ``-f CONFIG_FILE_PATH``: the full path of text-based file containing all
-    configuration items for running the application (See Configuration file
-    syntax section below). ``-f CONFIG_FILE_PATH`` **must** be specified.
-    **ONLY** the UNIX format configuration file is accepted.
-
 
 The mapping of lcores to port/queues is similar to other l3fwd applications.
 
-For example, given the following command line::
+For example, given the following command line to run application in poll mode::
 
     ./build/ipsec-secgw -l 20,21 -n 4 --socket-mem 0,2048       \
-           --vdev "crypto_null" -- -p 0xf -P -u 0x3      \
+           --vdev "crypto_null" -- -p 0xf -P -u 0x3             \
            --config="(0,0,20),(1,0,20),(2,0,21),(3,0,21)"       \
-           -f /path/to/config_file                              \
+           -f /path/to/config_file --transfer-mode poll         \
 
-where each options means:
+where each option means:
 
 *   The ``-l`` option enables cores 20 and 21.
 
@@ -200,7 +264,7 @@ where each options means:
 
 *   The ``-P`` option enables promiscuous mode.
 
-*   The ``-u`` option sets ports 1 and 2 as unprotected, leaving 2 and 3 as protected.
+*   The ``-u`` option sets ports 0 and 1 as unprotected, leaving 2 and 3 as protected.
 
 *   The ``--config`` option enables one queue per port with the following mapping:
 
@@ -228,6 +292,33 @@ where each options means:
     **note** the parser only accepts UNIX format text file. Other formats
     such as DOS/MAC format will cause a parse error.
 
+*   The ``--transfer-mode`` option selects poll mode for processing packets.
+
+Similarly for example, given the following command line to run application in
+event app mode::
+
+    ./build/ipsec-secgw -c 0x3 -- -P -p 0x3 -u 0x1       \
+           -f /path/to/config_file --transfer-mode event \
+           --event-schedule-type parallel                \
+
+where each option means:
+
+*   The ``-c`` option selects cores 0 and 1 to run on.
+
+*   The ``-P`` option enables promiscuous mode.
+
+*   The ``-p`` option enables ports (detected) 0 and 1.
+
+*   The ``-u`` option sets ports 0 as unprotected, leaving 1 as protected.
+
+*   The ``-f /path/to/config_file`` option has the same behavior as in poll
+    mode example.
+
+*   The ``--transfer-mode`` option selects event mode for processing packets.
+
+*   The ``--event-schedule-type`` option selects parallel ordering of event queues.
+
+
 Refer to the *DPDK Getting Started Guide* for general information on running
 applications and the Environment Abstraction Layer (EAL) options.
 
Signature · 1 line
2.7.4
#138 lore raw

Re: [dpdk-dev] [PATCH v5 14/15] doc: add event mode support to ipsec-secgw

27/02/2020 17:18, Lukasz Bartosik:

Quoted 5 lines

Document addition of event mode support
to ipsec-secgw application.

This patch is doing more than adding event mode in doc.
It should have been split to distinguish what are the real additions. And changes to event mode could have been merged with patch code.

It is too late to change it.
Please remind this advice for next time.

#139 lore raw

PATCH v5 15/15 examples/ipsec-secgw: reserve crypto queues in event mode

In reply to Lukasz Bartosik

Reserve minimum number of crypto queues equal to number of ports. This is to fulfill inline protocol offload requirements.

---
 examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +12 -2
index 5335c4c..ce36e6d 100644
@@ -1930,7 +1930,7 @@ check_cryptodev_mask(uint8_t cdev_id)
 }
 
 static uint16_t
-cryptodevs_init(void)
+cryptodevs_init(uint16_t req_queue_num)
 {
 	struct rte_cryptodev_config dev_conf;
 	struct rte_cryptodev_qp_conf qp_conf;
@@ -1993,6 +1993,7 @@ cryptodevs_init(void)
 			i++;
 		}
 
+		qp = RTE_MIN(max_nb_qps, RTE_MAX(req_queue_num, qp));
 		if (qp == 0)
 			continue;
 
@@ -2761,7 +2762,16 @@ main(int32_t argc, char **argv)
 
 	sess_sz = max_session_size();
 
-	nb_crypto_qp = cryptodevs_init();
+	/*
+	 * In event mode request minimum number of crypto queues
+	 * to be reserved equal to number of ports.
+	 */
+	if (eh_conf->mode == EH_PKT_TRANSFER_MODE_EVENT)
+		nb_crypto_qp = rte_eth_dev_count_avail();
+	else
+		nb_crypto_qp = 0;
+
+	nb_crypto_qp = cryptodevs_init(nb_crypto_qp);
 
 	if (nb_bufs_in_pool == 0) {
 		RTE_ETH_FOREACH_DEV(portid) {
Signature · 1 line
2.7.4
#140 lore raw
In reply to Lukasz Bartosik

Hi Akhil, Konstantin,

Are there any more comments? Or can we have the patches merged?

Thanks,
Anoob

Quoted 235 lines

-----Original Message-----
From: Lukasz Bartosik <[email protected]>
Sent: Thursday, February 27, 2020 9:48 PM
To: Akhil Goyal <[email protected]>; Radu Nicolau <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Ankur Dwivedi <[email protected]>; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; Konstantin Ananyev <[email protected]>; [email protected]
Subject: [PATCH v5 00/15] add eventmode to ipsec-secgw

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize performance. This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports.
When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in PARALLEL.

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event- schedule-type parallel

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event- schedule-type parallel --single-sa 0

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads added.

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Changes in v5:
* Rename function check_params() to check_poll_mode_params() and check_eh_conf() to check_event_mode_params() in order to make it clear what is their purpose.
* Forbid usage of --config option in event mode.
* Replace magic numbers on return with enum values in process_ipsec_ev_inbound()
and process_ipsec_ev_outbound() functions.
* Add session_priv_pool for both inbound and outbound configuration in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Add check of event type in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Update description of --config option in both ipsec-secgw help and documentation.

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth ports in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static keyword from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(), check_sp()
and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES"
in one line
instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port() and eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec- secgw.h,
remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

 doc/guides/sample_app_ug/ipsec_secgw.rst |  135 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812
++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  506 +++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  649 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   41 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3516 insertions(+), 134 deletions(-)  create mode 100644
examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h

--
2.7.4

#141 lore raw

Hi Anoob,

I will merge this series in this week.

Regards,
Akhil

Quoted 264 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Monday, March 2, 2020 2:17 PM
To: Akhil Goyal <[email protected]>; Konstantin Ananyev <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Ankur Dwivedi <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; [email protected]; Radu Nicolau <[email protected]>; Thomas Monjalon <[email protected]>; Lukas Bartosik <[email protected]>
Subject: RE: [PATCH v5 00/15] add eventmode to ipsec-secgw

Hi Akhil, Konstantin,

Are there any more comments? Or can we have the patches merged?

Thanks,
Anoob

Quoted 15 lines

-----Original Message-----
From: Lukasz Bartosik <[email protected]>
Sent: Thursday, February 27, 2020 9:48 PM
To: Akhil Goyal <[email protected]>; Radu Nicolau <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Ankur Dwivedi <[email protected]>; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; Konstantin Ananyev <[email protected]>; [email protected]
Subject: [PATCH v5 00/15] add eventmode to ipsec-secgw

This series introduces event-mode additions to ipsec-secgw.

Quoted 8 lines

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize performance. This series introduces usage of multiple worker threads, among which the one

to

Quoted 5 lines

be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue().

So

Quoted 1 line

a thread making an assumption that the device pair has internal port will not

be

Quoted 31 lines

the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports.
When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in PARALLEL.

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

Quoted 8 lines

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then

index

Quoted 11 lines

passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event- schedule-type parallel

Quoted 7 lines

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log- level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event- schedule-type parallel --single-sa 0

This series adds non burst tx internal port workers only. It provides

infrastructure

Quoted 19 lines

for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads added.

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Quoted 11 lines

Changes in v5:
* Rename function check_params() to check_poll_mode_params() and check_eh_conf() to check_event_mode_params() in order to make it clear what is their purpose.
* Forbid usage of --config option in event mode.
* Replace magic numbers on return with enum values in process_ipsec_ev_inbound()
and process_ipsec_ev_outbound() functions.
* Add session_priv_pool for both inbound and outbound configuration in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Add check of event type in ipsec_wrkr_non_burst_int_port_app_mode

worker.

Quoted 7 lines

* Update description of --config option in both ipsec-secgw help and documentation.

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth

ports

Quoted 4 lines

in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static

keyword

Quoted 7 lines

from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(), check_sp()
and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.

Quoted 8 lines

* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES"
in one line
instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port()

and

Quoted 93 lines

eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec- secgw.h,
remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

 doc/guides/sample_app_ug/ipsec_secgw.rst |  135 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812
++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  506 +++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  649 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   41 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3516 insertions(+), 134 deletions(-)  create mode 100644
examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h

--
2.7.4

#142 lore raw
In reply to Lukasz Bartosik
Quoted 213 lines

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize performance. This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports. When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in PARALLEL.

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel --single-sa 0

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads added.

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Changes in v5:
* Rename function check_params() to check_poll_mode_params() and check_eh_conf() to check_event_mode_params() in order to make it clear what is their purpose.
* Forbid usage of --config option in event mode.
* Replace magic numbers on return with enum values in process_ipsec_ev_inbound() and process_ipsec_ev_outbound() functions.
* Add session_priv_pool for both inbound and outbound configuration in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Add check of event type in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Update description of --config option in both ipsec-secgw help and documentation.

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth ports in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static keyword from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(), check_sp() and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES" in one line instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port() and eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec-secgw.h, remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

 doc/guides/sample_app_ug/ipsec_secgw.rst |  135 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812 ++++++++++++++++++++++++++++++
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  506 +++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  649 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   41 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3516 insertions(+), 134 deletions(-)
 create mode 100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h
Quoted 1 line

--

Have to say I didn't look extensively on event mode. My primary concern was poll-mode and common code changes. From that perspective - LGTM.

Series Acked-by: Konstantin Ananyev <[email protected]>

Quoted 1 line

2.7.4

#143 lore raw

Hi Akhil,

Reminder.

Do you have any further review comments?

Thanks,
Anoob

Quoted 255 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Tuesday, March 3, 2020 11:30 PM
To: Lukas Bartosik <[email protected]>; Akhil Goyal <[email protected]>; Nicolau, Radu <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Ankur Dwivedi <[email protected]>; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v5 00/15] add eventmode to ipsec-secgw

External Email

----------------------------------------------------------------------

Quoted 11 lines

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize

performance.

Quoted 12 lines

This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

Quoted 5 lines

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports. When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in

PARALLEL.

Quoted 46 lines

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON TX2 platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel --single-sa 0

Quoted 3 lines

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads

added.

Quoted 17 lines

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Quoted 6 lines

Changes in v5:
* Rename function check_params() to check_poll_mode_params() and check_eh_conf() to check_event_mode_params() in order to make it clear what is their purpose.
* Forbid usage of --config option in event mode.
* Replace magic numbers on return with enum values in

process_ipsec_ev_inbound()

Quoted 4 lines

and process_ipsec_ev_outbound() functions.
* Add session_priv_pool for both inbound and outbound configuration in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Add check of event type in ipsec_wrkr_non_burst_int_port_app_mode

worker.

Quoted 1 line

* Update description of --config option in both ipsec-secgw help and

documentation.

Quoted 5 lines

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth

ports

Quoted 4 lines

in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static

keyword

Quoted 2 lines

from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(),

check_sp()

Quoted 8 lines

and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put definition of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode = RTE_EVENT_QUEUE_CFG_ALL_TYPES"

in one line

Quoted 3 lines

instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port()

and

Quoted 3 lines

eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec-

secgw.h,

Quoted 66 lines

remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

Quoted 3 lines
 doc/guides/sample_app_ug/ipsec_secgw.rst |  135 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812

++++++++++++++++++++++++++++++

Quoted 17 lines
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  506 +++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  649 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   41 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3516 insertions(+), 134 deletions(-)  create mode
100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h
Quoted 1 line

--

Have to say I didn't look extensively on event mode. My primary concern was poll-mode and common code changes. From that perspective - LGTM.

Series Acked-by: Konstantin Ananyev <[email protected]>

Quoted 1 line

2.7.4

#144 lore raw

Hi Anoob,

Please send a release note update as a reply to this mail. I will update it while merging the patchset.

Regards,
Akhil

Quoted 268 lines

Hi Akhil,

Reminder.

Do you have any further review comments?

Thanks,
Anoob

Quoted 41 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Tuesday, March 3, 2020 11:30 PM
To: Lukas Bartosik <[email protected]>; Akhil Goyal <[email protected]>; Nicolau, Radu <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Ankur Dwivedi <[email protected]>; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v5 00/15] add eventmode to ipsec-secgw

External Email

----------------------------------------------------------------------

Quoted 11 lines

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize

performance.

Quoted 12 lines

This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

Quoted 38 lines
Quoted 5 lines

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports. When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in

PARALLEL.

Quoted 32 lines

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON

TX2

Quoted 55 lines
Quoted 14 lines

platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel --single-sa 0

Quoted 3 lines

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads

added.

Quoted 17 lines

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Quoted 6 lines

Changes in v5:
* Rename function check_params() to check_poll_mode_params() and check_eh_conf() to check_event_mode_params() in order to make it clear what is their purpose.
* Forbid usage of --config option in event mode.
* Replace magic numbers on return with enum values in

process_ipsec_ev_inbound()

Quoted 4 lines

and process_ipsec_ev_outbound() functions.
* Add session_priv_pool for both inbound and outbound configuration in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Add check of event type in ipsec_wrkr_non_burst_int_port_app_mode

worker.

Quoted 1 line

* Update description of --config option in both ipsec-secgw help and

documentation.

Quoted 5 lines

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth

ports

Quoted 14 lines
Quoted 4 lines

in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static

keyword

Quoted 2 lines

from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(),

check_sp()

Quoted 6 lines

and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put

definition

Quoted 2 lines
Quoted 2 lines

of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode =

RTE_EVENT_QUEUE_CFG_ALL_TYPES"

Quoted 105 lines

in one line

Quoted 3 lines

instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port()

and

Quoted 3 lines

eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec-

secgw.h,

Quoted 66 lines

remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

Quoted 3 lines
 doc/guides/sample_app_ug/ipsec_secgw.rst |  135 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812

++++++++++++++++++++++++++++++

Quoted 17 lines
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  506 +++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  649 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   41 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3516 insertions(+), 134 deletions(-)  create mode
100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h
Quoted 1 line

--

Have to say I didn't look extensively on event mode. My primary concern was poll-mode and common code changes. From that perspective - LGTM.

Series Acked-by: Konstantin Ananyev <[email protected]>

Quoted 1 line

2.7.4

#145 lore raw

Hi Akhil,

This is release note proposal for event mode feature.

doc/guides/rel_notes/release_20_05.rst +8 -0
index 2190eaf..f8deda7 100644
@@ -56,6 +56,14 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added event mode to ipsec-secgw application **
+
+  Added event mode to ipsec-secgw application. The ipsec-secgw worker thread(s)
+  would be receiving events and would be submitting it back to the event device after
+  the processing. This way, multicore scaling and HW assisted scheduling is achieved
+  by making use of the event device capabilities. The event mode currently supports
+  only inline IPsec protocol offload.
+
 
 Removed Items
 -------------

Thanks,
Lukasz

Quoted 278 lines · Akhil Goyal

External Email

----------------------------------------------------------------------
Hi Anoob,

Please send a release note update as a reply to this mail. I will update it while merging the patchset.

Regards,
Akhil

Quoted 268 lines

Hi Akhil,

Reminder.

Do you have any further review comments?

Thanks,
Anoob

Quoted 41 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Tuesday, March 3, 2020 11:30 PM
To: Lukas Bartosik <[email protected]>; Akhil Goyal <[email protected]>; Nicolau, Radu <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Ankur Dwivedi <[email protected]>; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>; Tejasree Kondoj <[email protected]>; Vamsi Krishna Attunuru <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v5 00/15] add eventmode to ipsec-secgw

External Email

----------------------------------------------------------------------

Quoted 11 lines

This series introduces event-mode additions to ipsec-secgw.

With this series, ipsec-secgw would be able to run in eventmode. The worker thread (executing loop) would be receiving events and would be submitting it back to the eventdev after the processing. This way, multicore scaling and h/w assisted scheduling is achieved by making use of the eventdev capabilities.

Since the underlying event device would be having varying capabilities, the worker thread could be drafted differently to maximize

performance.

Quoted 12 lines

This series introduces usage of multiple worker threads, among which the one to be used will be determined by the operating conditions and the underlying device capabilities.

For example, if an event device - eth device pair has Tx internal port, then application can do tx_adapter_enqueue() instead of regular event_enqueue(). So a thread making an assumption that the device pair has internal port will not be the right solution for another pair. The infrastructure added with these patches aims to help application to have multiple worker threads, there by extracting maximum performance from every device without affecting existing paths/use cases.

Quoted 38 lines
Quoted 5 lines

The eventmode configuration is predefined. All packets reaching one eth port will hit one event queue. All event queues will be mapped to all event ports. So all cores will be able to receive traffic from all ports. When schedule_type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event device will ensure the ordering. Ordering would be lost when tried in

PARALLEL.

Quoted 32 lines

Following command line options are introduced,

--transfer-mode: to choose between poll mode & event mode --event-schedule-type: to specify the scheduling type
(RTE_SCHED_TYPE_ORDERED/
RTE_SCHED_TYPE_ATOMIC/ RTE_SCHED_TYPE_PARALLEL)

Additionally the event mode introduces two modes of processing packets:

Driver-mode: This mode will have bare minimum changes in the application
to support ipsec. There woudn't be any lookup etc done in the application. And for inline-protocol use case, the thread would resemble l2fwd as the ipsec processing would be done entirely in the h/w. This mode can be used to benchmark the raw performance of the h/w. All the application side steps (like lookup) can be redone based on the requirement of the end user. Hence the need for a mode which would report the raw performance.

App-mode: This mode will have all the features currently implemented with
ipsec-secgw (non librte_ipsec mode). All the lookups etc would follow the existing methods and would report numbers that can be compared against regular ipsec-secgw benchmark numbers.

The driver mode is selected with existing --single-sa option (used also by poll mode). When --single-sa option is used in conjution with event mode then index passed to --single-sa is ignored.

Example commands to execute ipsec-secgw in various modes on OCTEON

TX2

Quoted 55 lines
Quoted 14 lines

platform,

#Inbound and outbound app mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel

#Inbound and outbound driver mode
ipsec-secgw -w 0002:02:00.0,ipsec_in_max_spi=128 -w 0002:03:00.0,ipsec_in_max_spi=128 -w 0002:0e:00.0 -w 0002:10:00.1 --log-level=8 -c 0x1 -- -P -p 0x3 -u 0x1 -f aes-gcm.cfg --transfer-mode event --event-schedule-type parallel --single-sa 0

Quoted 3 lines

This series adds non burst tx internal port workers only. It provides infrastructure for non internal port workers, however does not define any. Also, only inline ipsec protocol mode is supported by the worker threads

added.

Quoted 17 lines

Following are planned features,
1. Add burst mode workers.
2. Add non internal port workers.
3. Verify support for Rx core (the support is added but lack of h/w to verify).
4. Add lookaside protocol support.

Following are features that Marvell won't be attempting.
1. Inline crypto support.
2. Lookaside crypto support.

For the features that Marvell won't be attempting, new workers can be introduced by the respective stake holders.

This series is tested on Marvell OCTEON TX2.
This series is targeted for 20.05 release.

Quoted 6 lines

Changes in v5:
* Rename function check_params() to check_poll_mode_params() and check_eh_conf() to check_event_mode_params() in order to make it clear what is their purpose.
* Forbid usage of --config option in event mode.
* Replace magic numbers on return with enum values in

process_ipsec_ev_inbound()

Quoted 4 lines

and process_ipsec_ev_outbound() functions.
* Add session_priv_pool for both inbound and outbound configuration in ipsec_wrkr_non_burst_int_port_app_mode worker.
* Add check of event type in ipsec_wrkr_non_burst_int_port_app_mode

worker.

Quoted 1 line

* Update description of --config option in both ipsec-secgw help and

documentation.

Quoted 5 lines

Changes in v4:
* Update ipsec-secgw documentation to describe the new options as well as event mode support.
* In event mode reserve number of crypto queues equal to number of eth

ports

Quoted 14 lines
Quoted 4 lines

in order to meet inline protocol offload requirements.
* Add calculate_nb_mbufs() function to calculate number of mbufs in a pool and include fragments table size into the calculation.
* Move structures ipsec_xf and ipsec_sad to ipsec.h and remove static

keyword

Quoted 2 lines

from sa_out, nb_sa_out, sa_in and nb_sa_in in sa.c.
* Update process_ipsec_ev_inbound(), process_ipsec_ev_outbound(),

check_sp()

Quoted 6 lines

and prepare_out_sessions_tbl() functions as a result of changes introduced by SAD feature.
* Remove setting sa->cdev_id_qp to 0 in create_inline_session as sa_ctx is created with rte_zmalloc.
* Minor cleanup enhancements:
- In eh_set_default_conf_eventdev() function in event_helper.c put

definition

Quoted 2 lines
Quoted 2 lines

of int local vars in one line, remove invalid comment, put "eventdev_config->ev_queue_mode =

RTE_EVENT_QUEUE_CFG_ALL_TYPES"

Quoted 105 lines

in one line

Quoted 3 lines

instead of two.
- Remove extern "C" from event_helper.h.
- Put local vars in reverse xmas tree order in eh_dev_has_rx_internal_port()

and

Quoted 3 lines

eh_dev_has_tx_internal_port() functions in event_helper.c.
- Put #include <rte_bitmap.h> in alphabetical order in ipsec-secgw.c.
- Move "extern volatile bool force_quit" and "#include <stdbool.h>" to ipsec-

secgw.h,

Quoted 66 lines

remove #include <rte_hash.h>.
- Remove not needed includes in ipsec_worker.c.
- Remove expired todo from ipsec_worker.h.

Changes in v3:
* Move eh_conf_init() and eh_conf_uninit() functions to event_helper.c including minor rework.
* Rename --schedule-type option to --event-schedule-type.
* Replace macro UNPROTECTED_PORT with static inline function is_unprotected_port().
* Move definitions of global variables used by multiple modules to .c files and add externs in .h headers.
* Add eh_check_conf() which validates ipsec-secgw configuration for event mode.
* Add dynamic calculation of number of buffers in a pool based on number of cores, ports and crypto queues.
* Fix segmentation fault in event mode driver worker which happens when there are no inline outbound sessions configured.
* Remove change related to updating number of crypto queues in cryptodevs_init(). The update of crypto queues will be handled in a separate patch.
* Fix compilation error on 32-bit platforms by using userdata instead of udata64 from rte_mbuf.

Changes in v2:
* Remove --process-dir option. Instead use existing unprotected port mask option (-u) to decide wheter port handles inbound or outbound traffic.
* Remove --process-mode option. Instead use existing --single-sa option to select between app and driver modes.
* Add handling of PKT_RX_SEC_OFFLOAD_FAIL result in app worker thread.
* Fix passing of req_rx_offload flags to create_default_ipsec_flow().
* Move destruction of flows to a location where eth ports are stopped and closed.
* Print error and exit when event mode --schedule-type option is used in poll mode.
* Reduce number of goto statements replacing them with loop constructs.
* Remove sec_session_fixed table and replace it with locally build table in driver worker thread. Table is indexed by port identifier and holds first inline session pointer found for a given port.
* Print error and exit when sessions other than inline are configured in event mode.
* When number of event queues is less than number of eth ports then map all eth ports to one event queue.
* Cleanup and minor improvements in code as suggested by Konstantin

Ankur Dwivedi (1):
examples/ipsec-secgw: add default rte flow for inline Rx

Anoob Joseph (5):
examples/ipsec-secgw: add framework for eventmode helper examples/ipsec-secgw: add eventdev port-lcore link examples/ipsec-secgw: add Rx adapter support examples/ipsec-secgw: add Tx adapter support examples/ipsec-secgw: add routines to display config

Lukasz Bartosik (9):
examples/ipsec-secgw: add routines to launch workers examples/ipsec-secgw: add support for internal ports examples/ipsec-secgw: add event helper config init/uninit examples/ipsec-secgw: add eventmode to ipsec-secgw examples/ipsec-secgw: add driver mode worker examples/ipsec-secgw: add app mode worker examples/ipsec-secgw: make number of buffers dynamic
doc: add event mode support to ipsec-secgw examples/ipsec-secgw: reserve crypto queues in event mode

Quoted 3 lines
 doc/guides/sample_app_ug/ipsec_secgw.rst |  135 ++-
 examples/ipsec-secgw/Makefile            |    2 +
 examples/ipsec-secgw/event_helper.c      | 1812

++++++++++++++++++++++++++++++

Quoted 17 lines
 examples/ipsec-secgw/event_helper.h      |  327 ++++++
 examples/ipsec-secgw/ipsec-secgw.c       |  506 +++++++--
 examples/ipsec-secgw/ipsec-secgw.h       |   88 ++
 examples/ipsec-secgw/ipsec.c             |    5 +-
 examples/ipsec-secgw/ipsec.h             |   53 +-
 examples/ipsec-secgw/ipsec_worker.c      |  649 +++++++++++
 examples/ipsec-secgw/ipsec_worker.h      |   41 +
 examples/ipsec-secgw/meson.build         |    6 +-
 examples/ipsec-secgw/sa.c                |   21 +-
 examples/ipsec-secgw/sad.h               |    5 -
 13 files changed, 3516 insertions(+), 134 deletions(-)  create mode
100644 examples/ipsec-secgw/event_helper.c
 create mode 100644 examples/ipsec-secgw/event_helper.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.h
 create mode 100644 examples/ipsec-secgw/ipsec_worker.c
 create mode 100644 examples/ipsec-secgw/ipsec_worker.h
Quoted 1 line

--

Have to say I didn't look extensively on event mode. My primary concern was poll-mode and common code changes. From that perspective - LGTM.

Series Acked-by: Konstantin Ananyev <[email protected]>

Quoted 1 line

2.7.4

Applied
#146 lore raw
Quoted 25 lines

Hi Akhil,

This is release note proposal for event mode feature.

doc/guides/rel_notes/release_20_05.rst +4 -0
index 2190eaf..f8deda7 100644
@@ -56,6 +56,14 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added event mode to ipsec-secgw application **
+
+  Added event mode to ipsec-secgw application. The ipsec-secgw worker
 thread(s)
+  would be receiving events and would be submitting it back to the event device

after
+ the processing. This way, multicore scaling and HW assisted scheduling is achieved
+ by making use of the event device capabilities. The event mode currently supports

doc/guides/rel_notes/release_20_05.rst New Features · line 66

Quoted 2 lines
doc/guides/rel_notes/release_20_05.rst +2 -0
+  only inline IPsec protocol offload.
+

Modified it as below.
+* **Added event mode to ipsec-secgw application.** +

+  Updated ipsec-secgw application to add event based packet processing. The worker
+  thread(s) would receive events and submit them back to the event device after
+  the processing. This way, multicore scaling and HW assisted scheduling is achieved
+  by making use of the event device capabilities. The event mode currently supports
+  only inline IPsec protocol offload.

+

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Series Acked-by: Konstantin Ananyev <[email protected]>

Series Acked-by: Akhil Goyal <[email protected]>

Applied to dpdk-next-crypto

I may do some minor changes later while submitting pull request to master.

Thanks.