diff options
author | Matias Elo <matias.elo@nokia.com> | 2022-03-10 17:10:16 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2022-04-22 15:34:32 +0300 |
commit | 566e14b83a6a9727608318b299cb8271a2e78bb4 (patch) | |
tree | c0e717e1622965e2fad04c650dae084cf7397005 | |
parent | 91f5e1d5642630ede48def965bf6446f089cc162 (diff) |
Port fb4766cf9 "linux-gen: packet: implement tx completion event APIs"
Port original commit from linux-generic.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Jere Leppänen <jere.leppanen@nokia.com>
5 files changed, 44 insertions, 25 deletions
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h b/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h index 2f4d65281..2b8e849e6 100644 --- a/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h +++ b/platform/linux-dpdk/include/odp/api/plat/packet_inline_types.h @@ -1,4 +1,5 @@ /* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -112,7 +113,7 @@ typedef union { uint32_t all_flags; struct { - uint32_t reserved1: 8; + uint32_t reserved1: 7; /* * Init flags @@ -129,6 +130,7 @@ typedef union { uint32_t l4_chksum_set: 1; /* L4 chksum bit is valid */ uint32_t l4_chksum: 1; /* L4 chksum override */ uint32_t ts_set: 1; /* Set Tx timestamp */ + uint32_t tx_compl: 1; /* Tx completion event requested */ uint32_t shaper_len_adj: 8; /* Adjustment for traffic mgr */ /* @@ -146,8 +148,8 @@ typedef union { /* Flag groups */ struct { - uint32_t reserved2: 8; - uint32_t other: 16; /* All other flags */ + uint32_t reserved2: 7; + uint32_t other: 17; /* All other flags */ uint32_t error: 8; /* All error flags */ } all; diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h index 12b6d772c..5d8ef2e26 100644 --- a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h @@ -92,6 +92,8 @@ extern "C" { #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 + #define odp_packet_tx_compl_from_event __odp_packet_tx_compl_from_event + #define odp_packet_tx_compl_to_event __odp_packet_tx_compl_to_event #define odp_packet_free __odp_packet_free #define odp_packet_free_multi __odp_packet_free_multi #define odp_packet_free_sp __odp_packet_free_sp @@ -429,6 +431,16 @@ _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); } +_ODP_INLINE odp_packet_tx_compl_t odp_packet_tx_compl_from_event(odp_event_t ev) +{ + return (odp_packet_tx_compl_t)(uintptr_t)ev; +} + +_ODP_INLINE odp_event_t odp_packet_tx_compl_to_event(odp_packet_tx_compl_t tx_compl) +{ + return (odp_event_t)(uintptr_t)tx_compl; +} + _ODP_INLINE void odp_packet_free(odp_packet_t pkt) { rte_pktmbuf_free((struct rte_mbuf *)pkt); diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h index afca5c499..65a9cf543 100644 --- a/platform/linux-dpdk/include/odp_packet_internal.h +++ b/platform/linux-dpdk/include/odp_packet_internal.h @@ -124,7 +124,8 @@ typedef struct odp_packet_hdr_t { /* Timestamp value */ odp_time_t timestamp; - /* Classifier destination queue */ + /* Used as classifier destination queue, in IPsec inline input + * processing and as Tx completion event queue. */ odp_queue_t dst_queue; /* User area pointer */ diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h index afe275925..65c2fa166 100644 --- a/platform/linux-dpdk/include/odp_packet_io_internal.h +++ b/platform/linux-dpdk/include/odp_packet_io_internal.h @@ -226,6 +226,10 @@ typedef struct pktio_if_ops { const odp_pktout_queue_param_t *p); } pktio_if_ops_t; +typedef struct { + const void *user_ptr; +} _odp_pktio_tx_compl_t; + extern void *_odp_pktio_entry_ptr[]; static inline pktio_entry_t *get_pktio_entry(odp_pktio_t pktio) diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c index 57decc5b8..b7ebceb3c 100644 --- a/platform/linux-dpdk/odp_packet.c +++ b/platform/linux-dpdk/odp_packet.c @@ -5,6 +5,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include <odp/api/buffer.h> #include <odp/api/byteorder.h> #include <odp/api/hash.h> #include <odp/api/hints.h> @@ -26,6 +27,7 @@ #include <odp_event_internal.h> #include <odp_macros_internal.h> #include <odp_packet_internal.h> +#include <odp_packet_io_internal.h> #include <protocols/eth.h> #include <protocols/ip.h> @@ -2439,43 +2441,41 @@ uint64_t odp_packet_aging_tmo(odp_packet_t pkt) int odp_packet_tx_compl_request(odp_packet_t pkt, const odp_packet_tx_compl_opt_t *opt) { - (void)pkt; - (void)opt; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - return -1; -} - -int odp_packet_has_tx_compl_request(odp_packet_t pkt) -{ - (void)pkt; + pkt_hdr->p.flags.tx_compl = opt->mode == ODP_PACKET_TX_COMPL_ALL ? 1 : 0; + pkt_hdr->dst_queue = opt->queue; return 0; } -odp_packet_tx_compl_t odp_packet_tx_compl_from_event(odp_event_t ev) -{ - (void)ev; - - return ODP_PACKET_TX_COMPL_INVALID; -} - -odp_event_t odp_packet_tx_compl_to_event(odp_packet_tx_compl_t tx_compl) +int odp_packet_has_tx_compl_request(odp_packet_t pkt) { - (void)tx_compl; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - return ODP_EVENT_INVALID; + return pkt_hdr->p.flags.tx_compl; } void odp_packet_tx_compl_free(odp_packet_tx_compl_t tx_compl) { - (void)tx_compl; + if (odp_unlikely(tx_compl == ODP_PACKET_TX_COMPL_INVALID)) { + ODP_ERR("Bad TX completion event handle\n"); + return; + } + + odp_buffer_free((odp_buffer_t)tx_compl); } void *odp_packet_tx_compl_user_ptr(odp_packet_tx_compl_t tx_compl) { - (void)tx_compl; + if (odp_unlikely(tx_compl == ODP_PACKET_TX_COMPL_INVALID)) { + ODP_ERR("Bad TX completion event handle\n"); + return NULL; + } + + _odp_pktio_tx_compl_t *data = odp_buffer_addr((odp_buffer_t)tx_compl); - return NULL; + return (void *)(uintptr_t)data->user_ptr; } odp_packet_reass_status_t odp_packet_reass_status(odp_packet_t pkt) |