Skip to content

Commit

Permalink
net/bnxt: use dedicated CPR for async events
Browse files Browse the repository at this point in the history
This commit enables the creation of a dedicated completion
ring for asynchronous event handling instead of handling these
events on a receive completion ring.

For the stingray platform and other platforms needing tighter
control of resource utilization, we retain the ability to
process async events on a receive completion ring.

For Thor-based adapters, we use a dedicated NQ (notification
queue) ring for async events (async events can't currently
be received on a completion ring due to a firmware limitation).

Rename "def_cp_ring" to "async_cp_ring" to better reflect its
purpose (async event notifications) and to avoid confusion with
VNIC default receive completion rings.

Allow rxq 0 to be stopped when not being used for async events.

Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
  • Loading branch information
Lance Richardson authored and Ferruh Yigit committed Jul 25, 2019
1 parent 0270853 commit bd0a14c
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 56 deletions.
10 changes: 9 additions & 1 deletion drivers/net/bnxt/bnxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
#define BNXT_MAX_RX_RING_DESC 8192
#define BNXT_DB_SIZE 0x80

#ifdef RTE_ARCH_ARM64
#define BNXT_NUM_ASYNC_CPR(bp) (BNXT_STINGRAY(bp) ? 0 : 1)
#else
#define BNXT_NUM_ASYNC_CPR(bp) 1
#endif

/* Chimp Communication Channel */
#define GRCPF_REG_CHIMP_CHANNEL_OFFSET 0x0
#define GRCPF_REG_CHIMP_COMM_TRIGGER 0x100
Expand Down Expand Up @@ -351,6 +357,7 @@ struct bnxt {
#define BNXT_FLAG_TRUSTED_VF_EN (1 << 11)
#define BNXT_FLAG_DFLT_VNIC_SET (1 << 12)
#define BNXT_FLAG_THOR_CHIP (1 << 13)
#define BNXT_FLAG_STINGRAY (1 << 14)
#define BNXT_FLAG_EXT_STATS_SUPPORTED (1 << 29)
#define BNXT_FLAG_NEW_RM (1 << 30)
#define BNXT_FLAG_INIT_DONE (1U << 31)
Expand All @@ -363,6 +370,7 @@ struct bnxt {
#define BNXT_USE_KONG(bp) ((bp)->flags & BNXT_FLAG_KONG_MB_EN)
#define BNXT_VF_IS_TRUSTED(bp) ((bp)->flags & BNXT_FLAG_TRUSTED_VF_EN)
#define BNXT_CHIP_THOR(bp) ((bp)->flags & BNXT_FLAG_THOR_CHIP)
#define BNXT_STINGRAY(bp) ((bp)->flags & BNXT_FLAG_STINGRAY)
#define BNXT_HAS_NQ(bp) BNXT_CHIP_THOR(bp)
#define BNXT_HAS_RING_GRPS(bp) (!BNXT_CHIP_THOR(bp))

Expand All @@ -387,7 +395,7 @@ struct bnxt {
uint16_t fw_tx_port_stats_ext_size;

/* Default completion ring */
struct bnxt_cp_ring_info *def_cp_ring;
struct bnxt_cp_ring_info *async_cp_ring;
uint32_t max_ring_grps;
struct bnxt_ring_grp_info *grp_info;

Expand Down
19 changes: 17 additions & 2 deletions drivers/net/bnxt/bnxt_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,17 @@ static void bnxt_free_mem(struct bnxt *bp)
bnxt_free_stats(bp);
bnxt_free_tx_rings(bp);
bnxt_free_rx_rings(bp);
bnxt_free_async_cp_ring(bp);
}

static int bnxt_alloc_mem(struct bnxt *bp)
{
int rc;

rc = bnxt_alloc_async_ring_struct(bp);
if (rc)
goto alloc_mem_err;

rc = bnxt_alloc_vnic_mem(bp);
if (rc)
goto alloc_mem_err;
Expand All @@ -218,6 +223,10 @@ static int bnxt_alloc_mem(struct bnxt *bp)
if (rc)
goto alloc_mem_err;

rc = bnxt_alloc_async_cp_ring(bp);
if (rc)
goto alloc_mem_err;

return 0;

alloc_mem_err:
Expand Down Expand Up @@ -617,8 +626,8 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
/* Inherit new configurations */
if (eth_dev->data->nb_rx_queues > bp->max_rx_rings ||
eth_dev->data->nb_tx_queues > bp->max_tx_rings ||
eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues >
bp->max_cp_rings ||
eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues
+ BNXT_NUM_ASYNC_CPR(bp) > bp->max_cp_rings ||
eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues >
bp->max_stat_ctx)
goto resource_error;
Expand Down Expand Up @@ -3802,6 +3811,12 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
pci_dev->id.device_id == BROADCOM_DEV_ID_57500_VF2)
bp->flags |= BNXT_FLAG_THOR_CHIP;

if (pci_dev->id.device_id == BROADCOM_DEV_ID_58802 ||
pci_dev->id.device_id == BROADCOM_DEV_ID_58804 ||
pci_dev->id.device_id == BROADCOM_DEV_ID_58808 ||
pci_dev->id.device_id == BROADCOM_DEV_ID_58802_VF)
bp->flags |= BNXT_FLAG_STINGRAY;

rc = bnxt_init_board(eth_dev);
if (rc) {
PMD_DRV_LOG(ERR,
Expand Down
16 changes: 10 additions & 6 deletions drivers/net/bnxt/bnxt_hwrm.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,12 @@ int bnxt_hwrm_func_reserve_vf_resc(struct bnxt *bp, bool test)
req.num_tx_rings = rte_cpu_to_le_16(bp->tx_nr_rings);
req.num_rx_rings = rte_cpu_to_le_16(bp->rx_nr_rings *
AGG_RING_MULTIPLIER);
req.num_stat_ctxs = rte_cpu_to_le_16(bp->rx_nr_rings + bp->tx_nr_rings);
req.num_stat_ctxs = rte_cpu_to_le_16(bp->rx_nr_rings +
bp->tx_nr_rings +
BNXT_NUM_ASYNC_CPR(bp));
req.num_cmpl_rings = rte_cpu_to_le_16(bp->rx_nr_rings +
bp->tx_nr_rings);
bp->tx_nr_rings +
BNXT_NUM_ASYNC_CPR(bp));
req.num_vnics = rte_cpu_to_le_16(bp->rx_nr_rings);
if (bp->vf_resv_strategy ==
HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC) {
Expand Down Expand Up @@ -2073,7 +2076,7 @@ int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
return rc;
}

static void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
{
struct bnxt_ring *cp_ring = cpr->cp_ring_struct;

Expand All @@ -2083,9 +2086,10 @@ static void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
sizeof(*cpr->cp_desc_ring));
cpr->cp_raw_cons = 0;
cpr->valid = 0;
}

static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
{
struct bnxt_ring *cp_ring = cpr->cp_ring_struct;

Expand Down Expand Up @@ -3212,7 +3216,7 @@ int bnxt_hwrm_func_cfg_def_cp(struct bnxt *bp)
req.enables = rte_cpu_to_le_32(
HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
req.async_event_cr = rte_cpu_to_le_16(
bp->def_cp_ring->cp_ring_struct->fw_ring_id);
bp->async_cp_ring->cp_ring_struct->fw_ring_id);
rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);

HWRM_CHECK_RESULT();
Expand All @@ -3232,7 +3236,7 @@ int bnxt_hwrm_vf_func_cfg_def_cp(struct bnxt *bp)
req.enables = rte_cpu_to_le_32(
HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
req.async_event_cr = rte_cpu_to_le_16(
bp->def_cp_ring->cp_ring_struct->fw_ring_id);
bp->async_cp_ring->cp_ring_struct->fw_ring_id);
rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);

HWRM_CHECK_RESULT();
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/bnxt/bnxt_hwrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp);
int bnxt_free_all_hwrm_rings(struct bnxt *bp);
int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp);
int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp);
void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr);
void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr);
int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic);
int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic);
void bnxt_free_all_hwrm_resources(struct bnxt *bp);
Expand Down
44 changes: 30 additions & 14 deletions drivers/net/bnxt/bnxt_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void bnxt_int_handler(void *param)
{
struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;
struct bnxt *bp = eth_dev->data->dev_private;
struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
struct cmpl_base *cmp;
uint32_t raw_cons;
uint32_t cons;
Expand All @@ -43,10 +43,13 @@ static void bnxt_int_handler(void *param)

bnxt_event_hwrm_resp_handler(bp, cmp);
raw_cons = NEXT_RAW_CMP(raw_cons);
};
}

