Skip to content

Commit

Permalink
linux-dpdk: packet: move event subtype to _odp_event_hdr_int_t
Browse files Browse the repository at this point in the history
After the previous event header reorganization (d6461df) there is now a
one byte gap in the _odp_event_hdr_int_t struct. Move
odp_packet_hdr_t.subtype to this gap, after which all data required by
packet_init() is located on the same cache line. This can improve
performance for example with odp_l2fwd application.

Signed-off-by: Matias Elo <[email protected]>
Reviewed-by: Tuomas Taipale <[email protected]>
  • Loading branch information
MatiasElo committed Aug 8, 2023
1 parent 931808e commit 4344954
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions platform/linux-dpdk/include/odp_event_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ typedef struct _odp_event_hdr_int_t {
/* Event type. Maybe different than pool type (crypto compl event) */
int8_t event_type;

/* Event subtype */
int8_t subtype;

/* Event flow id */
uint8_t flow_id;

Expand Down
15 changes: 7 additions & 8 deletions platform/linux-dpdk/include/odp_packet_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ typedef struct ODP_ALIGNED_CACHE odp_packet_hdr_t {
/* Common internal header */
_odp_event_hdr_int_t event_hdr;

/* Parser metadata */
packet_parser_t p;

/* Input interface */
odp_pktio_t input;

/* Timestamp value */
Expand Down Expand Up @@ -162,9 +164,6 @@ typedef struct ODP_ALIGNED_CACHE odp_packet_hdr_t {
/* LSO profile index */
uint8_t lso_profile_idx;

/* Event subtype */
int8_t subtype;

union {
/* Result for crypto packet op */
odp_crypto_packet_result_t crypto_op_result;
Expand Down Expand Up @@ -215,7 +214,7 @@ static inline struct rte_mbuf *pkt_to_mbuf(odp_packet_t pkt)

static inline void packet_subtype_set(odp_packet_t pkt, int ev)
{
packet_hdr(pkt)->subtype = ev;
packet_hdr(pkt)->event_hdr.subtype = ev;
}

/**
Expand All @@ -231,8 +230,8 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, odp_pktio_t input)
pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID;

if (odp_unlikely(pkt_hdr->subtype != ODP_EVENT_PACKET_BASIC))
pkt_hdr->subtype = ODP_EVENT_PACKET_BASIC;
if (odp_unlikely(pkt_hdr->event_hdr.subtype != ODP_EVENT_PACKET_BASIC))
pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;

pkt_hdr->input = input;
}
Expand Down Expand Up @@ -277,10 +276,10 @@ static inline void _odp_packet_copy_md(odp_packet_hdr_t *dst_hdr,
odp_packet_hdr_t *src_hdr,
odp_bool_t uarea_copy)
{
const int8_t subtype = src_hdr->subtype;
const int8_t subtype = src_hdr->event_hdr.subtype;

dst_hdr->input = src_hdr->input;
dst_hdr->subtype = subtype;
dst_hdr->event_hdr.subtype = subtype;
dst_hdr->dst_queue = src_hdr->dst_queue;
dst_hdr->cos = src_hdr->cos;
dst_hdr->cls_mark = src_hdr->cls_mark;
Expand Down
6 changes: 3 additions & 3 deletions platform/linux-dpdk/odp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
.timestamp = offsetof(odp_packet_hdr_t, timestamp),
.input_flags = offsetof(odp_packet_hdr_t, p.input_flags),
.flags = offsetof(odp_packet_hdr_t, p.flags),
.subtype = offsetof(odp_packet_hdr_t, subtype),
.subtype = offsetof(odp_packet_hdr_t, event_hdr.subtype),
.cls_mark = offsetof(odp_packet_hdr_t, cls_mark),
.ipsec_ctx = offsetof(odp_packet_hdr_t, ipsec_ctx),
.crypto_op = offsetof(odp_packet_hdr_t, crypto_op_result),
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void odp_packet_print(odp_packet_t pkt)
odp_packet_to_u64(pkt));
len += _odp_snprint(&str[len], n - len, " pool index %u\n", pool->pool_idx);
len += _odp_snprint(&str[len], n - len, " buf index %u\n", hdr->event_hdr.index);
len += _odp_snprint(&str[len], n - len, " ev subtype %i\n", hdr->subtype);
len += _odp_snprint(&str[len], n - len, " ev subtype %i\n", hdr->event_hdr.subtype);
len += _odp_snprint(&str[len], n - len, " input_flags 0x%" PRIx64 "\n",
hdr->p.input_flags.all);
if (hdr->p.input_flags.all) {
Expand Down Expand Up @@ -1931,7 +1931,7 @@ odp_packet_t odp_packet_reassemble(odp_pool_t pool_hdl,
pkt_hdr->mb.data_off = headroom;

/* Reset metadata */
pkt_hdr->subtype = ODP_EVENT_PACKET_BASIC;
pkt_hdr->event_hdr.subtype = ODP_EVENT_PACKET_BASIC;
pkt_hdr->input = ODP_PKTIO_INVALID;
packet_parse_reset(pkt_hdr, 1);

Expand Down

0 comments on commit 4344954

Please sign in to comment.