Skip to content

Commit 5d9b976

Browse files
sgoutham-marvelldavem330
authored andcommitted
octeontx2-af: Support fixed transmit scheduler topology
CN96xx initial silicon doesn't support all features pertaining to NIX transmit scheduling and shaping. - It supports a fixed topology of 1:1 mapped transmit limiters at all levels. - Supports DWRR only at SMQ/MDQ and TL1. - Doesn't support shaping and coloring. This patch adds HW capability structure by which each variant and skew of silicon can be differentiated by their supported features. And adds support for A0 silicon's transmit scheduler capabilities or rather limitations. Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 206ff84 commit 5d9b976

File tree

9 files changed

+513
-259
lines changed

9 files changed

+513
-259
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,35 @@ void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable)
291291
}
292292
EXPORT_SYMBOL(cgx_lmac_promisc_config);
293293

294+
/* Enable or disable forwarding received pause frames to Tx block */
295+
void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable)
296+
{
297+
struct cgx *cgx = cgxd;
298+
u64 cfg;
299+
300+
if (!cgx)
301+
return;
302+
303+
if (enable) {
304+
cfg = cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL);
305+
cfg |= CGX_GMP_GMI_RXX_FRM_CTL_CTL_BCK;
306+
cgx_write(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL, cfg);
307+
308+
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
309+
cfg |= CGX_SMUX_RX_FRM_CTL_CTL_BCK;
310+
cgx_write(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL, cfg);
311+
} else {
312+
cfg = cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL);
313+
cfg &= ~CGX_GMP_GMI_RXX_FRM_CTL_CTL_BCK;
314+
cgx_write(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL, cfg);
315+
316+
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
317+
cfg &= ~CGX_SMUX_RX_FRM_CTL_CTL_BCK;
318+
cgx_write(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL, cfg);
319+
}
320+
}
321+
EXPORT_SYMBOL(cgx_lmac_enadis_rx_pause_fwding);
322+
294323
int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat)
295324
{
296325
struct cgx *cgx = cgxd;
@@ -331,6 +360,27 @@ int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable)
331360
}
332361
EXPORT_SYMBOL(cgx_lmac_rx_tx_enable);
333362

363+
int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable)
364+
{
365+
struct cgx *cgx = cgxd;
366+
u64 cfg, last;
367+
368+
if (!cgx || lmac_id >= cgx->lmac_count)
369+
return -ENODEV;
370+
371+
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_CFG);
372+
last = cfg;
373+
if (enable)
374+
cfg |= DATA_PKT_TX_EN;
375+
else
376+
cfg &= ~DATA_PKT_TX_EN;
377+
378+
if (cfg != last)
379+
cgx_write(cgx, lmac_id, CGXX_CMRX_CFG, cfg);
380+
return !!(last & DATA_PKT_TX_EN);
381+
}
382+
EXPORT_SYMBOL(cgx_lmac_tx_enable);
383+
334384
/* CGX Firmware interface low level support */
335385
static int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac)
336386
{

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
#define CGXX_GMP_PCS_MRX_CTL 0x30000
5757
#define CGXX_GMP_PCS_MRX_CTL_LBK BIT_ULL(14)
5858

59+
#define CGXX_SMUX_RX_FRM_CTL 0x20020
60+
#define CGX_SMUX_RX_FRM_CTL_CTL_BCK BIT_ULL(3)
61+
#define CGXX_GMP_GMI_RXX_FRM_CTL 0x38028
62+
#define CGX_GMP_GMI_RXX_FRM_CTL_CTL_BCK BIT_ULL(3)
63+
5964
#define CGX_COMMAND_REG CGXX_SCRATCH1_REG
6065
#define CGX_EVENT_REG CGXX_SCRATCH0_REG
6166
#define CGX_CMD_TIMEOUT 2200 /* msecs */
@@ -110,9 +115,11 @@ int cgx_lmac_evh_unregister(void *cgxd, int lmac_id);
110115
int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat);
111116
int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat);
112117
int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable);
118+
int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable);
113119
int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr);
114120
u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id);
115121
void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable);
122+
void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable);
116123
int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable);
117124
int cgx_get_link_info(void *cgxd, int lmac_id,
118125
struct cgx_link_user_info *linfo);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ M(ATTACH_RESOURCES, 0x002, attach_resources, rsrc_attach, msg_rsp) \
127127
M(DETACH_RESOURCES, 0x003, detach_resources, rsrc_detach, msg_rsp) \
128128
M(MSIX_OFFSET, 0x004, msix_offset, msg_req, msix_offset_rsp) \
129129
M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \
130+
M(GET_HW_CAP, 0x008, get_hw_cap, msg_req, get_hw_cap_rsp) \
130131
/* CGX mbox IDs (range 0x200 - 0x3FF) */ \
131132
M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
132133
M(CGX_STOP_RXTX, 0x201, cgx_stop_rxtx, msg_req, msg_rsp) \
@@ -302,6 +303,12 @@ struct msix_offset_rsp {
302303
u16 cptlf_msixoff[MAX_RVU_BLKLF_CNT];
303304
};
304305

