Fixes for inline ipsec test cases
cover Fixes for inline ipsec test cases
A series of small fixes for the inline ipsec test cases, with the third patch being the most significant - skipping tests where we don't have the necessary HW support to run the tests. Previously this was leading to test failures when the tests should never have been run due to missing HW capabilities.
Bruce Richardson (3):
test/security_inline_proto: remove fast-free Tx flag test/security_inline_proto: fix MTU calculation underflow test/security_inline_proto: check for capabilities
app/test/test_security_inline_proto.c | 75 +++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 5 deletions(-)
--
2.53.0
PATCH 1/3 test/security_inline_proto: remove fast-free Tx flag
The FAST_FREE Tx offload flag is an optimization that may not be supported by all drivers, but the test unconditionally sets this as part of the Tx config. Since it's an optimization that should not affect test correctness, and since this is a unit test, not perf test, just remove the flag.
--- app/test/test_security_inline_proto.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
app/test/test_security_inline_proto.c +1 -2
@@ -94,8 +94,7 @@ static struct rte_eth_conf port_conf = { }, .txmode = { .mq_mode = RTE_ETH_MQ_TX_NONE, - .offloads = RTE_ETH_TX_OFFLOAD_SECURITY | - RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE, + .offloads = RTE_ETH_TX_OFFLOAD_SECURITY, }, .lpbk_mode = 1, /* enable loopback */ };
Signature · 1 line
2.53.0
PATCH 2/3 test/security_inline_proto: fix MTU calculation underflow
In reply to Bruce RichardsonWhen testing with some NICs it was observed that the max MTU calculation could underflow. Despite the RTE_MIN, due to integer promotion, this lead to the configuring of the port with an excessively large, invalid value. For example, if lim_nb_seg_max == 0, that meant that max_data_room - 256 is -256 for comparison purposes using standard integers (promoted from uint16_t). That is lower than the max mtu so the -256 value is chosen, which becomes >65000 when converted back to uint16_t.
Fix this by a) checking for seg_max == 0 b) doing calculations using uint32_t and c) checking explicitly for underflow before subtracting.
--- app/test/test_security_inline_proto.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
app/test/test_security_inline_proto.c +13 -2
@@ -2045,8 +2045,19 @@ inline_ipsec_testsuite_setup(void)memcpy (&local_port_conf, &port_conf,sizeof (port_conf));/* Add Multi seg flags */ if (sg_mode) { -uint16_t max_data_room =RTE_MBUF_DEFAULT_DATAROOM * - dev_info.rx_desc_lim.nb_seg_max; +uint32_t max_data_room; + +if (dev_info.rx_desc_lim.nb_seg_max ==0 ) { +printf ("SG mode unsupported: invalid max Rx segments (0)\n" ); +return TEST_SKIPPED ; + } + + max_data_room =RTE_MBUF_DEFAULT_DATAROOM * dev_info.rx_desc_lim.nb_seg_max; +if (max_data_room <=256 ) { +printf ("SG mode unsupported: max data room (%u) too small\n" , + max_data_room); +return TEST_SKIPPED ; + } local_port_conf.rxmode.offloads |=RTE_ETH_RX_OFFLOAD_SCATTER ; local_port_conf.txmode.offloads |=RTE_ETH_TX_OFFLOAD_MULTI_SEGS ;
Signature · 1 line
2.53.0
PATCH 3/3 test/security_inline_proto: check for capabilities
In reply to Bruce RichardsonSkip the test cases when the HW doesn't support the necessary offloads, skipping the whole suite if necessary, e.g. if no IPsec capabilities are present. For event-based tests, skip those if no eventdev is present.
--- app/test/test_security_inline_proto.c | 57 ++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-)
app/test/test_security_inline_proto.c +56 -1
@@ -2043,10 +2043,25 @@ inline_ipsec_testsuite_setup(void) }memcpy (&local_port_conf, &port_conf,sizeof (port_conf)); + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + local_port_conf.txmode.offloads &= dev_info.tx_offload_capa; + +if (!(local_port_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SECURITY ) || + !(local_port_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY )) { +printf ("Inline IPsec unsupported: required security offloads are missing\n" ); +return TEST_SKIPPED ; + } +/* Add Multi seg flags */ if (sg_mode) {uint32_t max_data_room; +if (!(dev_info.rx_offload_capa &RTE_ETH_RX_OFFLOAD_SCATTER ) || + !(dev_info.tx_offload_capa &RTE_ETH_TX_OFFLOAD_MULTI_SEGS )) { +printf ("SG mode unsupported: required scatter or multi-seg offloads are missing\n" ); +return TEST_SKIPPED ; + } +if (dev_info.rx_desc_lim.nb_seg_max ==0 ) {printf ("SG mode unsupported: invalid max Rx segments (0)\n" );return TEST_SKIPPED ;
@@ -2112,6 +2127,25 @@ inline_ipsec_testsuite_setup(void) plaintext_len =0 ; } +/* Check that at least one inline IPsec capability is registered */ +void *sec_ctx =rte_eth_dev_get_sec_ctx (port_id); +const struct rte_security_capability *cap; + +if (sec_ctx ==NULL ) { +printf ("No security context on port %d\n" , port_id); +return TEST_SKIPPED ; + } +for (cap =rte_security_capabilities_get (sec_ctx); + cap !=NULL && cap->action !=RTE_SECURITY_ACTION_TYPE_NONE ; cap++) { +if (cap->action ==RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL && + cap->protocol ==RTE_SECURITY_PROTOCOL_IPSEC ) +break ; + } +if (cap ==NULL || cap->action ==RTE_SECURITY_ACTION_TYPE_NONE ) { +printf ("No inline IPsec capabilities registered\n" ); +return TEST_SKIPPED ; + } +return 0 ; }
@@ -2140,6 +2174,8 @@ event_inline_ipsec_testsuite_setup(void)struct rte_event_dev_config eventdev_conf = {0 };struct rte_event_queue_conf eventq_conf = {0 };struct rte_event_port_conf ev_port_conf = {0 }; +struct rte_eth_conf local_port_conf; +struct rte_eth_dev_info dev_info;const uint16_t nb_txd =1024 , nb_rxd =1024 ;uint16_t nb_rx_queue =1 , nb_tx_queue =1 ;uint8_t ev_queue_id =0 , tx_queue_id =0 ;
@@ -2151,6 +2187,11 @@ event_inline_ipsec_testsuite_setup(void)printf ("Start event inline IPsec test.\n" ); +if (rte_event_dev_count () ==0 ) { +printf ("Event inline IPsec unsupported: no event devices available\n" ); +return TEST_SKIPPED ; + } + nb_ports =rte_eth_dev_count_avail ();if (nb_ports ==0 ) {printf ("Test require: 1 port, available: 0\n" );
@@ -2182,9 +2223,23 @@ event_inline_ipsec_testsuite_setup(void)/* configuring port 0 for the test is enough */ port_id =0 ; +if (rte_eth_dev_info_get (port_id, &dev_info)) { +printf ("Failed to get devinfo" ); +return -1 ; + } + +memcpy (&local_port_conf, &port_conf,sizeof (port_conf)); + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + local_port_conf.txmode.offloads &= dev_info.tx_offload_capa; +if ((local_port_conf.rxmode.offloads &RTE_ETH_RX_OFFLOAD_SECURITY ) ==0 || + (local_port_conf.txmode.offloads &RTE_ETH_TX_OFFLOAD_SECURITY ) ==0 ) { +printf ("Event inline IPsec unsupported: required security offloads are missing\n" ); +return TEST_SKIPPED ; + } +/* port configure */ ret =rte_eth_dev_configure (port_id, nb_rx_queue, - nb_tx_queue, &port_conf); + nb_tx_queue, &local_port_conf);if (ret <0 ) {printf ("Cannot configure device: err=%d, port=%d\n" , ret, port_id);
Signature · 1 line
2.53.0
Akhil Goyal
AppliedQuoted 6 lines
A series of small fixes for the inline ipsec test cases, with the third patch being the most significant - skipping tests where we don't have the necessary HW support to run the tests. Previously this was leading to test failures when the tests should never have been run due to missing HW capabilities.
Quoted 8 lines
Bruce Richardson (3):
test/security_inline_proto: remove fast-free Tx flag test/security_inline_proto: fix MTU calculation underflow test/security_inline_proto: check for capabilitiesapp/test/test_security_inline_proto.c | 75 +++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 5 deletions(-)
Series Acked-by: Akhil Goyal <[email protected]>
Applied to dpdk-next-crypto