aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2023-11-23 16:15:58 +0200
committerPetri Savolainen <petri.savolainen@nokia.com>2024-01-11 17:43:56 +0200
commit187680b446c5ae2a399f89329b7fca05caeda56a (patch)
tree003cc3f1db9243ff4240bb6beec0017dc913063e
parent81573060a48a1436ff1a7f51216a4d23cbf3378f (diff)
linux-gen: event: move subtype into event header
Other events in addition to packets may have event subtype in the future. Move subtype field from packet to event header. Event header size did not change due to the move. Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
-rw-r--r--platform/linux-generic/include/odp/api/plat/event_inline_types.h1
-rw-r--r--platform/linux-generic/include/odp/api/plat/event_inlines.h17
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inline_types.h1
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inlines.h4
-rw-r--r--platform/linux-generic/include/odp_event_internal.h3
-rw-r--r--platform/linux-generic/include/odp_packet_internal.h17
-rw-r--r--platform/linux-generic/odp_event.c1
-rw-r--r--platform/linux-generic/odp_packet.c5
8 files changed, 30 insertions, 19 deletions
diff --git a/platform/linux-generic/include/odp/api/plat/event_inline_types.h b/platform/linux-generic/include/odp/api/plat/event_inline_types.h
index caa075871..cbf01588f 100644
--- a/platform/linux-generic/include/odp/api/plat/event_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/event_inline_types.h
@@ -28,6 +28,7 @@ extern "C" {
typedef struct _odp_event_inline_offset_t {
uint16_t event_type;
uint16_t base_data;
+ uint16_t subtype;
uint16_t flow_id;
uint16_t pool;
diff --git a/platform/linux-generic/include/odp/api/plat/event_inlines.h b/platform/linux-generic/include/odp/api/plat/event_inlines.h
index b68ced244..924b6dc65 100644
--- a/platform/linux-generic/include/odp/api/plat/event_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/event_inlines.h
@@ -49,6 +49,15 @@ static inline odp_event_type_t __odp_event_type_get(odp_event_t event)
return (odp_event_type_t)type;
}
+static inline odp_event_subtype_t __odp_event_subtype_get(odp_event_t event)
+{
+ int8_t type;
+
+ type = _odp_event_hdr_field(event, int8_t, subtype);
+
+ return (odp_event_subtype_t)type;
+}
+
_ODP_INLINE odp_event_type_t odp_event_type(odp_event_t event)
{
return __odp_event_type_get(event);
@@ -148,7 +157,7 @@ _ODP_INLINE odp_event_subtype_t odp_event_subtype(odp_event_t event)
if (__odp_event_type_get(event) != ODP_EVENT_PACKET)
return ODP_EVENT_NO_SUBTYPE;
- return (odp_event_subtype_t)_odp_pkt_get((odp_packet_t)event, int8_t, subtype);
+ return __odp_event_subtype_get(event);
}
_ODP_INLINE odp_event_type_t odp_event_types(odp_event_t event,
@@ -157,8 +166,7 @@ _ODP_INLINE odp_event_type_t odp_event_types(odp_event_t event,
odp_event_type_t event_type = __odp_event_type_get(event);
*subtype = event_type == ODP_EVENT_PACKET ?
- (odp_event_subtype_t)_odp_pkt_get((odp_packet_t)event, int8_t, subtype) :
- ODP_EVENT_NO_SUBTYPE;
+ __odp_event_subtype_get(event) : ODP_EVENT_NO_SUBTYPE;
return event_type;
}
@@ -174,8 +182,7 @@ _ODP_INLINE void odp_event_types_multi(const odp_event_t event[], odp_event_type
for (int i = 0; i < num; i++) {
subtype[i] = (type[i] == ODP_EVENT_PACKET) ?
- (odp_event_subtype_t)_odp_pkt_get((odp_packet_t)event[i], int8_t,
- subtype) : ODP_EVENT_NO_SUBTYPE;
+ __odp_event_subtype_get(event[i]) : ODP_EVENT_NO_SUBTYPE;
}
}
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
index eb20ca7d7..691965624 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
@@ -50,7 +50,6 @@ typedef struct _odp_packet_inline_offset_t {
uint16_t timestamp;
uint16_t input_flags;
uint16_t flags;
- uint16_t subtype;
uint16_t cls_mark;
uint16_t ipsec_ctx;
uint16_t crypto_op;
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
index 960dbc5fc..2dd74fa29 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h
@@ -24,6 +24,7 @@
#include <odp/api/plat/packet_io_inlines.h>
#include <odp/api/plat/packet_inline_types.h>
#include <odp/api/plat/pool_inline_types.h>
+#include <odp/api/plat/event_inline_types.h>
#include <stdint.h>
#include <string.h>
@@ -571,7 +572,8 @@ _ODP_INLINE void odp_packet_to_event_multi(const odp_packet_t pkt[],
_ODP_INLINE odp_event_subtype_t odp_packet_subtype(odp_packet_t pkt)
{
- return (odp_event_subtype_t)_odp_pkt_get(pkt, int8_t, subtype);
+ return (odp_event_subtype_t)_odp_event_hdr_field((odp_event_t)(uintptr_t)pkt,
+ int8_t, subtype);
}
_ODP_INLINE odp_packet_tx_compl_t odp_packet_tx_compl_from_event(odp_event_t ev)
diff --git a/platform/linux-generic/include/odp_event_internal.h b/platform/linux-generic/include/odp_event_internal.h
index d9957e530..1b85d64fc 100644
--- a/platform/linux-generic/include/odp_event_internal.h
+++ b/platform/linux-generic/include/odp_event_internal.h
@@ -65,6 +65,9 @@ typedef struct _odp_event_hdr_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;
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 41a44b83c..f7904c3bc 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -107,9 +107,6 @@ typedef struct ODP_ALIGNED_CACHE odp_packet_hdr_t {
uint16_t tailroom;
- /* Event subtype */
- int8_t subtype;
-
/* Used as classifier destination queue, in IPsec inline input processing and as Tx
* completion event queue. */
odp_queue_t dst_queue;
@@ -214,9 +211,11 @@ static inline odp_packet_hdr_t *packet_last_seg(odp_packet_hdr_t *hdr)
return hdr;
}
-static inline void packet_subtype_set(odp_packet_t pkt, int ev)
+static inline void packet_subtype_set(odp_packet_t pkt, int subtype)
{
- packet_hdr(pkt)->subtype = ev;
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ pkt_hdr->event_hdr.subtype = subtype;
}
/**
@@ -258,8 +257,8 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
pkt_hdr->headroom = pool->headroom;
pkt_hdr->tailroom = pool->seg_len - seg_len + pool->tailroom;
- 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 = ODP_PKTIO_INVALID;
}
@@ -304,7 +303,7 @@ static inline void _odp_packet_copy_md(odp_packet_hdr_t *dst_hdr,
odp_packet_hdr_t *src_hdr,
odp_bool_t uarea_copy)
{
- int8_t subtype = src_hdr->subtype;
+ int8_t subtype = src_hdr->event_hdr.subtype;
/* Lengths and segmentation data are not copied:
* .frame_len
@@ -316,7 +315,7 @@ static inline void _odp_packet_copy_md(odp_packet_hdr_t *dst_hdr,
* .seg_count
*/
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;
diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c
index e15cb1c50..9ec4b4bfb 100644
--- a/platform/linux-generic/odp_event.c
+++ b/platform/linux-generic/odp_event.c
@@ -36,6 +36,7 @@ const _odp_event_inline_offset_t
_odp_event_inline_offset ODP_ALIGNED_CACHE = {
.event_type = offsetof(_odp_event_hdr_t, event_type),
.base_data = offsetof(_odp_event_hdr_t, base_data),
+ .subtype = offsetof(_odp_event_hdr_t, subtype),
.flow_id = offsetof(_odp_event_hdr_t, flow_id),
.pool = offsetof(_odp_event_hdr_t, pool),
};
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 96fcd928a..17a4a9298 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -66,7 +66,6 @@ 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),
.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),
@@ -1454,7 +1453,7 @@ void odp_packet_print(odp_packet_t pkt)
len += _odp_snprint(&str[len], n - len, " pool index %u\n", hdr->event_hdr.index.pool);
len += _odp_snprint(&str[len], n - len, " buf index %u\n",
hdr->event_hdr.index.event);
- 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) {
@@ -2401,7 +2400,7 @@ odp_packet_t odp_packet_reassemble(odp_pool_t pool_hdl, odp_packet_buf_t pkt_buf
pkt_hdr->tailroom = tailroom;
/* 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);