ipsec: add transmit segmentation offload support
v3 cover ipsec: add transmit segmentation offload support
Add transmit segmentation offload support to the IPsec library and IPsec Security GW sample app.
These patches were split from previously sent patchsets with feedback addressed
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Radu Nicolau (2):
ipsec: add TSO support
examples/ipsec-secgw: add support for TSO
doc/guides/prog_guide/ipsec_lib.rst | 2 + doc/guides/rel_notes/release_21_11.rst | 5 + doc/guides/sample_app_ug/ipsec_secgw.rst | 11 ++ examples/ipsec-secgw/ipsec-secgw.c | 4 + examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/ipsec_process.c | 25 ++++ examples/ipsec-secgw/sa.c | 21 +++- lib/ipsec/esp_outb.c | 141 ++++++++++++++++++----- 8 files changed, 176 insertions(+), 34 deletions(-)
Signature · 4 lines
v2: addressed feedback and rebased to RC1 v3: added check for offload caps and removed duplicate code 2.25.1
PATCH v3 1/2 ipsec: add TSO support
Add support for transmit segmentation offload to inline crypto processing mode. This offload is not supported by other offload modes, as at a minimum it requires inline crypto for IPsec to be supported on the network interface.
--- doc/guides/prog_guide/ipsec_lib.rst | 2 + doc/guides/rel_notes/release_21_11.rst | 1 + lib/ipsec/esp_outb.c | 141 +++++++++++++++++++------ 3 files changed, 112 insertions(+), 32 deletions(-)
doc/guides/prog_guide/ipsec_lib.rst +2 -0
@@ -315,6 +315,8 @@ Supported features * NAT-T / UDP encapsulated ESP. +* TSO (only for inline crypto mode) + * algorithms: 3DES-CBC, AES-CBC, AES-CTR, AES-GCM, AES_CCM, CHACHA20_POLY1305, AES_GMAC, HMAC-SHA1, NULL.
doc/guides/rel_notes/release_21_11.rst +1 -0
@@ -268,6 +268,7 @@ New Features * Added support for NAT-T / UDP encapsulated ESP. * Added support for SA telemetry. * Added support for setting a non default starting ESN value. + * Added support for TSO in inline crypto mode. * **Added multi-process support for testpmd.**
lib/ipsec/esp_outb.c +109 -32
253 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 2/2 examples/ipsec-secgw: add support for TSO
In reply to Radu NicolauAdd support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
--- doc/guides/rel_notes/release_21_11.rst | 4 ++++ doc/guides/sample_app_ug/ipsec_secgw.rst | 11 +++++++++++ examples/ipsec-secgw/ipsec-secgw.c | 4 ++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/ipsec_process.c | 25 ++++++++++++++++++++++++ examples/ipsec-secgw/sa.c | 21 ++++++++++++++++++-- 6 files changed, 64 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -306,6 +306,10 @@ New Features * Pcapng format with timestamps and meta-data. * Fixes packet capture with stripped VLAN tags. +* **IPsec Security Gateway sample application new features.** + + * Added support for TSO + Removed Items -------------
doc/guides/sample_app_ug/ipsec_secgw.rst +11 -0
@@ -720,6 +720,17 @@ where each options means: * *udp-encap* + ``<mss>`` + + * Maximum segment size for TSO offload, available for egress SAs only. + + * Optional: Yes, TSO offload not set by default + + * Syntax: + + * *mss N* N is the segment size in bytes + + Example SA rules: .. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +4 -0
@@ -398,6 +398,10 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) pkt->l2_len =0 ; pkt->l3_len =sizeof (*iph4); pkt->packet_type |=RTE_PTYPE_L3_IPV4 ; +if (pkt->packet_type &RTE_PTYPE_L4_TCP ) + pkt->l4_len =sizeof (struct rte_tcp_hdr ); +else if (pkt->packet_type &RTE_PTYPE_L4_UDP ) + pkt->l4_len =sizeof (struct rte_udp_hdr ); }else if (eth->ether_type ==rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV6 )) {int next_proto;size_t l3len, ext_len;
examples/ipsec-secgw/ipsec.h +1 -0
@@ -137,6 +137,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;
examples/ipsec-secgw/ipsec_process.c +25 -0
@@ -222,6 +222,31 @@ prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt)for (j =0 ; j != cnt; j++) { priv =get_priv (mb[j]); priv->sa = sa; +/* setup TSO related fields if TSO enabled*/ +if (priv->sa->mss) { + mb[j]->tso_segsz = priv->sa->mss; + +if ((IS_TUNNEL (priv->sa->flags))) { + mb[j]->outer_l3_len = mb[j]->l3_len; + mb[j]->outer_l2_len = mb[j]->l2_len; + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_OUTER_IP_CKSUM | +RTE_MBUF_F_TX_TUNNEL_ESP ); + } +uint32_t ptype = mb[j]->packet_type; +if (ptype &RTE_PTYPE_L4_TCP ) + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_TCP_SEG | +RTE_MBUF_F_TX_TCP_CKSUM ); +else + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_UDP_SEG | +RTE_MBUF_F_TX_UDP_CKSUM ); +if (RTE_ETH_IS_IPV4_HDR (ptype)) + mb[j]->ol_flags |=RTE_MBUF_F_TX_OUTER_IPV4 ; +else + mb[j]->ol_flags |=RTE_MBUF_F_TX_OUTER_IPV6 ; + } } }
examples/ipsec-secgw/sa.c +19 -2
@@ -677,6 +677,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;
@@ -970,7 +980,7 @@ sa_create(const char *name, int32_t socket_id, uint32_t nb_sa) }static int -check_eth_dev_caps (uint16_t portid,uint32_t inbound) +check_eth_dev_caps (uint16_t portid,uint32_t inbound,uint32_t tso) {struct rte_eth_dev_info dev_info;int retval;
@@ -999,6 +1009,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound) "hardware TX IPSec offload is not supported\n");return -EINVAL ; } +if (tso && (dev_info.tx_offload_capa & + (RTE_ETH_TX_OFFLOAD_TCP_TSO | +RTE_ETH_TX_OFFLOAD_UDP_TSO )) ==0 ) { +RTE_LOG (WARNING ,PORT , +"hardware TSO offload is not supported\n" ); +return -EINVAL ; + } }return 0 ; }
@@ -1127,7 +1144,7 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],if (ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL || ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) { -if (check_eth_dev_caps (sa->portid, inbound)) +if (check_eth_dev_caps (sa->portid, inbound, sa->mss))return -EINVAL ; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: add support for TSO
Quoted 99 lines
Add support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++++ doc/guides/sample_app_ug/ipsec_secgw.rst | 11 +++++++++++ examples/ipsec-secgw/ipsec-secgw.c | 4 ++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/ipsec_process.c | 25 ++++++++++++++++++++++++ examples/ipsec-secgw/sa.c | 21 ++++++++++++++++++-- 6 files changed, 64 insertions(+), 2 deletions(-)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -306,6 +306,10 @@ New Features * Pcapng format with timestamps and meta-data. * Fixes packet capture with stripped VLAN tags. +* **IPsec Security Gateway sample application new features.** + + * Added support for TSO + Removed Items -------------doc/guides/sample_app_ug/ipsec_secgw.rst +11
-0@@ -720,6 +720,17 @@ where each options means: * *udp-encap* + ``<mss>`` + + * Maximum segment size for TSO offload, available for egress SAs only. + + * Optional: Yes, TSO offload not set by default + + * Syntax: + + * *mss N* N is the segment size in bytes + + Example SA rules: .. code-block:: consoleexamples/ipsec-secgw/ipsec-secgw.c +4
-0@@ -398,6 +398,10 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) pkt->l2_len =0 ; pkt->l3_len =sizeof (*iph4); pkt->packet_type |=RTE_PTYPE_L3_IPV4 ; +if (pkt->packet_type &RTE_PTYPE_L4_TCP ) + pkt->l4_len =sizeof (struct rte_tcp_hdr ); +else if (pkt->packet_type &RTE_PTYPE_L4_UDP ) + pkt->l4_len =sizeof (struct rte_udp_hdr ); }else if (eth->ether_type ==rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV6 )) {int next_proto;size_t l3len, ext_len;examples/ipsec-secgw/ipsec.h +1
-0@@ -137,6 +137,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;examples/ipsec-secgw/ipsec_process.c +10
-0@@ -222,6 +222,31 @@ prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt)for (j =0 ; j != cnt; j++) { priv =get_priv (mb[j]); priv->sa = sa; +/* setup TSO related fields if TSO enabled*/ +if (priv->sa->mss) { + mb[j]->tso_segsz = priv->sa->mss; + +if ((IS_TUNNEL (priv->sa->flags))) { + mb[j]->outer_l3_len = mb[j]->l3_len; + mb[j]->outer_l2_len = mb[j]->l2_len; + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_OUTER_IP_CKSUM | +RTE_MBUF_F_TX_TUNNEL_ESP );
examples/ipsec-secgw/ipsec_process.c prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt) · line 244
Quoted 10 lines
examples/ipsec-secgw/ipsec_process.c +10
-0+ } +uint32_t ptype = mb[j]->packet_type; +if (ptype &RTE_PTYPE_L4_TCP ) + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_TCP_SEG | +RTE_MBUF_F_TX_TCP_CKSUM ); +else + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_UDP_SEG | +RTE_MBUF_F_TX_UDP_CKSUM );
Could it be that packet is neither TCP nor UDP?
Quoted 39 lines
examples/ipsec-secgw/ipsec_process.c +5
-0+if (RTE_ETH_IS_IPV4_HDR (ptype)) + mb[j]->ol_flags |=RTE_MBUF_F_TX_OUTER_IPV4 ; +else + mb[j]->ol_flags |=RTE_MBUF_F_TX_OUTER_IPV6 ; + } } }examples/ipsec-secgw/sa.c +11
-1@@ -677,6 +677,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;@@ -970,7 +980,7 @@ sa_create(const char *name, int32_t socket_id, uint32_t nb_sa) }static int -check_eth_dev_caps (uint16_t portid,uint32_t inbound) +check_eth_dev_caps (uint16_t portid,uint32_t inbound,uint32_t tso) {struct rte_eth_dev_info dev_info;int retval;
examples/ipsec-secgw/sa.c check_eth_dev_caps(uint16_t portid, uint32_t inbound) · line 1014
Quoted 6 lines
examples/ipsec-secgw/sa.c +3
-0@@ -999,6 +1009,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound) "hardware TX IPSec offload is not supported\n");return -EINVAL ; } +if (tso && (dev_info.tx_offload_capa & + (RTE_ETH_TX_OFFLOAD_TCP_TSO | +RTE_ETH_TX_OFFLOAD_UDP_TSO )) ==0 ) {
Shouldn't it be:
dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO)) == RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO)
?
examples/ipsec-secgw/sa.c check_eth_dev_caps(uint16_t portid, uint32_t inbound) · line 1021
Quoted 7 lines
examples/ipsec-secgw/sa.c +4
-0+RTE_LOG (WARNING ,PORT , +"hardware TSO offload is not supported\n" ); +return -EINVAL ; + } }return 0 ; }
I think you missed changes in a_check_offloads().
That's where we specify which HW offloads should be enabled for given port.
Quoted 11 lines
examples/ipsec-secgw/sa.c +1
-2@@ -1127,7 +1144,7 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],if (ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL || ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) { -if (check_eth_dev_caps (sa->portid, inbound)) +if (check_eth_dev_caps (sa->portid, inbound, sa->mss))return -EINVAL ; } --2.25.1
Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: add support for TSO
Quoted 101 lines · Konstantin
Quoted 101 lines
Add support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++++ doc/guides/sample_app_ug/ipsec_secgw.rst | 11 +++++++++++ examples/ipsec-secgw/ipsec-secgw.c | 4 ++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/ipsec_process.c | 25 ++++++++++++++++++++++++ examples/ipsec-secgw/sa.c | 21 ++++++++++++++++++-- 6 files changed, 64 insertions(+), 2 deletions(-)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -306,6 +306,10 @@ New Features * Pcapng format with timestamps and meta-data. * Fixes packet capture with stripped VLAN tags. +* **IPsec Security Gateway sample application new features.** + + * Added support for TSO + Removed Items -------------doc/guides/sample_app_ug/ipsec_secgw.rst +11
-0@@ -720,6 +720,17 @@ where each options means: * *udp-encap* + ``<mss>`` + + * Maximum segment size for TSO offload, available for egress SAs only. + + * Optional: Yes, TSO offload not set by default + + * Syntax: + + * *mss N* N is the segment size in bytes + + Example SA rules: .. code-block:: consoleexamples/ipsec-secgw/ipsec-secgw.c +4
-0@@ -398,6 +398,10 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) pkt->l2_len =0 ; pkt->l3_len =sizeof (*iph4); pkt->packet_type |=RTE_PTYPE_L3_IPV4 ; +if (pkt->packet_type &RTE_PTYPE_L4_TCP ) + pkt->l4_len =sizeof (struct rte_tcp_hdr ); +else if (pkt->packet_type &RTE_PTYPE_L4_UDP ) + pkt->l4_len =sizeof (struct rte_udp_hdr ); }else if (eth->ether_type ==rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV6 )) {int next_proto;size_t l3len, ext_len;examples/ipsec-secgw/ipsec.h +1
-0@@ -137,6 +137,7 @@ struct ipsec_sa {enum rte_security_ipsec_sa_direction direction;uint8_t udp_encap;uint16_t portid; +uint16_t mss;uint8_t fdir_qid;uint8_t fdir_flag;examples/ipsec-secgw/ipsec_process.c +13
-0@@ -222,6 +222,31 @@ prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt)for (j =0 ; j != cnt; j++) { priv =get_priv (mb[j]); priv->sa = sa; +/* setup TSO related fields if TSO enabled*/ +if (priv->sa->mss) { + mb[j]->tso_segsz = priv->sa->mss; + +if ((IS_TUNNEL (priv->sa->flags))) { + mb[j]->outer_l3_len = mb[j]->l3_len; + mb[j]->outer_l2_len = mb[j]->l2_len; + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_OUTER_IP_CKSUM | +RTE_MBUF_F_TX_TUNNEL_ESP ); + } +uint32_t ptype = mb[j]->packet_type; +if (ptype &RTE_PTYPE_L4_TCP )
Quoted 8 lines
examples/ipsec-secgw/ipsec_process.c prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt) · line 244
Quoted 7 lines
examples/ipsec-secgw/ipsec_process.c +7
-0+ mb[j]->ol_flags |= + (RTE_MBUF_F_TX_TCP_SEG | +RTE_MBUF_F_TX_TCP_CKSUM ); + else + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_UDP_SEG | +RTE_MBUF_F_TX_UDP_CKSUM );Could it be that packet is neither TCP nor UDP?
Yes, I will add a third branch for unsupported packet type.
Quoted 42 lines
Quoted 42 lines
examples/ipsec-secgw/ipsec_process.c +5
-0+if (RTE_ETH_IS_IPV4_HDR (ptype)) + mb[j]->ol_flags |=RTE_MBUF_F_TX_OUTER_IPV4 ; +else + mb[j]->ol_flags |=RTE_MBUF_F_TX_OUTER_IPV6 ; + } } }examples/ipsec-secgw/sa.c +11
-1@@ -677,6 +677,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,continue ; } +if (strcmp (tokens[ti],"mss" ) ==0 ) { +INCREMENT_TOKEN_INDEX (ti, n_tokens, status); +if (status->status <0 ) +return ; + rule->mss =atoi (tokens[ti]); +if (status->status <0 ) +return ; +continue ; + } +if (strcmp (tokens[ti],"fallback" ) ==0 ) {struct rte_ipsec_session *fb;@@ -970,7 +980,7 @@ sa_create(const char *name, int32_t socket_id, uint32_t nb_sa) }static int -check_eth_dev_caps (uint16_t portid,uint32_t inbound) +check_eth_dev_caps (uint16_t portid,uint32_t inbound,uint32_t tso) {struct rte_eth_dev_info dev_info;int retval;@@ -999,6 +1009,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound) "hardware TX IPSec offload is not supported\n");return -EINVAL ;
Quoted 8 lines
examples/ipsec-secgw/sa.c check_eth_dev_caps(uint16_t portid, uint32_t inbound) · line 1014
Quoted 4 lines
examples/ipsec-secgw/sa.c +3
-0} +if (tso && (dev_info.tx_offload_capa & + (RTE_ETH_TX_OFFLOAD_TCP_TSO | +RTE_ETH_TX_OFFLOAD_UDP_TSO )) ==0 ) {Shouldn't it be:
dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO|RTE_ETH_TX_OFFLOAD_UDP_TSO)) ==RTE_ETH_TX_OFFLOAD_TCP_TSO|RTE_ETH_TX_OFFLOAD_UDP_TSO)
?
It should be that but negated, if none of the flags are set we exit - we can't tell at this point if we need TCP or UDP.
Quoted 10 lines
examples/ipsec-secgw/sa.c check_eth_dev_caps(uint16_t portid, uint32_t inbound) · line 1021
Quoted 8 lines
examples/ipsec-secgw/sa.c +4
-0+RTE_LOG (WARNING ,PORT , +"hardware TSO offload is not supported\n" ); +return -EINVAL ; + } }return 0 ; }I think you missed changes in
a_check_offloads().
That's where we specify which HW offloads should be enabled for given port.
Yes.
Quoted 13 lines
Quoted 13 lines
examples/ipsec-secgw/sa.c +1
-2@@ -1127,7 +1144,7 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],if (ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL || ips->type ==RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ) { -if (check_eth_dev_caps (sa->portid, inbound)) +if (check_eth_dev_caps (sa->portid, inbound, sa->mss))return -EINVAL ; } --2.25.1
Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: add support for TSO
I'm seeing this problem: if we support both TCP and UDP TSO then we will check the TX offloads for both (and IPsec) and so far the only PMDs that support IPsec and TSO only support TCP TSO. So I will rework the patch to only enable TSO for TCP Inline crypto.
Quoted 194 lines · Radu
Quoted 105 lines · Konstantin
Quoted 105 lines
Add support to allow user to specific MSS for TSO offload on a per SA basis. MSS configuration in the context of IPsec is only supported for outbound SA's in the context of an inline IPsec Crypto offload.
Signed-off-by Declan Doherty <[email protected]>Signed-off-by Radu Nicolau <[email protected]>---
doc/guides/rel_notes/release_21_11.rst | 4 ++++doc/guides/sample_app_ug/ipsec_secgw.rst| 11 +++++++++++ examples/ipsec-secgw/ipsec-secgw.c | 4 ++++ examples/ipsec-secgw/ipsec.h | 1 + examples/ipsec-secgw/ipsec_process.c | 25
++++++++++++++++++++++++
examples/ipsec-secgw/sa.c | 21 ++++++++++++++++++--6 files changed, 64 insertions(+), 2 deletions(-)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -306,6 +306,10 @@ New Features * Pcapng format with timestamps and meta-data. * Fixes packet capture with stripped VLAN tags. +* **IPsec Security Gateway sample application new features.** + + * Added support for TSO +Removed Items
-------------doc/guides/sample_app_ug/ipsec_secgw.rst +3
-0@@ -720,6 +720,17 @@ where each options means: * *udp-encap* + ``<mss>`` + + * Maximum segment size for TSO offload, available for egress SAsonly.
doc/guides/sample_app_ug/ipsec_secgw.rst +8
-0+ + * Optional: Yes, TSO offload not set by default + + * Syntax: + + * *mss N* N is the segment size in bytes + +Example SA rules:
.. code-block:: console
examples/ipsec-secgw/ipsec-secgw.c +4
-0@@ -398,6 +398,10 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) pkt->l2_len = 0; pkt->l3_len = sizeof(*iph4); pkt->packet_type |= RTE_PTYPE_L3_IPV4; + if (pkt->packet_type & RTE_PTYPE_L4_TCP) + pkt->l4_len = sizeof(struct rte_tcp_hdr); + else if (pkt->packet_type & RTE_PTYPE_L4_UDP) + pkt->l4_len = sizeof(struct rte_udp_hdr); } else if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) { int next_proto;
size_tl3len,ext_len;examples/ipsec-secgw/ipsec.h +1
-0@@ -137,6 +137,7 @@ struct ipsec_sa { enum rte_security_ipsec_sa_direction direction; uint8_t udp_encap; uint16_t portid; + uint16_t mss; uint8_t fdir_qid; uint8_t fdir_flag;examples/ipsec-secgw/ipsec_process.c +13
-0@@ -222,6 +222,31 @@ prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt) for (j = 0; j != cnt; j++) { priv = get_priv(mb[j]); priv->sa = sa; + /* setup TSO related fields if TSO enabled*/ + if (priv->sa->mss) { + mb[j]->tso_segsz = priv->sa->mss; + + if ((IS_TUNNEL(priv->sa->flags))) { + mb[j]->outer_l3_len = mb[j]->l3_len; + mb[j]->outer_l2_len = mb[j]->l2_len; + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_OUTER_IP_CKSUM | + RTE_MBUF_F_TX_TUNNEL_ESP); + } + uint32_t ptype = mb[j]->packet_type; + if (ptype & RTE_PTYPE_L4_TCP)Quoted 8 lines
examples/ipsec-secgw/ipsec_process.c prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt) · line 244
Quoted 7 lines
examples/ipsec-secgw/ipsec_process.c +7
-0+ mb[j]->ol_flags |= + (RTE_MBUF_F_TX_TCP_SEG | + RTE_MBUF_F_TX_TCP_CKSUM); + else + mb[j]->ol_flags |= + (RTE_MBUF_F_TX_UDP_SEG | + RTE_MBUF_F_TX_UDP_CKSUM);Could it be that packet is neither TCP nor UDP?
Yes, I will add a third branch for unsupported packet type.
Quoted 44 lines
Quoted 44 lines
examples/ipsec-secgw/ipsec_process.c +5
-0+ if (RTE_ETH_IS_IPV4_HDR(ptype)) + mb[j]->ol_flags |= RTE_MBUF_F_TX_OUTER_IPV4; + else + mb[j]->ol_flags |= RTE_MBUF_F_TX_OUTER_IPV6; + } } }examples/ipsec-secgw/sa.c +10
-0@@ -677,6 +677,16 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, continue; } + if (strcmp(tokens[ti], "mss") == 0) { + INCREMENT_TOKEN_INDEX(ti, n_tokens, status); + if (status->status < 0) + return; + rule->mss = atoi(tokens[ti]); + if (status->status < 0) + return; + continue; + } + if (strcmp(tokens[ti], "fallback") == 0) { struct rte_ipsec_session *fb;@@ -970,7 +980,7 @@ sa_create(const char *name, int32_t socket_id, uint32_t nb_sa) }static int
examples/ipsec-secgw/sa.c +1
-1-check_eth_dev_caps(uint16_t portid, uint32_t inbound) +check_eth_dev_caps(uint16_t portid, uint32_t inbound, uint32_t tso){
structrte_eth_dev_infodev_info;
int retval;examples/ipsec-secgw/sa.c +0
-0@@ -999,6 +1009,13 @@ check_eth_dev_caps(uint16_t portid, uint32_t inbound) "hardware TX IPSec offload is not supported\n"); return -EINVAL;Quoted 8 lines
examples/ipsec-secgw/sa.c check_eth_dev_caps(uint16_t portid, uint32_t inbound) · line 1014
Quoted 4 lines
examples/ipsec-secgw/sa.c +3
-0} + if (tso && (dev_info.tx_offload_capa & + (RTE_ETH_TX_OFFLOAD_TCP_TSO | + RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {Shouldn't it be:
dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO|RTE_ETH_TX_OFFLOAD_UDP_TSO)) ==RTE_ETH_TX_OFFLOAD_TCP_TSO|RTE_ETH_TX_OFFLOAD_UDP_TSO)
?It should be that but negated, if none of the flags are set we exit - we can't tell at this point if we need TCP or UDP.
Quoted 10 lines
Quoted 8 lines
examples/ipsec-secgw/sa.c +4
-0+ RTE_LOG(WARNING, PORT, + "hardware TSO offload is not supported\n"); + return -EINVAL; + } } return 0;}
I think you missed changes in
a_check_offloads().
That's where we specify which HW offloads should be enabled for given port.Yes.
Quoted 14 lines
Quoted 14 lines
examples/ipsec-secgw/sa.c +0
-0@@ -1127,7 +1144,7 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],if (
ips->type==RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL||ips->type==RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) { - if (check_eth_dev_caps(sa->portid, inbound))
+ if (check_eth_dev_caps(sa->portid, inbound, sa->mss)) return-EINVAL;
}Signature · 1 line
2.25.1