dpdk: move port config to single struct
Type: refactor Change-Id: I0bce385c7e391fa2b74646d001980610f80f7062 Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:

committed by
Florin Coras

parent
fdc874af1e
commit
7c11bd7a87
@ -19,6 +19,7 @@ ForEachMacros:
|
||||
- 'vec_foreach_index_backwards'
|
||||
- 'vlib_foreach_rx_tx'
|
||||
- 'foreach_vlib_main'
|
||||
- 'RTE_ETH_FOREACH_DEV'
|
||||
|
||||
StatementMacros:
|
||||
- 'CLIB_MULTIARCH_FN'
|
||||
|
@ -302,18 +302,18 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
|
||||
hw = vnet_get_hw_interface (vnm, hw_if_index);
|
||||
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
|
||||
|
||||
if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) &&
|
||||
(nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc))
|
||||
if ((nb_rx_desc == (u32) ~0 || nb_rx_desc == xd->conf.n_rx_desc) &&
|
||||
(nb_tx_desc == (u32) ~0 || nb_tx_desc == xd->conf.n_tx_desc))
|
||||
{
|
||||
error = clib_error_return (0, "nothing changed");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (nb_rx_desc != (u32) ~ 0)
|
||||
xd->nb_rx_desc = nb_rx_desc;
|
||||
xd->conf.n_rx_desc = nb_rx_desc;
|
||||
|
||||
if (nb_tx_desc != (u32) ~ 0)
|
||||
xd->nb_tx_desc = nb_tx_desc;
|
||||
xd->conf.n_tx_desc = nb_tx_desc;
|
||||
|
||||
dpdk_device_setup (xd);
|
||||
|
||||
|
@ -89,8 +89,8 @@ dpdk_device_setup (dpdk_device_t * xd)
|
||||
xd->port_conf.rxmode.offloads ^= bitmap;
|
||||
}
|
||||
|
||||
rv = rte_eth_dev_configure (xd->port_id, xd->rx_q_used,
|
||||
xd->tx_q_used, &xd->port_conf);
|
||||
rv = rte_eth_dev_configure (xd->port_id, xd->conf.n_rx_queues,
|
||||
xd->conf.n_tx_queues, &xd->port_conf);
|
||||
|
||||
if (rv < 0)
|
||||
{
|
||||
@ -98,30 +98,28 @@ dpdk_device_setup (dpdk_device_t * xd)
|
||||
goto error;
|
||||
}
|
||||
|
||||
vec_validate_aligned (xd->tx_queues, xd->tx_q_used - 1,
|
||||
vec_validate_aligned (xd->tx_queues, xd->conf.n_tx_queues - 1,
|
||||
CLIB_CACHE_LINE_BYTES);
|
||||
for (j = 0; j < xd->tx_q_used; j++)
|
||||
for (j = 0; j < xd->conf.n_tx_queues; j++)
|
||||
{
|
||||
rv =
|
||||
rte_eth_tx_queue_setup (xd->port_id, j, xd->nb_tx_desc,
|
||||
xd->cpu_socket, &xd->tx_conf);
|
||||
rv = rte_eth_tx_queue_setup (xd->port_id, j, xd->conf.n_tx_desc,
|
||||
xd->cpu_socket, &xd->tx_conf);
|
||||
|
||||
/* retry with any other CPU socket */
|
||||
if (rv < 0)
|
||||
rv =
|
||||
rte_eth_tx_queue_setup (xd->port_id, j,
|
||||
xd->nb_tx_desc, SOCKET_ID_ANY,
|
||||
&xd->tx_conf);
|
||||
rv = rte_eth_tx_queue_setup (xd->port_id, j, xd->conf.n_tx_desc,
|
||||
SOCKET_ID_ANY, &xd->tx_conf);
|
||||
if (rv < 0)
|
||||
dpdk_device_error (xd, "rte_eth_tx_queue_setup", rv);
|
||||
|
||||
if (xd->tx_q_used < tm->n_vlib_mains)
|
||||
if (xd->conf.n_tx_queues < tm->n_vlib_mains)
|
||||
clib_spinlock_init (&vec_elt (xd->tx_queues, j).lock);
|
||||
}
|
||||
|
||||
vec_validate_aligned (xd->rx_queues, xd->rx_q_used - 1,
|
||||
vec_validate_aligned (xd->rx_queues, xd->conf.n_rx_queues - 1,
|
||||
CLIB_CACHE_LINE_BYTES);
|
||||
for (j = 0; j < xd->rx_q_used; j++)
|
||||
|
||||
for (j = 0; j < xd->conf.n_rx_queues; j++)
|
||||
{
|
||||
dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, j);
|
||||
u8 bpidx = vlib_buffer_pool_get_default_for_numa (
|
||||
@ -129,12 +127,12 @@ dpdk_device_setup (dpdk_device_t * xd)
|
||||
vlib_buffer_pool_t *bp = vlib_get_buffer_pool (vm, bpidx);
|
||||
struct rte_mempool *mp = dpdk_mempool_by_buffer_pool_index[bpidx];
|
||||
|
||||
rv = rte_eth_rx_queue_setup (xd->port_id, j, xd->nb_rx_desc,
|
||||
rv = rte_eth_rx_queue_setup (xd->port_id, j, xd->conf.n_rx_desc,
|
||||
xd->cpu_socket, 0, mp);
|
||||
|
||||
/* retry with any other CPU socket */
|
||||
if (rv < 0)
|
||||
rv = rte_eth_rx_queue_setup (xd->port_id, j, xd->nb_rx_desc,
|
||||
rv = rte_eth_rx_queue_setup (xd->port_id, j, xd->conf.n_rx_desc,
|
||||
SOCKET_ID_ANY, 0, mp);
|
||||
|
||||
rxq->buffer_pool_index = bp->index;
|
||||
@ -215,7 +213,7 @@ dpdk_setup_interrupts (dpdk_device_t *xd)
|
||||
if (xd->flags & DPDK_DEVICE_FLAG_INT_SUPPORTED)
|
||||
{
|
||||
hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
|
||||
for (int q = 0; q < xd->rx_q_used; q++)
|
||||
for (int q = 0; q < xd->conf.n_rx_queues; q++)
|
||||
{
|
||||
dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, q);
|
||||
clib_file_t f = { 0 };
|
||||
|
@ -164,7 +164,7 @@ static_always_inline
|
||||
int queue_id;
|
||||
|
||||
n_retry = 16;
|
||||
queue_id = vm->thread_index % xd->tx_q_used;
|
||||
queue_id = vm->thread_index % xd->conf.n_tx_queues;
|
||||
txq = vec_elt_at_index (xd->tx_queues, queue_id);
|
||||
|
||||
do
|
||||
|
@ -163,6 +163,25 @@ typedef struct
|
||||
clib_spinlock_t lock;
|
||||
} dpdk_tx_queue_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u16 no_multi_seg : 1;
|
||||
u16 enable_lro : 1;
|
||||
u16 enable_tcp_udp_checksum : 1;
|
||||
u16 enable_outer_checksum_offload : 1;
|
||||
u16 no_tx_checksum_offload : 1;
|
||||
u16 n_rx_queues;
|
||||
u16 n_tx_queues;
|
||||
u16 n_rx_desc;
|
||||
u16 n_tx_desc;
|
||||
};
|
||||
u64 as_u64[3];
|
||||
} dpdk_port_conf_t;
|
||||
|
||||
STATIC_ASSERT_SIZEOF (dpdk_port_conf_t, 24);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
|
||||
@ -180,8 +199,6 @@ typedef struct
|
||||
/* next node index if we decide to steal the rx graph arc */
|
||||
u32 per_interface_next_index;
|
||||
|
||||
u16 rx_q_used;
|
||||
u16 tx_q_used;
|
||||
u16 flags;
|
||||
|
||||
/* DPDK device port number */
|
||||
@ -190,8 +207,6 @@ typedef struct
|
||||
i8 cpu_socket;
|
||||
|
||||
CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
|
||||
u16 nb_tx_desc;
|
||||
u16 nb_rx_desc;
|
||||
|
||||
u8 *name;
|
||||
u8 *interface_name_suffix;
|
||||
@ -228,6 +243,7 @@ typedef struct
|
||||
|
||||
/* error string */
|
||||
clib_error_t *errors;
|
||||
dpdk_port_conf_t conf;
|
||||
} dpdk_device_t;
|
||||
|
||||
#define DPDK_STATS_POLL_INTERVAL (10.0)
|
||||
@ -282,11 +298,6 @@ typedef struct
|
||||
u8 **eal_init_args;
|
||||
u8 *eal_init_args_str;
|
||||
u8 *uio_driver_name;
|
||||
u8 no_multi_seg;
|
||||
u8 enable_lro;
|
||||
u8 enable_tcp_udp_checksum;
|
||||
u8 enable_outer_checksum_offload;
|
||||
u8 no_tx_checksum_offload;
|
||||
u8 enable_telemetry;
|
||||
u16 max_simd_bitwidth;
|
||||
|
||||
@ -345,6 +356,7 @@ typedef struct
|
||||
f64 stat_poll_interval;
|
||||
|
||||
dpdk_config_main_t *conf;
|
||||
dpdk_port_conf_t default_port_conf;
|
||||
|
||||
/* API message ID base */
|
||||
u16 msg_id_base;
|
||||
|
@ -578,16 +578,18 @@ format_dpdk_device (u8 * s, va_list * args)
|
||||
if (di.device->devargs && di.device->devargs->args)
|
||||
s = format (s, "%UDevargs: %s\n",
|
||||
format_white_space, indent + 2, di.device->devargs->args);
|
||||
s = format (s, "%Urx: queues %d (max %d), desc %d "
|
||||
s = format (s,
|
||||
"%Urx: queues %d (max %d), desc %d "
|
||||
"(min %d max %d align %d)\n",
|
||||
format_white_space, indent + 2, xd->rx_q_used, di.max_rx_queues,
|
||||
xd->nb_rx_desc, di.rx_desc_lim.nb_min, di.rx_desc_lim.nb_max,
|
||||
di.rx_desc_lim.nb_align);
|
||||
s = format (s, "%Utx: queues %d (max %d), desc %d "
|
||||
format_white_space, indent + 2, xd->conf.n_rx_queues,
|
||||
di.max_rx_queues, xd->conf.n_rx_desc, di.rx_desc_lim.nb_min,
|
||||
di.rx_desc_lim.nb_max, di.rx_desc_lim.nb_align);
|
||||
s = format (s,
|
||||
"%Utx: queues %d (max %d), desc %d "
|
||||
"(min %d max %d align %d)\n",
|
||||
format_white_space, indent + 2, xd->tx_q_used, di.max_tx_queues,
|
||||
xd->nb_tx_desc, di.tx_desc_lim.nb_min, di.tx_desc_lim.nb_max,
|
||||
di.tx_desc_lim.nb_align);
|
||||
format_white_space, indent + 2, xd->conf.n_tx_queues,
|
||||
di.max_tx_queues, xd->conf.n_tx_desc, di.tx_desc_lim.nb_min,
|
||||
di.tx_desc_lim.nb_max, di.tx_desc_lim.nb_align);
|
||||
|
||||
rss_conf.rss_key = 0;
|
||||
rss_conf.rss_hf = 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user