security: enforce semantics for Tx inline processing
PATCH 1/2 security: enforce semantics for Tx inline processing
From: Nithin Dabilpuram <[email protected]>
For Tx inline processing, when RTE_SECURITY_TX_OLOAD_NEED_MDATA is set, rte_security_set_pkt_metadata() needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags. rte_security_set_pkt_metadata() is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation that rte_security_set_pkt_metadata() should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.
On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.
--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)
doc/guides/nics/features.rst +2 -0
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.
doc/guides/prog_guide/rte_security.rst +5 -1
@@ -560,7 +560,11 @@ created by the application is attached to the security session by the API For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header. Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register a pointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2 -0
@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
Signature · 1 line
2.25.1
PATCH 2/2 examples/ipsec-secgw: modify event mode inline path
From: Nithin Dabilpuram <[email protected]>
Align event mode path for Tx inline IPsec processing to adhere to security spec. Call rte_security_set_pkt_metadata() only with mbuf containing L3 header and above. Also update mbuf.l2_len with L2 header size.
This patch also fixes a bug in arg parsing.
--- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 50 +++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 14 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +2 -0
@@ -1495,6 +1495,8 @@ parse_portmask(const char *portmask)char *end =NULL ;unsigned long pm; + errno =0 ; +/* parse hexadecimal string */ pm =strtoul (portmask, &end,16 );if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))
examples/ipsec-secgw/ipsec_worker.c +36 -14
119 lines not on this page · raw message
Signature · 1 line
2.25.1
Hi Konstantin/ Olivier,
Could you please review this patch? This has also an update in documentation of mbuf.
Regards,
Akhil
Quoted 26 lines
From: Nithin Dabilpuram <[email protected]>
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>
Quoted 59 lines
From: Nithin Dabilpuram <[email protected]>
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API · line 565
Quoted 7 lines
doc/guides/prog_guide/rte_security.rst +3
-1@@ -560,7 +560,11 @@ created by the application is attached to the security session by the API For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.
Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
Quoted 21 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 60 lines · Konstantin
Quoted 60 lines
From: Nithin Dabilpuram <[email protected]>
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the API
Quoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1. receive_pkt()
2. strip_l2_hdr()
3. Do policy lookup ()
4. Call rte_security_set_pkt_metadata() if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Do route_lookup()
6. add_l2hdr() which might be different from stripped l2hdr.
7. Send packet out.
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following. While in event mode, step 2 and step 6 are missing.
This patch is trying to enforce semantics as above so that rte_security_set_pkt_metadata() can predict what comes in the pkt when he is called.
I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 85 lines · Konstantin
Quoted 60 lines
Quoted 60 lines
From: Nithin Dabilpuram <[email protected]>
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.
Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If your rte_security_set_pkt_metadata() implementation really needs to know L3 hdr offset (not sure why?), then I suppose we can add a requirement that l2_len has to be set properly before calling rte_security_set_pkt_metadata().
Quoted 31 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 88 lines · Konstantin
Quoted 85 lines · Konstantin
Quoted 60 lines
Quoted 60 lines
From: Nithin Dabilpuram <[email protected]>
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),
Since rte_security_set_pkt_metadata() is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec via rte_eth_tx_burst(). This saves us cycles later in rte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time of rte_security_set_pkt_metadata() call, then I think having a PMD specific callback is not much of use except for saving SA priv data to rte_mbuf.
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().
This is also fine with us.
Quoted 32 lines
Quoted 32 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 90 lines
Quoted 84 lines
Quoted 81 lines
Quoted 58 lines
Quoted 58 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),
Quoted 8 lines
Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before calling rte_security_set_pkt_metadata() mbuf.l2_len should be properly set.
2. after rte_security_set_pkt_metadata() and before rte_eth_tx_burst() packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?
Is that correct understanding?
If yes, I wonder how 2) will correlate with rte_eth_tx_prepare() concept?
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 95 lines · Konstantin
Quoted 95 lines
Quoted 84 lines
Quoted 81 lines
Quoted 58 lines
Quoted 58 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?
Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?
Since our PMD doesn't have a prepare function, I missed that but, since rte_security_set_pkt_metadata() is only used for Inline Crypto/Protocol via a rte_eth_dev, and both rte_security_set_pkt_metadata() and rte_eth_tx_prepare() are callbacks from same PMD, do you see any issue ?
The restriction is from user side, data is not supposed to be modified unless rte_security_set_pkt_metadata() is called again.
If your question is can't we do the preprocessing in rte_eth_tx_prepare() for security, my only argument was that since there is already a hit in rte_security_set_pkt_metadata() to PMD specific callback and
struct rte_security_session is passed as an argument to it, it is more benefitial to do security related pre-processing there.
Also rte_eth_tx_prepare() if implemented will be called for both security and non-security pkts.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 108 lines
Quoted 94 lines
Quoted 94 lines
Quoted 83 lines
Quoted 80 lines
Quoted 57 lines
Quoted 57 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API · line 565
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?
Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */ rte_eth_tx_prepare(..., &mb, 1); rte_eth_tx_burst(..., &mb, 1);
With the new restrictions you are proposing it wouldn't be allowed any more.
Quoted 3 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,
Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.
Yes, it would be extra callback call that way.
Though tx_prepare() accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.
Yes, but tx_prepare() can distinguish (by ol_flags and/or other field contents) which modifications are required for the packet.
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 116 lines · Konstantin
Quoted 108 lines
Quoted 94 lines
Quoted 94 lines
Quoted 83 lines
Quoted 80 lines
Quoted 57 lines
Quoted 57 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API · line 565
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.
Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
I think insisting that rte_security_set_pkt_metadata() be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?
Quoted 17 lines
Quoted 4 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.
Quoted 5 lines
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.
But the major issues I see are
1. tx_prepare() doesn't take rte_security_session as argument though ol_flags has security flag. In our case, we need to know the security session details to do things.
2. AFAIU tx_prepare() is not mandatory as per spec and even by default disabled under compile time macro RTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we do tx_prepare(), rte_security_set_pkt_mdata() is mandatory to associate struct rte_security_session to a pkt as unlike ol_flags, there is no direct space to do the same.
So I think instead of enforcing yet another callback tx_prepare() for inline security processing, it can be done via security specific set_pkt_metadata(). I'm fine to introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.
If rte_security_set_pkt_metadata() was not a PMD specific function ptr call and rte_mbuf had space for struct rte_security_session pointer,
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 123 lines
Quoted 123 lines
Quoted 108 lines
Quoted 94 lines
Quoted 94 lines
Quoted 83 lines
Quoted 80 lines
Quoted 57 lines
Quoted 57 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API · line 565
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);
Quoted 7 lines
Quoted 1 line
With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?
AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
union ixgbe_crypto_tx_desc_md *mdata = (union ixgbe_crypto_tx_desc_md *)
rte_security_dynfield(m);
mdata->enc = 1;
mdata->sa_idx = ic_session->sa_index; mdata->pad_len = ixgbe_crypto_compute_pad_len(m);
Then this data will be used by tx_burst() function.
Quoted 21 lines
Quoted 21 lines
Quoted 5 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.
Quoted 7 lines
Quoted 2 lines
Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.But the major issues I see are
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.
I suppose you can store pointer to session (or so) inside mbuf in rte_security_dynfield, no?
Quoted 4 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.
Didn't get you here, obviously we do have rte_security_dynfield inside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().
But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use tx_prepare() - why doing these calculations inside tx_burst() itself is not an option?
Quoted 6 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,
But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it via mbuf_dynfield and store there whatever is needed.
Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 126 lines · Konstantin
Quoted 126 lines
Quoted 116 lines
Quoted 108 lines
Quoted 94 lines
Quoted 94 lines
Quoted 83 lines
Quoted 80 lines
Quoted 57 lines
Quoted 57 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API · line 565
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
Quoted 8 lines
Quoted 4 lines
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
This implies rte_security_set_pkt_metadata() cannot be called when mbuf does't have ESP trailer updated or when mbuf->pkt_len = 0
Quoted 8 lines
union
ixgbe_crypto_tx_desc_md*mdata = (unionixgbe_crypto_tx_desc_md*)rte_security_dynfield(m);
mdata->enc= 1;
mdata->sa_idx=ic_session->sa_index;mdata->pad_len=ixgbe_crypto_compute_pad_len(m);Then this data will be used by
tx_burst()function.
So it implies that after above rte_security_set_pkt_metadata() call, and before tx_burst(), mbuf data / packet len cannot be modified right as if modified, then tx_burst() will be using incorrect pad len ?
This patch is also trying to add similar restriction on when rte_security_set_pkt_metadata() should be called and what cannot be done after calling rte_security_set_pkt_metadata().
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 6 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.
Quoted 6 lines
Quoted 4 lines
But the major issues I see are
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.I suppose you can store pointer to session (or so) inside mbuf in
rte_security_dynfield, no?
We can do. But having to call PMD specific function call via rte_security_set_pkt_metadata() just for storing session pointer in rte_security_dynfield consumes unnecessary cycles per pkt.
Quoted 10 lines
Quoted 5 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.Didn't get you here, obviously we do have
rte_security_dynfieldinside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.
Quoted 6 lines
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use
tx_prepare()- why doing these calculations insidetx_burst()itself is not an option?
We can do things in tx_burst() but if we are doing it there, then we want to avoid having callback for rte_security_set_pkt_metadata().
Are you fine if we can update the spec that "When DEV_TX_OFFLOAD_SEC_NEED_MDATA is not set, then, user needs to update struct rte_security_session's sess_private_data in a in rte_security_dynfield like below ?
<snip>
static inline void
inline_outb_mbuf_prepare(const struct rte_ipsec_session *ss,
struct rte_mbuf *mb[], uint16_t num)
{
uint32_t i, ol_flags;
ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA;
for (i = 0; i != num; i++) {
mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD;
if (ol_flags != 0)
rte_security_set_pkt_metadata(ss->security.ctx,
ss->security.ses, mb[i], NULL);
else
*rte_security_dynfield(mb[i]) =
(uint64_t)ss->security.ses->sess_private_data; If the above can be done, then in our PMD, we will not have a callback for set_pkt_metadata() and DEV_TX_OFFLOAD_SEC_NEED_MDATA will also be not set in capabilities.
Quoted 50 lines
Quoted 7 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it viambuf_dynfieldand store there whatever is needed.Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Adding more rte_security and PMD maintainers into the loop.
Quoted 144 lines
Quoted 125 lines
Quoted 125 lines
Quoted 115 lines
Quoted 107 lines
Quoted 93 lines
Quoted 93 lines
Quoted 82 lines
Quoted 79 lines
Quoted 56 lines
Quoted 56 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API · line 565
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
Quoted 8 lines
Quoted 4 lines
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
This implies
rte_security_set_pkt_metadata()cannot be called when mbuf does't have ESP trailer updated or whenmbuf->pkt_len= 0Quoted 7 lines
union
ixgbe_crypto_tx_desc_md*mdata = (unionixgbe_crypto_tx_desc_md*)rte_security_dynfield(m);
mdata->enc= 1;
mdata->sa_idx=ic_session->sa_index;mdata->pad_len=ixgbe_crypto_compute_pad_len(m);
Quoted 4 lines
Quoted 1 line
Then this data will be used by
tx_burst()function.So it implies that after above
rte_security_set_pkt_metadata()call, and beforetx_burst(), mbuf data / packet len cannot be modified right as if modified, thentx_burst()will be using incorrect pad len ?
No, pkt_len can be modified.
Though ESP trailer pad_len can't.
Quoted 4 lines
This patch is also trying to add similar restriction on when
rte_security_set_pkt_metadata()should be called and what cannot be done after callingrte_security_set_pkt_metadata().
No, I don't think it is really the same.
Also, IMO, inside ixgbe set_pkt_metadata() implementaion we probably shouldn't silently imply that ESP packet is already formed and trailer contains valid data.
In fact, I think this pad_len calculation can be moved to actual TX function.
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 20 lines
Quoted 7 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 5 lines
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.But the major issues I see are
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.I suppose you can store pointer to session (or so) inside mbuf in
rte_security_dynfield, no?We can do. But having to call PMD specific function call via
rte_security_set_pkt_metadata()just for storing session pointer inrte_security_dynfieldconsumes unnecessary cycles per pkt.
In fact there are two function calls: one for rte_security_set_pkt_metadata(), second for instance->ops->set_pkt_metadata() callback.
Which off-course way too expensive for such simple operation.
Actually same thought for rte_security_get_userdata().
Both of these functions belong to data-path and ideally have to be as fast as possible. Probably 21.11 is a right timeframe for that.
Quoted 45 lines
Quoted 10 lines
Quoted 5 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.Didn't get you here, obviously we do have
rte_security_dynfieldinside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.Quoted 6 lines
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use
tx_prepare()- why doing these calculations insidetx_burst()itself is not an option?We can do things in
tx_burst()but if we are doing it there, then we want to avoid having callback forrte_security_set_pkt_metadata().Are you fine if we can update the spec that "When
DEV_TX_OFFLOAD_SEC_NEED_MDATAis not set, then, user needs to update struct rte_security_session'ssess_private_datain a inrte_security_dynfieldlike below ?<snip>
static inline void
inline_outb_mbuf_prepare(const structrte_ipsec_session*ss,struct rte_mbuf *mb[], uint16_t num) { uint32_t i, ol_flags; ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA; for (i = 0; i != num; i++) { mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD; if (ol_flags != 0) rte_security_set_pkt_metadata(ss->security.ctx, ss->security.ses, mb[i], NULL); else *rte_security_dynfield(mb[i]) = (uint64_t)ss->security.ses->sess_private_data;
Quoted 3 lines
If the above can be done, then in our PMD, we will not have a callback for
set_pkt_metadata()andDEV_TX_OFFLOAD_SEC_NEED_MDATAwill also be not set in capabilities.
That's an interesting idea, but what you propose is the change in current rte_security API behaviour. So all existing apps that use this API will have to be changed.
We'd better avoid such changes unless there is really good reason for that.
So, I'd suggest to tweak your idea a bit:
1) change rte_security_set_pkt_metadata():
if ops->set_pkt_metadata != NULL, then call it (existing behaviour) otherwise just: rte_security_dynfield(m) = sess->session_private_data; (fast-path)
2) consider to make rte_security_set_pkt_metadata() inline function. We probably can have some special flag inside struct rte_security_ctx, or even store inside ctx a pointer to set_pkt_metadata() itself.
As a brief code snippet:
struct rte_security_ctx {
void *device;
/**< Crypto/ethernet device attached */
const struct rte_security_ops *ops;
/**< Pointer to security ops for the device */
uint16_t sess_cnt;
/**< Number of sessions attached to this context */+ int (*set_pkt_mdata)(void *, struct rte_security_session *, struct rte_mbuf *, void *);
};
static inline int
rte_security_set_pkt_metadata(struct rte_security_ctx *instance,
struct rte_security_session *sess, struct rte_mbuf *m, void *params)
{
/* fast-path */
if (instance->set_pkt_mdata == NULL) {
*rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data);
return 0;
/* slow path */
} else
return instance->set_pkt_mdata(instance->device, sess, m, params);
}That probably would be an ABI breakage (new fileld in rte_security_ctx) and would require some trivial changes for all existing PMDs that use RTE_SECURITY_TX_OFLOAD_NEED_MDATA (ctx_create()), but hopefully will benefit everyone.
Quoted 51 lines
Quoted 51 lines
Quoted 8 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it viambuf_dynfieldand store there whatever is needed.Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 264 lines
Adding more
rte_securityand PMD maintainers into the loop.Quoted 144 lines
Quoted 125 lines
Quoted 125 lines
Quoted 115 lines
Quoted 107 lines
Quoted 93 lines
Quoted 93 lines
Quoted 82 lines
Quoted 79 lines
Quoted 56 lines
Quoted 56 lines
For Tx inline processing, when
RTE_SECURITY_TX_OLOAD_NEED_MDATAis set,rte_security_set_pkt_metadata()needs to be called for pkts to associate a Security session with a mbuf before submitting to Ethdev Tx. This is apart from settingPKT_TX_SEC_OFFLOADin mbuf.ol_flags.rte_security_set_pkt_metadata()is also used to set some opaque metadata in mbuf for PMD's use.
This patch updates documentation thatrte_security_set_pkt_metadata()should be called only with mbuf containing Layer 3 and above data. This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing. Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Reviewed-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ doc/guides/prog_guide/rte_security.rst | 6 +++++- lib/mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.doc/guides/prog_guide/rte_security.rst +0
-0@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
doc/guides/prog_guide/rte_security.rst created by the application is attached to the security session by the API · line 565
Quoted 6 lines
doc/guides/prog_guide/rte_security.rst +3
-1For Inline Crypto and Inline protocol offload, device specific defined metadata is updated in the mbuf using ``rte_security_set_pkt_metadata()`` if -``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()`` +should be called on mbuf only with Layer 3 and above data present and +``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
Quoted 8 lines
Quoted 4 lines
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
This implies
rte_security_set_pkt_metadata()cannot be called when mbuf does't have ESP trailer updated or whenmbuf->pkt_len= 0Quoted 7 lines
union
ixgbe_crypto_tx_desc_md*mdata = (unionixgbe_crypto_tx_desc_md*)rte_security_dynfield(m);
mdata->enc= 1;
mdata->sa_idx=ic_session->sa_index;mdata->pad_len=ixgbe_crypto_compute_pad_len(m);Quoted 4 lines
Quoted 1 line
Then this data will be used by
tx_burst()function.So it implies that after above
rte_security_set_pkt_metadata()call, and beforetx_burst(), mbuf data / packet len cannot be modified right as if modified, thentx_burst()will be using incorrect pad len ?No,
pkt_lencan be modified.
Though ESP trailerpad_lencan't.Quoted 4 lines
This patch is also trying to add similar restriction on when
rte_security_set_pkt_metadata()should be called and what cannot be done after callingrte_security_set_pkt_metadata().No, I don't think it is really the same.
Also, IMO, inside ixgbeset_pkt_metadata()implementaion we probably shouldn't silently imply that ESP packet is already formed and trailer contains valid data.
In fact, I think thispad_lencalculation can be moved to actual TX function.Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 20 lines
Quoted 7 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 5 lines
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.But the major issues I see are
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.I suppose you can store pointer to session (or so) inside mbuf in
rte_security_dynfield, no?We can do. But having to call PMD specific function call via
rte_security_set_pkt_metadata()just for storing session pointer inrte_security_dynfieldconsumes unnecessary cycles per pkt.In fact there are two function calls: one for
rte_security_set_pkt_metadata(), second forinstance->ops->set_pkt_metadata()callback.
Which off-course way too expensive for such simple operation.
Actually same thought forrte_security_get_userdata().
Both of these functions belong to data-path and ideally have to be as fast as possible. Probably 21.11 is a right timeframe for that.Quoted 45 lines
Quoted 10 lines
Quoted 5 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.Didn't get you here, obviously we do have
rte_security_dynfieldinside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.Quoted 6 lines
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use
tx_prepare()- why doing these calculations insidetx_burst()itself is not an option?We can do things in
tx_burst()but if we are doing it there, then we want to avoid having callback forrte_security_set_pkt_metadata().Are you fine if we can update the spec that "When
DEV_TX_OFFLOAD_SEC_NEED_MDATAis not set, then, user needs to update struct rte_security_session'ssess_private_datain a inrte_security_dynfieldlike below ?<snip>
static inline void
inline_outb_mbuf_prepare(const structrte_ipsec_session*ss,struct rte_mbuf *mb[], uint16_t num) { uint32_t i, ol_flags; ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA; for (i = 0; i != num; i++) { mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD; if (ol_flags != 0) rte_security_set_pkt_metadata(ss->security.ctx, ss->security.ses, mb[i], NULL); else *rte_security_dynfield(mb[i]) = (uint64_t)ss->security.ses->sess_private_data;Quoted 3 lines
If the above can be done, then in our PMD, we will not have a callback for
set_pkt_metadata()andDEV_TX_OFFLOAD_SEC_NEED_MDATAwill also be not set in capabilities.That's an interesting idea, but what you propose is the change in current
rte_securityAPI behaviour. So all existing apps that use this API will have to be changed.
We'd better avoid such changes unless there is really good reason for that.
So, I'd suggest to tweak your idea a bit:
Quoted 8 lines
1) change
rte_security_set_pkt_metadata():
ifops->set_pkt_metadata!= NULL, then call it (existing behaviour) otherwise just:rte_security_dynfield(m)=sess->session_private_data; (fast-path)2) consider to make
rte_security_set_pkt_metadata()inline function. We probably can have some special flag inside structrte_security_ctx, or even store inside ctx a pointer toset_pkt_metadata()itself.
After another thoughts some new flags might be better.
Then later, if we'll realize that set_pkt_metadata() and get_useradata() are not really used by PMDs, it might be easier to deprecate these callbacks.
Quoted 82 lines
As a brief code snippet:
struct rte_security_ctx { void *device; /**< Crypto/ethernet device attached */ const struct rte_security_ops *ops; /**< Pointer to security ops for the device */ uint16_t sess_cnt; /**< Number of sessions attached to this context */+ int (*set_pkt_mdata)(void *, struct
rte_security_session*, structrte_mbuf*, void *);
};static inline int
rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params){ /* fast-path */ if (instance->set_pkt_mdata == NULL) { *rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data); return 0; /* slow path */ } else return instance->set_pkt_mdata(instance->device, sess, m, params); }That probably would be an ABI breakage (new fileld in
rte_security_ctx) and would require some trivial changes for all existing PMDs that useRTE_SECURITY_TX_OFLOAD_NEED_MDATA(ctx_create()), but hopefully will benefit everyone.Quoted 51 lines
Quoted 51 lines
Quoted 8 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it viambuf_dynfieldand store there whatever is needed.Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
doc/guides/prog_guide/rte_security.rst +2
-0Once called, +Layer 3 and above data cannot be modified or moved around unless +``rte_security_set_pkt_metadata()`` is called again. For inline protocol offloaded ingress traffic, the application can register apointer, ``userdata`` , in the security session. When the packet is received,
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --2.25.1
Quoted 269 lines · Konstantin
Quoted 269 lines
Adding more
rte_securityand PMD maintainers into the loop.Quoted 144 lines
Quoted 125 lines
Quoted 125 lines
Quoted 115 lines
Quoted 107 lines
Quoted 93 lines
Quoted 93 lines
Quoted 82 lines
Quoted 79 lines
Quoted 56 lines
Quoted 56 lines
For Tx inline processing, when RTE_SECURITY_TX_OLOAD_NEED_MDATA is
set, rte_security_set_pkt_metadata() needs to be called for pkts
to associate a Security session with a mbuf before submitting
to Ethdev Tx. This is apart from setting PKT_TX_SEC_OFFLOAD in
mbuf.ol_flags. rte_security_set_pkt_metadata() is also used to
set some opaque metadata in mbuf for PMD's use.
This patch updates documentation that rte_security_set_pkt_metadata()
should be called only with mbuf containing Layer 3 and above data.
This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify
L2 header and L3 header locations on Tx. This is inline with other
Tx offloads requirements such as L3 checksum, L4 checksum offload,
etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for
HW to be able to generate checksum. Since Inline IPSec is also
such a Tx offload, some PMD's at least need mbuf.l2_len to be
valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting
mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags
for Inline IPSec Crypto / Protocol offload processing to
work on Tx.Signed-off-by: Nithin Dabilpuram <[email protected]>
Reviewed-by: Akhil Goyal <[email protected]>
---
doc/guides/nics/features.rst | 2 ++
doc/guides/prog_guide/rte_security.rst | 6 +++++-
lib/mbuf/rte_mbuf_core.h | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index 403c2b03a..414baf14f 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``.
* **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``,
``capabilities_get``.
diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index f72bc8a78..7b68c698d 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIQuoted 10 lines
Quoted 6 lines
For Inline Crypto and Inline protocol offload, device specific defined metadata is
updated in the mbuf using ``rte_security_set_pkt_metadata()`` if
-``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set.
+``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()``
+should be called on mbuf only with Layer 3 and above data present and
+``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr. Who will add L2 hdr to the packet in that case? Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?
That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
Quoted 6 lines
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 8 lines
Quoted 3 lines
Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before callingrte_security_set_pkt_metadata().This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
Quoted 8 lines
Quoted 4 lines
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
This implies
rte_security_set_pkt_metadata()cannot be called when mbuf does't have ESP trailer updated or whenmbuf->pkt_len= 0Quoted 7 lines
union
ixgbe_crypto_tx_desc_md*mdata = (unionixgbe_crypto_tx_desc_md*)rte_security_dynfield(m);
mdata->enc= 1;
mdata->sa_idx=ic_session->sa_index;mdata->pad_len=ixgbe_crypto_compute_pad_len(m);Quoted 4 lines
Quoted 1 line
Then this data will be used by
tx_burst()function.So it implies that after above
rte_security_set_pkt_metadata()call, and beforetx_burst(), mbuf data / packet len cannot be modified right as if modified, thentx_burst()will be using incorrect pad len ?No,
pkt_lencan be modified.
Though ESP trailerpad_lencan't.Quoted 4 lines
This patch is also trying to add similar restriction on when
rte_security_set_pkt_metadata()should be called and what cannot be done after callingrte_security_set_pkt_metadata().No, I don't think it is really the same.
Also, IMO, inside ixgbeset_pkt_metadata()implementaion we probably shouldn't silently imply that ESP packet is already formed and trailer contains valid data.
In fact, I think thispad_lencalculation can be moved to actual TX function.Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 20 lines
Quoted 7 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 5 lines
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.But the major issues I see are
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.I suppose you can store pointer to session (or so) inside mbuf in
rte_security_dynfield, no?We can do. But having to call PMD specific function call via
rte_security_set_pkt_metadata()just for storing session pointer inrte_security_dynfieldconsumes unnecessary cycles per pkt.In fact there are two function calls: one for
rte_security_set_pkt_metadata(), second forinstance->ops->set_pkt_metadata()callback.
Which off-course way too expensive for such simple operation.
Actually same thought forrte_security_get_userdata().
Both of these functions belong to data-path and ideally have to be as fast as possible. Probably 21.11 is a right timeframe for that.Quoted 45 lines
Quoted 10 lines
Quoted 5 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.Didn't get you here, obviously we do have
rte_security_dynfieldinside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.Quoted 6 lines
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use
tx_prepare()- why doing these calculations insidetx_burst()itself is not an option?We can do things in
tx_burst()but if we are doing it there, then we want to avoid having callback forrte_security_set_pkt_metadata().Are you fine if we can update the spec that "When
DEV_TX_OFFLOAD_SEC_NEED_MDATAis not set, then, user needs to update struct rte_security_session'ssess_private_datain a inrte_security_dynfieldlike below ?<snip>
static inline void
inline_outb_mbuf_prepare(const structrte_ipsec_session*ss,struct rte_mbuf *mb[], uint16_t num) { uint32_t i, ol_flags; ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA; for (i = 0; i != num; i++) { mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD; if (ol_flags != 0) rte_security_set_pkt_metadata(ss->security.ctx, ss->security.ses, mb[i], NULL); else *rte_security_dynfield(mb[i]) = (uint64_t)ss->security.ses->sess_private_data;Quoted 3 lines
If the above can be done, then in our PMD, we will not have a callback for
set_pkt_metadata()andDEV_TX_OFFLOAD_SEC_NEED_MDATAwill also be not set in capabilities.That's an interesting idea, but what you propose is the change in current
rte_securityAPI behaviour. So all existing apps that use this API will have to be changed.
We'd better avoid such changes unless there is really good reason for that.
So, I'd suggest to tweak your idea a bit:1) change
rte_security_set_pkt_metadata():
ifops->set_pkt_metadata!= NULL, then call it (existing behaviour) otherwise just:rte_security_dynfield(m)=sess->session_private_data; (fast-path)
Quoted 7 lines
Quoted 3 lines
2) consider to make
rte_security_set_pkt_metadata()inline function. We probably can have some special flag inside structrte_security_ctx, or even store inside ctx a pointer toset_pkt_metadata()itself.After another thoughts some new flags might be better.
Then later, if we'll realize thatset_pkt_metadata()andget_useradata()are not really used by PMDs, it might be easier to deprecate these callbacks.
Thanks, I agree with your thoughts. I'll submit a V2 with above change, new flags and set_pkt_metadata() and get_userdata() function pointers moved to rte_security_ctx for review so that it can be targeted for 21.11.
Even with flags moving set_pkt_metadata() and get_userdata() function pointers is still needed as we need to make rte_security_set_pkt_metadata() API inline while struct rte_security_ops is not exposed to user. I think this is fine as it is inline with how fast path function pointers of rte_ethdev and rte_cryptodev are currently placed.
Quoted 83 lines
Quoted 83 lines
As a brief code snippet:
struct rte_security_ctx { void *device; /**< Crypto/ethernet device attached */ const struct rte_security_ops *ops; /**< Pointer to security ops for the device */ uint16_t sess_cnt; /**< Number of sessions attached to this context */+ int (*set_pkt_mdata)(void *, struct
rte_security_session*, structrte_mbuf*, void *);
};static inline int
rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params){ /* fast-path */ if (instance->set_pkt_mdata == NULL) { *rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data); return 0; /* slow path */ } else return instance->set_pkt_mdata(instance->device, sess, m, params); }That probably would be an ABI breakage (new fileld in
rte_security_ctx) and would require some trivial changes for all existing PMDs that useRTE_SECURITY_TX_OFLOAD_NEED_MDATA(ctx_create()), but hopefully will benefit everyone.Quoted 51 lines
Quoted 51 lines
Quoted 8 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it viambuf_dynfieldand store there whatever is needed.Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Quoted 22 lines
Once called,
+Layer 3 and above data cannot be modified or moved around unless
+``rte_security_set_pkt_metadata()`` is called again.For inline protocol offloaded ingress traffic, the application can register a
pointer, ``userdata`` , in the security session. When the packet is received,
diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index bb38d7f58..9d8e3ddc8 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -228,6 +228,8 @@ extern "C" {/**
* Request security offload processing on the TX packet.
+ * To use Tx security offload, the user needs to fill l2_len in mbuf
+ * indicating L2 header size and where L3 header starts.
*/
#define PKT_TX_SEC_OFFLOAD (1ULL << 43)--
2.25.1
Quoted 277 lines
Quoted 89 lines
Quoted 89 lines
Adding more
rte_securityand PMD maintainers into the loop.Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 79 lines
Quoted 66 lines
For Tx inline processing, when RTE_SECURITY_TX_OLOAD_NEED_MDATA is
set, rte_security_set_pkt_metadata() needs to be called for pkts
to associate a Security session with a mbuf before submitting
to Ethdev Tx. This is apart from setting PKT_TX_SEC_OFFLOAD in
mbuf.ol_flags. rte_security_set_pkt_metadata() is also used to
set some opaque metadata in mbuf for PMD's use.
This patch updates documentation that rte_security_set_pkt_metadata()
should be called only with mbuf containing Layer 3 and above data.
This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify
L2 header and L3 header locations on Tx. This is inline with other
Tx offloads requirements such as L3 checksum, L4 checksum offload,
etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for
HW to be able to generate checksum. Since Inline IPSec is also
such a Tx offload, some PMD's at least need mbuf.l2_len to be
valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting
mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags
for Inline IPSec Crypto / Protocol offload processing to
work on Tx.Signed-off-by: Nithin Dabilpuram <[email protected]>
Reviewed-by: Akhil Goyal <[email protected]>
---
doc/guides/nics/features.rst | 2 ++
doc/guides/prog_guide/rte_security.rst | 6 +++++-
lib/mbuf/rte_mbuf_core.h | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index 403c2b03a..414baf14f 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``.
* **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``,
``capabilities_get``.
diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index f72bc8a78..7b68c698d 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIFor Inline Crypto and Inline protocol offload, device specific defined metadata is
updated in the mbuf using ``rte_security_set_pkt_metadata()`` if
-``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set.
+``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()``
+should be called on mbuf only with Layer 3 and above data present and
+``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr.
Who will add L2 hdr to the packet in that case?
Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?That is the semantics I was trying to define. I think below are the sequence of operations to be done for ipsec processing,
1.
receive_pkt()
2.strip_l2_hdr()
3. Do policy lookup ()
4. Callrte_security_set_pkt_metadata()if pkt needs to be encrypted with a particular SA. Now pkt only has L3 and above data.
5. Doroute_lookup()
6.add_l2hdr()which might be different from stripped l2hdr.
7. Send packet out.Quoted 2 lines
The above sequence is what I believe the current poll mode worker thread in ipsec-secgw is following.
That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before calling
rte_security_set_pkt_metadata().Quoted 171 lines
Quoted 171 lines
Quoted 50 lines
Quoted 31 lines
Quoted 31 lines
Quoted 21 lines
Quoted 13 lines
Quoted 7 lines
Quoted 2 lines
This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
Quoted 8 lines
Quoted 4 lines
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
This implies
rte_security_set_pkt_metadata()cannot be called when mbuf does't have ESP trailer updated or whenmbuf->pkt_len= 0Quoted 7 lines
union
ixgbe_crypto_tx_desc_md*mdata = (unionixgbe_crypto_tx_desc_md*)rte_security_dynfield(m);
mdata->enc= 1;
mdata->sa_idx=ic_session->sa_index;mdata->pad_len=ixgbe_crypto_compute_pad_len(m);Quoted 4 lines
Quoted 1 line
Then this data will be used by
tx_burst()function.So it implies that after above
rte_security_set_pkt_metadata()call, and beforetx_burst(), mbuf data / packet len cannot be modified right as if modified, thentx_burst()will be using incorrect pad len ?No,
pkt_lencan be modified.
Though ESP trailerpad_lencan't.Quoted 4 lines
This patch is also trying to add similar restriction on when
rte_security_set_pkt_metadata()should be called and what cannot be done after callingrte_security_set_pkt_metadata().No, I don't think it is really the same.
Also, IMO, inside ixgbeset_pkt_metadata()implementaion we probably shouldn't silently imply that ESP packet is already formed and trailer contains valid data.
In fact, I think thispad_lencalculation can be moved to actual TX function.Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 20 lines
Quoted 7 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 5 lines
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.But the major issues I see are
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.I suppose you can store pointer to session (or so) inside mbuf in
rte_security_dynfield, no?We can do. But having to call PMD specific function call via
rte_security_set_pkt_metadata()just for storing session pointer inrte_security_dynfieldconsumes unnecessary cycles per pkt.In fact there are two function calls: one for
rte_security_set_pkt_metadata(), second forinstance->ops->set_pkt_metadata()callback.
Which off-course way too expensive for such simple operation.
Actually same thought forrte_security_get_userdata().
Both of these functions belong to data-path and ideally have to be as fast as possible. Probably 21.11 is a right timeframe for that.Quoted 45 lines
Quoted 10 lines
Quoted 5 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.Didn't get you here, obviously we do have
rte_security_dynfieldinside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.Quoted 6 lines
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use
tx_prepare()- why doing these calculations insidetx_burst()itself is not an option?We can do things in
tx_burst()but if we are doing it there, then we want to avoid having callback forrte_security_set_pkt_metadata().Are you fine if we can update the spec that "When
DEV_TX_OFFLOAD_SEC_NEED_MDATAis not set, then, user needs to update struct rte_security_session'ssess_private_datain a inrte_security_dynfieldlike below ?<snip>
static inline void
inline_outb_mbuf_prepare(const structrte_ipsec_session*ss,struct rte_mbuf *mb[], uint16_t num) { uint32_t i, ol_flags; ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA; for (i = 0; i != num; i++) { mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD; if (ol_flags != 0) rte_security_set_pkt_metadata(ss->security.ctx, ss->security.ses, mb[i], NULL); else *rte_security_dynfield(mb[i]) = (uint64_t)ss->security.ses->sess_private_data;Quoted 3 lines
If the above can be done, then in our PMD, we will not have a callback for
set_pkt_metadata()andDEV_TX_OFFLOAD_SEC_NEED_MDATAwill also be not set in capabilities.That's an interesting idea, but what you propose is the change in current
rte_securityAPI behaviour. So all existing apps that use this API will have to be changed.
We'd better avoid such changes unless there is really good reason for that.
So, I'd suggest to tweak your idea a bit:1) change
rte_security_set_pkt_metadata():
ifops->set_pkt_metadata!= NULL, then call it (existing behaviour) otherwise just:rte_security_dynfield(m)=sess->session_private_data; (fast-path)Quoted 7 lines
Quoted 3 lines
2) consider to make
rte_security_set_pkt_metadata()inline function. We probably can have some special flag inside structrte_security_ctx, or even store inside ctx a pointer toset_pkt_metadata()itself.After another thoughts some new flags might be better.
Then later, if we'll realize thatset_pkt_metadata()andget_useradata()are not really used by PMDs, it might be easier to deprecate these callbacks.
Quoted 8 lines
Thanks, I agree with your thoughts. I'll submit a V2 with above change, new flags and
set_pkt_metadata()andget_userdata()function pointers moved torte_security_ctxfor review so that it can be targeted for 21.11.Even with flags moving
set_pkt_metadata()andget_userdata()function pointers is still needed as we need to makerte_security_set_pkt_metadata()API inline while structrte_security_opsis not exposed to user. I think this is fine as it is inline with how fast path function pointers ofrte_ethdevandrte_cryptodevare currently placed.
My thought was we can get away with just flags only. Something like that:rte_security.h:
...
enum {
RTE_SEC_CTX_F_FAST_SET_MDATA = 0x1,
RTE_SEC_CTX_F_FAST_GET_UDATA = 0x2,
}; struct rte_security_ctx {
void *device;
/**< Crypto/ethernet device attached */
const struct rte_security_ops *ops;
/**< Pointer to security ops for the device */
uint16_t sess_cnt;
/**< Number of sessions attached to this context */
uint32_t flags;
};extern int
__rte_security_set_pkt_metadata(struct rte_security_ctx *instance,
struct rte_security_session *sess, struct rte_mbuf *m, void *params);
static inline int
rte_security_set_pkt_metadata(struct rte_security_ctx *instance,
struct rte_security_session *sess, struct rte_mbuf *m, void *params)
{
/* fast-path */
if (instance->flags & RTE_SEC_CTX_F_FAST_SET_MDATA) {
*rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data);
return 0;
/* slow path */
} else
return __rte_security_set_pkt_metadata (instance->device, sess, m, params);
}rte_security.c:
...
/* existing one, just renamed */
int
__rte_security_set_pkt_metadata(struct rte_security_ctx *instance,
struct rte_security_session *sess, struct rte_mbuf *m, void *params)
{
#ifdef RTE_DEBUG
RTE_PTR_OR_ERR_RET(sess, -EINVAL);
RTE_PTR_OR_ERR_RET(instance, -EINVAL);
RTE_PTR_OR_ERR_RET(instance->ops, -EINVAL);
#endif
RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->set_pkt_metadata, -ENOTSUP);
return instance->ops->set_pkt_metadata(instance->device,
sess, m, params);
}I think both ways are possible (flags vs actual func pointers) and both have some pluses and minuses.
I suppose the main choice here what do we think should be the future of set_pkt_metadata() and rte_security_get_userdata().
If we think that they will be useful for some future PMDs and we want to keep them, then probably storing actual func pointers inside ctx is a better approach. If not, then flags seems like a better one, as in that case we can eventually deprecate and remove these callbacks.
From what I see right now, custom callbacks seems excessive,
and rte_security_dynfield is enough.
But might be there are some future plans that would require them?
Quoted 84 lines
Quoted 84 lines
Quoted 84 lines
As a brief code snippet:
struct rte_security_ctx { void *device; /**< Crypto/ethernet device attached */ const struct rte_security_ops *ops; /**< Pointer to security ops for the device */ uint16_t sess_cnt; /**< Number of sessions attached to this context */+ int (*set_pkt_mdata)(void *, struct
rte_security_session*, structrte_mbuf*, void *);
};static inline int
rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params){ /* fast-path */ if (instance->set_pkt_mdata == NULL) { *rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data); return 0; /* slow path */ } else return instance->set_pkt_mdata(instance->device, sess, m, params); }That probably would be an ABI breakage (new fileld in
rte_security_ctx) and would require some trivial changes for all existing PMDs that useRTE_SECURITY_TX_OFLOAD_NEED_MDATA(ctx_create()), but hopefully will benefit everyone.Quoted 51 lines
Quoted 51 lines
Quoted 8 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it viambuf_dynfieldand store there whatever is needed.Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata()can predict what comes in the pkt when he is called.I also think above sequence is what Linux kernel stack or other stacks follow. Does it makes sense ?
Quoted 23 lines
Once called,
+Layer 3 and above data cannot be modified or moved around unless
+``rte_security_set_pkt_metadata()`` is called again.For inline protocol offloaded ingress traffic, the application can register a
pointer, ``userdata`` , in the security session. When the packet is received,
diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index bb38d7f58..9d8e3ddc8 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -228,6 +228,8 @@ extern "C" {/**
* Request security offload processing on the TX packet.
+ * To use Tx security offload, the user needs to fill l2_len in mbuf
+ * indicating L2 header size and where L3 header starts.
*/
#define PKT_TX_SEC_OFFLOAD (1ULL << 43)--
2.25.1
Quoted 346 lines · Konstantin
Quoted 277 lines
Quoted 89 lines
Quoted 89 lines
Adding more
rte_securityand PMD maintainers into the loop.Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 81 lines
For Tx inline processing, when RTE_SECURITY_TX_OLOAD_NEED_MDATA is
set, rte_security_set_pkt_metadata() needs to be called for pkts
to associate a Security session with a mbuf before submitting
to Ethdev Tx. This is apart from setting PKT_TX_SEC_OFFLOAD in
mbuf.ol_flags. rte_security_set_pkt_metadata() is also used to
set some opaque metadata in mbuf for PMD's use.
This patch updates documentation that rte_security_set_pkt_metadata()
should be called only with mbuf containing Layer 3 and above data.
This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify
L2 header and L3 header locations on Tx. This is inline with other
Tx offloads requirements such as L3 checksum, L4 checksum offload,
etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for
HW to be able to generate checksum. Since Inline IPSec is also
such a Tx offload, some PMD's at least need mbuf.l2_len to be
valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting
mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags
for Inline IPSec Crypto / Protocol offload processing to
work on Tx.Signed-off-by: Nithin Dabilpuram <[email protected]>
Reviewed-by: Akhil Goyal <[email protected]>
---
doc/guides/nics/features.rst | 2 ++
doc/guides/prog_guide/rte_security.rst | 6 +++++-
lib/mbuf/rte_mbuf_core.h | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index 403c2b03a..414baf14f 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``.
* **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``,
``capabilities_get``.
diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index f72bc8a78..7b68c698d 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIFor Inline Crypto and Inline protocol offload, device specific defined metadata is
updated in the mbuf using ``rte_security_set_pkt_metadata()`` if
-``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set.
+``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()``
+should be called on mbuf only with Layer 3 and above data present and
+``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr.
Who will add L2 hdr to the packet in that case?
Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?That is the semantics I was trying to define. I think below are the sequence of
operations to be done for ipsec processing,1. receive_pkt()
2. strip_l2_hdr()
3. Do policy lookup ()
4. Call rte_security_set_pkt_metadata() if pkt needs to be encrypted with a
particular SA. Now pkt only has L3 and above data.
5. Do route_lookup()
6. add_l2hdr() which might be different from stripped l2hdr.
7. Send packet out.The above sequence is what I believe the current poll mode worker thread in
ipsec-secgw is following.That's just a sample app, it doesn't mean it has to be the only possible way.
Quoted 1 line
While in event mode, step 2 and step 6 are missing.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
I think this L2 hdr manipulation is totally optional.
If yourrte_security_set_pkt_metadata()implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 1 line
then I suppose we can add a requirement that
l2_lenhas to be set properly before calling
rte_security_set_pkt_metadata().Quoted 171 lines
Quoted 171 lines
Quoted 50 lines
Quoted 31 lines
Quoted 31 lines
Quoted 21 lines
Quoted 13 lines
Quoted 7 lines
Quoted 2 lines
This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
Quoted 8 lines
Quoted 4 lines
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
This implies
rte_security_set_pkt_metadata()cannot be called when mbuf does't have ESP trailer updated or whenmbuf->pkt_len= 0Quoted 7 lines
union
ixgbe_crypto_tx_desc_md*mdata = (unionixgbe_crypto_tx_desc_md*)rte_security_dynfield(m);
mdata->enc= 1;
mdata->sa_idx=ic_session->sa_index;mdata->pad_len=ixgbe_crypto_compute_pad_len(m);Quoted 4 lines
Quoted 1 line
Then this data will be used by
tx_burst()function.So it implies that after above
rte_security_set_pkt_metadata()call, and beforetx_burst(), mbuf data / packet len cannot be modified right as if modified, thentx_burst()will be using incorrect pad len ?No,
pkt_lencan be modified.
Though ESP trailerpad_lencan't.Quoted 4 lines
This patch is also trying to add similar restriction on when
rte_security_set_pkt_metadata()should be called and what cannot be done after callingrte_security_set_pkt_metadata().No, I don't think it is really the same.
Also, IMO, inside ixgbeset_pkt_metadata()implementaion we probably shouldn't silently imply that ESP packet is already formed and trailer contains valid data.
In fact, I think thispad_lencalculation can be moved to actual TX function.Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 20 lines
Quoted 7 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 5 lines
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.But the major issues I see are
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.I suppose you can store pointer to session (or so) inside mbuf in
rte_security_dynfield, no?We can do. But having to call PMD specific function call via
rte_security_set_pkt_metadata()just for storing session pointer inrte_security_dynfieldconsumes unnecessary cycles per pkt.In fact there are two function calls: one for
rte_security_set_pkt_metadata(), second forinstance->ops->set_pkt_metadata()callback.
Which off-course way too expensive for such simple operation.
Actually same thought forrte_security_get_userdata().
Both of these functions belong to data-path and ideally have to be as fast as possible. Probably 21.11 is a right timeframe for that.Quoted 45 lines
Quoted 10 lines
Quoted 5 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.Didn't get you here, obviously we do have
rte_security_dynfieldinside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.Quoted 6 lines
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use
tx_prepare()- why doing these calculations insidetx_burst()itself is not an option?We can do things in
tx_burst()but if we are doing it there, then we want to avoid having callback forrte_security_set_pkt_metadata().Are you fine if we can update the spec that "When
DEV_TX_OFFLOAD_SEC_NEED_MDATAis not set, then, user needs to update struct rte_security_session'ssess_private_datain a inrte_security_dynfieldlike below ?<snip>
static inline void
inline_outb_mbuf_prepare(const structrte_ipsec_session*ss,struct rte_mbuf *mb[], uint16_t num) { uint32_t i, ol_flags; ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA; for (i = 0; i != num; i++) { mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD; if (ol_flags != 0) rte_security_set_pkt_metadata(ss->security.ctx, ss->security.ses, mb[i], NULL); else *rte_security_dynfield(mb[i]) = (uint64_t)ss->security.ses->sess_private_data;Quoted 3 lines
If the above can be done, then in our PMD, we will not have a callback for
set_pkt_metadata()andDEV_TX_OFFLOAD_SEC_NEED_MDATAwill also be not set in capabilities.That's an interesting idea, but what you propose is the change in current
rte_securityAPI behaviour. So all existing apps that use this API will have to be changed.
We'd better avoid such changes unless there is really good reason for that.
So, I'd suggest to tweak your idea a bit:1) change
rte_security_set_pkt_metadata():
ifops->set_pkt_metadata!= NULL, then call it (existing behaviour) otherwise just:rte_security_dynfield(m)=sess->session_private_data; (fast-path)Quoted 7 lines
Quoted 3 lines
2) consider to make
rte_security_set_pkt_metadata()inline function. We probably can have some special flag inside structrte_security_ctx, or even store inside ctx a pointer toset_pkt_metadata()itself.After another thoughts some new flags might be better.
Then later, if we'll realize thatset_pkt_metadata()andget_useradata()are not really used by PMDs, it might be easier to deprecate these callbacks.Quoted 8 lines
Thanks, I agree with your thoughts. I'll submit a V2 with above change, new flags and
set_pkt_metadata()andget_userdata()function pointers moved torte_security_ctxfor review so that it can be targeted for 21.11.Even with flags moving
set_pkt_metadata()andget_userdata()function pointers is still needed as we need to makerte_security_set_pkt_metadata()API inline while structrte_security_opsis not exposed to user. I think this is fine as it is inline with how fast path function pointers ofrte_ethdevandrte_cryptodevare currently placed.My thought was we can get away with just flags only. Something like that:
rte_security.h:...
enum { RTE_SEC_CTX_F_FAST_SET_MDATA = 0x1, RTE_SEC_CTX_F_FAST_GET_UDATA = 0x2, };struct rte_security_ctx { void *device; /**< Crypto/ethernet device attached */ const struct rte_security_ops *ops; /**< Pointer to security ops for the device */ uint16_t sess_cnt; /**< Number of sessions attached to this context */ uint32_t flags; };extern int
__rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params);static inline int
rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params){ /* fast-path */ if (instance->flags & RTE_SEC_CTX_F_FAST_SET_MDATA) { *rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data); return 0; /* slow path */ } else return __rte_security_set_pkt_metadata (instance->device, sess, m, params); }
rte_security.c:...
/* existing one, just renamed */
int
__rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params)
{#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET(sess, -EINVAL); RTE_PTR_OR_ERR_RET(instance, -EINVAL); RTE_PTR_OR_ERR_RET(instance->ops, -EINVAL); #endif RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->set_pkt_metadata, -ENOTSUP); return instance->ops->set_pkt_metadata(instance->device, sess, m, params); }
Quoted 11 lines
I think both ways are possible (flags vs actual func pointers) and both have some pluses and minuses.
I suppose the main choice here what do we think should be the future ofset_pkt_metadata()andrte_security_get_userdata().
If we think that they will be useful for some future PMDs and we want to keep them, then probably storing actual func pointers inside ctx is a better approach. If not, then flags seems like a better one, as in that case we can eventually deprecate and remove these callbacks.
From what I see right now, custom callbacks seems excessive,
andrte_security_dynfieldis enough.
But might be there are some future plans that would require them?
Above method is also fine. Moving fn pointers to rte_security_ctx can be done later if other PMD's need it.
Atleast our HW PMD's doesn't plan to use set_pkt_metada()/get_user_data() fn pointers in future if above is implemented.
Quoted 85 lines
Quoted 85 lines
Quoted 85 lines
Quoted 85 lines
As a brief code snippet:
struct rte_security_ctx { void *device; /**< Crypto/ethernet device attached */ const struct rte_security_ops *ops; /**< Pointer to security ops for the device */ uint16_t sess_cnt; /**< Number of sessions attached to this context */+ int (*set_pkt_mdata)(void *, struct
rte_security_session*, structrte_mbuf*, void *);
};static inline int
rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params){ /* fast-path */ if (instance->set_pkt_mdata == NULL) { *rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data); return 0; /* slow path */ } else return instance->set_pkt_mdata(instance->device, sess, m, params); }That probably would be an ABI breakage (new fileld in
rte_security_ctx) and would require some trivial changes for all existing PMDs that useRTE_SECURITY_TX_OFLOAD_NEED_MDATA(ctx_create()), but hopefully will benefit everyone.Quoted 51 lines
Quoted 51 lines
Quoted 8 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it viambuf_dynfieldand store there whatever is needed.Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata() can predict what comes in the pkt when he is
called.I also think above sequence is what Linux kernel stack or other stacks follow.
Does it makes sense ?Once called,
+Layer 3 and above data cannot be modified or moved around unless
+``rte_security_set_pkt_metadata()`` is called again.For inline protocol offloaded ingress traffic, the application can register a
pointer, ``userdata`` , in the security session. When the packet is received,
diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index bb38d7f58..9d8e3ddc8 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -228,6 +228,8 @@ extern "C" {/**
* Request security offload processing on the TX packet.
+ * To use Tx security offload, the user needs to fill l2_len in mbuf
+ * indicating L2 header size and where L3 header starts.
*/
#define PKT_TX_SEC_OFFLOAD (1ULL << 43)--
2.25.1
Quoted 370 lines
-----Original Message-----
From: Nithin Dabilpuram <[email protected]>
Sent: Wednesday, July 14, 2021 2:30 PM
To: Ananyev, Konstantin <[email protected]>
Cc: Akhil Goyal <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; Zhang, Roy Fan <[email protected]>; [email protected]; [email protected]; Doherty, Declan <[email protected]>; Nicolau, Radu <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH 1/2] security: enforce semantics for Tx inline processingQuoted 346 lines · Konstantin
Quoted 277 lines
Quoted 89 lines
Quoted 89 lines
Adding more
rte_securityand PMD maintainers into the loop.Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
For Tx inline processing, when RTE_SECURITY_TX_OLOAD_NEED_MDATA is
set, rte_security_set_pkt_metadata() needs to be called for pkts
to associate a Security session with a mbuf before submitting
to Ethdev Tx. This is apart from setting PKT_TX_SEC_OFFLOAD in
mbuf.ol_flags. rte_security_set_pkt_metadata() is also used to
set some opaque metadata in mbuf for PMD's use.
This patch updates documentation that rte_security_set_pkt_metadata()
should be called only with mbuf containing Layer 3 and above data.
This behaviour is consistent with existing PMD's such as ixgbe.On Tx, not all net PMD's/HW can parse packet and identify
L2 header and L3 header locations on Tx. This is inline with other
Tx offloads requirements such as L3 checksum, L4 checksum offload,
etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for
HW to be able to generate checksum. Since Inline IPSec is also
such a Tx offload, some PMD's at least need mbuf.l2_len to be
valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting
mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags
for Inline IPSec Crypto / Protocol offload processing to
work on Tx.Signed-off-by: Nithin Dabilpuram <[email protected]>
Reviewed-by: Akhil Goyal <[email protected]>
---
doc/guides/nics/features.rst | 2 ++
doc/guides/prog_guide/rte_security.rst | 6 +++++-
lib/mbuf/rte_mbuf_core.h | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index 403c2b03a..414baf14f 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``.
* **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``,
* **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``.
+* **[uses] mbuf**: ``mbuf.l2_len``.
* **[implements] rte_security_ops**: ``session_create``, ``session_update``,
``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``,
``capabilities_get``.
diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index f72bc8a78..7b68c698d 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -560,7 +560,11 @@ created by the application is attached to the security session by the APIFor Inline Crypto and Inline protocol offload, device specific defined metadata is
updated in the mbuf using ``rte_security_set_pkt_metadata()`` if
-``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set.
+``RTE_SECURITY_TX_OLOAD_NEED_MDATA`` is set. ``rte_security_set_pkt_metadata()``
+should be called on mbuf only with Layer 3 and above data present and
+``mbuf.data_off`` should be pointing to Layer 3 Header.Hmm... not sure why mbuf.data_off should point to L3 hdr.
Who will add L2 hdr to the packet in that case?
Or did you mean ``mbuf.data_off + mbuf.l2_len`` here?That is the semantics I was trying to define. I think below are the sequence of
operations to be done for ipsec processing,1. receive_pkt()
2. strip_l2_hdr()
3. Do policy lookup ()
4. Call rte_security_set_pkt_metadata() if pkt needs to be encrypted with a
particular SA. Now pkt only has L3 and above data.
5. Do route_lookup()
6. add_l2hdr() which might be different from stripped l2hdr.
7. Send packet out.The above sequence is what I believe the current poll mode worker thread in
ipsec-secgw is following.That's just a sample app, it doesn't mean it has to be the only possible way.
While in event mode, step 2 and step 6 are missing.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
I think this L2 hdr manipulation is totally optional.
If your rte_security_set_pkt_metadata() implementation really needs to know L3 hdr offset (not sure why?),Since
rte_security_set_pkt_metadata()is PMD specific function ptr call, we are currently doing some pre-processing here before submitting packet to inline IPSec viarte_eth_tx_burst(). This saves us cycles later inrte_eth_tx_burst(). If we cannot know for sure, the pkt content at the time ofrte_security_set_pkt_metadata()call, then I think having a PMD specific callback is not much of use except for saving SA priv data torte_mbuf.Quoted 1 line
then I suppose we can add a requirement that l2_len has to be set properly before calling
rte_security_set_pkt_metadata().Quoted 171 lines
Quoted 171 lines
Quoted 50 lines
Quoted 31 lines
Quoted 31 lines
Quoted 21 lines
Quoted 13 lines
Quoted 7 lines
Quoted 2 lines
This is also fine with us.
Ok, so to make sure we are on the same page, you propose:
1. before callingrte_security_set_pkt_metadata()mbuf.l2_len should be properly set.
2. afterrte_security_set_pkt_metadata()and beforerte_eth_tx_burst()packet contents at [mbuf.l2_len, mbuf.pkt_len) can't be modified?Yes.
Quoted 3 lines
Is that correct understanding?
If yes, I wonder how 2) will correlate withrte_eth_tx_prepare()concept?Quoted 7 lines
Since our PMD doesn't have a prepare function, I missed that but, since
rte_security_set_pkt_metadata()is only used for Inline Crypto/Protocol via arte_eth_dev, and bothrte_security_set_pkt_metadata()andrte_eth_tx_prepare()are callbacks from same PMD, do you see any issue ?The restriction is from user side, data is not supposed to be modified unless
rte_security_set_pkt_metadata()is called again.Quoted 8 lines
Yep, I do have a concern here.
Right now it is perfectly valid to do something like that:rte_security_set_pkt_metadata(..., mb, ...);
/* can modify contents of the packet */rte_eth_tx_prepare(..., &mb, 1);rte_eth_tx_burst(..., &mb, 1);With the new restrictions you are proposing it wouldn't be allowed any more.
You can still modify L2 header and IPSEC is only concerned about L3 and above.
Quoted 8 lines
Quoted 4 lines
I think insisting that
rte_security_set_pkt_metadata()be called after all L3 and above header modifications is no a problem. I guess existing ixgbe/txgbe PMD which are the ones only implementing the call back are already expecting the same ?AFAIK, no there are no such requirements for ixgbe or txgbe. All that ixgbe callback does - store session related data inside mbuf. It's only expectation to have ESP trailer at the proper place (after ICV):
This implies
rte_security_set_pkt_metadata()cannot be called when mbuf does't have ESP trailer updated or whenmbuf->pkt_len= 0Quoted 7 lines
union
ixgbe_crypto_tx_desc_md*mdata = (unionixgbe_crypto_tx_desc_md*)rte_security_dynfield(m);
mdata->enc= 1;
mdata->sa_idx=ic_session->sa_index;mdata->pad_len=ixgbe_crypto_compute_pad_len(m);Quoted 4 lines
Quoted 1 line
Then this data will be used by
tx_burst()function.So it implies that after above
rte_security_set_pkt_metadata()call, and beforetx_burst(), mbuf data / packet len cannot be modified right as if modified, thentx_burst()will be using incorrect pad len ?No,
pkt_lencan be modified.
Though ESP trailerpad_lencan't.Quoted 4 lines
This patch is also trying to add similar restriction on when
rte_security_set_pkt_metadata()should be called and what cannot be done after callingrte_security_set_pkt_metadata().No, I don't think it is really the same.
Also, IMO, inside ixgbeset_pkt_metadata()implementaion we probably shouldn't silently imply that ESP packet is already formed and trailer contains valid data.
In fact, I think thispad_lencalculation can be moved to actual TX function.Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 20 lines
Quoted 7 lines
If your question is can't we do the preprocessing in
rte_eth_tx_prepare()for security,Yes, that was my thought.
Quoted 4 lines
my only argument was that since there is already a hit in
rte_security_set_pkt_metadata()to PMD specific callback and
structrte_security_sessionis passed as an argument to it, it is more benefitial to do security related pre-processing there.Yes, it would be extra callback call that way.
Thoughtx_prepare()accepts burst of packets, so the overhead of function call will be spread around the whole burst, and I presume shouldn't be too high.Quoted 5 lines
Quoted 2 lines
Also
rte_eth_tx_prepare()if implemented will be called for both security and non-security pkts.Yes, but
tx_prepare()can distinguish (byol_flagsand/or other field contents) which modifications are required for the packet.But the major issues I see are
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
1.
tx_prepare()doesn't takerte_security_sessionas argument thoughol_flagshas security flag. In our case, we need to know the security session details to do things.I suppose you can store pointer to session (or so) inside mbuf in
rte_security_dynfield, no?We can do. But having to call PMD specific function call via
rte_security_set_pkt_metadata()just for storing session pointer inrte_security_dynfieldconsumes unnecessary cycles per pkt.In fact there are two function calls: one for
rte_security_set_pkt_metadata(), second forinstance->ops->set_pkt_metadata()callback.
Which off-course way too expensive for such simple operation.
Actually same thought forrte_security_get_userdata().
Both of these functions belong to data-path and ideally have to be as fast as possible. Probably 21.11 is a right timeframe for that.Quoted 45 lines
Quoted 10 lines
Quoted 5 lines
2. AFAIU
tx_prepare()is not mandatory as per spec and even by default disabled under compile time macroRTE_ETHDEV_TX_PREPARE_NOOP.
3. Even if we dotx_prepare(),rte_security_set_pkt_mdata()is mandatory to associate structrte_security_sessionto a pkt as unlikeol_flags, there is no direct space to do the same.Didn't get you here, obviously we do have
rte_security_dynfieldinside mbuf, specially for that - to store secuiryt related data inside the mbuf.
Yes your PMD has to request it at initialization time, but I suppose it is not a big deal.Quoted 6 lines
Quoted 2 lines
So I think instead of enforcing yet another callback
tx_prepare()for inline security processing, it can be done via security specificset_pkt_metadata().But what you proposing introduces new limitations and might existing functionality. BTW, if you don't like to use
tx_prepare()- why doing these calculations insidetx_burst()itself is not an option?We can do things in
tx_burst()but if we are doing it there, then we want to avoid having callback forrte_security_set_pkt_metadata().Are you fine if we can update the spec that "When
DEV_TX_OFFLOAD_SEC_NEED_MDATAis not set, then, user needs to update struct rte_security_session'ssess_private_datain a inrte_security_dynfieldlike below ?<snip>
static inline void
inline_outb_mbuf_prepare(const structrte_ipsec_session*ss,struct rte_mbuf *mb[], uint16_t num) { uint32_t i, ol_flags; ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA; for (i = 0; i != num; i++) { mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD; if (ol_flags != 0) rte_security_set_pkt_metadata(ss->security.ctx, ss->security.ses, mb[i], NULL); else *rte_security_dynfield(mb[i]) = (uint64_t)ss->security.ses->sess_private_data;Quoted 3 lines
If the above can be done, then in our PMD, we will not have a callback for
set_pkt_metadata()andDEV_TX_OFFLOAD_SEC_NEED_MDATAwill also be not set in capabilities.That's an interesting idea, but what you propose is the change in current
rte_securityAPI behaviour. So all existing apps that use this API will have to be changed.
We'd better avoid such changes unless there is really good reason for that.
So, I'd suggest to tweak your idea a bit:1) change
rte_security_set_pkt_metadata():
ifops->set_pkt_metadata!= NULL, then call it (existing behaviour) otherwise just:rte_security_dynfield(m)=sess->session_private_data; (fast-path)Quoted 7 lines
Quoted 3 lines
2) consider to make
rte_security_set_pkt_metadata()inline function. We probably can have some special flag inside structrte_security_ctx, or even store inside ctx a pointer toset_pkt_metadata()itself.After another thoughts some new flags might be better.
Then later, if we'll realize thatset_pkt_metadata()andget_useradata()are not really used by PMDs, it might be easier to deprecate these callbacks.Quoted 8 lines
Thanks, I agree with your thoughts. I'll submit a V2 with above change, new flags and
set_pkt_metadata()andget_userdata()function pointers moved torte_security_ctxfor review so that it can be targeted for 21.11.Even with flags moving
set_pkt_metadata()andget_userdata()function pointers is still needed as we need to makerte_security_set_pkt_metadata()API inline while structrte_security_opsis not exposed to user. I think this is fine as it is inline with how fast path function pointers ofrte_ethdevandrte_cryptodevare currently placed.My thought was we can get away with just flags only. Something like that:
rte_security.h:...
enum { RTE_SEC_CTX_F_FAST_SET_MDATA = 0x1, RTE_SEC_CTX_F_FAST_GET_UDATA = 0x2, };struct rte_security_ctx { void *device; /**< Crypto/ethernet device attached */ const struct rte_security_ops *ops; /**< Pointer to security ops for the device */ uint16_t sess_cnt; /**< Number of sessions attached to this context */ uint32_t flags; };extern int
__rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params);static inline int
rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params){ /* fast-path */ if (instance->flags & RTE_SEC_CTX_F_FAST_SET_MDATA) { *rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data); return 0; /* slow path */ } else return __rte_security_set_pkt_metadata (instance->device, sess, m, params); }
rte_security.c:...
/* existing one, just renamed */
int
__rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params)
{#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET(sess, -EINVAL); RTE_PTR_OR_ERR_RET(instance, -EINVAL); RTE_PTR_OR_ERR_RET(instance->ops, -EINVAL); #endif RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->set_pkt_metadata, -ENOTSUP); return instance->ops->set_pkt_metadata(instance->device, sess, m, params); }Quoted 11 lines
I think both ways are possible (flags vs actual func pointers) and both have some pluses and minuses.
I suppose the main choice here what do we think should be the future ofset_pkt_metadata()andrte_security_get_userdata().
If we think that they will be useful for some future PMDs and we want to keep them, then probably storing actual func pointers inside ctx is a better approach. If not, then flags seems like a better one, as in that case we can eventually deprecate and remove these callbacks.
From what I see right now, custom callbacks seems excessive,
andrte_security_dynfieldis enough.
But might be there are some future plans that would require them?
Quoted 2 lines
Above method is also fine. Moving fn pointers to
rte_security_ctxcan be done later if other PMD's need it.
Yes, agree.
Quoted 89 lines
Atleast our HW PMD's doesn't plan to use set_pkt_metada()/get_user_data() fn pointers in future if above is implemented.
Quoted 85 lines
Quoted 85 lines
Quoted 85 lines
Quoted 85 lines
As a brief code snippet:
struct rte_security_ctx { void *device; /**< Crypto/ethernet device attached */ const struct rte_security_ops *ops; /**< Pointer to security ops for the device */ uint16_t sess_cnt; /**< Number of sessions attached to this context */+ int (*set_pkt_mdata)(void *, struct
rte_security_session*, structrte_mbuf*, void *);
};static inline int
rte_security_set_pkt_metadata(structrte_security_ctx*instance,
structrte_security_session*sess, structrte_mbuf*m, void *params){ /* fast-path */ if (instance->set_pkt_mdata == NULL) { *rte_security_dynfield(m) = (rte_security_dynfield_t)(session->sess_priv_data); return 0; /* slow path */ } else return instance->set_pkt_mdata(instance->device, sess, m, params); }That probably would be an ABI breakage (new fileld in
rte_security_ctx) and would require some trivial changes for all existing PMDs that useRTE_SECURITY_TX_OFLOAD_NEED_MDATA(ctx_create()), but hopefully will benefit everyone.Quoted 51 lines
Quoted 51 lines
Quoted 8 lines
I'm fine to
introduce a burst call for the same(I was thinking to propose it in future) to compensate for the overhead.If
rte_security_set_pkt_metadata()was not a PMD specific function ptr call andrte_mbufhad space for structrte_security_sessionpointer,But it does, see above.
In fact it even more flexible - because it is driver specific, you are not limited to one 64-bit field. If your PMD requires more data to be associated with mbuf
- you can request it viambuf_dynfieldand store there whatever is needed.Quoted 37 lines
then then I guess it would have been better to do the way you proposed.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
This patch is trying to enforce semantics as above so that
rte_security_set_pkt_metadata() can predict what comes in the pkt when he is
called.I also think above sequence is what Linux kernel stack or other stacks follow.
Does it makes sense ?Once called,
+Layer 3 and above data cannot be modified or moved around unless
+``rte_security_set_pkt_metadata()`` is called again.For inline protocol offloaded ingress traffic, the application can register a
pointer, ``userdata`` , in the security session. When the packet is received,
diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index bb38d7f58..9d8e3ddc8 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -228,6 +228,8 @@ extern "C" {/**
* Request security offload processing on the TX packet.
+ * To use Tx security offload, the user needs to fill l2_len in mbuf
+ * indicating L2 header size and where L3 header starts.
*/
#define PKT_TX_SEC_OFFLOAD (1ULL << 43)--
2.25.1
v2 cover security: Improve inline fast path routines
In reply to Akhil GoyalImprovements to Inline inbound and outbound processing fast path routines rte_security_set_pkt_metadata() and rte_security_get_userdata() to make them inline functions and also provide mechanism for drivers to support fast userdata and metadata access instead of driver specific per-pkt function callbacks.
This series updates requirements of mbuf fields to be updated for outbound inline processing.
Nithin Dabilpuram (3):
security: enforce semantics for Tx inline processing
security: add option for faster udata or mdata access examples/ipsec-secgw: update L2 length for Tx
v2:
- Remove restrictions on rte_security_set_pkt_metadata() w.r.t pkt content
- Add inline functions for rte_security_set_pkt_metadata() and rte_security_get_userdata() and also faster mdata, udata access via patch 2/3
doc/guides/nics/features.rst | 2 ++ examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 42 ++++++++++++++++++++----------- lib/mbuf/rte_mbuf_core.h | 2 ++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 49 ++++++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 7 files changed, 85 insertions(+), 22 deletions(-)
Signature · 1 line
2.8.4
PATCH v2 1/3 security: enforce semantics for Tx inline processing
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.
--- doc/guides/nics/features.rst | 2 ++ lib/mbuf/rte_mbuf_core.h | 2 ++ 2 files changed, 4 insertions(+)
doc/guides/nics/features.rst +2 -0
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.
lib/mbuf/rte_mbuf_core.h +2 -0
@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
Signature · 1 line
2.8.4
PATCH v2 2/3 security: add option for faster udata or mdata access
In reply to Nithin DabilpuramCurrently rte_security_set_pkt_metadata() and rte_security_get_userdata() methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.
For drivers that do not have much to do in the callbacks but just to update metadata in rte_security dynamic field and get userdata from rte_security dynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.
--- lib/security/rte_security.c | 8 ++++---- lib/security/rte_security.h | 49 +++++++++++++++++++++++++++++++++++++++++---- lib/security/version.map | 2 ++ 3 files changed, 51 insertions(+), 8 deletions(-)
lib/security/rte_security.c +4 -4
@@ -122,9 +122,9 @@ rte_security_session_destroy(struct rte_security_ctx *instance, }int -rte_security_set_pkt_metadata (struct rte_security_ctx *instance, -struct rte_security_session *sess, -struct rte_mbuf *m,void *params) +__rte_security_set_pkt_metadata (struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params) {#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET (sess, -EINVAL );
@@ -137,7 +137,7 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, }void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +__rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) {void *userdata =NULL ;
lib/security/rte_security.h +45 -4
77 lines not on this page · raw message
lib/security/version.map +2 -0
@@ -20,4 +20,6 @@ EXPERIMENTAL { rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update; + __rte_security_set_pkt_metadata; + __rte_security_get_userdata; };
Signature · 1 line
2.8.4
PATCH v2 3/3 examples/ipsec-secgw: update L2 length for Tx
In reply to Nithin DabilpuramUpdate mbuf.l2_len with L2 header size for outbound inline processing.
This patch also fixes a bug in arg parsing.
--- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 42 ++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +2 -0
@@ -1495,6 +1495,8 @@ parse_portmask(const char *portmask)char *end =NULL ;unsigned long pm; + errno =0 ; +/* parse hexadecimal string */ pm =strtoul (portmask, &end,16 );if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))
examples/ipsec-secgw/ipsec_worker.c +28 -14
105 lines not on this page · raw message
Signature · 1 line
2.8.4
v3 cover security: Improve inline fast path routines
In reply to Akhil GoyalImprovements to Inline inbound and outbound processing fast path routines rte_security_set_pkt_metadata() and rte_security_get_userdata() to make them inline functions and also provide mechanism for drivers to support fast userdata and metadata access instead of driver specific per-pkt function callbacks.
This series updates requirements of mbuf fields to be updated for outbound inline processing.
Nithin Dabilpuram (3):
security: enforce semantics for Tx inline processing
security: add option for faster udata or mdata access examples/ipsec-secgw: update event mode inline path
v3:
- Rebased and fixed compilation issue with rte_security_get_userdata() on 32-bit platform
- Updated l2_len on patch 3/3 only for outbound.
v2:
- Remove restrictions on rte_security_set_pkt_metadata() w.r.t pkt content
- Add inline functions for rte_security_set_pkt_metadata() and rte_security_get_userdata() and also faster mdata, udata access via patch 2/3
doc/guides/nics/features.rst | 2 ++ examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 ++++++++++++++++++++----------- lib/mbuf/rte_mbuf_core.h | 2 ++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 49 ++++++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 7 files changed, 84 insertions(+), 22 deletions(-)
Signature · 1 line
2.8.4
PATCH v3 1/3 security: enforce semantics for Tx inline processing
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.
--- doc/guides/nics/features.rst | 2 ++ lib/mbuf/rte_mbuf_core.h | 2 ++ 2 files changed, 4 insertions(+)
doc/guides/nics/features.rst +2 -0
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.
lib/mbuf/rte_mbuf_core.h +2 -0
@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
Signature · 1 line
2.8.4
PATCH v3 2/3 security: add option for faster udata or mdata access
In reply to Nithin DabilpuramCurrently rte_security_set_pkt_metadata() and rte_security_get_userdata() methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.
For drivers that do not have much to do in the callbacks but just to update metadata in rte_security dynamic field and get userdata from rte_security dynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.
--- lib/security/rte_security.c | 8 ++++---- lib/security/rte_security.h | 49 +++++++++++++++++++++++++++++++++++++++++---- lib/security/version.map | 2 ++ 3 files changed, 51 insertions(+), 8 deletions(-)
lib/security/rte_security.c +4 -4
@@ -122,9 +122,9 @@ rte_security_session_destroy(struct rte_security_ctx *instance, }int -rte_security_set_pkt_metadata (struct rte_security_ctx *instance, -struct rte_security_session *sess, -struct rte_mbuf *m,void *params) +__rte_security_set_pkt_metadata (struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params) {#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET (sess, -EINVAL );
@@ -137,7 +137,7 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, }void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +__rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) {void *userdata =NULL ;
lib/security/rte_security.h +45 -4
77 lines not on this page · raw message
lib/security/version.map +2 -0
@@ -20,4 +20,6 @@ EXPERIMENTAL { rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update; + __rte_security_set_pkt_metadata; + __rte_security_get_userdata; };
Signature · 1 line
2.8.4
PATCH v3 3/3 examples/ipsec-secgw: update event mode inline path
In reply to Nithin DabilpuramUpdate mbuf.l2_len with L2 header size for outbound inline processing.
This patch also fixes a bug in arg parsing.
--- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +2 -0
@@ -1495,6 +1495,8 @@ parse_portmask(const char *portmask)char *end =NULL ;unsigned long pm; + errno =0 ; +/* parse hexadecimal string */ pm =strtoul (portmask, &end,16 );if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))
examples/ipsec-secgw/ipsec_worker.c +27 -14
104 lines not on this page · raw message
Signature · 1 line
2.8.4
v4 cover security: Improve inline fast path routines
In reply to Akhil GoyalImprovements to Inline inbound and outbound processing fast path routines rte_security_set_pkt_metadata() and rte_security_get_userdata() to make them inline functions and also provide mechanism for drivers to support fast userdata and metadata access instead of driver specific per-pkt function callbacks.
This series updates requirements of mbuf fields to be updated for outbound inline processing.
Nithin Dabilpuram (4):
security: enforce semantics for Tx inline processing
security: add option for faster udata or mdata access examples/ipsec-secgw: update event mode inline path
doc: remove deprecation notice for security fast path change
v4:
- Removed entry from deprecation notice.
- Fixed issue with rte_security_set_pkt_metadata() to pass instance instead of device ptr to non-inline C function.
v3:
- Rebased and fixed compilation issue with rte_security_get_userdata() on 32-bit platform
- Updated l2_len on patch 3/3 only for outbound.
v2:
- Remove restrictions on rte_security_set_pkt_metadata() w.r.t pkt content
- Add inline functions for rte_security_set_pkt_metadata() and rte_security_get_userdata() and also faster mdata, udata access via patch 2/3
doc/guides/nics/features.rst | 2 ++ doc/guides/rel_notes/deprecation.rst | 4 --- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 +++++++++++++++++++----------- lib/mbuf/rte_mbuf_core.h | 2 ++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 48 +++++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 8 files changed, 83 insertions(+), 26 deletions(-)
Signature · 1 line
2.8.4
PATCH v4 1/4 security: enforce semantics for Tx inline processing
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.
--- doc/guides/nics/features.rst | 2 ++ lib/mbuf/rte_mbuf_core.h | 2 ++ 2 files changed, 4 insertions(+)
doc/guides/nics/features.rst +2 -0
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.
lib/mbuf/rte_mbuf_core.h +2 -0
@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
Signature · 1 line
2.8.4
Quoted 8 lines
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Quoted 6 lines
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>
PATCH v4 2/4 security: add option for faster udata or mdata access
In reply to Nithin DabilpuramCurrently rte_security_set_pkt_metadata() and rte_security_get_userdata() methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.
For drivers that do not have much to do in the callbacks but just to update metadata in rte_security dynamic field and get userdata from rte_security dynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.
--- lib/security/rte_security.c | 8 ++++---- lib/security/rte_security.h | 48 +++++++++++++++++++++++++++++++++++++++++---- lib/security/version.map | 2 ++ 3 files changed, 50 insertions(+), 8 deletions(-)
lib/security/rte_security.c +4 -4
@@ -122,9 +122,9 @@ rte_security_session_destroy(struct rte_security_ctx *instance, }int -rte_security_set_pkt_metadata (struct rte_security_ctx *instance, -struct rte_security_session *sess, -struct rte_mbuf *m,void *params) +__rte_security_set_pkt_metadata (struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params) {#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET (sess, -EINVAL );
@@ -137,7 +137,7 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, }void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +__rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) {void *userdata =NULL ;
lib/security/rte_security.h +44 -4
76 lines not on this page · raw message
lib/security/version.map +2 -0
@@ -20,4 +20,6 @@ EXPERIMENTAL { rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update; + __rte_security_set_pkt_metadata; + __rte_security_get_userdata; };
Signature · 1 line
2.8.4
Re: [dpdk-dev] [PATCH v4 2/4] security: add option for faster udata or mdata access
Quoted 166 lines
-----Original Message-----
From: Nithin Dabilpuram <[email protected]>
Sent: Thursday, August 12, 2021 6:03 PM
To: [email protected]
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Akhil Goyal <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nithin Kumar Dabilpuram <[email protected]>
Subject: [PATCH v4 2/4] security: add option for faster udata or mdata accessCurrently
rte_security_set_pkt_metadata()andrte_security_get_userdata()methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.For drivers that do not have much to do in the callbacks but just to update metadata in
rte_securitydynamic field and get userdata fromrte_securitydynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.Signed-off-by Nithin Dabilpuram <[email protected]>--- lib/security/rte_security.c | 8 ++++---- lib/security/rte_security.h | 48 +++++++++++++++++++++++++++++++++++++++++---- lib/security/version.map | 2 ++ 3 files changed, 50 insertions(+), 8 deletions(-)lib/security/rte_security.c +3
-3@@ -122,9 +122,9 @@ rte_security_session_destroy(struct rte_security_ctx *instance, }int -rte_security_set_pkt_metadata (struct rte_security_ctx *instance, -struct rte_security_session *sess, -struct rte_mbuf *m,void *params) +__rte_security_set_pkt_metadata (struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params) {#ifdef RTE_DEBUG lib/security/rte_security.c +1
-1RTE_PTR_OR_ERR_RET (sess, -EINVAL );@@ -137,7 +137,7 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, }void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +__rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) {void *userdata =NULL ;lib/security/rte_security.h +10
-0@@ -71,8 +71,18 @@ struct rte_security_ctx {/**< Pointer to security ops for the device */ uint16_t sess_cnt;/**< Number of sessions attached to this context */ +uint32_t flags; +/**< Flags for security context */ }; +#define RTE_SEC_CTX_F_FAST_SET_MDATA 0x00000001 +/**< Driver uses fast metadata update without using driver specific callback */ + +#define RTE_SEC_CTX_F_FAST_GET_UDATA 0x00000002 +/**< Driver provides udata using fast method without using driver specific +* callback. +*/ +/** * IPSEC tunnel parameters *
lib/security/rte_security.h +6
-0@@ -493,6 +503,12 @@ static inline boolrte_security_dynfield_is_registered (void ) return rte_security_dynfield_offset >= 0; } +/** Function to call PMD specific function pointer set_pkt_metadata() */ +__rte_experimental +extern int __rte_security_set_pkt_metadata(struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params); +/** * Updates the buffer with device-specific defined metadata *
lib/security/rte_security.h +18
-2@@ -506,10 +522,26 @@ static inline boolrte_security_dynfield_is_registered(void) * - On success, zero. * - On failure, a negative value. */ -int +static inline int rte_security_set_pkt_metadata (struct rte_security_ctx *instance,struct rte_security_session *sess, -struct rte_mbuf *mb,void *params); +struct rte_mbuf *mb,void *params) +{ +/* Fast Path */ +if (instance->flags &RTE_SEC_CTX_F_FAST_SET_MDATA ) { + *rte_security_dynfield (mb) = + (rte_security_dynfield_t)(sess->sess_private_data); +return 0 ; + } + +/* Jump to PMD specific function pointer */ +return __rte_security_set_pkt_metadata (instance, sess, mb, params); +} + +/** Function to call PMD specific function pointer get_userdata() */ +__rte_experimental +extern void *__rte_security_get_userdata(struct rte_security_ctx *instance, +uint64_t md);/**
* Get userdata associated with the security session. Device specific
metadatalib/security/rte_security.h +10
-2@@ -529,8 +561,16 @@ rte_security_set_pkt_metadata(structrte_security_ctx *instance, * - On failure, NULL */ __rte_experimental -void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md); +static inline void * +rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +{ +/* Fast Path */ +if (instance->flags &RTE_SEC_CTX_F_FAST_GET_UDATA ) +return (void *)(uintptr_t )md; + +/* Jump to PMD specific function pointer */ +return __rte_security_get_userdata (instance, md); +}/** * Attach a session to a symmetric crypto operation
lib/security/version.map +2
-1@@ -20,4 +20,6 @@ EXPERIMENTAL { rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update; + __rte_security_set_pkt_metadata; + __rte_security_get_userdata; }; --2.8.4
Re: [dpdk-dev] [PATCH v4 2/4] security: add option for faster udata or mdata access
In reply to Nithin DabilpuramQuoted 11 lines
Currently
rte_security_set_pkt_metadata()andrte_security_get_userdata()methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.For drivers that do not have much to do in the callbacks but just to update metadata in
rte_securitydynamic field and get userdata fromrte_securitydynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.
Quoted 2 lines
Signed-off-by Nithin Dabilpuram <[email protected]>---
PATCH v4 3/4 examples/ipsec-secgw: update event mode inline path
In reply to Nithin DabilpuramUpdate mbuf.l2_len with L2 header size for outbound inline processing.
This patch also fixes a bug in arg parsing.
--- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +2 -0
@@ -1495,6 +1495,8 @@ parse_portmask(const char *portmask)char *end =NULL ;unsigned long pm; + errno =0 ; +/* parse hexadecimal string */ pm =strtoul (portmask, &end,16 );if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))
examples/ipsec-secgw/ipsec_worker.c +27 -14
104 lines not on this page · raw message
Signature · 1 line
2.8.4
Re: [dpdk-dev] [PATCH v4 3/4] examples/ipsec-secgw: update event mode inline path
Quoted 7 lines
Update mbuf.l2_len with L2 header size for outbound inline processing.
This patch also fixes a bug in arg parsing.
Signed-off-by Nithin Dabilpuram <[email protected]>---
PATCH v4 4/4 doc: remove deprecation notice for security fast path change
In reply to Nithin DabilpuramRemove deprecation notice for security fast path change.
--- doc/guides/rel_notes/deprecation.rst | 4 ---- 1 file changed, 4 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -4
@@ -279,10 +279,6 @@ Deprecation Notices content. On Linux and FreeBSD, supported prior to DPDK 20.11, original structure will be kept until DPDK 21.11. -* security: The functions ``rte_security_set_pkt_metadata`` and - ``rte_security_get_userdata`` will be made inline functions and additional - flags will be added in structure ``rte_security_ctx`` in DPDK 21.11. - * cryptodev: The structure ``rte_crypto_op`` would be updated to reduce reserved bytes to 2 (from 3), and use 1 byte to indicate warnings and other information from the crypto/security operation. This field will be used to
Signature · 1 line
2.8.4
Re: [dpdk-dev] [PATCH v4 4/4] doc: remove deprecation notice for security fast path change
Quoted 13 lines
Remove deprecation notice for security fast path change.
Signed-off-by Nithin Dabilpuram <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 4 ---- 1 file changed, 4 deletions(-)doc/guides/rel_notes/deprecation.rst +0
-0
doc/guides/rel_notes/deprecation.rst Deprecation Notices · line 285
Quoted 7 lines
doc/guides/rel_notes/deprecation.rst +0
-4@@ -279,10 +279,6 @@ Deprecation Notices content. On Linux and FreeBSD, supported prior to DPDK 20.11, original structure will be kept until DPDK 21.11. -* security: The functions ``rte_security_set_pkt_metadata`` and - ``rte_security_get_userdata`` will be made inline functions and additional - flags will be added in structure ``rte_security_ctx`` in DPDK 21.11. -
Corresponding update in release notes is also needed when a deprecation notice is removed. You can update in the ABI/API changes section of the release notes.
Also squash this patch in the 2/4 patch. Doc changes should be part of the patch.
Regards
v5 cover security: Improve inline fast path routines
In reply to Akhil GoyalImprovements to Inline inbound and outbound processing fast path routines rte_security_set_pkt_metadata() and rte_security_get_userdata() to make them inline functions and also provide mechanism for drivers to support fast userdata and metadata access instead of driver specific per-pkt function callbacks.
This series updates requirements of mbuf fields to be updated for outbound inline processing.
Nithin Dabilpuram (3):
security: enforce semantics for Tx inline processing
security: add option for faster udata or mdata access examples/ipsec-secgw: update event mode inline path
v5:
- Squash 4/4 patch to 2/4 and update release notes
v4:
- Removed entry from deprecation notice.
- Fixed issue with rte_security_set_pkt_metadata() to pass instance instead of device ptr to non-inline C function.
v3:
- Rebased and fixed compilation issue with rte_security_get_userdata() on 32-bit platform
- Updated l2_len on patch 3/3 only for outbound.
v2:
- Remove restrictions on rte_security_set_pkt_metadata() w.r.t pkt content
- Add inline functions for rte_security_set_pkt_metadata() and rte_security_get_userdata() and also faster mdata, udata access via patch 2/3
doc/guides/nics/features.rst | 2 ++ doc/guides/rel_notes/deprecation.rst | 4 --- doc/guides/rel_notes/release_21_08.rst | 6 +++++ examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 +++++++++++++++++++---------- lib/mbuf/rte_mbuf_core.h | 2 ++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 48 +++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 9 files changed, 89 insertions(+), 26 deletions(-)
Signature · 1 line
2.8.4
PATCH v5 1/3 security: enforce semantics for Tx inline processing
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.
--- doc/guides/nics/features.rst | 2 ++ lib/mbuf/rte_mbuf_core.h | 2 ++ 2 files changed, 4 insertions(+)
doc/guides/nics/features.rst +2 -0
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.
lib/mbuf/rte_mbuf_core.h +2 -0
@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
Signature · 1 line
2.8.4
Quoted 48 lines
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Acked-by Akhil Goyal <[email protected]>--- doc/guides/nics/features.rst | 2 ++ lib/mbuf/rte_mbuf_core.h | 2 ++ 2 files changed, 4 insertions(+)doc/guides/nics/features.rst +2
-0@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.lib/mbuf/rte_mbuf_core.h +0
-0
lib/mbuf/rte_mbuf_core.h extern "C" {
Quoted 9 lines
lib/mbuf/rte_mbuf_core.h +2
-1@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43) --
Quoted 1 line
2.8.4
PATCH v5 2/3 security: add option for faster udata or mdata access
In reply to Nithin DabilpuramCurrently rte_security_set_pkt_metadata() and rte_security_get_userdata() methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.
For drivers that do not have much to do in the callbacks but just to update metadata in rte_security dynamic field and get userdata from rte_security dynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.
--- doc/guides/rel_notes/deprecation.rst | 4 --- doc/guides/rel_notes/release_21_08.rst | 6 +++++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 48 +++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 5 files changed, 56 insertions(+), 12 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -4
@@ -276,10 +276,6 @@ Deprecation Notices content. On Linux and FreeBSD, supported prior to DPDK 20.11, original structure will be kept until DPDK 21.11. -* security: The functions ``rte_security_set_pkt_metadata`` and - ``rte_security_get_userdata`` will be made inline functions and additional - flags will be added in structure ``rte_security_ctx`` in DPDK 21.11. - * cryptodev: The structure ``rte_crypto_op`` would be updated to reduce reserved bytes to 2 (from 3), and use 1 byte to indicate warnings and other information from the crypto/security operation. This field will be used to
doc/guides/rel_notes/release_21_08.rst +6 -0
@@ -223,6 +223,12 @@ ABI Changes * No ABI change that would break compatibility with 20.11. +* security: ``rte_security_set_pkt_metadata`` and ``rte_security_get_userdata`` + routines used by Inline outbound and Inline inbound security processing are + made inline and enhanced to do simple 64-bit set/get for PMD's that donot + have much processing in PMD specific callbacks but just 64-bit set/get. + This avoids a per-pkt function pointer jump overhead for such PMD's. + Known Issues ------------
lib/security/rte_security.c +4 -4
@@ -122,9 +122,9 @@ rte_security_session_destroy(struct rte_security_ctx *instance, }int -rte_security_set_pkt_metadata (struct rte_security_ctx *instance, -struct rte_security_session *sess, -struct rte_mbuf *m,void *params) +__rte_security_set_pkt_metadata (struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params) {#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET (sess, -EINVAL );
@@ -137,7 +137,7 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, }void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +__rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) {void *userdata =NULL ;
lib/security/rte_security.h +44 -4
76 lines not on this page · raw message
lib/security/version.map +2 -0
@@ -20,4 +20,6 @@ EXPERIMENTAL { rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update; + __rte_security_set_pkt_metadata; + __rte_security_get_userdata; };
Signature · 1 line
2.8.4
Re: [dpdk-dev] [PATCH v5 2/3] security: add option for faster udata or mdata access
Quoted 86 lines
Currently
rte_security_set_pkt_metadata()andrte_security_get_userdata()methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.For drivers that do not have much to do in the callbacks but just to update metadata in
rte_securitydynamic field and get userdata fromrte_securitydynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.Signed-off-by Nithin Dabilpuram <[email protected]>Acked-by Akhil Goyal <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 4 --- doc/guides/rel_notes/release_21_08.rst | 6 +++++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 48 +++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 5 files changed, 56 insertions(+), 12 deletions(-)doc/guides/rel_notes/deprecation.rst +0
-4@@ -276,10 +276,6 @@ Deprecation Notices content. On Linux and FreeBSD, supported prior to DPDK 20.11, original structure will be kept until DPDK 21.11. -* security: The functions ``rte_security_set_pkt_metadata`` and - ``rte_security_get_userdata`` will be made inline functions and additional - flags will be added in structure ``rte_security_ctx`` in DPDK 21.11. - * cryptodev: The structure ``rte_crypto_op`` would be updated to reduce reserved bytes to 2 (from 3), and use 1 byte to indicate warnings and other information from the crypto/security operation. This field will be used todoc/guides/rel_notes/release_21_08.rst +6
-0@@ -223,6 +223,12 @@ ABI Changes * No ABI change that would break compatibility with 20.11. +* security: ``rte_security_set_pkt_metadata`` and ``rte_security_get_userdata`` + routines used by Inline outbound and Inline inbound security processing are + made inline and enhanced to do simple 64-bit set/get for PMD's that donot + have much processing in PMD specific callbacks but just 64-bit set/get. + This avoids a per-pkt function pointer jump overhead for such PMD's. + Known Issues ------------lib/security/rte_security.c +4
-4@@ -122,9 +122,9 @@ rte_security_session_destroy(struct rte_security_ctx *instance, }int -rte_security_set_pkt_metadata (struct rte_security_ctx *instance, -struct rte_security_session *sess, -struct rte_mbuf *m,void *params) +__rte_security_set_pkt_metadata (struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params) {#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET (sess, -EINVAL );@@ -137,7 +137,7 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, }void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +__rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) {void *userdata =NULL ;lib/security/rte_security.h +0
-0
lib/security/rte_security.h struct rte_security_ctx { · line 79
Quoted 9 lines
lib/security/rte_security.h +4
-0@@ -71,8 +71,18 @@ struct rte_security_ctx {/**< Pointer to security ops for the device */ uint16_t sess_cnt;/**< Number of sessions attached to this context */ +uint32_t flags; +/**< Flags for security context */ }; +#define RTE_SEC_CTX_F_FAST_SET_MDATA 0x00000001 +/**< Driver uses fast metadata update without using driver specific callback */
Probably worth to mention somewhere that it is driver responsibility to call rte_security_dynfield_register() to expose that flag.
Quoted 82 lines
lib/security/rte_security.h +40
-4+ +#define RTE_SEC_CTX_F_FAST_GET_UDATA 0x00000002 +/**< Driver provides udata using fast method without using driver specific +* callback. +*/ +/** * IPSEC tunnel parameters * @@ -494,6 +504,12 @@ static inline bool rte_security_dynfield_is_registered(void)return rte_security_dynfield_offset >=0 ; } +/** Function to call PMD specific function pointer set_pkt_metadata() */ +__rte_experimental +extern int __rte_security_set_pkt_metadata(struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params); +/** * Updates the buffer with device-specific defined metadata * @@ -507,10 +523,26 @@ static inline bool rte_security_dynfield_is_registered(void)* - On success, zero. * - On failure, a negative value. */ -int +static inline int rte_security_set_pkt_metadata (struct rte_security_ctx *instance,struct rte_security_session *sess, -struct rte_mbuf *mb,void *params); +struct rte_mbuf *mb,void *params) +{ +/* Fast Path */ +if (instance->flags &RTE_SEC_CTX_F_FAST_SET_MDATA ) { + *rte_security_dynfield (mb) = + (rte_security_dynfield_t)(sess->sess_private_data); +return 0 ; + } + +/* Jump to PMD specific function pointer */ +return __rte_security_set_pkt_metadata (instance, sess, mb, params); +} + +/** Function to call PMD specific function pointer get_userdata() */ +__rte_experimental +extern void *__rte_security_get_userdata(struct rte_security_ctx *instance, +uint64_t md);/** * Get userdata associated with the security session. Device specific metadata @@ -530,8 +562,16 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance,* - On failure, NULL */ __rte_experimental -void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md); +static inline void * +rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +{ +/* Fast Path */ +if (instance->flags &RTE_SEC_CTX_F_FAST_GET_UDATA ) +return (void *)(uintptr_t )md; + +/* Jump to PMD specific function pointer */ +return __rte_security_get_userdata (instance, md); +}/** * Attach a session to a symmetric crypto operation lib/security/version.map +2
-1@@ -20,4 +20,6 @@ EXPERIMENTAL { rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update; + __rte_security_set_pkt_metadata; + __rte_security_get_userdata; }; --
Quoted 1 line
2.8.4
PATCH v5 3/3 examples/ipsec-secgw: update event mode inline path
In reply to Nithin DabilpuramUpdate mbuf.l2_len with L2 header size for outbound inline processing.
This patch also fixes a bug in arg parsing.
--- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +2 -0
@@ -1495,6 +1495,8 @@ parse_portmask(const char *portmask)char *end =NULL ;unsigned long pm; + errno =0 ; +/* parse hexadecimal string */ pm =strtoul (portmask, &end,16 );if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))
examples/ipsec-secgw/ipsec_worker.c +27 -14
104 lines not on this page · raw message
Signature · 1 line
2.8.4
Re: [dpdk-dev] [PATCH v5 3/3] examples/ipsec-secgw: update event mode inline path
Quoted 133 lines
Update mbuf.l2_len with L2 header size for outbound inline processing.
This patch also fixes a bug in arg parsing.
Signed-off-by Nithin Dabilpuram <[email protected]>Acked-by Akhil Goyal <[email protected]>--- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-)examples/ipsec-secgw/ipsec-secgw.c +2
-0@@ -1495,6 +1495,8 @@ parse_portmask(const char *portmask)char *end =NULL ;unsigned long pm; + errno =0 ; +/* parse hexadecimal string */ pm =strtoul (portmask, &end,16 );if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))examples/ipsec-secgw/ipsec_worker.c +24
-14@@ -12,6 +12,11 @@#include "ipsec-secgw.h" #include "ipsec_worker.h" +struct port_drv_mode_data { +struct rte_security_session *sess; +struct rte_security_ctx *ctx; +}; +static inline enum pkt_type process_ipsec_get_pkt_type (struct rte_mbuf *pkt,uint8_t **nlp) {@@ -60,7 +65,8 @@ ipsec_event_pre_forward(struct rte_mbuf *m, unsigned int port_id)static inline void prepare_out_sessions_tbl (struct sa_ctx *sa_out, -struct rte_security_session **sess_tbl,uint16_t size) +struct port_drv_mode_data *data, +uint16_t size) {struct rte_ipsec_session *pri_sess;struct ipsec_sa *sa;@@ -95,9 +101,10 @@ prepare_out_sessions_tbl(struct sa_ctx *sa_out, }/* Use only first inline session found for a given port */ -if (sess_tbl[sa->portid]) +if (data[sa->portid].sess)continue ; - sess_tbl[sa->portid] = pri_sess->security.ses; + data[sa->portid].sess = pri_sess->security.ses; + data[sa->portid].ctx = pri_sess->security.ctx; } }@@ -356,9 +363,8 @@ process_ipsec_ev_outbound(struct ipsec_ctx *ctx, struct route_table *rt, goto drop_pkt_and_exit; } -if (sess->security.ol_flags &RTE_SECURITY_TX_OLOAD_NEED_MDATA ) - *(struct rte_security_session **)rte_security_dynfield (pkt) = - sess->security.ses; +rte_security_set_pkt_metadata (sess->security.ctx, + sess->security.ses, pkt,NULL );/* Mark the packet for Tx security offload */ pkt->ol_flags |=PKT_TX_SEC_OFFLOAD ;@@ -367,6 +373,9 @@ process_ipsec_ev_outbound(struct ipsec_ctx *ctx, struct route_table *rt, port_id = sa->portid; send_pkt: +/* Provide L2 len for Outbound processing */ + pkt->l2_len =RTE_ETHER_HDR_LEN ; +/* Update mac addresses */ update_mac_addrs (pkt, port_id);@@ -398,7 +407,7 @@ static void ipsec_wrkr_non_burst_int_port_drv_mode(struct eh_event_link_info *links, uint8_t nb_links) { -struct rte_security_session *sess_tbl[RTE_MAX_ETHPORTS ] = {NULL }; +struct port_drv_mode_data data[RTE_MAX_ETHPORTS ];unsigned int nb_rx =0 ;struct rte_mbuf *pkt;struct rte_event ev;@@ -412,6 +421,8 @@ ipsec_wrkr_non_burst_int_port_drv_mode(struct eh_event_link_info *links,return ; } +memset (&data,0 ,sizeof (struct port_drv_mode_data )); +/* Get core ID */ lcore_id =rte_lcore_id ();@@ -422,8 +433,8 @@ ipsec_wrkr_non_burst_int_port_drv_mode(struct eh_event_link_info *links,* Prepare security sessions table. In outbound driver mode * we always use first session configured for a given port */ -prepare_out_sessions_tbl (socket_ctx[socket_id].sa_out, sess_tbl, -RTE_MAX_ETHPORTS ); +prepare_out_sessions_tbl (socket_ctx[socket_id].sa_out, data, +RTE_MAX_ETHPORTS );RTE_LOG (INFO ,IPSEC , "Launching event mode worker (non-burst - Tx internal port - "@@ -460,19 +471,21 @@ ipsec_wrkr_non_burst_int_port_drv_mode(struct eh_event_link_info *links,if (!is_unprotected_port (port_id)) { -if (unlikely (!sess_tbl[port_id])) { +if (unlikely (!data[port_id].sess)) {rte_pktmbuf_free (pkt);continue ; }/* Save security session */ -if (rte_security_dynfield_is_registered ()) - *(struct rte_security_session **) -rte_security_dynfield (pkt) = - sess_tbl[port_id]; +rte_security_set_pkt_metadata (data[port_id].ctx, + data[port_id].sess, pkt, +NULL );
examples/ipsec-secgw/ipsec_worker.c ipsec_wrkr_non_burst_int_port_drv_mode(struct eh_event_link_info *links,
Quoted 10 lines
examples/ipsec-secgw/ipsec_worker.c +3
-1/* Mark the packet for Tx security offload */ pkt->ol_flags |=PKT_TX_SEC_OFFLOAD ; + +/* Provide L2 len for Outbound processing */ + pkt->l2_len =RTE_ETHER_HDR_LEN ; }/* --
Quoted 1 line
2.8.4
v6 cover security: Improve inline fast path routines
In reply to Akhil GoyalImprovements to Inline inbound and outbound processing fast path routines rte_security_set_pkt_metadata() and rte_security_get_userdata() to make them inline functions and also provide mechanism for drivers to support fast userdata and metadata access instead of driver specific per-pkt function callbacks.
This series updates requirements of mbuf fields to be updated for outbound inline processing.
Nithin Dabilpuram (3):
security: enforce semantics for Tx inline processing
security: add option for faster udata or mdata access examples/ipsec-secgw: update event mode inline path
v6:
- Addressed comment from Konstantin.
v5:
- Squash 4/4 patch to 2/4 and update release notes
v4:
- Removed entry from deprecation notice.
- Fixed issue with rte_security_set_pkt_metadata() to pass instance instead of device ptr to non-inline C function.
v3:
- Rebased and fixed compilation issue with rte_security_get_userdata() on 32-bit platform
- Updated l2_len on patch 3/3 only for outbound.
v2:
- Remove restrictions on rte_security_set_pkt_metadata() w.r.t pkt content
- Add inline functions for rte_security_set_pkt_metadata() and rte_security_get_userdata() and also faster mdata, udata access via patch 2/3
doc/guides/nics/features.rst | 2 ++ doc/guides/rel_notes/deprecation.rst | 4 --- doc/guides/rel_notes/release_21_08.rst | 6 +++++ examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 ++++++++++++++++++---------- lib/mbuf/rte_mbuf_core.h | 2 ++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 49 +++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 9 files changed, 90 insertions(+), 26 deletions(-)
Signature · 1 line
2.8.4
PATCH v6 1/3 security: enforce semantics for Tx inline processing
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting PKT_TX_SEC_OFFLOAD in mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.
--- doc/guides/nics/features.rst | 2 ++ lib/mbuf/rte_mbuf_core.h | 2 ++ 2 files changed, 4 insertions(+)
doc/guides/nics/features.rst +2 -0
@@ -430,6 +430,7 @@ of protocol operations. See Security library and PMD documentation for more deta * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``capabilities_get``. * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_SECURITY``,
@@ -451,6 +452,7 @@ protocol operations. See security library and PMD documentation for more details * **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_SECURITY``, * **[uses] rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_SECURITY``. +* **[uses] mbuf**: ``mbuf.l2_len``. * **[implements] rte_security_ops**: ``session_create``, ``session_update``, ``session_stats_get``, ``session_destroy``, ``set_pkt_metadata``, ``get_userdata``, ``capabilities_get``.
lib/mbuf/rte_mbuf_core.h +2 -0
@@ -228,6 +228,8 @@ extern "C" {/** * Request security offload processing on the TX packet. +* To use Tx security offload, the user needs to fill l2_len in mbuf +* indicating L2 header size and where L3 header starts. */ #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
Signature · 1 line
2.8.4
Quoted 9 lines
Not all net PMD's/HW can parse packet and identify L2 header and L3 header locations on Tx. This is inline with other Tx offloads requirements such as L3 checksum, L4 checksum offload, etc, where mbuf.l2_len, mbuf.l3_len etc, needs to be set for HW to be able to generate checksum. Since Inline IPSec is also such a Tx offload, some PMD's at least need mbuf.l2_len to be valid to find L3 header and perform Outbound IPSec processing.
Quoted 8 lines
Hence, this patch updates documentation to enforce setting mbuf.l2_len while setting
PKT_TX_SEC_OFFLOADin mbuf.ol_flags for Inline IPSec Crypto / Protocol offload processing to work on Tx.Signed-off-by Nithin Dabilpuram <[email protected]>Acked-by Akhil Goyal <[email protected]>
Title updated as mbuf: enforce semantics for Tx inline IPSec processing
Series Applied to dpdk-next-crypto
PATCH v6 2/3 security: add option for faster udata or mdata access
In reply to Nithin DabilpuramCurrently rte_security_set_pkt_metadata() and rte_security_get_userdata() methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.
For drivers that do not have much to do in the callbacks but just to update metadata in rte_security dynamic field and get userdata from rte_security dynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.
--- doc/guides/rel_notes/deprecation.rst | 4 --- doc/guides/rel_notes/release_21_08.rst | 6 +++++ lib/security/rte_security.c | 8 +++--- lib/security/rte_security.h | 49 +++++++++++++++++++++++++++++++--- lib/security/version.map | 2 ++ 5 files changed, 57 insertions(+), 12 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -4
@@ -276,10 +276,6 @@ Deprecation Notices content. On Linux and FreeBSD, supported prior to DPDK 20.11, original structure will be kept until DPDK 21.11. -* security: The functions ``rte_security_set_pkt_metadata`` and - ``rte_security_get_userdata`` will be made inline functions and additional - flags will be added in structure ``rte_security_ctx`` in DPDK 21.11. - * cryptodev: The structure ``rte_crypto_op`` would be updated to reduce reserved bytes to 2 (from 3), and use 1 byte to indicate warnings and other information from the crypto/security operation. This field will be used to
doc/guides/rel_notes/release_21_08.rst +6 -0
@@ -223,6 +223,12 @@ ABI Changes * No ABI change that would break compatibility with 20.11. +* security: ``rte_security_set_pkt_metadata`` and ``rte_security_get_userdata`` + routines used by Inline outbound and Inline inbound security processing are + made inline and enhanced to do simple 64-bit set/get for PMD's that do not + have much processing in PMD specific callbacks but just 64-bit set/get. + This avoids a per pkt function pointer jump overhead for such PMD's. + Known Issues ------------
lib/security/rte_security.c +4 -4
@@ -122,9 +122,9 @@ rte_security_session_destroy(struct rte_security_ctx *instance, }int -rte_security_set_pkt_metadata (struct rte_security_ctx *instance, -struct rte_security_session *sess, -struct rte_mbuf *m,void *params) +__rte_security_set_pkt_metadata (struct rte_security_ctx *instance, +struct rte_security_session *sess, +struct rte_mbuf *m,void *params) {#ifdef RTE_DEBUG RTE_PTR_OR_ERR_RET (sess, -EINVAL );
@@ -137,7 +137,7 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, }void * -rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) +__rte_security_get_userdata (struct rte_security_ctx *instance,uint64_t md) {void *userdata =NULL ;
lib/security/rte_security.h +45 -4
77 lines not on this page · raw message
lib/security/version.map +2 -0
@@ -20,4 +20,6 @@ EXPERIMENTAL { rte_security_get_userdata; rte_security_session_stats_get; rte_security_session_update; + __rte_security_set_pkt_metadata; + __rte_security_get_userdata; };
Signature · 1 line
2.8.4
Re: [dpdk-dev] [PATCH v6 2/3] security: add option for faster udata or mdata access
15/09/2021 18:30, Nithin Dabilpuram:
Quoted 14 lines
Currently
rte_security_set_pkt_metadata()andrte_security_get_userdata()methods to set pkt metadata on Inline outbound and get userdata after Inline inbound processing is always driver specific callbacks.For drivers that do not have much to do in the callbacks but just to update metadata in
rte_securitydynamic field and get userdata fromrte_securitydynamic field, having to just to PMD specific callback is costly per packet operation. This patch provides a mechanism to do the same in inline function and avoid function pointer jump if a driver supports the same.Signed-off-by Nithin Dabilpuram <[email protected]>Acked-by Akhil Goyal <[email protected]>
[...]
doc/guides/rel_notes/release_21_08.rst ABI Changes · line 230
Quoted 11 lines
doc/guides/rel_notes/release_21_08.rst +5
-0@@ -223,6 +223,12 @@ ABI Changes * No ABI change that would break compatibility with 20.11. +* security: ``rte_security_set_pkt_metadata`` and ``rte_security_get_userdata`` + routines used by Inline outbound and Inline inbound security processing are + made inline and enhanced to do simple 64-bit set/get for PMD's that do not + have much processing in PMD specific callbacks but just 64-bit set/get. + This avoids a per pkt function pointer jump overhead for such PMD's.
Please pay attention it is not the right release notes.
Re: [dpdk-dev] [EXT] Re: [PATCH v6 2/3] security: add option for faster udata or mdata access
Quoted 8 lines
doc/guides/rel_notes/release_21_08.rst ABI Changes · line 226
Quoted 7 lines
doc/guides/rel_notes/release_21_08.rst +1
-0@@ -223,6 +223,12 @@ ABI Changes * No ABI change that would break compatibility with 20.11. +* security: ``rte_security_set_pkt_metadata`` and``rte_security_get_userdata``
Quoted 9 lines
doc/guides/rel_notes/release_21_08.rst ABI Changes · line 227
Quoted 1 line
doc/guides/rel_notes/release_21_08.rst +1
-0+ routines used by Inline outbound and Inline inbound security processingare
doc/guides/rel_notes/release_21_08.rst ABI Changes · line 228
Quoted 1 line
doc/guides/rel_notes/release_21_08.rst +1
-0+ made inline and enhanced to do simple 64-bit set/get for PMD's that donot
doc/guides/rel_notes/release_21_08.rst ABI Changes · line 230
Quoted 2 lines
doc/guides/rel_notes/release_21_08.rst +2
-0+ have much processing in PMD specific callbacks but just 64-bit set/get. + This avoids a per pkt function pointer jump overhead for such PMD's.Please pay attention it is not the right release notes.
Fixed... My bad.
PATCH v6 3/3 examples/ipsec-secgw: update event mode inline path
In reply to Nithin DabilpuramUpdate mbuf.l2_len with L2 header size for outbound inline processing.
This patch also fixes a bug in arg parsing.
--- examples/ipsec-secgw/ipsec-secgw.c | 2 ++ examples/ipsec-secgw/ipsec_worker.c | 41 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +2 -0
@@ -1495,6 +1495,8 @@ parse_portmask(const char *portmask)char *end =NULL ;unsigned long pm; + errno =0 ; +/* parse hexadecimal string */ pm =strtoul (portmask, &end,16 );if ((portmask[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ))
examples/ipsec-secgw/ipsec_worker.c +27 -14
104 lines not on this page · raw message
Signature · 1 line
2.8.4