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>
This commit is contained in:
parent
70418e322b
commit
1abc7209bb
@ -41,6 +41,7 @@ The public API headers are grouped by topics:
|
||||
[vhost] (@ref rte_vhost.h),
|
||||
[vdpa] (@ref rte_vdpa.h),
|
||||
[KNI] (@ref rte_kni.h),
|
||||
[ark] (@ref rte_pmd_ark.h),
|
||||
[ixgbe] (@ref rte_pmd_ixgbe.h),
|
||||
[i40e] (@ref rte_pmd_i40e.h),
|
||||
[ice] (@ref rte_pmd_ice.h),
|
||||
|
@ -8,6 +8,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \
|
||||
@TOPDIR@/drivers/bus/vdev \
|
||||
@TOPDIR@/drivers/crypto/scheduler \
|
||||
@TOPDIR@/drivers/mempool/dpaa2 \
|
||||
@TOPDIR@/drivers/net/ark \
|
||||
@TOPDIR@/drivers/net/bnxt \
|
||||
@TOPDIR@/drivers/net/bonding \
|
||||
@TOPDIR@/drivers/net/dpaa \
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <rte_ethdev_pci.h>
|
||||
#include <rte_kvargs.h>
|
||||
|
||||
#include "rte_pmd_ark.h"
|
||||
#include "ark_global.h"
|
||||
#include "ark_logs.h"
|
||||
#include "ark_ethdev_tx.h"
|
||||
@ -78,6 +79,9 @@ static int eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
|
||||
#define ARK_TX_MAX_QUEUE (4096 * 4)
|
||||
#define ARK_TX_MIN_QUEUE (256)
|
||||
|
||||
int rte_pmd_ark_rx_userdata_dynfield_offset = -1;
|
||||
int rte_pmd_ark_tx_userdata_dynfield_offset = -1;
|
||||
|
||||
static const char * const valid_arguments[] = {
|
||||
ARK_PKTGEN_ARG,
|
||||
ARK_PKTCHKR_ARG,
|
||||
@ -245,6 +249,16 @@ eth_ark_dev_init(struct rte_eth_dev *dev)
|
||||
int ret;
|
||||
int port_count = 1;
|
||||
int p;
|
||||
static const struct rte_mbuf_dynfield ark_tx_userdata_dynfield_desc = {
|
||||
.name = RTE_PMD_ARK_TX_USERDATA_DYNFIELD_NAME,
|
||||
.size = sizeof(rte_pmd_ark_tx_userdata_t),
|
||||
.align = __alignof__(rte_pmd_ark_tx_userdata_t),
|
||||
};
|
||||
static const struct rte_mbuf_dynfield ark_rx_userdata_dynfield_desc = {
|
||||
.name = RTE_PMD_ARK_RX_USERDATA_DYNFIELD_NAME,
|
||||
.size = sizeof(rte_pmd_ark_rx_userdata_t),
|
||||
.align = __alignof__(rte_pmd_ark_rx_userdata_t),
|
||||
};
|
||||
|
||||
ark->eth_dev = dev;
|
||||
|
||||
@ -254,6 +268,31 @@ eth_ark_dev_init(struct rte_eth_dev *dev)
|
||||
ret = check_for_ext(ark);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Extra mbuf fields for user data */
|
||||
if (RTE_PMD_ARK_TX_USERDATA_ENABLE) {
|
||||
rte_pmd_ark_tx_userdata_dynfield_offset =
|
||||
rte_mbuf_dynfield_register(&ark_tx_userdata_dynfield_desc);
|
||||
if (rte_pmd_ark_tx_userdata_dynfield_offset < 0) {
|
||||
ARK_PMD_LOG(ERR,
|
||||
"Failed to register mbuf field for tx userdata\n");
|
||||
return -rte_errno;
|
||||
}
|
||||
ARK_PMD_LOG(INFO, "Registered TX-meta dynamic field at %d\n",
|
||||
rte_pmd_ark_tx_userdata_dynfield_offset);
|
||||
}
|
||||
if (RTE_PMD_ARK_RX_USERDATA_ENABLE) {
|
||||
rte_pmd_ark_rx_userdata_dynfield_offset =
|
||||
rte_mbuf_dynfield_register(&ark_rx_userdata_dynfield_desc);
|
||||
if (rte_pmd_ark_rx_userdata_dynfield_offset < 0) {
|
||||
ARK_PMD_LOG(ERR,
|
||||
"Failed to register mbuf field for rx userdata\n");
|
||||
return -rte_errno;
|
||||
}
|
||||
ARK_PMD_LOG(INFO, "Registered RX-meta dynamic field at %d\n",
|
||||
rte_pmd_ark_rx_userdata_dynfield_offset);
|
||||
}
|
||||
|
||||
pci_dev = RTE_ETH_DEV_TO_PCI(dev);
|
||||
rte_eth_copy_pci_info(dev, pci_dev);
|
||||
dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "rte_pmd_ark.h"
|
||||
#include "ark_ethdev_rx.h"
|
||||
#include "ark_global.h"
|
||||
#include "ark_logs.h"
|
||||
@ -272,7 +273,7 @@ eth_ark_recv_pkts(void *rx_queue,
|
||||
mbuf->pkt_len = meta->pkt_len;
|
||||
mbuf->data_len = meta->pkt_len;
|
||||
mbuf->timestamp = meta->timestamp;
|
||||
mbuf->udata64 = meta->user_data;
|
||||
rte_pmd_ark_mbuf_rx_userdata_set(mbuf, meta->user_data);
|
||||
|
||||
if (ARK_DEBUG_CORE) { /* debug sanity checks */
|
||||
if ((meta->pkt_len > (1024 * 16)) ||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "rte_pmd_ark.h"
|
||||
#include "ark_ethdev_tx.h"
|
||||
#include "ark_global.h"
|
||||
#include "ark_mpu.h"
|
||||
@ -70,7 +71,7 @@ eth_ark_tx_meta_from_mbuf(struct ark_tx_meta *meta,
|
||||
uint8_t flags)
|
||||
{
|
||||
meta->physaddr = rte_mbuf_data_iova(mbuf);
|
||||
meta->user1 = (uint32_t)mbuf->udata64;
|
||||
meta->user1 = rte_pmd_ark_mbuf_tx_userdata_get(mbuf);
|
||||
meta->data_len = rte_pktmbuf_data_len(mbuf);
|
||||
meta->flags = flags;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright(c) 2018 Intel Corporation
|
||||
|
||||
headers = files('rte_pmd_ark.h')
|
||||
|
||||
sources = files('ark_ddm.c',
|
||||
'ark_ethdev.c',
|
||||
'ark_ethdev_rx.c',
|
||||
|
125
drivers/net/ark/rte_pmd_ark.h
Normal file
125
drivers/net/ark/rte_pmd_ark.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* 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 */
|
@ -1,3 +1,10 @@
|
||||
DPDK_21 {
|
||||
local: *;
|
||||
};
|
||||
|
||||
EXPERIMENTAL {
|
||||
global:
|
||||
|
||||
rte_pmd_ark_tx_userdata_dynfield_offset;
|
||||
rte_pmd_ark_rx_userdata_dynfield_offset;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user