net/bnxt: handle multi queue mode properly

We are currently not handling multi queue RX/RSS modes correctly.
If RSS is not requested, create one VNIC per RXQ.

Fixes: 6133f20797 ("net/bnxt: add Rx queue create/destroy")
Cc: stable@dpdk.org

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
This commit is contained in:
Ajit Khaparde 2017-09-28 16:43:26 -05:00 committed by Ferruh Yigit
parent e28538f162
commit 4191bc8f79
2 changed files with 110 additions and 96 deletions

View File

@ -360,6 +360,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
{ {
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
uint16_t max_vnics, i, j, vpool, vrxq; uint16_t max_vnics, i, j, vpool, vrxq;
unsigned int max_rx_rings;
dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
@ -370,8 +371,12 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
/* PF/VF specifics */ /* PF/VF specifics */
if (BNXT_PF(bp)) if (BNXT_PF(bp))
dev_info->max_vfs = bp->pdev->max_vfs; dev_info->max_vfs = bp->pdev->max_vfs;
dev_info->max_rx_queues = bp->max_rx_rings; max_rx_rings = RTE_MIN(bp->max_vnics, RTE_MIN(bp->max_l2_ctx,
dev_info->max_tx_queues = bp->max_tx_rings; RTE_MIN(bp->max_rsscos_ctx,
bp->max_stat_ctx)));
/* For the sake of symmetry, max_rx_queues = max_tx_queues */
dev_info->max_rx_queues = max_rx_rings;
dev_info->max_tx_queues = max_rx_rings;
dev_info->reta_size = bp->max_rsscos_ctx; dev_info->reta_size = bp->max_rsscos_ctx;
max_vnics = bp->max_vnics; max_vnics = bp->max_vnics;
@ -827,7 +832,7 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
*/ */
if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) { if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
if (!rss_conf->rss_hf) if (!rss_conf->rss_hf)
return -EINVAL; RTE_LOG(ERR, PMD, "Hash type NONE\n");
} else { } else {
if (rss_conf->rss_hf & BNXT_ETH_RSS_SUPPORT) if (rss_conf->rss_hf & BNXT_ETH_RSS_SUPPORT)
return -EINVAL; return -EINVAL;

View File

@ -60,11 +60,13 @@ void bnxt_free_rxq_stats(struct bnxt_rx_queue *rxq)
int bnxt_mq_rx_configure(struct bnxt *bp) int bnxt_mq_rx_configure(struct bnxt *bp)
{ {
struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
unsigned int i, j, nb_q_per_grp, ring_idx; unsigned int i, j, nb_q_per_grp = 1, ring_idx = 0;
int start_grp_id, end_grp_id, rc = 0; int start_grp_id, end_grp_id = 1, rc = 0;
struct bnxt_vnic_info *vnic; struct bnxt_vnic_info *vnic;
struct bnxt_filter_info *filter; struct bnxt_filter_info *filter;
enum rte_eth_nb_pools pools = bp->rx_cp_nr_rings, max_pools = 0;
struct bnxt_rx_queue *rxq; struct bnxt_rx_queue *rxq;
bool rss_dflt_cr = false;
bp->nr_vnics = 0; bp->nr_vnics = 0;
@ -98,116 +100,123 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
} }
/* Multi-queue mode */ /* Multi-queue mode */
if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG) { if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_DCB_RSS) {
/* VMDq ONLY, VMDq+RSS, VMDq+DCB, VMDq+DCB+RSS */ /* VMDq ONLY, VMDq+RSS, VMDq+DCB, VMDq+DCB+RSS */
enum rte_eth_nb_pools pools; const struct rte_eth_vmdq_rx_conf *conf =
&dev_conf->rx_adv_conf.vmdq_rx_conf;
switch (dev_conf->rxmode.mq_mode) { switch (dev_conf->rxmode.mq_mode) {
case ETH_MQ_RX_VMDQ_RSS: case ETH_MQ_RX_VMDQ_RSS:
case ETH_MQ_RX_VMDQ_ONLY: case ETH_MQ_RX_VMDQ_ONLY:
{ /* ETH_8/64_POOLs */
const struct rte_eth_vmdq_rx_conf *conf = pools = conf->nb_queue_pools;
&dev_conf->rx_adv_conf.vmdq_rx_conf; /* For each pool, allocate MACVLAN CFA rule & VNIC */
max_pools = RTE_MIN(bp->max_vnics,
/* ETH_8/64_POOLs */ RTE_MIN(bp->max_l2_ctx,
pools = conf->nb_queue_pools; RTE_MIN(bp->max_rsscos_ctx,
break; ETH_64_POOLS)));
} if (pools > max_pools)
pools = max_pools;
break;
case ETH_MQ_RX_RSS:
pools = 1;
break;
default: default:
RTE_LOG(ERR, PMD, "Unsupported mq_mod %d\n", RTE_LOG(ERR, PMD, "Unsupported mq_mod %d\n",
dev_conf->rxmode.mq_mode); dev_conf->rxmode.mq_mode);
rc = -EINVAL; rc = -EINVAL;
goto err_out; goto err_out;
} }
/* For each pool, allocate MACVLAN CFA rule & VNIC */ }
if (!pools) { /*
pools = RTE_MIN(bp->max_vnics, * If MQ RX w/o RSS no need for per VNIC filter.
RTE_MIN(bp->max_l2_ctx, */
RTE_MIN(bp->max_rsscos_ctx, ETH_64_POOLS))); if ((dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_DCB) ||
RTE_LOG(ERR, PMD, (bp->rx_cp_nr_rings &&
"VMDq pool not set, defaulted to %d\n", pools); !(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS)))
rss_dflt_cr = true;
nb_q_per_grp = bp->rx_cp_nr_rings / pools;
start_grp_id = 0;
end_grp_id = nb_q_per_grp;
for (i = 0; i < pools; i++) {
vnic = bnxt_alloc_vnic(bp);
if (!vnic) {
RTE_LOG(ERR, PMD, "VNIC alloc failed\n");
rc = -ENOMEM;
goto err_out;
} }
nb_q_per_grp = bp->rx_cp_nr_rings / pools; vnic->flags |= BNXT_VNIC_INFO_BCAST;
start_grp_id = 0; STAILQ_INSERT_TAIL(&bp->ff_pool[i], vnic, next);
end_grp_id = nb_q_per_grp; bp->nr_vnics++;
ring_idx = 0; for (j = 0, ring_idx = 0; j < nb_q_per_grp; j++, ring_idx++) {
for (i = 0; i < pools; i++) { rxq = bp->eth_dev->data->rx_queues[ring_idx];
vnic = bnxt_alloc_vnic(bp); rxq->vnic = vnic;
if (!vnic) {
RTE_LOG(ERR, PMD,
"VNIC alloc failed\n");
rc = -ENOMEM;
goto err_out;
}
vnic->flags |= BNXT_VNIC_INFO_BCAST;
STAILQ_INSERT_TAIL(&bp->ff_pool[i], vnic, next);
bp->nr_vnics++;
for (j = 0; j < nb_q_per_grp; j++, ring_idx++) {
rxq = bp->eth_dev->data->rx_queues[ring_idx];
rxq->vnic = vnic;
}
if (i == 0)
vnic->func_default = true;
vnic->ff_pool_idx = i;
vnic->start_grp_id = start_grp_id;
vnic->end_grp_id = end_grp_id;
filter = bnxt_alloc_filter(bp);
if (!filter) {
RTE_LOG(ERR, PMD,
"L2 filter alloc failed\n");
rc = -ENOMEM;
goto err_out;
}
/*
* TODO: Configure & associate CFA rule for
* each VNIC for each VMDq with MACVLAN, MACVLAN+TC
*/
STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
start_grp_id = end_grp_id;
end_grp_id += nb_q_per_grp;
} }
goto out; if (i == 0)
} vnic->func_default = true;
vnic->ff_pool_idx = i;
vnic->start_grp_id = start_grp_id;
vnic->end_grp_id = end_grp_id;
/* Non-VMDq mode - RSS, DCB, RSS+DCB */ if (rss_dflt_cr && i) {
/* Init default VNIC for RSS or DCB only */ vnic->rss_dflt_cr = true;
vnic = bnxt_alloc_vnic(bp); goto skip_filter_allocation;
if (!vnic) { }
RTE_LOG(ERR, PMD, "VNIC alloc failed\n"); filter = bnxt_alloc_filter(bp);
rc = -ENOMEM; if (!filter) {
goto err_out; RTE_LOG(ERR, PMD, "L2 filter alloc failed\n");
} rc = -ENOMEM;
vnic->flags |= BNXT_VNIC_INFO_BCAST; goto err_out;
/* Partition the rx queues for the single pool */ }
for (i = 0; i < bp->rx_cp_nr_rings; i++) { /*
rxq = bp->eth_dev->data->rx_queues[i]; * TODO: Configure & associate CFA rule for
rxq->vnic = vnic; * each VNIC for each VMDq with MACVLAN, MACVLAN+TC
} */
STAILQ_INSERT_TAIL(&bp->ff_pool[0], vnic, next); STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
bp->nr_vnics++;
vnic->func_default = true; skip_filter_allocation:
vnic->ff_pool_idx = 0; start_grp_id = end_grp_id;
vnic->start_grp_id = 0; end_grp_id += nb_q_per_grp;
vnic->end_grp_id = bp->rx_cp_nr_rings;
filter = bnxt_alloc_filter(bp);
if (!filter) {
RTE_LOG(ERR, PMD, "L2 filter alloc failed\n");
rc = -ENOMEM;
goto err_out;
} }
STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
vnic->hash_type =
HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4 |
HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
out: out:
if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
struct rte_eth_rss_conf *rss = &dev_conf->rx_adv_conf.rss_conf;
uint16_t hash_type = 0;
if (rss->rss_hf & ETH_RSS_IPV4)
hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
if (rss->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4;
if (rss->rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4;
if (rss->rss_hf & ETH_RSS_IPV6)
hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6;
if (rss->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP)
hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6;
if (rss->rss_hf & ETH_RSS_NONFRAG_IPV6_UDP)
hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6;
for (i = 0; i < bp->nr_vnics; i++) {
STAILQ_FOREACH(vnic, &bp->ff_pool[i], next) {
vnic->hash_type |= hash_type;
/*
* Use the supplied key if the key length is
* acceptable and the rss_key is not NULL
*/
if (rss->rss_key &&
rss->rss_key_len <= HW_HASH_KEY_SIZE)
memcpy(vnic->rss_hash_key,
rss->rss_key, rss->rss_key_len);
}
}
}
return rc; return rc;
err_out: err_out: