- const void *cur = vlib_buffer_get_current (b);
- clib_memcpy_fast (wqe->eseg.inline_hdr_start,
- cur, MLX5_ETH_L2_INLINE_HEADER_SIZE);
- wqe->eseg.inline_hdr_sz = htobe16 (inline_sz);
- wqe->dseg.byte_count = htobe32 (sz - inline_sz);
- wqe->dseg.addr = htobe64 (pointer_to_uword (cur) + inline_sz);
+ STATIC_ASSERT (STRUCT_SIZE_OF (struct mlx5_wqe_eth_seg, inline_hdr_start) +
+ STRUCT_SIZE_OF (struct mlx5_wqe_eth_seg,
+ inline_hdr) >=
+ MLX5_ETH_L2_INLINE_HEADER_SIZE, "wrong size");
+ clib_memcpy_fast (wqe->eseg.inline_hdr_start, cur,
+ MLX5_ETH_L2_INLINE_HEADER_SIZE);
+
+ wqe->wqe_index_lo = tail;
+ wqe->wqe_index_hi = tail >> 8;
+ if (PREDICT_TRUE (sz >= MLX5_ETH_L2_INLINE_HEADER_SIZE))
+ {
+ /* inline_hdr_sz is set to MLX5_ETH_L2_INLINE_HEADER_SIZE
+ in the template */
+ wqe->dseg.byte_count = htobe32 (sz - MLX5_ETH_L2_INLINE_HEADER_SIZE);
+ wqe->dseg.addr = htobe64 (addr + MLX5_ETH_L2_INLINE_HEADER_SIZE);
+ }
+ else
+ {
+ /* dseg.byte_count and desg.addr are set to 0 in the template */
+ wqe->eseg.inline_hdr_sz = htobe16 (sz);
+ }