Skip to content

Commit e4060d3

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Reserve RDMA resources by default.
If the device supports RDMA, we'll setup network default rings so that there are enough minimum resources for RDMA, if possible. However, the user can still increase network rings to the max if he wants. The actual RDMA resources won't be reserved until the RDMA driver registers. v2: Fix compile warning when BNXT_CONFIG_SRIOV is not set. Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7b08f66 commit e4060d3

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4166,6 +4166,11 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
41664166
if (rc)
41674167
goto hwrm_func_qcaps_exit;
41684168

4169+
if (resp->flags & cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_ROCE_V1_SUPPORTED))
4170+
bp->flags |= BNXT_FLAG_ROCEV1_CAP;
4171+
if (resp->flags & cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_ROCE_V2_SUPPORTED))
4172+
bp->flags |= BNXT_FLAG_ROCEV2_CAP;
4173+
41694174
bp->tx_push_thresh = 0;
41704175
if (resp->flags &
41714176
cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED))
@@ -4808,6 +4813,24 @@ static int bnxt_setup_int_mode(struct bnxt *bp)
48084813
return rc;
48094814
}
48104815

4816+
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp)
4817+
{
4818+
#if defined(CONFIG_BNXT_SRIOV)
4819+
if (BNXT_VF(bp))
4820+
return bp->vf.max_stat_ctxs;
4821+
#endif
4822+
return bp->pf.max_stat_ctxs;
4823+
}
4824+
4825+
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp)
4826+
{
4827+
#if defined(CONFIG_BNXT_SRIOV)
4828+
if (BNXT_VF(bp))
4829+
return bp->vf.max_cp_rings;
4830+
#endif
4831+
return bp->pf.max_cp_rings;
4832+
}
4833+
48114834
static unsigned int bnxt_get_max_func_irqs(struct bnxt *bp)
48124835
{
48134836
#if defined(CONFIG_BNXT_SRIOV)
@@ -6832,6 +6855,39 @@ int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared)
68326855
return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared);
68336856
}
68346857

6858+
static int bnxt_get_dflt_rings(struct bnxt *bp, int *max_rx, int *max_tx,
6859+
bool shared)
6860+
{
6861+
int rc;
6862+
6863+
rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared);
6864+
if (rc)
6865+
return rc;
6866+
6867+
if (bp->flags & BNXT_FLAG_ROCE_CAP) {
6868+
int max_cp, max_stat, max_irq;
6869+
6870+
/* Reserve minimum resources for RoCE */
6871+
max_cp = bnxt_get_max_func_cp_rings(bp);
6872+
max_stat = bnxt_get_max_func_stat_ctxs(bp);
6873+
max_irq = bnxt_get_max_func_irqs(bp);
6874+
if (max_cp <= BNXT_MIN_ROCE_CP_RINGS ||
6875+
max_irq <= BNXT_MIN_ROCE_CP_RINGS ||
6876+
max_stat <= BNXT_MIN_ROCE_STAT_CTXS)
6877+
return 0;
6878+
6879+
max_cp -= BNXT_MIN_ROCE_CP_RINGS;
6880+
max_irq -= BNXT_MIN_ROCE_CP_RINGS;
6881+
max_stat -= BNXT_MIN_ROCE_STAT_CTXS;
6882+
max_cp = min_t(int, max_cp, max_irq);
6883+
max_cp = min_t(int, max_cp, max_stat);
6884+
rc = bnxt_trim_rings(bp, max_rx, max_tx, max_cp, shared);
6885+
if (rc)
6886+
rc = 0;
6887+
}
6888+
return rc;
6889+
}
6890+
68356891
static int bnxt_set_dflt_rings(struct bnxt *bp)
68366892
{
68376893
int dflt_rings, max_rx_rings, max_tx_rings, rc;
@@ -6840,7 +6896,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp)
68406896
if (sh)
68416897
bp->flags |= BNXT_FLAG_SHARED_RINGS;
68426898
dflt_rings = netif_get_num_default_rss_queues();
6843-
rc = bnxt_get_max_rings(bp, &max_rx_rings, &max_tx_rings, sh);
6899+
rc = bnxt_get_dflt_rings(bp, &max_rx_rings, &max_tx_rings, sh);
68446900
if (rc)
68456901
return rc;
68466902
bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ struct rx_tpa_end_cmp_ext {
387387
#define DB_KEY_TX_PUSH (0x4 << 28)
388388
#define DB_LONG_TX_PUSH (0x2 << 24)
389389

390+
#define BNXT_MIN_ROCE_CP_RINGS 2
391+
#define BNXT_MIN_ROCE_STAT_CTXS 1
392+
390393
#define INVALID_HW_RING_ID ((u16)-1)
391394

392395
/* The hardware supports certain page sizes. Use the supported page sizes
@@ -953,6 +956,10 @@ struct bnxt {
953956
#define BNXT_FLAG_PORT_STATS 0x400
954957
#define BNXT_FLAG_UDP_RSS_CAP 0x800
955958
#define BNXT_FLAG_EEE_CAP 0x1000
959+
#define BNXT_FLAG_ROCEV1_CAP 0x8000
960+
#define BNXT_FLAG_ROCEV2_CAP 0x10000
961+
#define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \
962+
BNXT_FLAG_ROCEV2_CAP)
956963
#define BNXT_FLAG_CHIP_NITRO_A0 0x1000000
957964

958965
#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
@@ -1234,6 +1241,8 @@ int _hwrm_send_message(struct bnxt *, void *, u32, int);
12341241
int hwrm_send_message(struct bnxt *, void *, u32, int);
12351242
int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
12361243
int bnxt_hwrm_set_coal(struct bnxt *);
1244+
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
1245+
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
12371246
void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max);
12381247
void bnxt_tx_disable(struct bnxt *bp);
12391248
void bnxt_tx_enable(struct bnxt *bp);

0 commit comments

Comments
 (0)