numam-dpdk/drivers/net/ark/rte_pmd_ark.h
Ed Czeck 1abc7209bb net/ark: switch user data to dynamic mbuf fields
The second field of metadata is reserved for user data
which was using a deprecated mbuf field.
It is moved to dynamic fields in order to allow removal of udata64.

The use of meta data must be enabled with a compile-time flag
RTE_PMD_ARK_{TX,RX}_USERDATA_ENABLE.
User data on Tx and Rx paths can be defined and used separately.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Ed Czeck <ed.czeck@atomicrules.com>
2020-10-31 16:13:11 +01:00

126 lines
2.8 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2020 Atomic Rules LLC
*/
#ifndef RTE_PMD_ARK_H
#define RTE_PMD_ARK_H
/**
* @file
* ARK driver-specific API
*/
#include <rte_mbuf.h>
#include <rte_mbuf_dyn.h>
#ifndef RTE_PMD_ARK_TX_USERDATA_ENABLE
#define RTE_PMD_ARK_TX_USERDATA_ENABLE 0
#endif
#ifndef RTE_PMD_ARK_RX_USERDATA_ENABLE
#define RTE_PMD_ARK_RX_USERDATA_ENABLE 0
#endif
typedef uint32_t rte_pmd_ark_tx_userdata_t;
typedef uint64_t rte_pmd_ark_rx_userdata_t;
extern int rte_pmd_ark_tx_userdata_dynfield_offset;
extern int rte_pmd_ark_rx_userdata_dynfield_offset;
/** mbuf dynamic field for custom Tx ARK data */
#define RTE_PMD_ARK_TX_USERDATA_DYNFIELD_NAME "rte_net_ark_dynfield_tx_userdata"
/** mbuf dynamic field for custom Rx ARK data */
#define RTE_PMD_ARK_RX_USERDATA_DYNFIELD_NAME "rte_net_ark_dynfield_rx_userdata"
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
* Read Tx user data from mbuf.
*
* @param mbuf Structure to read from.
* @return user data
*/
__rte_experimental
static inline rte_pmd_ark_tx_userdata_t
rte_pmd_ark_mbuf_tx_userdata_get(const struct rte_mbuf *mbuf)
{
#if RTE_PMD_ARK_TX_USERDATA_ENABLE
return *RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_tx_userdata_dynfield_offset,
rte_pmd_ark_tx_userdata_t *);
#else
RTE_SET_USED(mbuf);
return 0;
#endif
}
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
* Write Tx user data to mbuf.
*
* @param mbuf Structure to write into.
* @param data User data.
*/
__rte_experimental
static inline void
rte_pmd_ark_mbuf_tx_userdata_set(struct rte_mbuf *mbuf,
rte_pmd_ark_tx_userdata_t data)
{
#if RTE_PMD_ARK_TX_USERDATA_ENABLE
*RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_tx_userdata_dynfield_offset,
rte_pmd_ark_tx_userdata_t *) = data;
#else
RTE_SET_USED(mbuf);
RTE_SET_USED(data);
#endif
}
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
* Read Rx user data from mbuf.
*
* @param mbuf Structure to read from.
* @return user data
*/
__rte_experimental
static inline rte_pmd_ark_rx_userdata_t
rte_pmd_ark_mbuf_rx_userdata_get(const struct rte_mbuf *mbuf)
{
#if RTE_PMD_ARK_RX_USERDATA_ENABLE
return *RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_rx_userdata_dynfield_offset,
rte_pmd_ark_rx_userdata_t *);
#else
RTE_SET_USED(mbuf);
return 0;
#endif
}
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
* Write Rx user data to mbuf.
*
* @param mbuf Structure to write into.
* @param data User data.
*/
__rte_experimental
static inline void
rte_pmd_ark_mbuf_rx_userdata_set(struct rte_mbuf *mbuf,
rte_pmd_ark_rx_userdata_t data)
{
#if RTE_PMD_ARK_RX_USERDATA_ENABLE
*RTE_MBUF_DYNFIELD(mbuf, rte_pmd_ark_rx_userdata_dynfield_offset,
rte_pmd_ark_rx_userdata_t *) = data;
#else
RTE_SET_USED(mbuf);
RTE_SET_USED(data);
#endif
}
#endif /* RTE_PMD_ARK_H */