Skip to content

Commit 459f326

Browse files
sgoutham-marvelldavem330
authored andcommitted
octeontx2-af: Set NIX link credits based on max LMAC
When number of LMACs active on a CGX/RPM are 3, then current NIX link credit config based on per lmac fifo length which inturn is calculated as 'lmac_fifo_len = total_fifo_len / 3', is incorrect. In HW one of the LMAC gets half of the FIFO and rest gets 1/4th. Signed-off-by: Nithin Dabilpuram <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: Geetha Sowjanya <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent da92e03 commit 459f326

File tree

7 files changed

+102
-9
lines changed

7 files changed

+102
-9
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,32 @@ static u8 cgx_get_lmac_type(void *cgxd, int lmac_id)
498498
return (cfg >> CGX_LMAC_TYPE_SHIFT) & CGX_LMAC_TYPE_MASK;
499499
}
500500

501+
static u32 cgx_get_lmac_fifo_len(void *cgxd, int lmac_id)
502+
{
503+
struct cgx *cgx = cgxd;
504+
u8 num_lmacs;
505+
u32 fifo_len;
506+
507+
fifo_len = cgx->mac_ops->fifo_len;
508+
num_lmacs = cgx->mac_ops->get_nr_lmacs(cgx);
509+
510+
switch (num_lmacs) {
511+
case 1:
512+
return fifo_len;
513+
case 2:
514+
return fifo_len / 2;
515+
case 3:
516+
/* LMAC0 gets half of the FIFO, reset 1/4th */
517+
if (lmac_id == 0)
518+
return fifo_len / 2;
519+
return fifo_len / 4;
520+
case 4:
521+
default:
522+
return fifo_len / 4;
523+
}
524+
return 0;
525+
}
526+
501527
/* Configure CGX LMAC in internal loopback mode */
502528
int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable)
503529
{
@@ -1704,6 +1730,7 @@ static struct mac_ops cgx_mac_ops = {
17041730
.tx_stats_cnt = 18,
17051731
.get_nr_lmacs = cgx_get_nr_lmacs,
17061732
.get_lmac_type = cgx_get_lmac_type,
1733+
.lmac_fifo_len = cgx_get_lmac_fifo_len,
17071734
.mac_lmac_intl_lbk = cgx_lmac_internal_loopback,
17081735
.mac_get_rx_stats = cgx_get_rx_stats,
17091736
.mac_get_tx_stats = cgx_get_tx_stats,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct mac_ops {
8080
*/
8181
int (*get_nr_lmacs)(void *cgx);
8282
u8 (*get_lmac_type)(void *cgx, int lmac_id);
83+
u32 (*lmac_fifo_len)(void *cgx, int lmac_id);
8384
int (*mac_lmac_intl_lbk)(void *cgx, int lmac_id,
8485
bool enable);
8586
/* Register Stats related functions */

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static struct mac_ops rpm_mac_ops = {
2222
.tx_stats_cnt = 34,
2323
.get_nr_lmacs = rpm_get_nr_lmacs,
2424
.get_lmac_type = rpm_get_lmac_type,
25+
.lmac_fifo_len = rpm_get_lmac_fifo_len,
2526
.mac_lmac_intl_lbk = rpm_lmac_internal_loopback,
2627
.mac_get_rx_stats = rpm_get_rx_stats,
2728
.mac_get_tx_stats = rpm_get_tx_stats,
@@ -350,6 +351,35 @@ u8 rpm_get_lmac_type(void *rpmd, int lmac_id)
350351
return err;
351352
}
352353

354+
u32 rpm_get_lmac_fifo_len(void *rpmd, int lmac_id)
355+
{
356+
rpm_t *rpm = rpmd;
357+
u64 hi_perf_lmac;
358+
u8 num_lmacs;
359+
u32 fifo_len;
360+
361+
fifo_len = rpm->mac_ops->fifo_len;
362+
num_lmacs = rpm->mac_ops->get_nr_lmacs(rpm);
363+
364+
switch (num_lmacs) {
365+
case 1:
366+
return fifo_len;
367+
case 2:
368+
return fifo_len / 2;
369+
case 3:
370+
/* LMAC marked as hi_perf gets half of the FIFO and rest 1/4th */
371+
hi_perf_lmac = rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS);
372+
hi_perf_lmac = (hi_perf_lmac >> 4) & 0x3ULL;
373+
if (lmac_id == hi_perf_lmac)
374+
return fifo_len / 2;
375+
return fifo_len / 4;
376+
case 4:
377+
default:
378+
return fifo_len / 4;
379+
}
380+
return 0;
381+
}
382+
353383
int rpm_lmac_internal_loopback(void *rpmd, int lmac_id, bool enable)
354384
{
355385
rpm_t *rpm = rpmd;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
/* Function Declarations */
7676
int rpm_get_nr_lmacs(void *rpmd);
7777
u8 rpm_get_lmac_type(void *rpmd, int lmac_id);
78+
u32 rpm_get_lmac_fifo_len(void *rpmd, int lmac_id);
7879
int rpm_lmac_internal_loopback(void *rpmd, int lmac_id, bool enable);
7980
void rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lmac_id, bool enable);
8081
int rpm_lmac_get_pause_frm_status(void *cgxd, int lmac_id, u8 *tx_pause,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable);
827827
int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause,
828828
u16 pfc_en);
829829
int rvu_cgx_cfg_pause_frm(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause);
830-
830+
u32 rvu_cgx_get_lmac_fifolen(struct rvu *rvu, int cgx, int lmac);
831831
int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf,
832832
int type);
833833
bool is_mcam_entry_enabled(struct rvu *rvu, struct npc_mcam *mcam, int blkaddr,

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,22 @@ u32 rvu_cgx_get_fifolen(struct rvu *rvu)
861861
return fifo_len;
862862
}
863863

