Skip to content

Commit a7ef63d

Browse files
Bharat Bhushandavem330
authored andcommitted
octeontx2-af: Disable backpressure between CPT and NIX
NIX can assert backpressure to CPT on the NIX<=>CPT link. Keep the backpressure disabled for now. NIX block anyways handles backpressure asserted by MAC due to PFC or flow control pkts. Signed-off-by: Bharat Bhushan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c460b74 commit a7ef63d

File tree

6 files changed

+106
-17
lines changed

6 files changed

+106
-17
lines changed

drivers/net/ethernet/marvell/octeontx2/af/mbox.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ M(NIX_BANDPROF_FREE, 0x801e, nix_bandprof_free, nix_bandprof_free_req, \
313313
msg_rsp) \
314314
M(NIX_BANDPROF_GET_HWINFO, 0x801f, nix_bandprof_get_hwinfo, msg_req, \
315315
nix_bandprof_get_hwinfo_rsp) \
316+
M(NIX_CPT_BP_ENABLE, 0x8020, nix_cpt_bp_enable, nix_bp_cfg_req, \
317+
nix_bp_cfg_rsp) \
318+
M(NIX_CPT_BP_DISABLE, 0x8021, nix_cpt_bp_disable, nix_bp_cfg_req, \
319+
msg_rsp) \
316320
M(NIX_READ_INLINE_IPSEC_CFG, 0x8023, nix_read_inline_ipsec_cfg, \
317321
msg_req, nix_inline_ipsec_cfg) \
318322
M(NIX_MCAST_GRP_CREATE, 0x802b, nix_mcast_grp_create, nix_mcast_grp_create_req, \

drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,25 @@ void rvu_nix_flr_free_bpids(struct rvu *rvu, u16 pcifunc)
569569
mutex_unlock(&rvu->rsrc_lock);
570570
}
571571

572-
int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
573-
struct nix_bp_cfg_req *req,
574-
struct msg_rsp *rsp)
572+
static u16 nix_get_channel(u16 chan, bool cpt_link)
573+
{
574+
/* CPT channel for a given link channel is always
575+
* assumed to be BIT(11) set in link channel.
576+
*/
577+
return cpt_link ? chan | BIT(11) : chan;
578+
}
579+
580+
static int nix_bp_disable(struct rvu *rvu,
581+
struct nix_bp_cfg_req *req,
582+
struct msg_rsp *rsp, bool cpt_link)
575583
{
576584
u16 pcifunc = req->hdr.pcifunc;
577585
int blkaddr, pf, type, err;
578586
u16 chan_base, chan, bpid;
579587
struct rvu_pfvf *pfvf;
580588
struct nix_hw *nix_hw;
581589
struct nix_bp *bp;
590+
u16 chan_v;
582591
u64 cfg;
583592

584593
pf = rvu_get_pf(pcifunc);
@@ -589,6 +598,9 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
589598
if (is_sdp_pfvf(pcifunc))
590599
type = NIX_INTF_TYPE_SDP;
591600

601+
if (cpt_link && !rvu->hw->cpt_links)
602+
return 0;
603+
592604
pfvf = rvu_get_pfvf(rvu, pcifunc);
593605
err = nix_get_struct_ptrs(rvu, pcifunc, &nix_hw, &blkaddr);
594606
if (err)
@@ -597,8 +609,9 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
597609
bp = &nix_hw->bp;
598610
chan_base = pfvf->rx_chan_base + req->chan_base;
599611
for (chan = chan_base; chan < (chan_base + req->chan_cnt); chan++) {
600-
cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan));
601-
rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan),
612+
chan_v = nix_get_channel(chan, cpt_link);
613+
cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v));
614+
rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v),
602615
cfg & ~BIT_ULL(16));
603616

604617
if (type == NIX_INTF_TYPE_LBK) {
@@ -617,6 +630,20 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
617630
return 0;
618631
}
619632

633+
int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
634+
struct nix_bp_cfg_req *req,
635+
struct msg_rsp *rsp)
636+
{
637+
return nix_bp_disable(rvu, req, rsp, false);
638+
}
639+
640+
int rvu_mbox_handler_nix_cpt_bp_disable(struct rvu *rvu,
641+
struct nix_bp_cfg_req *req,
642+
struct msg_rsp *rsp)
643+
{
644+
return nix_bp_disable(rvu, req, rsp, true);
645+
}
646+
620647
static int rvu_nix_get_bpid(struct rvu *rvu, struct nix_bp_cfg_req *req,
621648
int type, int chan_id)
622649
{
@@ -696,15 +723,17 @@ static int rvu_nix_get_bpid(struct rvu *rvu, struct nix_bp_cfg_req *req,
696723
return bpid;
697724
}
698725

699-
int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
700-
struct nix_bp_cfg_req *req,
701-
struct nix_bp_cfg_rsp *rsp)
726+
static int nix_bp_enable(struct rvu *rvu,
727+
struct nix_bp_cfg_req *req,
728+
struct nix_bp_cfg_rsp *rsp,
729+
bool cpt_link)
702730
{
703731
int blkaddr, pf, type, chan_id = 0;
704732
u16 pcifunc = req->hdr.pcifunc;
705733
struct rvu_pfvf *pfvf;
706734
u16 chan_base, chan;
707735
s16 bpid, bpid_base;
736+
u16 chan_v;
708737
u64 cfg;
709738

710739
pf = rvu_get_pf(pcifunc);
@@ -717,6 +746,9 @@ int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
717746
type != NIX_INTF_TYPE_SDP)
718747
return 0;
719748

