Skip to content

Commit

Permalink
validation: pktio: lso: improve test coverage of custom segnum add
Browse files Browse the repository at this point in the history
Currently the validation test of the custom segment number add operation
passes even if the ODP implementation overwrites the field instead of
adding to it. Fix the problem by using a non-zero value in the field
in the original packet. Also select the value so that with the third
segment the addition carries to the most significant byte of the two byte
field used in the test.

Signed-off-by: Janne Peltonen <[email protected]>
Reviewed-by: Jere Leppänen <[email protected]>
  • Loading branch information
JannePeltonen authored and MatiasElo committed Nov 8, 2024
1 parent 77b456b commit 7de9ac6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/validation/api/pktio/lso.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#define LSO_TEST_IPV4_FLAG_MF 0x2000 /* More fragments flag within the frag_offset field */
#define LSO_TEST_IPV4_FLAG_DF 0x4000 /* Don't fragment flag within the frag_offset field */
#define LSO_TEST_IPV4_FRAG_OFFS_MASK 0x1fff /* Fragment offset bits in the frag_offset field */
/* Segment number field value in the original packet. Nonzero to verify that the LSO operation
* adds to the value instead of simply overwriting it. */
#define LSO_TEST_CUSTOM_ETH_SEGNUM 0x00fe

/* Pktio interface info
*/
Expand Down Expand Up @@ -825,7 +828,7 @@ static void update_custom_eth_hdr(uint8_t *hdr, uint32_t hdr_len, uint32_t orig_
(void)pkt;
(void)seg_offset;
(void)hdr_len;
odp_u16be_t segnum_be = odp_cpu_to_be_16(seg_num);
odp_u16be_t segnum_be = odp_cpu_to_be_16(seg_num + LSO_TEST_CUSTOM_ETH_SEGNUM);

memcpy(hdr + LSO_TEST_CUSTOM_ETH_SEGNUM_OFFSET, &segnum_be, sizeof(segnum_be));
}
Expand All @@ -852,11 +855,16 @@ static void lso_send_custom_eth(const uint8_t *test_packet, uint32_t pkt_len, ui
static void lso_send_custom_eth_723(uint32_t max_payload, int use_opt)
{
uint32_t pkt_len = sizeof(test_packet_custom_eth_1);
odp_u16be_t segnum = odp_cpu_to_be_16(LSO_TEST_CUSTOM_ETH_SEGNUM);
uint8_t test_pkt[pkt_len];

memcpy(test_pkt, test_packet_custom_eth_1, pkt_len);
memcpy(test_pkt + LSO_TEST_CUSTOM_ETH_SEGNUM_OFFSET, &segnum, sizeof(segnum));

if (max_payload > pktio_a->capa.lso.max_payload_len)
max_payload = pktio_a->capa.lso.max_payload_len;

lso_send_custom_eth(test_packet_custom_eth_1, pkt_len, max_payload, use_opt);
lso_send_custom_eth(test_pkt, pkt_len, max_payload, use_opt);
}

/* No segmentation needed: packet size 723 bytes, LSO segment payload 800 bytes */
Expand Down

0 comments on commit 7de9ac6

Please sign in to comment.