#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
-#include <sys/unistd.h>
+#include <unistd.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <ctype.h>
#include <getopt.h>
#include <signal.h>
-#include <rte_atomic.h>
#include <rte_common.h>
#include <rte_eal.h>
#include <rte_cycles.h>
#include <rte_lcore.h>
#include <rte_malloc.h>
#include <rte_mbuf.h>
+#include <rte_mbuf_dyn.h>
#include <rte_memory.h>
#include <rte_mempool.h>
#include <rte_log.h>
} \
} while (0)
+static int input_dynfield_offset = -1;
+
+static inline struct rte_mbuf **
+mbuf_input(struct rte_mbuf *mbuf)
+{
+ return RTE_MBUF_DYNFIELD(mbuf,
+ input_dynfield_offset, struct rte_mbuf **);
+}
+
static const struct rte_eth_conf port_conf = {
.rxmode = {
- .mq_mode = ETH_MQ_RX_NONE,
- .max_rx_pkt_len = RTE_ETHER_MAX_LEN,
+ .mq_mode = RTE_ETH_MQ_RX_NONE,
.split_hdr_size = 0,
},
.txmode = {
- .mq_mode = ETH_MQ_TX_NONE,
+ .mq_mode = RTE_ETH_MQ_TX_NONE,
},
};
.num_dec_cores = 1,
};
-static rte_atomic16_t global_exit_flag;
+static uint16_t global_exit_flag;
/* display usage */
static inline void
signal_handler(int signum)
{
printf("\nSignal %d received\n", signum);
- rte_atomic16_set(&global_exit_flag, 1);
+ __atomic_store_n(&global_exit_flag, 1, __ATOMIC_RELAXED);
}
static void
print_mac(unsigned int portid, struct rte_ether_addr *bbdev_ports_eth_address)
{
- printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
+ printf("Port %u, MAC address: " RTE_ETHER_ADDR_PRT_FMT "\n\n",
(unsigned int) portid,
- bbdev_ports_eth_address->addr_bytes[0],
- bbdev_ports_eth_address->addr_bytes[1],
- bbdev_ports_eth_address->addr_bytes[2],
- bbdev_ports_eth_address->addr_bytes[3],
- bbdev_ports_eth_address->addr_bytes[4],
- bbdev_ports_eth_address->addr_bytes[5]);
+ RTE_ETHER_ADDR_BYTES(bbdev_ports_eth_address));
}
static inline void
}
static inline void
-pktmbuf_userdata_free_bulk(struct rte_mbuf **mbufs, unsigned int nb_to_free)
+pktmbuf_input_free_bulk(struct rte_mbuf **mbufs, unsigned int nb_to_free)
{
unsigned int i;
for (i = 0; i < nb_to_free; ++i) {
- struct rte_mbuf *rx_pkt = mbufs[i]->userdata;
+ struct rte_mbuf *rx_pkt = *mbuf_input(mbufs[i]);
rte_pktmbuf_free(rx_pkt);
rte_pktmbuf_free(mbufs[i]);
}
fflush(stdout);
for (count = 0; count <= MAX_CHECK_TIME &&
- !rte_atomic16_read(&global_exit_flag); count++) {
+ !__atomic_load_n(&global_exit_flag, __ATOMIC_RELAXED); count++) {
memset(&link, 0, sizeof(link));
link_get_err = rte_eth_link_get_nowait(port_id, &link);
if (link_get_err >= 0 && link.link_status) {
const char *dp = (link.link_duplex ==
- ETH_LINK_FULL_DUPLEX) ?
+ RTE_ETH_LINK_FULL_DUPLEX) ?
"full-duplex" : "half-duplex";
printf("\nPort %u Link Up - speed %s - %s\n",
port_id,
/* Encoder output to Decoder input adapter. The Decoder accepts only soft input
* so each bit of the encoder output must be translated into one byte of LLR. If
* Sub-block Deinterleaver is bypassed, which is the case, the padding bytes
- * must additionally be insterted at the end of each sub-block.
+ * must additionally be inserted at the end of each sub-block.
*/
static inline void
transform_enc_out_dec_in(struct rte_mbuf **mbufs, uint8_t *temp_buf,
uint16_t i;
for (i = 0; i < num_pkts; ++i) {
struct rte_mbuf *out = mbufs[i];
- struct rte_mbuf *in = out->userdata;
+ struct rte_mbuf *in = *mbuf_input(out);
if (memcmp(rte_pktmbuf_mtod_offset(in, uint8_t *,
sizeof(struct rte_ether_hdr)),
{
struct stats_lcore_params *stats_lcore = arg;
- while (!rte_atomic16_read(&global_exit_flag)) {
+ while (!__atomic_load_n(&global_exit_flag, __ATOMIC_RELAXED)) {
print_stats(stats_lcore);
rte_delay_ms(500);
}
rte_pktmbuf_data_len(rx_pkts_burst[i]) -
sizeof(struct rte_ether_hdr);
/* save input mbuf pointer for later comparison */
- enc_out_pkts[i]->userdata = rx_pkts_burst[i];
+ *mbuf_input(enc_out_pkts[i]) = rx_pkts_burst[i];
/* copy ethernet header */
rte_pktmbuf_reset(enc_out_pkts[i]);
nb_enq = rte_bbdev_enqueue_enc_ops(bbdev_id, enc_queue_id,
bbdev_ops_burst, nb_rx);
if (unlikely(nb_enq < nb_rx)) {
- pktmbuf_userdata_free_bulk(&enc_out_pkts[nb_enq],
+ pktmbuf_input_free_bulk(&enc_out_pkts[nb_enq],
nb_rx - nb_enq);
rte_bbdev_enc_op_free_bulk(&bbdev_ops_burst[nb_enq],
nb_rx - nb_enq);
nb_sent = rte_ring_enqueue_burst(enc_to_dec_ring, (void **)enc_out_pkts,
nb_deq, NULL);
if (unlikely(nb_sent < nb_deq)) {
- pktmbuf_userdata_free_bulk(&enc_out_pkts[nb_sent],
+ pktmbuf_input_free_bulk(&enc_out_pkts[nb_sent],
nb_deq - nb_sent);
lcore_stats->enc_to_dec_lost_packets += nb_deq - nb_sent;
}
if (unlikely(rte_bbdev_dec_op_alloc_bulk(bbdev_op_pool, bbdev_ops_burst,
nb_recv) != 0)) {
- pktmbuf_userdata_free_bulk(recv_pkts_burst, nb_recv);
+ pktmbuf_input_free_bulk(recv_pkts_burst, nb_recv);
lcore_stats->rx_lost_packets += nb_recv;
return;
}
nb_enq = rte_bbdev_enqueue_dec_ops(bbdev_id, bbdev_queue_id,
bbdev_ops_burst, nb_recv);
if (unlikely(nb_enq < nb_recv)) {
- pktmbuf_userdata_free_bulk(&recv_pkts_burst[nb_enq],
+ pktmbuf_input_free_bulk(&recv_pkts_burst[nb_enq],
nb_recv - nb_enq);
rte_bbdev_dec_op_free_bulk(&bbdev_ops_burst[nb_enq],
nb_recv - nb_enq);
/* Free the RX mbufs after verification */
for (i = 0; i < nb_deq; ++i)
- rte_pktmbuf_free(recv_pkts_burst[i]->userdata);
+ rte_pktmbuf_free(*mbuf_input(recv_pkts_burst[i]));
/* Transmit the packets */
nb_tx = rte_eth_tx_burst(port_id, tx_queue_id, recv_pkts_burst, nb_deq);
if (unlikely(nb_tx < nb_deq)) {
- pktmbuf_userdata_free_bulk(&recv_pkts_burst[nb_tx],
+ pktmbuf_input_free_bulk(&recv_pkts_burst[nb_tx],
nb_deq - nb_tx);
lcore_stats->tx_lost_packets += nb_deq - nb_tx;
}
const bool run_decoder = (lcore_conf->core_type &
(1 << RTE_BBDEV_OP_TURBO_DEC));
- while (!rte_atomic16_read(&global_exit_flag)) {
+ while (!__atomic_load_n(&global_exit_flag, __ATOMIC_RELAXED)) {
if (run_encoder)
run_encoding(lcore_conf);
if (run_decoder)
bool stats_thread_started = false;
unsigned int main_lcore_id = rte_get_main_lcore();
- rte_atomic16_init(&global_exit_flag);
+ static const struct rte_mbuf_dynfield input_dynfield_desc = {
+ .name = "example_bbdev_dynfield_input",
+ .size = sizeof(struct rte_mbuf *),
+ .align = __alignof__(struct rte_mbuf *),
+ };
+
+ __atomic_store_n(&global_exit_flag, 0, __ATOMIC_RELAXED);
sigret = signal(SIGTERM, signal_handler);
if (sigret == SIG_ERR)
if (bbdev_mbuf_mempool == NULL)
rte_exit(EXIT_FAILURE, "Cannot create ethdev mbuf mempool\n");
+ /* register mbuf field to store input pointer */
+ input_dynfield_offset =
+ rte_mbuf_dynfield_register(&input_dynfield_desc);
+ if (input_dynfield_offset < 0)
+ rte_exit(EXIT_FAILURE, "Cannot register mbuf field\n");
+
/* initialize ports */
ret = initialize_ports(&app_params, ethdev_mbuf_mempool);
ret |= rte_eal_wait_lcore(lcore_id);
}
+ /* clean up the EAL */
+ rte_eal_cleanup();
+
return ret;
}