749+
if (cpt_link && !rvu->hw->cpt_links)
750+
return 0;
751+
720752
pfvf = rvu_get_pfvf(rvu, pcifunc);
721753
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
722754

@@ -730,9 +762,11 @@ int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
730762
return -EINVAL;
731763
}
732764

733-
cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan));
765+
chan_v = nix_get_channel(chan, cpt_link);
766+
767+
cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v));
734768
cfg &= ~GENMASK_ULL(8, 0);
735-
rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan),
769+
rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v),
736770
cfg | (bpid & GENMASK_ULL(8, 0)) | BIT_ULL(16));
737771
chan_id++;
738772
bpid = rvu_nix_get_bpid(rvu, req, type, chan_id);
@@ -750,6 +784,20 @@ int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
750784
return 0;
751785
}
752786

787+
int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
788+
struct nix_bp_cfg_req *req,
789+
struct nix_bp_cfg_rsp *rsp)
790+
{
791+
return nix_bp_enable(rvu, req, rsp, false);
792+
}
793+
794+
int rvu_mbox_handler_nix_cpt_bp_enable(struct rvu *rvu,
795+
struct nix_bp_cfg_req *req,
796+
struct nix_bp_cfg_rsp *rsp)
797+
{
798+
return nix_bp_enable(rvu, req, rsp, true);
799+
}
800+
753801
static void nix_setup_lso_tso_l3(struct rvu *rvu, int blkaddr,
754802
u64 format, bool v4, u64 *fidx)
755803
{

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include "otx2_struct.h"
1818
#include "cn10k.h"
1919

20+
static bool otx2_is_pfc_enabled(struct otx2_nic *pfvf)
21+
{
22+
return IS_ENABLED(CONFIG_DCB) && !!pfvf->pfc_en;
23+
}
24+
2025
static void otx2_nix_rq_op_stats(struct queue_stats *stats,
2126
struct otx2_nic *pfvf, int qidx)
2227
{
@@ -1723,18 +1728,43 @@ int otx2_nix_config_bp(struct otx2_nic *pfvf, bool enable)
17231728
return -ENOMEM;
17241729

17251730
req->chan_base = 0;
1726-
#ifdef CONFIG_DCB
1727-
req->chan_cnt = pfvf->pfc_en ? IEEE_8021QAZ_MAX_TCS : 1;
1728-
req->bpid_per_chan = pfvf->pfc_en ? 1 : 0;
1729-
#else
1730-
req->chan_cnt = 1;
1731-
req->bpid_per_chan = 0;
1732-
#endif
1731+
if (otx2_is_pfc_enabled(pfvf)) {
1732+
req->chan_cnt = IEEE_8021QAZ_MAX_TCS;
1733+
req->bpid_per_chan = 1;
1734+
} else {
1735+
req->chan_cnt = 1;
1736+
req->bpid_per_chan = 0;
1737+
}
17331738

17341739
return otx2_sync_mbox_msg(&pfvf->mbox);
17351740
}
17361741
EXPORT_SYMBOL(otx2_nix_config_bp);
17371742

1743+
int otx2_nix_cpt_config_bp(struct otx2_nic *pfvf, bool enable)
1744+
{
1745+
struct nix_bp_cfg_req *req;
1746+
1747+
if (enable)
1748+
req = otx2_mbox_alloc_msg_nix_cpt_bp_enable(&pfvf->mbox);
1749+
else
1750+
req = otx2_mbox_alloc_msg_nix_cpt_bp_disable(&pfvf->mbox);
1751+
1752+
if (!req)
1753+
return -ENOMEM;
1754+
1755+
req->chan_base = 0;
1756+
if (otx2_is_pfc_enabled(pfvf)) {
1757+
req->chan_cnt = IEEE_8021QAZ_MAX_TCS;
1758+
req->bpid_per_chan = 1;
1759+
} else {
1760+
req->chan_cnt = 1;
1761+
req->bpid_per_chan = 0;
1762+
}
1763+
1764+
return otx2_sync_mbox_msg(&pfvf->mbox);
1765+
}
1766+
EXPORT_SYMBOL(otx2_nix_cpt_config_bp);
1767+
17381768
/* Mbox message handlers */
17391769
void mbox_handler_cgx_stats(struct otx2_nic *pfvf,
17401770
struct cgx_stats_rsp *rsp)

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ int otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool,
985985
int otx2_rxtx_enable(struct otx2_nic *pfvf, bool enable);
986986
void otx2_ctx_disable(struct mbox *mbox, int type, bool npa);
987987
int otx2_nix_config_bp(struct otx2_nic *pfvf, bool enable);
988+
int otx2_nix_cpt_config_bp(struct otx2_nic *pfvf, bool enable);
988989
void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq, int qidx);
989990
void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq);
990991
int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ static int otx2_dcbnl_ieee_setpfc(struct net_device *dev, struct ieee_pfc *pfc)
435435
return err;
436436
}
437437

438+
/* Default disable backpressure on NIX-CPT */
439+
otx2_nix_cpt_config_bp(pfvf, false);
440+
438441
/* Request Per channel Bpids */
439442
if (pfc->pfc_en)
440443
otx2_nix_config_bp(pfvf, true);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,9 @@ int otx2_init_hw_resources(struct otx2_nic *pf)
15511551
if (err)
15521552
goto err_free_npa_lf;
15531553

1554+
/* Default disable backpressure on NIX-CPT */
1555+
otx2_nix_cpt_config_bp(pf, false);
1556+
15541557
/* Enable backpressure for CGX mapped PF/VFs */
15551558
if (!is_otx2_lbkvf(pf->pdev))
15561559
otx2_nix_config_bp(pf, true);

0 commit comments

Comments
 (0)