cpr->cp_raw_cons = raw_cons;
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
if (BNXT_HAS_NQ(bp))
bnxt_db_nq_arm(cpr);
else
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
}

int bnxt_free_int(struct bnxt *bp)
Expand Down Expand Up @@ -92,27 +95,43 @@ int bnxt_free_int(struct bnxt *bp)

void bnxt_disable_int(struct bnxt *bp)
{
struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;

if (BNXT_NUM_ASYNC_CPR(bp) == 0)
return;

if (!cpr || !cpr->cp_db.doorbell)
return;

/* Only the default completion ring */
if (cpr != NULL && cpr->cp_db.doorbell != NULL)
if (BNXT_HAS_NQ(bp))
bnxt_db_nq(cpr);
else
B_CP_DB_DISARM(cpr);
}

void bnxt_enable_int(struct bnxt *bp)
{
struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;

if (BNXT_NUM_ASYNC_CPR(bp) == 0)
return;

if (!cpr || !cpr->cp_db.doorbell)
return;

/* Only the default completion ring */
if (cpr != NULL && cpr->cp_db.doorbell != NULL)
if (BNXT_HAS_NQ(bp))
bnxt_db_nq_arm(cpr);
else
B_CP_DB_ARM(cpr);
}

int bnxt_setup_int(struct bnxt *bp)
{
uint16_t total_vecs;
const int len = sizeof(bp->irq_tbl[0].name);
int i, rc = 0;
int i;

/* DPDK host only supports 1 MSI-X vector */
total_vecs = 1;
Expand All @@ -126,14 +145,11 @@ int bnxt_setup_int(struct bnxt *bp)
bp->irq_tbl[i].handler = bnxt_int_handler;
}
} else {
rc = -ENOMEM;
goto setup_exit;
PMD_DRV_LOG(ERR, "bnxt_irq_tbl setup failed\n");
return -ENOMEM;
}
return 0;

setup_exit:
PMD_DRV_LOG(ERR, "bnxt_irq_tbl setup failed\n");
return rc;
return 0;
}

int bnxt_request_int(struct bnxt *bp)
Expand Down
Loading

0 comments on commit bd0a14c

Please sign in to comment.