864+
u32 rvu_cgx_get_lmac_fifolen(struct rvu *rvu, int cgx, int lmac)
865+
{
866+
struct mac_ops *mac_ops;
867+
void *cgxd;
868+
869+
cgxd = rvu_cgx_pdata(cgx, rvu);
870+
if (!cgxd)
871+
return 0;
872+
873+
mac_ops = get_mac_ops(cgxd);
874+
if (!mac_ops->lmac_fifo_len)
875+
return 0;
876+
877+
return mac_ops->lmac_fifo_len(cgxd, lmac);
878+
}
879+
864880
static int rvu_cgx_config_intlbk(struct rvu *rvu, u16 pcifunc, bool en)
865881
{
866882
int pf = rvu_get_pf(pcifunc);

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

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4010,9 +4010,13 @@ int rvu_mbox_handler_nix_set_hw_frs(struct rvu *rvu, struct nix_frs_cfg *req,
40104010
return 0;
40114011

40124012
/* Update transmit credits for CGX links */
4013-
lmac_fifo_len =
4014-
rvu_cgx_get_fifolen(rvu) /
4015-
cgx_get_lmac_cnt(rvu_cgx_pdata(cgx, rvu));
4013+
lmac_fifo_len = rvu_cgx_get_lmac_fifolen(rvu, cgx, lmac);
4014+
if (!lmac_fifo_len) {
4015+
dev_err(rvu->dev,
4016+
"%s: Failed to get CGX/RPM%d:LMAC%d FIFO size\n",
4017+
__func__, cgx, lmac);
4018+
return 0;
4019+
}
40164020
return nix_config_link_credits(rvu, blkaddr, link, pcifunc,
40174021
(lmac_fifo_len - req->maxlen) / 16);
40184022
}
@@ -4064,7 +4068,10 @@ static void nix_link_config(struct rvu *rvu, int blkaddr,
40644068
struct rvu_hwinfo *hw = rvu->hw;
40654069
int cgx, lmac_cnt, slink, link;
40664070
u16 lbk_max_frs, lmac_max_frs;
4071+
unsigned long lmac_bmap;
40674072
u64 tx_credits, cfg;
4073+
u64 lmac_fifo_len;
4074+
int iter;
40684075

40694076
rvu_get_lbk_link_max_frs(rvu, &lbk_max_frs);
40704077
rvu_get_lmac_link_max_frs(rvu, &lmac_max_frs);
@@ -4098,12 +4105,23 @@ static void nix_link_config(struct rvu *rvu, int blkaddr,
40984105
/* Skip when cgx is not available or lmac cnt is zero */
40994106
if (lmac_cnt <= 0)
41004107
continue;
4101-
tx_credits = ((rvu_cgx_get_fifolen(rvu) / lmac_cnt) -
4102-
lmac_max_frs) / 16;
4103-
/* Enable credits and set credit pkt count to max allowed */
4104-
cfg = (tx_credits << 12) | (0x1FF << 2) | BIT_ULL(1);
41054108
slink = cgx * hw->lmac_per_cgx;
4106-
for (link = slink; link < (slink + lmac_cnt); link++) {
4109+
4110+
/* Get LMAC id's from bitmap */
4111+
lmac_bmap = cgx_get_lmac_bmap(rvu_cgx_pdata(cgx, rvu));
4112+
for_each_set_bit(iter, &lmac_bmap, MAX_LMAC_PER_CGX) {
4113+
lmac_fifo_len = rvu_cgx_get_lmac_fifolen(rvu, cgx, iter);
4114+
if (!lmac_fifo_len) {
4115+
dev_err(rvu->dev,
4116+
"%s: Failed to get CGX/RPM%d:LMAC%d FIFO size\n",
4117+
__func__, cgx, iter);
4118+
continue;
4119+
}
4120+
tx_credits = (lmac_fifo_len - lmac_max_frs) / 16;
4121+
/* Enable credits and set credit pkt count to max allowed */
4122+
cfg = (tx_credits << 12) | (0x1FF << 2) | BIT_ULL(1);
4123+
4124+
link = iter + slink;
41074125
nix_hw->tx_credits[link] = tx_credits;
41084126
rvu_write64(rvu, blkaddr,
41094127
NIX_AF_TX_LINKX_NORM_CREDIT(link), cfg);

0 commit comments

Comments
 (0)