Skip to content

Commit 65fb7d1

Browse files
alexveskerSaeed Mahameed
authored andcommitted
net/mlx5: DR, Fix STEv1 incorrect L3 decapsulation padding
Decapsulation L3 on small inner packets which are less than 64 Bytes was done incorrectly. In small packets there is an extra padding added in L2 which should not be included in L3 length. The issue was that after decapL3 the extra L2 padding caused an update on the L3 length. To avoid this issue the new header is pushed to the beginning of the packet (offset 0) which should not cause a HW reparse and update the L3 length. Fixes: c349b41 ("net/mlx5: DR, Add STEv1 modify header logic") Reviewed-by: Erez Shitrit <[email protected]> Reviewed-by: Yevgeny Kliteynik <[email protected]> Signed-off-by: Alex Vesker <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent c7d6c19 commit 65fb7d1

File tree

1 file changed

+16
-10
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/steering

1 file changed

+16
-10
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,11 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data,
694694
if (hw_action_sz / DR_STE_ACTION_DOUBLE_SZ < DR_STE_DECAP_L3_ACTION_NUM)
695695
return -EINVAL;
696696

697-
memcpy(padded_data, data, data_sz);
697+
inline_data_sz =
698+
MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data);
699+
700+
/* Add an alignment padding */
701+
memcpy(padded_data + data_sz % inline_data_sz, data, data_sz);
698702

699703
/* Remove L2L3 outer headers */
700704
MLX5_SET(ste_single_action_remove_header_v1, hw_action, action_id,
@@ -706,32 +710,34 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data,
706710
hw_action += DR_STE_ACTION_DOUBLE_SZ;
707711
used_actions++; /* Remove and NOP are a single double action */
708712

709-
inline_data_sz =
710-
MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data);
713+
/* Point to the last dword of the header */
714+
data_ptr += (data_sz / inline_data_sz) * inline_data_sz;
711715

712-
/* Add the new header inline + 2 extra bytes */
716+
/* Add the new header using inline action 4Byte at a time, the header
717+
* is added in reversed order to the beginning of the packet to avoid
718+
* incorrect parsing by the HW. Since header is 14B or 18B an extra
719+
* two bytes are padded and later removed.
720+
*/
713721
for (i = 0; i < data_sz / inline_data_sz + 1; i++) {
714722
void *addr_inline;
715723

716724
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, action_id,
717725
DR_STE_V1_ACTION_ID_INSERT_INLINE);
718726
/* The hardware expects here offset to words (2 bytes) */
719-
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset,
720-
i * 2);
727+
MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset, 0);
721728

722729
/* Copy bytes one by one to avoid endianness problem */
723730
addr_inline = MLX5_ADDR_OF(ste_double_action_insert_with_inline_v1,
724731
hw_action, inline_data);
725-
memcpy(addr_inline, data_ptr, inline_data_sz);
732+
memcpy(addr_inline, data_ptr - i * inline_data_sz, inline_data_sz);
726733
hw_action += DR_STE_ACTION_DOUBLE_SZ;
727-
data_ptr += inline_data_sz;
728734
used_actions++;
729735
}
730736

731-
/* Remove 2 extra bytes */
737+
/* Remove first 2 extra bytes */
732738
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, action_id,
733739
DR_STE_V1_ACTION_ID_REMOVE_BY_SIZE);
734-
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, data_sz / 2);
740+
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, 0);
735741
/* The hardware expects here size in words (2 bytes) */
736742
MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, remove_size, 1);
737743
used_actions++;

0 commit comments

Comments
 (0)