Skip to content

Commit

Permalink
linux-gen: packet: implementation subtype api
Browse files Browse the repository at this point in the history
Add inlined implementation of the new subtype API call and use
that internally.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
  • Loading branch information
Petri Savolainen authored and muvarov committed Nov 28, 2018
1 parent e49af8a commit 2411cd3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Expand Up @@ -45,6 +45,7 @@ typedef struct _odp_packet_inline_offset_t {
uint16_t timestamp;
uint16_t input_flags;
uint16_t flags;
uint16_t subtype;

} _odp_packet_inline_offset_t;

Expand Down
7 changes: 7 additions & 0 deletions platform/linux-generic/include/odp/api/plat/packet_inlines.h
Expand Up @@ -19,6 +19,7 @@
#include <odp/api/hints.h>
#include <odp/api/time.h>
#include <odp/api/abi/buffer.h>
#include <odp/api/abi/event.h>

#include <odp/api/plat/packet_inline_types.h>
#include <odp/api/plat/pool_inline_types.h>
Expand Down Expand Up @@ -64,6 +65,7 @@
#define odp_packet_to_event __odp_packet_to_event
#define odp_packet_from_event_multi __odp_packet_from_event_multi
#define odp_packet_to_event_multi __odp_packet_to_event_multi
#define odp_packet_subtype __odp_packet_subtype
#else
#undef _ODP_INLINE
#define _ODP_INLINE
Expand Down Expand Up @@ -355,6 +357,11 @@ _ODP_INLINE void odp_packet_to_event_multi(const odp_packet_t pkt[],
ev[i] = odp_packet_to_event(pkt[i]);
}

_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);
}

/** @endcond */

#endif
5 changes: 0 additions & 5 deletions platform/linux-generic/include/odp_packet_internal.h
Expand Up @@ -147,11 +147,6 @@ static inline seg_entry_t *seg_entry_last(odp_packet_hdr_t *hdr)
return &last->buf_hdr.seg[last_seg];
}

static inline odp_event_subtype_t packet_subtype(odp_packet_t pkt)
{
return packet_hdr(pkt)->subtype;
}

static inline void packet_subtype_set(odp_packet_t pkt, int ev)
{
packet_hdr(pkt)->subtype = ev;
Expand Down
5 changes: 3 additions & 2 deletions platform/linux-generic/odp_event.c
Expand Up @@ -19,14 +19,15 @@

/* Inlined API functions */
#include <odp/api/plat/event_inlines.h>
#include <odp/api/plat/packet_inlines.h>

odp_event_subtype_t odp_event_subtype(odp_event_t event)
{
if (_odp_buffer_event_type(odp_buffer_from_event(event)) !=
ODP_EVENT_PACKET)
return ODP_EVENT_NO_SUBTYPE;

return packet_subtype(odp_packet_from_event(event));
return odp_packet_subtype(odp_packet_from_event(event));
}

odp_event_type_t odp_event_types(odp_event_t event,
Expand All @@ -36,7 +37,7 @@ odp_event_type_t odp_event_types(odp_event_t event,
odp_event_type_t event_type = _odp_buffer_event_type(buf);

*subtype = event_type == ODP_EVENT_PACKET ?
packet_subtype(odp_packet_from_event(event)) :
odp_packet_subtype(odp_packet_from_event(event)) :
ODP_EVENT_NO_SUBTYPE;

return event_type;
Expand Down
3 changes: 2 additions & 1 deletion platform/linux-generic/odp_packet.c
Expand Up @@ -51,7 +51,8 @@ const _odp_packet_inline_offset_t ODP_ALIGNED_CACHE _odp_packet_inline = {
.flow_hash = offsetof(odp_packet_hdr_t, flow_hash),
.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)
.flags = offsetof(odp_packet_hdr_t, p.flags),
.subtype = offsetof(odp_packet_hdr_t, subtype)

};

Expand Down
2 changes: 1 addition & 1 deletion platform/linux-generic/pktio/loop.c
Expand Up @@ -319,7 +319,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
for (i = 0; i < nb_tx; ++i) {
odp_ipsec_packet_result_t result;

if (packet_subtype(pkt_tbl[i]) ==
if (odp_packet_subtype(pkt_tbl[i]) ==
ODP_EVENT_PACKET_IPSEC &&
pktio_entry->s.config.outbound_ipsec) {

Expand Down

0 comments on commit 2411cd3

Please sign in to comment.