306+
struct get_hw_cap_rsp {
307+
struct mbox_msghdr hdr;
308+
u8 nix_fixed_txschq_mapping; /* Schq mapping fixed or flexible */
309+
u8 nix_shaping; /* Is shaping and coloring supported */
310+
};
311+
305312
/* CGX mbox message formats */
306313

307314
struct cgx_stats_rsp {
@@ -514,6 +521,9 @@ struct nix_txsch_alloc_rsp {
514521
/* Scheduler queue list allocated at each level */
515522
u16 schq_contig_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
516523
u16 schq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
524+
u8 aggr_level; /* Traffic aggregation scheduler level */
525+
u8 aggr_lvl_rr_prio; /* Aggregation lvl's RR_PRIO config */
526+
u8 link_cfg_lvl; /* LINKX_CFG CSRs mapped to TL3 or TL2's index ? */
517527
};
518528

519529
struct nix_txsch_free_req {

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,31 @@ static char *mkex_profile; /* MKEX profile name */
5656
module_param(mkex_profile, charp, 0000);
5757
MODULE_PARM_DESC(mkex_profile, "MKEX profile name string");
5858

59+
static void rvu_setup_hw_capabilities(struct rvu *rvu)
60+
{
61+
struct rvu_hwinfo *hw = rvu->hw;
62+
63+
hw->cap.nix_tx_aggr_lvl = NIX_TXSCH_LVL_TL1;
64+
hw->cap.nix_fixed_txschq_mapping = false;
65+
hw->cap.nix_shaping = true;
66+
hw->cap.nix_tx_link_bp = true;
67+
68+
if (is_rvu_96xx_B0(rvu)) {
69+
hw->cap.nix_fixed_txschq_mapping = true;
70+
hw->cap.nix_txsch_per_cgx_lmac = 4;
71+
hw->cap.nix_txsch_per_lbk_lmac = 132;
72+
hw->cap.nix_txsch_per_sdp_lmac = 76;
73+
hw->cap.nix_shaping = false;
74+
hw->cap.nix_tx_link_bp = false;
75+
}
76+
}
77+
5978
/* Poll a RVU block's register 'offset', for a 'zero'
6079
* or 'nonzero' at bits specified by 'mask'
6180
*/
6281
int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero)
6382
{
64-
unsigned long timeout = jiffies + usecs_to_jiffies(100);
83+
unsigned long timeout = jiffies + usecs_to_jiffies(10000);
6584
void __iomem *reg;
6685
u64 reg_val;
6786

@@ -73,7 +92,6 @@ int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero)
7392
if (!zero && (reg_val & mask))
7493
return 0;
7594
usleep_range(1, 5);
76-
timeout--;
7795
}
7896
return -EBUSY;
7997
}
@@ -1363,6 +1381,17 @@ int rvu_mbox_handler_vf_flr(struct rvu *rvu, struct msg_req *req,
13631381
return 0;
13641382
}
13651383

