2018-01-29 13:11:30 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright 2015 6WIND S.A.
|
2018-03-20 19:20:35 +00:00
|
|
|
* Copyright 2015 Mellanox Technologies, Ltd
|
2015-10-30 18:52:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2020-06-10 09:32:29 +00:00
|
|
|
#include <stdint.h>
|
2015-10-30 18:52:30 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <rte_atomic.h>
|
2018-01-22 00:16:22 +00:00
|
|
|
#include <rte_ethdev_driver.h>
|
2017-10-26 10:06:08 +00:00
|
|
|
#include <rte_bus_pci.h>
|
2015-10-30 18:52:30 +00:00
|
|
|
#include <rte_mbuf.h>
|
|
|
|
#include <rte_common.h>
|
2015-10-30 18:57:23 +00:00
|
|
|
#include <rte_interrupts.h>
|
2016-03-17 15:38:55 +00:00
|
|
|
#include <rte_malloc.h>
|
2018-03-12 11:33:00 +00:00
|
|
|
#include <rte_string_fns.h>
|
net/mlx5: add new memory region support
This is the new design of Memory Region (MR) for mlx PMD, in order to:
- Accommodate the new memory hotplug model.
- Support non-contiguous Mempool.
There are multiple layers for MR search.
L0 is to look up the last-hit entry which is pointed by mr_ctrl->mru (Most
Recently Used). If L0 misses, L1 is to look up the address in a fixed-sized
array by linear search. L0/L1 is in an inline function -
mlx5_mr_lookup_cache().
If L1 misses, the bottom-half function is called to look up the address
from the bigger local cache of the queue. This is L2 - mlx5_mr_addr2mr_bh()
and it is not an inline function. Data structure for L2 is the Binary Tree.
If L2 misses, the search falls into the slowest path which takes locks in
order to access global device cache (priv->mr.cache) which is also a B-tree
and caches the original MR list (priv->mr.mr_list) of the device. Unless
the global cache is overflowed, it is all-inclusive of the MR list. This is
L3 - mlx5_mr_lookup_dev(). The size of the L3 cache table is limited and
can't be expanded on the fly due to deadlock. Refer to the comments in the
code for the details - mr_lookup_dev(). If L3 is overflowed, the list will
have to be searched directly bypassing the cache although it is slower.
If L3 misses, a new MR for the address should be created -
mlx5_mr_create(). When it creates a new MR, it tries to register adjacent
memsegs as much as possible which are virtually contiguous around the
address. This must take two locks - memory_hotplug_lock and
priv->mr.rwlock. Due to memory_hotplug_lock, there can't be any
allocation/free of memory inside.
In the free callback of the memory hotplug event, freed space is searched
from the MR list and corresponding bits are cleared from the bitmap of MRs.
This can fragment a MR and the MR will have multiple search entries in the
caches. Once there's a change by the event, the global cache must be
rebuilt and all the per-queue caches will be flushed as well. If memory is
frequently freed in run-time, that may cause jitter on dataplane processing
in the worst case by incurring MR cache flush and rebuild. But, it would be
the least probable scenario.
To guarantee the most optimal performance, it is highly recommended to use
an EAL option - '--socket-mem'. Then, the reserved memory will be pinned
and won't be freed dynamically. And it is also recommended to configure
per-lcore cache of Mempool. Even though there're many MRs for a device or
MRs are highly fragmented, the cache of Mempool will be much helpful to
reduce misses on per-queue caches anyway.
'--legacy-mem' is also supported.
Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
2018-05-09 11:09:04 +00:00
|
|
|
#include <rte_rwlock.h>
|
2019-05-27 04:58:32 +00:00
|
|
|
#include <rte_cycles.h>
|
2015-10-30 18:52:30 +00:00
|
|
|
|
2020-06-28 07:35:26 +00:00
|
|
|
#include <mlx5_malloc.h>
|
|
|
|
|
2015-10-30 18:52:33 +00:00
|
|
|
#include "mlx5_rxtx.h"
|
2020-06-10 09:32:29 +00:00
|
|
|
#include "mlx5_autoconf.h"
|
2018-07-10 16:04:54 +00:00
|
|
|
|
2018-04-05 15:07:19 +00:00
|
|
|
/**
|
|
|
|
* Get the interface index from device name.
|
|
|
|
*
|
|
|
|
* @param[in] dev
|
|
|
|
* Pointer to Ethernet device.
|
|
|
|
*
|
|
|
|
* @return
|
2018-07-25 11:24:33 +00:00
|
|
|
* Nonzero interface index on success, zero otherwise and rte_errno is set.
|
2018-04-05 15:07:19 +00:00
|
|
|
*/
|
2018-07-25 11:24:33 +00:00
|
|
|
unsigned int
|
2018-04-05 15:07:19 +00:00
|
|
|
mlx5_ifindex(const struct rte_eth_dev *dev)
|
|
|
|
{
|
2019-07-21 14:56:40 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-07-25 11:24:33 +00:00
|
|
|
unsigned int ifindex;
|
2018-04-05 15:07:19 +00:00
|
|
|
|
2020-01-30 16:14:40 +00:00
|
|
|
MLX5_ASSERT(priv);
|
|
|
|
MLX5_ASSERT(priv->if_index);
|
2019-07-21 14:56:40 +00:00
|
|
|
ifindex = priv->if_index;
|
2018-07-25 11:24:33 +00:00
|
|
|
if (!ifindex)
|
2019-07-21 14:56:40 +00:00
|
|
|
rte_errno = ENXIO;
|
2018-07-25 11:24:33 +00:00
|
|
|
return ifindex;
|
2018-04-05 15:07:19 +00:00
|
|
|
}
|
|
|
|
|
2015-10-30 18:52:33 +00:00
|
|
|
/**
|
2018-03-05 12:21:03 +00:00
|
|
|
* DPDK callback for Ethernet device configuration.
|
2015-10-30 18:52:33 +00:00
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
|
|
|
*
|
|
|
|
* @return
|
2018-03-05 12:21:06 +00:00
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
2015-10-30 18:52:33 +00:00
|
|
|
*/
|
2018-03-05 12:21:03 +00:00
|
|
|
int
|
|
|
|
mlx5_dev_configure(struct rte_eth_dev *dev)
|
2015-10-30 18:52:33 +00:00
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2015-10-30 18:52:33 +00:00
|
|
|
unsigned int rxqs_n = dev->data->nb_rx_queues;
|
|
|
|
unsigned int txqs_n = dev->data->nb_tx_queues;
|
2017-10-09 14:44:56 +00:00
|
|
|
const uint8_t use_app_rss_key =
|
2017-12-26 07:40:41 +00:00
|
|
|
!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
|
2018-03-05 12:21:06 +00:00
|
|
|
int ret = 0;
|
2018-01-10 09:17:00 +00:00
|
|
|
|
2017-10-09 14:44:56 +00:00
|
|
|
if (use_app_rss_key &&
|
|
|
|
(dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
|
2018-07-12 09:30:59 +00:00
|
|
|
MLX5_RSS_HASH_KEY_LEN)) {
|
|
|
|
DRV_LOG(ERR, "port %u RSS key len must be %s Bytes long",
|
|
|
|
dev->data->port_id, RTE_STR(MLX5_RSS_HASH_KEY_LEN));
|
2018-03-05 12:21:06 +00:00
|
|
|
rte_errno = EINVAL;
|
|
|
|
return -rte_errno;
|
2017-10-09 14:44:56 +00:00
|
|
|
}
|
|
|
|
priv->rss_conf.rss_key =
|
2020-06-28 07:35:26 +00:00
|
|
|
mlx5_realloc(priv->rss_conf.rss_key, MLX5_MEM_RTE,
|
|
|
|
MLX5_RSS_HASH_KEY_LEN, 0, SOCKET_ID_ANY);
|
2017-10-09 14:44:56 +00:00
|
|
|
if (!priv->rss_conf.rss_key) {
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(ERR, "port %u cannot allocate RSS hash key memory (%u)",
|
|
|
|
dev->data->port_id, rxqs_n);
|
2018-03-05 12:21:06 +00:00
|
|
|
rte_errno = ENOMEM;
|
|
|
|
return -rte_errno;
|
2017-10-09 14:44:56 +00:00
|
|
|
}
|
2019-11-11 13:19:08 +00:00
|
|
|
|
2019-11-14 16:40:50 +00:00
|
|
|
if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
|
|
|
|
dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
|
2019-11-11 13:19:08 +00:00
|
|
|
|
2017-10-09 14:44:56 +00:00
|
|
|
memcpy(priv->rss_conf.rss_key,
|
|
|
|
use_app_rss_key ?
|
|
|
|
dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key :
|
|
|
|
rss_hash_default_key,
|
2018-07-12 09:30:59 +00:00
|
|
|
MLX5_RSS_HASH_KEY_LEN);
|
|
|
|
priv->rss_conf.rss_key_len = MLX5_RSS_HASH_KEY_LEN;
|
2017-10-09 14:44:56 +00:00
|
|
|
priv->rss_conf.rss_hf = dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf;
|
2015-10-30 18:52:33 +00:00
|
|
|
priv->rxqs = (void *)dev->data->rx_queues;
|
|
|
|
priv->txqs = (void *)dev->data->tx_queues;
|
|
|
|
if (txqs_n != priv->txqs_n) {
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(INFO, "port %u Tx queues number update: %u -> %u",
|
|
|
|
dev->data->port_id, priv->txqs_n, txqs_n);
|
2015-10-30 18:52:33 +00:00
|
|
|
priv->txqs_n = txqs_n;
|
|
|
|
}
|
2018-01-10 09:16:58 +00:00
|
|
|
if (rxqs_n > priv->config.ind_table_max_size) {
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(ERR, "port %u cannot handle this many Rx queues (%u)",
|
|
|
|
dev->data->port_id, rxqs_n);
|
2018-03-05 12:21:06 +00:00
|
|
|
rte_errno = EINVAL;
|
|
|
|
return -rte_errno;
|
2015-11-02 18:11:57 +00:00
|
|
|
}
|
2019-05-05 11:44:24 +00:00
|
|
|
if (rxqs_n != priv->rxqs_n) {
|
|
|
|
DRV_LOG(INFO, "port %u Rx queues number update: %u -> %u",
|
|
|
|
dev->data->port_id, priv->rxqs_n, rxqs_n);
|
|
|
|
priv->rxqs_n = rxqs_n;
|
2015-11-02 18:11:57 +00:00
|
|
|
}
|
2019-10-30 23:53:19 +00:00
|
|
|
priv->skip_default_rss_reta = 0;
|
2019-04-10 18:41:17 +00:00
|
|
|
ret = mlx5_proc_priv_init(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-10-30 18:55:06 +00:00
|
|
|
return 0;
|
2015-10-30 18:52:33 +00:00
|
|
|
}
|
|
|
|
|
2019-10-30 23:53:19 +00:00
|
|
|
/**
|
|
|
|
* Configure default RSS reta.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
|
|
|
unsigned int rxqs_n = dev->data->nb_rx_queues;
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int j;
|
|
|
|
unsigned int reta_idx_n;
|
|
|
|
int ret = 0;
|
|
|
|
unsigned int *rss_queue_arr = NULL;
|
|
|
|
unsigned int rss_queue_n = 0;
|
|
|
|
|
|
|
|
if (priv->skip_default_rss_reta)
|
|
|
|
return ret;
|
2020-06-28 07:35:26 +00:00
|
|
|
rss_queue_arr = mlx5_malloc(0, rxqs_n * sizeof(unsigned int), 0,
|
|
|
|
SOCKET_ID_ANY);
|
2019-10-30 23:53:19 +00:00
|
|
|
if (!rss_queue_arr) {
|
|
|
|
DRV_LOG(ERR, "port %u cannot allocate RSS queue list (%u)",
|
|
|
|
dev->data->port_id, rxqs_n);
|
|
|
|
rte_errno = ENOMEM;
|
|
|
|
return -rte_errno;
|
|
|
|
}
|
|
|
|
for (i = 0, j = 0; i < rxqs_n; i++) {
|
|
|
|
struct mlx5_rxq_data *rxq_data;
|
|
|
|
struct mlx5_rxq_ctrl *rxq_ctrl;
|
|
|
|
|
|
|
|
rxq_data = (*priv->rxqs)[i];
|
|
|
|
rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
|
2019-11-27 14:18:41 +00:00
|
|
|
if (rxq_ctrl && rxq_ctrl->type == MLX5_RXQ_TYPE_STANDARD)
|
2019-10-30 23:53:19 +00:00
|
|
|
rss_queue_arr[j++] = i;
|
|
|
|
}
|
|
|
|
rss_queue_n = j;
|
|
|
|
if (rss_queue_n > priv->config.ind_table_max_size) {
|
|
|
|
DRV_LOG(ERR, "port %u cannot handle this many Rx queues (%u)",
|
|
|
|
dev->data->port_id, rss_queue_n);
|
|
|
|
rte_errno = EINVAL;
|
2020-06-28 07:35:26 +00:00
|
|
|
mlx5_free(rss_queue_arr);
|
2019-10-30 23:53:19 +00:00
|
|
|
return -rte_errno;
|
|
|
|
}
|
|
|
|
DRV_LOG(INFO, "port %u Rx queues number update: %u -> %u",
|
|
|
|
dev->data->port_id, priv->rxqs_n, rxqs_n);
|
|
|
|
priv->rxqs_n = rxqs_n;
|
|
|
|
/*
|
|
|
|
* If the requested number of RX queues is not a power of two,
|
|
|
|
* use the maximum indirection table size for better balancing.
|
|
|
|
* The result is always rounded to the next power of two.
|
|
|
|
*/
|
|
|
|
reta_idx_n = (1 << log2above((rss_queue_n & (rss_queue_n - 1)) ?
|
|
|
|
priv->config.ind_table_max_size :
|
|
|
|
rss_queue_n));
|
|
|
|
ret = mlx5_rss_reta_index_resize(dev, reta_idx_n);
|
|
|
|
if (ret) {
|
2020-06-28 07:35:26 +00:00
|
|
|
mlx5_free(rss_queue_arr);
|
2019-10-30 23:53:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* When the number of RX queues is not a power of two,
|
|
|
|
* the remaining table entries are padded with reused WQs
|
|
|
|
* and hashes are not spread uniformly.
|
|
|
|
*/
|
|
|
|
for (i = 0, j = 0; (i != reta_idx_n); ++i) {
|
|
|
|
(*priv->reta_idx)[i] = rss_queue_arr[j];
|
|
|
|
if (++j == rss_queue_n)
|
|
|
|
j = 0;
|
|
|
|
}
|
2020-06-28 07:35:26 +00:00
|
|
|
mlx5_free(rss_queue_arr);
|
2019-10-30 23:53:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-05-01 09:58:49 +00:00
|
|
|
/**
|
|
|
|
* Sets default tuning parameters.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device.
|
|
|
|
* @param[out] info
|
|
|
|
* Info structure output buffer.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
mlx5_set_default_params(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
|
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-05-01 09:58:49 +00:00
|
|
|
|
|
|
|
/* Minimum CPU utilization. */
|
|
|
|
info->default_rxportconf.ring_size = 256;
|
|
|
|
info->default_txportconf.ring_size = 256;
|
2019-11-15 11:35:06 +00:00
|
|
|
info->default_rxportconf.burst_size = MLX5_RX_DEFAULT_BURST;
|
|
|
|
info->default_txportconf.burst_size = MLX5_TX_DEFAULT_BURST;
|
2020-05-06 12:22:08 +00:00
|
|
|
if ((priv->link_speed_capa & ETH_LINK_SPEED_200G) |
|
|
|
|
(priv->link_speed_capa & ETH_LINK_SPEED_100G)) {
|
2018-05-01 09:58:49 +00:00
|
|
|
info->default_rxportconf.nb_queues = 16;
|
|
|
|
info->default_txportconf.nb_queues = 16;
|
|
|
|
if (dev->data->nb_rx_queues > 2 ||
|
|
|
|
dev->data->nb_tx_queues > 2) {
|
|
|
|
/* Max Throughput. */
|
|
|
|
info->default_rxportconf.ring_size = 2048;
|
|
|
|
info->default_txportconf.ring_size = 2048;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
info->default_rxportconf.nb_queues = 8;
|
|
|
|
info->default_txportconf.nb_queues = 8;
|
|
|
|
if (dev->data->nb_rx_queues > 2 ||
|
|
|
|
dev->data->nb_tx_queues > 2) {
|
|
|
|
/* Max Throughput. */
|
|
|
|
info->default_rxportconf.ring_size = 4096;
|
|
|
|
info->default_txportconf.ring_size = 4096;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-21 14:25:00 +00:00
|
|
|
/**
|
|
|
|
* Sets tx mbuf limiting parameters.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device.
|
|
|
|
* @param[out] info
|
|
|
|
* Info structure output buffer.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
mlx5_set_txlimit_params(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
|
|
|
|
{
|
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
|
|
|
struct mlx5_dev_config *config = &priv->config;
|
|
|
|
unsigned int inlen;
|
|
|
|
uint16_t nb_max;
|
|
|
|
|
|
|
|
inlen = (config->txq_inline_max == MLX5_ARG_UNSET) ?
|
|
|
|
MLX5_SEND_DEF_INLINE_LEN :
|
|
|
|
(unsigned int)config->txq_inline_max;
|
2020-01-30 16:14:40 +00:00
|
|
|
MLX5_ASSERT(config->txq_inline_min >= 0);
|
2019-07-21 14:25:00 +00:00
|
|
|
inlen = RTE_MAX(inlen, (unsigned int)config->txq_inline_min);
|
|
|
|
inlen = RTE_MIN(inlen, MLX5_WQE_SIZE_MAX +
|
|
|
|
MLX5_ESEG_MIN_INLINE_SIZE -
|
|
|
|
MLX5_WQE_CSEG_SIZE -
|
|
|
|
MLX5_WQE_ESEG_SIZE -
|
|
|
|
MLX5_WQE_DSEG_SIZE * 2);
|
|
|
|
nb_max = (MLX5_WQE_SIZE_MAX +
|
|
|
|
MLX5_ESEG_MIN_INLINE_SIZE -
|
|
|
|
MLX5_WQE_CSEG_SIZE -
|
|
|
|
MLX5_WQE_ESEG_SIZE -
|
|
|
|
MLX5_WQE_DSEG_SIZE -
|
|
|
|
inlen) / MLX5_WSEG_SIZE;
|
|
|
|
info->tx_desc_lim.nb_seg_max = nb_max;
|
|
|
|
info->tx_desc_lim.nb_mtu_seg_max = nb_max;
|
|
|
|
}
|
|
|
|
|
2015-10-30 18:52:33 +00:00
|
|
|
/**
|
|
|
|
* DPDK callback to get information about the device.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
|
|
|
* @param[out] info
|
|
|
|
* Info structure output buffer.
|
|
|
|
*/
|
2019-09-12 16:42:28 +00:00
|
|
|
int
|
2015-10-30 18:52:33 +00:00
|
|
|
mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
|
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-01-10 09:16:58 +00:00
|
|
|
struct mlx5_dev_config *config = &priv->config;
|
2015-10-30 18:52:33 +00:00
|
|
|
unsigned int max;
|
|
|
|
|
|
|
|
/* FIXME: we should ask the device for these values. */
|
|
|
|
info->min_rx_bufsize = 32;
|
|
|
|
info->max_rx_pktlen = 65536;
|
2019-11-11 17:47:34 +00:00
|
|
|
info->max_lro_pkt_size = MLX5_MAX_LRO_SIZE;
|
2015-10-30 18:52:33 +00:00
|
|
|
/*
|
|
|
|
* Since we need one CQ per QP, the limit is the minimum number
|
|
|
|
* between the two values.
|
|
|
|
*/
|
2020-06-03 15:05:58 +00:00
|
|
|
max = RTE_MIN(priv->sh->device_attr.max_cq,
|
|
|
|
priv->sh->device_attr.max_qp);
|
2020-02-09 21:17:25 +00:00
|
|
|
/* max_rx_queues is uint16_t. */
|
|
|
|
max = RTE_MIN(max, (unsigned int)UINT16_MAX);
|
2015-10-30 18:52:33 +00:00
|
|
|
info->max_rx_queues = max;
|
|
|
|
info->max_tx_queues = max;
|
2018-04-23 11:09:27 +00:00
|
|
|
info->max_mac_addrs = MLX5_MAX_UC_MAC_ADDRESSES;
|
2018-03-05 12:21:04 +00:00
|
|
|
info->rx_queue_offload_capa = mlx5_get_rx_queue_offloads(dev);
|
2019-07-29 11:53:29 +00:00
|
|
|
info->rx_offload_capa = (mlx5_get_rx_port_offloads() |
|
2018-01-10 09:17:01 +00:00
|
|
|
info->rx_queue_offload_capa);
|
2018-03-05 12:21:04 +00:00
|
|
|
info->tx_offload_capa = mlx5_get_tx_port_offloads(dev);
|
2019-07-21 14:56:40 +00:00
|
|
|
info->if_index = mlx5_ifindex(dev);
|
2017-03-20 23:04:34 +00:00
|
|
|
info->reta_size = priv->reta_idx_n ?
|
2018-01-10 09:16:58 +00:00
|
|
|
priv->reta_idx_n : config->ind_table_max_size;
|
2018-07-12 09:30:59 +00:00
|
|
|
info->hash_key_size = MLX5_RSS_HASH_KEY_LEN;
|
2016-10-26 09:44:01 +00:00
|
|
|
info->speed_capa = priv->link_speed_capa;
|
2018-01-22 20:52:14 +00:00
|
|
|
info->flow_type_rss_offloads = ~MLX5_RSS_HF_MASK;
|
2018-05-01 09:58:49 +00:00
|
|
|
mlx5_set_default_params(dev, info);
|
2019-07-21 14:25:00 +00:00
|
|
|
mlx5_set_txlimit_params(dev, info);
|
2018-07-10 16:04:54 +00:00
|
|
|
info->switch_info.name = dev->data->name;
|
|
|
|
info->switch_info.domain_id = priv->domain_id;
|
|
|
|
info->switch_info.port_id = priv->representor_id;
|
|
|
|
if (priv->representor) {
|
2019-09-25 07:53:33 +00:00
|
|
|
uint16_t port_id;
|
2018-07-10 16:04:54 +00:00
|
|
|
|
2019-09-25 07:53:34 +00:00
|
|
|
if (priv->pf_bond >= 0) {
|
|
|
|
/*
|
|
|
|
* Switch port ID is opaque value with driver defined
|
|
|
|
* format. Push the PF index in bonding configurations
|
|
|
|
* in upper four bits of port ID. If we get too many
|
|
|
|
* representors (more than 4K) or PFs (more than 15)
|
|
|
|
* this approach must be reconsidered.
|
|
|
|
*/
|
|
|
|
if ((info->switch_info.port_id >>
|
|
|
|
MLX5_PORT_ID_BONDING_PF_SHIFT) ||
|
|
|
|
priv->pf_bond > MLX5_PORT_ID_BONDING_PF_MASK) {
|
|
|
|
DRV_LOG(ERR, "can't update switch port ID"
|
|
|
|
" for bonding device");
|
2020-01-30 16:14:40 +00:00
|
|
|
MLX5_ASSERT(false);
|
2019-09-25 07:53:34 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
info->switch_info.port_id |=
|
|
|
|
priv->pf_bond << MLX5_PORT_ID_BONDING_PF_SHIFT;
|
|
|
|
}
|
2019-10-07 13:56:19 +00:00
|
|
|
MLX5_ETH_FOREACH_DEV(port_id, priv->pci_dev) {
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *opriv =
|
2019-09-25 07:53:33 +00:00
|
|
|
rte_eth_devices[port_id].data->dev_private;
|
2018-07-10 16:04:54 +00:00
|
|
|
|
|
|
|
if (!opriv ||
|
|
|
|
opriv->representor ||
|
2019-09-25 07:53:33 +00:00
|
|
|
opriv->sh != priv->sh ||
|
2018-07-10 16:04:54 +00:00
|
|
|
opriv->domain_id != priv->domain_id)
|
|
|
|
continue;
|
|
|
|
/*
|
|
|
|
* Override switch name with that of the master
|
|
|
|
* device.
|
|
|
|
*/
|
|
|
|
info->switch_info.name = opriv->dev_data->name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-09-12 16:42:28 +00:00
|
|
|
return 0;
|
2015-10-30 18:52:33 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 22:25:19 +00:00
|
|
|
/**
|
|
|
|
* Get firmware version of a device.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Ethernet device port.
|
|
|
|
* @param fw_ver
|
|
|
|
* String output allocated by caller.
|
|
|
|
* @param fw_size
|
|
|
|
* Size of the output string, including terminating null byte.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 0 on success, or the size of the non truncated string if too big.
|
|
|
|
*/
|
2020-06-10 09:32:29 +00:00
|
|
|
int
|
|
|
|
mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
|
2019-02-06 22:25:19 +00:00
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2020-06-03 15:05:58 +00:00
|
|
|
struct mlx5_dev_attr *attr = &priv->sh->device_attr;
|
2019-02-06 22:25:19 +00:00
|
|
|
size_t size = strnlen(attr->fw_ver, sizeof(attr->fw_ver)) + 1;
|
|
|
|
|
|
|
|
if (fw_size < size)
|
|
|
|
return size;
|
|
|
|
if (fw_ver != NULL)
|
|
|
|
strlcpy(fw_ver, attr->fw_ver, fw_size);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-05 12:21:01 +00:00
|
|
|
/**
|
|
|
|
* Get supported packet types.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* A pointer to the supported Packet types array.
|
|
|
|
*/
|
2016-03-14 20:50:50 +00:00
|
|
|
const uint32_t *
|
|
|
|
mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
static const uint32_t ptypes[] = {
|
|
|
|
/* refers to rxq_cq_to_pkt_type() */
|
2017-07-26 19:29:33 +00:00
|
|
|
RTE_PTYPE_L2_ETHER,
|
2017-02-24 09:16:56 +00:00
|
|
|
RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
|
|
|
|
RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
|
2017-07-26 19:29:33 +00:00
|
|
|
RTE_PTYPE_L4_NONFRAG,
|
|
|
|
RTE_PTYPE_L4_FRAG,
|
|
|
|
RTE_PTYPE_L4_TCP,
|
|
|
|
RTE_PTYPE_L4_UDP,
|
2017-02-24 09:16:56 +00:00
|
|
|
RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
|
|
|
|
RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
|
2017-07-26 19:29:33 +00:00
|
|
|
RTE_PTYPE_INNER_L4_NONFRAG,
|
|
|
|
RTE_PTYPE_INNER_L4_FRAG,
|
|
|
|
RTE_PTYPE_INNER_L4_TCP,
|
|
|
|
RTE_PTYPE_INNER_L4_UDP,
|
2016-03-14 20:50:50 +00:00
|
|
|
RTE_PTYPE_UNKNOWN
|
|
|
|
};
|
|
|
|
|
2017-07-06 18:41:10 +00:00
|
|
|
if (dev->rx_pkt_burst == mlx5_rx_burst ||
|
2018-05-09 11:13:50 +00:00
|
|
|
dev->rx_pkt_burst == mlx5_rx_burst_mprq ||
|
2017-07-06 18:41:10 +00:00
|
|
|
dev->rx_pkt_burst == mlx5_rx_burst_vec)
|
2016-03-14 20:50:50 +00:00
|
|
|
return ptypes;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-10-30 18:52:35 +00:00
|
|
|
/**
|
|
|
|
* DPDK callback to change the MTU.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
|
|
|
* @param in_mtu
|
|
|
|
* New MTU.
|
|
|
|
*
|
|
|
|
* @return
|
2018-03-05 12:21:06 +00:00
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
2015-10-30 18:52:35 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
|
|
|
|
{
|
2019-02-21 09:29:14 +00:00
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
2018-03-05 12:21:06 +00:00
|
|
|
uint16_t kern_mtu = 0;
|
|
|
|
int ret;
|
2015-10-30 18:52:35 +00:00
|
|
|
|
2018-03-05 12:21:04 +00:00
|
|
|
ret = mlx5_get_mtu(dev, &kern_mtu);
|
2017-08-03 09:31:27 +00:00
|
|
|
if (ret)
|
2018-03-05 12:21:06 +00:00
|
|
|
return ret;
|
2015-10-30 18:52:35 +00:00
|
|
|
/* Set kernel interface MTU first. */
|
2018-03-05 12:21:04 +00:00
|
|
|
ret = mlx5_set_mtu(dev, mtu);
|
2017-08-03 09:31:27 +00:00
|
|
|
if (ret)
|
2018-03-05 12:21:06 +00:00
|
|
|
return ret;
|
2018-03-05 12:21:04 +00:00
|
|
|
ret = mlx5_get_mtu(dev, &kern_mtu);
|
2017-08-03 09:31:27 +00:00
|
|
|
if (ret)
|
2018-03-05 12:21:06 +00:00
|
|
|
return ret;
|
2017-08-03 09:31:27 +00:00
|
|
|
if (kern_mtu == mtu) {
|
|
|
|
priv->mtu = mtu;
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(DEBUG, "port %u adapter MTU set to %u",
|
|
|
|
dev->data->port_id, mtu);
|
2018-03-05 12:21:06 +00:00
|
|
|
return 0;
|
2015-10-30 18:52:35 +00:00
|
|
|
}
|
2018-03-05 12:21:06 +00:00
|
|
|
rte_errno = EAGAIN;
|
|
|
|
return -rte_errno;
|
2015-10-30 18:52:35 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 13:17:51 +00:00
|
|
|
/**
|
|
|
|
* Configure the RX function to use.
|
|
|
|
*
|
2017-10-06 15:45:48 +00:00
|
|
|
* @param dev
|
2018-03-05 12:21:04 +00:00
|
|
|
* Pointer to private data structure.
|
2018-01-10 09:16:57 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Pointer to selected Rx burst function.
|
2016-06-24 13:17:51 +00:00
|
|
|
*/
|
2018-01-10 09:16:57 +00:00
|
|
|
eth_rx_burst_t
|
2018-03-05 12:21:04 +00:00
|
|
|
mlx5_select_rx_function(struct rte_eth_dev *dev)
|
2016-06-24 13:17:51 +00:00
|
|
|
{
|
2018-01-10 09:16:57 +00:00
|
|
|
eth_rx_burst_t rx_pkt_burst = mlx5_rx_burst;
|
|
|
|
|
2020-01-30 16:14:40 +00:00
|
|
|
MLX5_ASSERT(dev != NULL);
|
2018-03-05 12:21:04 +00:00
|
|
|
if (mlx5_check_vec_rx_support(dev) > 0) {
|
2018-01-10 09:16:57 +00:00
|
|
|
rx_pkt_burst = mlx5_rx_burst_vec;
|
2018-03-13 09:23:56 +00:00
|
|
|
DRV_LOG(DEBUG, "port %u selected Rx vectorized function",
|
|
|
|
dev->data->port_id);
|
2018-05-09 11:13:50 +00:00
|
|
|
} else if (mlx5_mprq_enabled(dev)) {
|
|
|
|
rx_pkt_burst = mlx5_rx_burst_mprq;
|
2017-07-06 18:41:10 +00:00
|
|
|
}
|
2018-01-10 09:16:57 +00:00
|
|
|
return rx_pkt_burst;
|
2016-06-24 13:17:51 +00:00
|
|
|
}
|
2018-01-20 21:12:21 +00:00
|
|
|
|
2019-04-18 13:16:02 +00:00
|
|
|
/**
|
2019-09-25 07:53:31 +00:00
|
|
|
* Get the E-Switch parameters by port id.
|
2019-04-18 13:16:02 +00:00
|
|
|
*
|
|
|
|
* @param[in] port
|
|
|
|
* Device port id.
|
2019-11-07 17:09:53 +00:00
|
|
|
* @param[in] valid
|
|
|
|
* Device port id is valid, skip check. This flag is useful
|
|
|
|
* when trials are performed from probing and device is not
|
|
|
|
* flagged as valid yet (in attaching process).
|
2019-04-18 13:16:02 +00:00
|
|
|
* @param[out] es_domain_id
|
|
|
|
* E-Switch domain id.
|
|
|
|
* @param[out] es_port_id
|
|
|
|
* The port id of the port in the E-Switch.
|
|
|
|
*
|
|
|
|
* @return
|
2019-09-25 07:53:31 +00:00
|
|
|
* pointer to device private data structure containing data needed
|
|
|
|
* on success, NULL otherwise and rte_errno is set.
|
2019-04-18 13:16:02 +00:00
|
|
|
*/
|
2019-09-25 07:53:31 +00:00
|
|
|
struct mlx5_priv *
|
2019-11-07 17:09:53 +00:00
|
|
|
mlx5_port_to_eswitch_info(uint16_t port, bool valid)
|
2019-04-18 13:16:02 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct mlx5_priv *priv;
|
|
|
|
|
|
|
|
if (port >= RTE_MAX_ETHPORTS) {
|
|
|
|
rte_errno = EINVAL;
|
2019-09-25 07:53:31 +00:00
|
|
|
return NULL;
|
2019-04-18 13:16:02 +00:00
|
|
|
}
|
2019-11-07 17:09:53 +00:00
|
|
|
if (!valid && !rte_eth_dev_is_valid_port(port)) {
|
2019-04-18 13:16:02 +00:00
|
|
|
rte_errno = ENODEV;
|
2019-09-25 07:53:31 +00:00
|
|
|
return NULL;
|
2019-04-18 13:16:02 +00:00
|
|
|
}
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
priv = dev->data->dev_private;
|
|
|
|
if (!(priv->representor || priv->master)) {
|
|
|
|
rte_errno = EINVAL;
|
2019-09-25 07:53:31 +00:00
|
|
|
return NULL;
|
2019-04-18 13:16:02 +00:00
|
|
|
}
|
2019-09-25 07:53:31 +00:00
|
|
|
return priv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the E-Switch parameters by device instance.
|
|
|
|
*
|
|
|
|
* @param[in] port
|
|
|
|
* Device port id.
|
|
|
|
* @param[out] es_domain_id
|
|
|
|
* E-Switch domain id.
|
|
|
|
* @param[out] es_port_id
|
|
|
|
* The port id of the port in the E-Switch.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* pointer to device private data structure containing data needed
|
|
|
|
* on success, NULL otherwise and rte_errno is set.
|
|
|
|
*/
|
|
|
|
struct mlx5_priv *
|
|
|
|
mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct mlx5_priv *priv;
|
|
|
|
|
|
|
|
priv = dev->data->dev_private;
|
|
|
|
if (!(priv->representor || priv->master)) {
|
|
|
|
rte_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return priv;
|
2019-04-18 13:16:02 +00:00
|
|
|
}
|
|
|
|
|
2019-10-30 23:53:16 +00:00
|
|
|
/**
|
|
|
|
* DPDK callback to retrieve hairpin capabilities.
|
|
|
|
*
|
|
|
|
* @param dev
|
|
|
|
* Pointer to Ethernet device structure.
|
|
|
|
* @param[out] cap
|
|
|
|
* Storage for hairpin capability data.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 0 on success, a negative errno value otherwise and rte_errno is set.
|
|
|
|
*/
|
2020-06-10 09:32:29 +00:00
|
|
|
int
|
|
|
|
mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
|
2019-10-30 23:53:16 +00:00
|
|
|
struct rte_eth_hairpin_cap *cap)
|
|
|
|
{
|
|
|
|
struct mlx5_priv *priv = dev->data->dev_private;
|
|
|
|
|
|
|
|
if (priv->sh->devx == 0) {
|
|
|
|
rte_errno = ENOTSUP;
|
|
|
|
return -rte_errno;
|
|
|
|
}
|
|
|
|
cap->max_nb_queues = UINT16_MAX;
|
|
|
|
cap->max_rx_2_tx = 1;
|
|
|
|
cap->max_tx_2_rx = 1;
|
|
|
|
cap->max_nb_desc = 8192;
|
|
|
|
return 0;
|
|
|
|
}
|