From e33af3d175eb92813899ca6e4f1e77bf6207ea96 Mon Sep 17 00:00:00 2001 From: Janne Peltonen Date: Mon, 25 Nov 2024 09:48:30 +0000 Subject: [PATCH 1/2] api: pktio: lso: promise maximum-sized segments for the custom proto Specify that all segments, except the last one, have the maximum payload length with the custom protocol. Rounding down the payload length by ODP implementations would be problematic for certain custom protocols that need to know the exact length of the segments in advance. Signed-off-by: Janne Peltonen Reviewed-by: Matias Elo Reviewed-by: Petri Savolainen Reviewed-by: Nithin Dabilpuram --- include/odp/api/spec/packet_io_types.h | 6 +++++- include/odp/api/spec/packet_types.h | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/odp/api/spec/packet_io_types.h b/include/odp/api/spec/packet_io_types.h index 0ba680f94d..6402205eb4 100644 --- a/include/odp/api/spec/packet_io_types.h +++ b/include/odp/api/spec/packet_io_types.h @@ -792,7 +792,11 @@ typedef enum odp_lso_protocol_t { /** Protocol not selected. */ ODP_LSO_PROTO_NONE = 0, - /** Custom protocol. LSO performs only custom field updates to the packet headers. */ + /** Custom protocol. LSO performs only custom field updates to the packet headers. + * + * All segments except the last one have exactly the maximum number of payload + * bytes as given by the max_payload_len parameter in odp_packet_lso_opt_t. + */ ODP_LSO_PROTO_CUSTOM, /** LSO performs IPv4 fragmentation. diff --git a/include/odp/api/spec/packet_types.h b/include/odp/api/spec/packet_types.h index b9d55abde8..33f00b8b5d 100644 --- a/include/odp/api/spec/packet_types.h +++ b/include/odp/api/spec/packet_types.h @@ -407,9 +407,10 @@ typedef struct odp_packet_lso_opt_t { /** Maximum payload length in an LSO segment * * Max_payload_len parameter defines the maximum number of payload bytes in each - * created segment. Depending on the implementation, segments with less payload may be - * created. However, this value is used typically to divide packet payload evenly over - * all segments except the last one, which contains the remaining payload bytes. + * created segment. Depending on the implementation and the LSO profile, segments + * with less payload may be created. However, this value is used typically to divide + * packet payload evenly over all segments except the last one, which contains the + * remaining payload bytes. */ uint32_t max_payload_len; From 357a6a220c90636c259e149c086783182ddbdf94 Mon Sep 17 00:00:00 2001 From: Janne Peltonen Date: Tue, 10 Dec 2024 10:46:30 +0200 Subject: [PATCH 2/2] validation: pktio: lso: check that custom segments are of maximum length Check that the non-last segments of a custom LSO protocol have the maximum payload length as promised by the API. Signed-off-by: Janne Peltonen Reviewed-by: Matias Elo Reviewed-by: Nithin Dabilpuram --- test/validation/api/pktio/lso.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/validation/api/pktio/lso.c b/test/validation/api/pktio/lso.c index 8d1e518546..5800570e70 100644 --- a/test/validation/api/pktio/lso.c +++ b/test/validation/api/pktio/lso.c @@ -767,6 +767,7 @@ static void lso_test(odp_lso_profile_param_t param, uint32_t max_payload, uint32_t offset, len, payload_len, payload_sum; odp_packet_t pkt_out[MAX_NUM_SEG]; uint32_t sent_payload = pkt_len - hdr_len; + const int is_custom_proto = (param.lso_proto == ODP_LSO_PROTO_CUSTOM); profile = odp_lso_profile_create(pktio_a->hdl, ¶m); CU_ASSERT_FATAL(profile != ODP_LSO_PROFILE_INVALID); @@ -821,6 +822,8 @@ static void lso_test(odp_lso_profile_param_t param, uint32_t max_payload, } CU_ASSERT(payload_len <= max_payload); + if (is_custom_proto && seg_num < num - 1) + CU_ASSERT(payload_len == max_payload); if (compare_data(seg, hdr_len, test_packet + offset, payload_len) >= 0) { ODPH_ERR(" Payload compare failed at offset %u\n", offset);