1384+
int rvu_mbox_handler_get_hw_cap(struct rvu *rvu, struct msg_req *req,
1385+
struct get_hw_cap_rsp *rsp)
1386+
{
1387+
struct rvu_hwinfo *hw = rvu->hw;
1388+
1389+
rsp->nix_fixed_txschq_mapping = hw->cap.nix_fixed_txschq_mapping;
1390+
rsp->nix_shaping = hw->cap.nix_shaping;
1391+
1392+
return 0;
1393+
}
1394+
13661395
static int rvu_process_mbox_msg(struct otx2_mbox *mbox, int devid,
13671396
struct mbox_msghdr *req)
13681397
{
@@ -2448,6 +2477,8 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
24482477

24492478
rvu_reset_all_blocks(rvu);
24502479

2480+
rvu_setup_hw_capabilities(rvu);
2481+
24512482
err = rvu_setup_hw_resources(rvu);
24522483
if (err)
24532484
goto err_release_regions;

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ struct rvu_pfvf {
184184
struct nix_txsch {
185185
struct rsrc_bmap schq;
186186
u8 lvl;
187-
#define NIX_TXSCHQ_TL1_CFG_DONE BIT_ULL(0)
187+
#define NIX_TXSCHQ_FREE BIT_ULL(1)
188+
#define NIX_TXSCHQ_CFG_DONE BIT_ULL(0)
188189
#define TXSCH_MAP_FUNC(__pfvf_map) ((__pfvf_map) & 0xFFFF)
189190
#define TXSCH_MAP_FLAGS(__pfvf_map) ((__pfvf_map) >> 16)
190191
#define TXSCH_MAP(__func, __flags) (((__func) & 0xFFFF) | ((__flags) << 16))
192+
#define TXSCH_SET_FLAG(__pfvf_map, flag) ((__pfvf_map) | ((flag) << 16))
191193
u32 *pfvf_map;
192194
};
193195

@@ -221,6 +223,20 @@ struct nix_hw {
221223
struct nix_lso lso;
222224
};
223225

226+
/* RVU block's capabilities or functionality,
227+
* which vary by silicon version/skew.
228+
*/
229+
struct hw_cap {
230+
/* Transmit side supported functionality */
231+
u8 nix_tx_aggr_lvl; /* Tx link's traffic aggregation level */
232+
u16 nix_txsch_per_cgx_lmac; /* Max Q's transmitting to CGX LMAC */
233+
u16 nix_txsch_per_lbk_lmac; /* Max Q's transmitting to LBK LMAC */
234+
u16 nix_txsch_per_sdp_lmac; /* Max Q's transmitting to SDP LMAC */
235+
bool nix_fixed_txschq_mapping; /* Schq mapping fixed or flexible */
236+
bool nix_shaping; /* Is shaping and coloring supported */
237+
bool nix_tx_link_bp; /* Can link backpressure TL queues ? */
238+
};
239+
224240
struct rvu_hwinfo {
225241
u8 total_pfs; /* MAX RVU PFs HW supports */
226242
u16 total_vfs; /* Max RVU VFs HW supports */
@@ -232,7 +248,7 @@ struct rvu_hwinfo {
232248
u8 sdp_links;
233249
u8 npc_kpus; /* No of parser units */
234250

235-
251+
struct hw_cap cap;
236252
struct rvu_block block[BLK_COUNT]; /* Block info */
237253
struct nix_hw *nix0;
238254
struct npc_pkind pkind;
@@ -317,14 +333,23 @@ static inline u64 rvupf_read64(struct rvu *rvu, u64 offset)
317333
return readq(rvu->pfreg_base + offset);
318334
}
319335

320-
static inline bool is_rvu_9xxx_A0(struct rvu *rvu)
336+
/* Silicon revisions */
337+
static inline bool is_rvu_96xx_A0(struct rvu *rvu)
321338
{
322339
struct pci_dev *pdev = rvu->pdev;
323340

324341
return (pdev->revision == 0x00) &&
325342
(pdev->subsystem_device == PCI_SUBSYS_DEVID_96XX);
326343
}
327344

345+
static inline bool is_rvu_96xx_B0(struct rvu *rvu)
346+
{
347+
struct pci_dev *pdev = rvu->pdev;
348+
349+
return ((pdev->revision == 0x00) || (pdev->revision == 0x01)) &&
350+
(pdev->subsystem_device == PCI_SUBSYS_DEVID_96XX);
351+
}
352+
328353
/* Function Prototypes
329354
* RVU
330355
*/
@@ -383,6 +408,7 @@ int rvu_cgx_init(struct rvu *rvu);
383408
int rvu_cgx_exit(struct rvu *rvu);
384409
void *rvu_cgx_pdata(u8 cgx_id, struct rvu *rvu);
385410
int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start);
411+
void rvu_cgx_enadis_rx_bp(struct rvu *rvu, int pf, bool enable);
386412
int rvu_cgx_nix_cuml_stats(struct rvu *rvu, void *cgxd, int lmac_id, int index,
387413
int rxtxflag, u64 *stat);
388414
/* NPA APIs */
@@ -400,6 +426,7 @@ int rvu_nix_reserve_mark_format(struct rvu *rvu, struct nix_hw *nix_hw,
400426
void rvu_nix_freemem(struct rvu *rvu);
401427
int rvu_get_nixlf_count(struct rvu *rvu);
402428
void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int npalf);
429+
int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf);
403430

404431
/* NPC APIs */
405432
int rvu_npc_init(struct rvu *rvu);

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,24 @@ int rvu_cgx_exit(struct rvu *rvu)
348348
return 0;
349349
}
350350

351+
void rvu_cgx_enadis_rx_bp(struct rvu *rvu, int pf, bool enable)
352+
{
353+
u8 cgx_id, lmac_id;
354+
void *cgxd;
355+
356+
if (!is_pf_cgxmapped(rvu, pf))
357+
return;
358+
359+
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
360+
cgxd = rvu_cgx_pdata(cgx_id, rvu);
361+
362+
/* Set / clear CTL_BCK to control pause frame forwarding to NIX */
363+
if (enable)
364+
cgx_lmac_enadis_rx_pause_fwding(cgxd, lmac_id, true);
365+
else
366+
cgx_lmac_enadis_rx_pause_fwding(cgxd, lmac_id, false);
367+
}
368+
351369
int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start)
352370
{
353371
int pf = rvu_get_pf(pcifunc);

0 commit comments

Comments
 (0)