Skip to content

Commit 2f7f33a

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: Add representors for sdp MAC
Hardware supports different types of MACs eg RPM, SDP, LBK. LBK is for internal Tx->Rx HW loopback path. RPM and SDP MACs support ingress/egress pkt IO on interfaces with different set of capabilities like interface modes. At the time of netdev driver registration PF will seek MAC related information from Admin function driver 'drivers/net/ethernet/marvell/octeontx2/af' and sets up ingress/egress queues etc such that pkt IO on the channels of these different MACs is possible. This patch add representors for SDP MAC. Signed-off-by: Geetha sowjanya <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3392f91 commit 2f7f33a

File tree

8 files changed

+88
-26
lines changed

8 files changed

+88
-26
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ enum nix_scheduler {
156156
#define NIC_HW_MIN_FRS 40
157157
#define NIC_HW_MAX_FRS 9212
158158
#define SDP_HW_MAX_FRS 65535
159+
#define SDP_HW_MIN_FRS 16
159160
#define CN10K_LMAC_LINK_MAX_FRS 16380 /* 16k - FCS */
160161
#define CN10K_LBK_LINK_MAX_FRS 65535 /* 64k */
161162

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
586586
if (!is_pf_cgxmapped(rvu, pf) && type != NIX_INTF_TYPE_LBK)
587587
return 0;
588588

589+
if (is_sdp_pfvf(pcifunc))
590+
type = NIX_INTF_TYPE_SDP;
591+
589592
pfvf = rvu_get_pfvf(rvu, pcifunc);
590593
err = nix_get_struct_ptrs(rvu, pcifunc, &nix_hw, &blkaddr);
591594
if (err)
@@ -4687,7 +4690,7 @@ static void nix_link_config(struct rvu *rvu, int blkaddr,
46874690
if (hw->sdp_links) {
46884691
link = hw->cgx_links + hw->lbk_links;
46894692
rvu_write64(rvu, blkaddr, NIX_AF_RX_LINKX_CFG(link),
4690-
SDP_HW_MAX_FRS << 16 | NIC_HW_MIN_FRS);
4693+
SDP_HW_MAX_FRS << 16 | SDP_HW_MIN_FRS);
46914694
}
46924695

46934696
/* Get MCS external bypass status for CN10K-B */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int cn10k_lmtst_init(struct otx2_nic *pfvf)
7272
}
7373
EXPORT_SYMBOL(cn10k_lmtst_init);
7474

75-
int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
75+
int cn10k_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura)
7676
{
7777
struct nix_cn10k_aq_enq_req *aq;
7878
struct otx2_nic *pfvf = dev;
@@ -88,7 +88,7 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
8888
aq->sq.ena = 1;
8989
aq->sq.smq = otx2_get_smq_idx(pfvf, qidx);
9090
aq->sq.smq_rr_weight = mtu_to_dwrr_weight(pfvf, pfvf->tx_max_pktlen);
91-
aq->sq.default_chan = pfvf->hw.tx_chan_base;
91+
aq->sq.default_chan = pfvf->hw.tx_chan_base + chan_offset;
9292
aq->sq.sqe_stype = NIX_STYPE_STF; /* Cache SQB */
9393
aq->sq.sqb_aura = sqb_aura;
9494
aq->sq.sq_int_ena = NIX_SQINT_BITS;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static inline int mtu_to_dwrr_weight(struct otx2_nic *pfvf, int mtu)
2626

2727
int cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
2828
void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx);
29-
int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
29+
int cn10k_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura);
3030
int cn10k_lmtst_init(struct otx2_nic *pfvf);
3131
int cn10k_free_all_ipolicers(struct otx2_nic *pfvf);
3232
int cn10k_alloc_matchall_ipolicer(struct otx2_nic *pfvf);

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

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int otx2_config_pause_frm(struct otx2_nic *pfvf)
253253
struct cgx_pause_frm_cfg *req;
254254
int err;
255255

256-
if (is_otx2_lbkvf(pfvf->pdev))
256+
if (is_otx2_lbkvf(pfvf->pdev) || is_otx2_sdp_rep(pfvf->pdev))
257257
return 0;
258258

259259
mutex_lock(&pfvf->mbox.lock);
@@ -647,20 +647,31 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool txschq_for
647647
req->reg[2] = NIX_AF_MDQX_SCHEDULE(schq);
648648
req->regval[2] = dwrr_val;
649649
} else if (lvl == NIX_TXSCH_LVL_TL4) {
650+
int sdp_chan = hw->tx_chan_base + prio;
651+
652+
if (is_otx2_sdp_rep(pfvf->pdev))
653+
prio = 0;
650654
parent = schq_list[NIX_TXSCH_LVL_TL3][prio];
651655
req->reg[0] = NIX_AF_TL4X_PARENT(schq);
652656
req->regval[0] = (u64)parent << 16;
653657
req->num_regs++;
654658
req->reg[1] = NIX_AF_TL4X_SCHEDULE(schq);
655659
req->regval[1] = dwrr_val;
660+
if (is_otx2_sdp_rep(pfvf->pdev)) {
661+
req->num_regs++;
662+
req->reg[2] = NIX_AF_TL4X_SDP_LINK_CFG(schq);
663+
req->regval[2] = BIT_ULL(12) | BIT_ULL(13) |
664+
(sdp_chan & 0xff);
665+
}
656666
} else if (lvl == NIX_TXSCH_LVL_TL3) {
657667
parent = schq_list[NIX_TXSCH_LVL_TL2][prio];
658668
req->reg[0] = NIX_AF_TL3X_PARENT(schq);
659669
req->regval[0] = (u64)parent << 16;
660670
req->num_regs++;
661671
req->reg[1] = NIX_AF_TL3X_SCHEDULE(schq);
662672
req->regval[1] = dwrr_val;
663-
if (lvl == hw->txschq_link_cfg_lvl) {
673+
if (lvl == hw->txschq_link_cfg_lvl &&
674+
!is_otx2_sdp_rep(pfvf->pdev)) {
664675
req->num_regs++;
665676
req->reg[2] = NIX_AF_TL3_TL2X_LINKX_CFG(schq, hw->tx_link);
666677
/* Enable this queue and backpressure
@@ -677,7 +688,8 @@ int otx2_txschq_config(struct otx2_nic *pfvf, int lvl, int prio, bool txschq_for
677688
req->reg[1] = NIX_AF_TL2X_SCHEDULE(schq);
678689
req->regval[1] = (u64)hw->txschq_aggr_lvl_rr_prio << 24 | dwrr_val;
679690

680-
if (lvl == hw->txschq_link_cfg_lvl) {
691+
if (lvl == hw->txschq_link_cfg_lvl &&
692+
!is_otx2_sdp_rep(pfvf->pdev)) {
681693
req->num_regs++;
682694
req->reg[2] = NIX_AF_TL3_TL2X_LINKX_CFG(schq, hw->tx_link);
683695
/* Enable this queue and backpressure
@@ -736,6 +748,7 @@ EXPORT_SYMBOL(otx2_smq_flush);
736748

737749
int otx2_txsch_alloc(struct otx2_nic *pfvf)
738750
{
751+
int chan_cnt = pfvf->hw.tx_chan_cnt;
739752
struct nix_txsch_alloc_req *req;
740753
struct nix_txsch_alloc_rsp *rsp;
741754
int lvl, schq, rc;
@@ -748,6 +761,12 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)
748761
/* Request one schq per level */
749762
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++)
750763
req->schq[lvl] = 1;
764+
765+
if (is_otx2_sdp_rep(pfvf->pdev) && chan_cnt > 1) {
766+
req->schq[NIX_TXSCH_LVL_SMQ] = chan_cnt;
767+
req->schq[NIX_TXSCH_LVL_TL4] = chan_cnt;
768+
}
769+
751770
rc = otx2_sync_mbox_msg(&pfvf->mbox);
752771
if (rc)
753772
return rc;
@@ -758,10 +777,12 @@ int otx2_txsch_alloc(struct otx2_nic *pfvf)
758777
return PTR_ERR(rsp);
759778

760779
/* Setup transmit scheduler list */
761-
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++)
780+
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
781+
pfvf->hw.txschq_cnt[lvl] = rsp->schq[lvl];
762782
for (schq = 0; schq < rsp->schq[lvl]; schq++)
763783
pfvf->hw.txschq_list[lvl][schq] =
764784
rsp->schq_list[lvl][schq];
785+
}
765786

766787
pfvf->hw.txschq_link_cfg_lvl = rsp->link_cfg_lvl;
767788
pfvf->hw.txschq_aggr_lvl_rr_prio = rsp->aggr_lvl_rr_prio;
@@ -799,12 +820,15 @@ EXPORT_SYMBOL(otx2_txschq_free_one);
799820

800821
void otx2_txschq_stop(struct otx2_nic *pfvf)
801822
{
802-
int lvl, schq;
823+
int lvl, schq, idx;
803824

804825
/* free non QOS TLx nodes */
805-
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++)
806-
otx2_txschq_free_one(pfvf, lvl,
807-
pfvf->hw.txschq_list[lvl][0]);
826+
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
827+
for (idx = 0; idx < pfvf->hw.txschq_cnt[lvl]; idx++) {
828+
otx2_txschq_free_one(pfvf, lvl,
829+
pfvf->hw.txschq_list[lvl][idx]);
830+
}
831+
}
808832

809833
/* Clear the txschq list */
810834
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
@@ -884,7 +908,7 @@ static int otx2_rq_init(struct otx2_nic *pfvf, u16 qidx, u16 lpb_aura)
884908
return otx2_sync_mbox_msg(&pfvf->mbox);
885909
}
886910

887-
int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
911+
int otx2_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura)
888912
{
889913
struct otx2_nic *pfvf = dev;
890914
struct otx2_snd_queue *sq;
@@ -903,7 +927,7 @@ int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
903927
aq->sq.ena = 1;
904928
aq->sq.smq = otx2_get_smq_idx(pfvf, qidx);
905929
aq->sq.smq_rr_quantum = mtu_to_dwrr_weight(pfvf, pfvf->tx_max_pktlen);
906-
aq->sq.default_chan = pfvf->hw.tx_chan_base;
930+
aq->sq.default_chan = pfvf->hw.tx_chan_base + chan_offset;
907931
aq->sq.sqe_stype = NIX_STYPE_STF; /* Cache SQB */
908932
aq->sq.sqb_aura = sqb_aura;
909933
aq->sq.sq_int_ena = NIX_SQINT_BITS;
@@ -926,6 +950,7 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
926950
struct otx2_qset *qset = &pfvf->qset;
927951
struct otx2_snd_queue *sq;
928952
struct otx2_pool *pool;
953+
u8 chan_offset;
929954
int err;
930955

931956
pool = &pfvf->qset.pool[sqb_aura];
@@ -972,7 +997,8 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
972997
sq->stats.bytes = 0;
973998
sq->stats.pkts = 0;
974999

975-
err = pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
1000+
chan_offset = qidx % pfvf->hw.tx_chan_cnt;
1001+
err = pfvf->hw_ops->sq_aq_init(pfvf, qidx, chan_offset, sqb_aura);
9761002
if (err) {
9771003
kfree(sq->sg);
9781004
sq->sg = NULL;
@@ -1739,6 +1765,8 @@ void mbox_handler_nix_lf_alloc(struct otx2_nic *pfvf,
17391765
pfvf->hw.sqb_size = rsp->sqb_size;
17401766
pfvf->hw.rx_chan_base = rsp->rx_chan_base;
17411767
pfvf->hw.tx_chan_base = rsp->tx_chan_base;
1768+
pfvf->hw.rx_chan_cnt = rsp->rx_chan_cnt;
1769+
pfvf->hw.tx_chan_cnt = rsp->tx_chan_cnt;
17421770
pfvf->hw.lso_tsov4_idx = rsp->lso_tsov4_idx;
17431771
pfvf->hw.lso_tsov6_idx = rsp->lso_tsov6_idx;
17441772
pfvf->hw.cgx_links = rsp->cgx_links;

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#define PCI_SUBSYS_DEVID_96XX_RVU_PFVF 0xB200
4343
#define PCI_SUBSYS_DEVID_CN10K_B_RVU_PFVF 0xBD00
4444

45+
#define PCI_DEVID_OCTEONTX2_SDP_REP 0xA0F7
46+
4547
/* PCI BAR nos */
4648
#define PCI_CFG_REG_BAR_NUM 2
4749
#define PCI_MBOX_BAR_NUM 4
@@ -198,6 +200,7 @@ struct otx2_hw {
198200

199201
/* NIX */
200202
u8 txschq_link_cfg_lvl;
203+
u8 txschq_cnt[NIX_TXSCH_LVL_CNT];
201204
u8 txschq_aggr_lvl_rr_prio;
202205
u16 txschq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
203206
u16 matchall_ipolicer;
@@ -208,6 +211,8 @@ struct otx2_hw {
208211
/* HW settings, coalescing etc */
209212
u16 rx_chan_base;
210213
u16 tx_chan_base;
214+
u8 rx_chan_cnt;
215+
u8 tx_chan_cnt;
211216
u16 cq_qcount_wait;
212217
u16 cq_ecount_wait;
213218
u16 rq_skid;
@@ -342,7 +347,8 @@ struct otx2_flow_config {
342347
};
343348

344349
struct dev_hw_ops {
345-
int (*sq_aq_init)(void *dev, u16 qidx, u16 sqb_aura);
350+
int (*sq_aq_init)(void *dev, u16 qidx, u8 chan_offset,
351+
u16 sqb_aura);
346352
void (*sqe_flush)(void *dev, struct otx2_snd_queue *sq,
347353
int size, int qidx);
348354
int (*refill_pool_ptrs)(void *dev, struct otx2_cq_queue *cq);
@@ -536,6 +542,11 @@ static inline bool is_96xx_B0(struct pci_dev *pdev)
536542
(pdev->subsystem_device == PCI_SUBSYS_DEVID_96XX_RVU_PFVF);
537543
}
538544

545+
static inline bool is_otx2_sdp_rep(struct pci_dev *pdev)
546+
{
547+
return pdev->device == PCI_DEVID_OCTEONTX2_SDP_REP;
548+
}
549+
539550
/* REVID for PCIe devices.
540551
* Bits 0..1: minor pass, bit 3..2: major pass
541552
* bits 7..4: midr id
@@ -898,15 +909,19 @@ static inline void otx2_dma_unmap_page(struct otx2_nic *pfvf,
898909
static inline u16 otx2_get_smq_idx(struct otx2_nic *pfvf, u16 qidx)
899910
{
900911
u16 smq;
912+
int idx;
913+
901914
#ifdef CONFIG_DCB
902915
if (qidx < NIX_PF_PFC_PRIO_MAX && pfvf->pfc_alloc_status[qidx])
903916
return pfvf->pfc_schq_list[NIX_TXSCH_LVL_SMQ][qidx];
904917
#endif
905918
/* check if qidx falls under QOS queues */
906-
if (qidx >= pfvf->hw.non_qos_queues)
919+
if (qidx >= pfvf->hw.non_qos_queues) {
907920
smq = pfvf->qos.qid_to_sqmap[qidx - pfvf->hw.non_qos_queues];
908-
else
909-
smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ][0];
921+
} else {
922+
idx = qidx % pfvf->hw.txschq_cnt[NIX_TXSCH_LVL_SMQ];
923+
smq = pfvf->hw.txschq_list[NIX_TXSCH_LVL_SMQ][idx];
924+
}
910925

911926
return smq;
912927
}
@@ -973,8 +988,8 @@ int otx2_nix_config_bp(struct otx2_nic *pfvf, bool enable);
973988
void otx2_cleanup_rx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq, int qidx);
974989
void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq);
975990
int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura);
976-
int otx2_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
977-
int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
991+
int otx2_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura);
992+
int cn10k_sq_aq_init(void *dev, u16 qidx, u8 chan_offset, u16 sqb_aura);
978993
int otx2_alloc_buffer(struct otx2_nic *pfvf, struct otx2_cq_queue *cq,
979994
dma_addr_t *dma);
980995
int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,10 +1591,15 @@ int otx2_init_hw_resources(struct otx2_nic *pf)
15911591
}
15921592

15931593
for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
1594-
err = otx2_txschq_config(pf, lvl, 0, false);
1595-
if (err) {
1596-
mutex_unlock(&mbox->lock);
1597-
goto err_free_nix_queues;
1594+
int idx;
1595+
1596+
for (idx = 0; idx < pf->hw.txschq_cnt[lvl]; idx++) {
1597+
err = otx2_txschq_config(pf, lvl, idx, false);
1598+
if (err) {
1599+
dev_err(pf->dev, "Failed to config TXSCH\n");
1600+
mutex_unlock(&mbox->lock);
1601+
goto err_free_nix_queues;
1602+
}
15981603
}
15991604
}
16001605

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
static const struct pci_device_id otx2_vf_id_table[] = {
2222
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_AFVF) },
2323
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_VF) },
24+
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_SDP_REP) },
2425
{ }
2526
};
2627

@@ -371,7 +372,7 @@ static int otx2vf_open(struct net_device *netdev)
371372

372373
/* LBKs do not receive link events so tell everyone we are up here */
373374
vf = netdev_priv(netdev);
374-
if (is_otx2_lbkvf(vf->pdev)) {
375+
if (is_otx2_lbkvf(vf->pdev) || is_otx2_sdp_rep(vf->pdev)) {
375376
pr_info("%s NIC Link is UP\n", netdev->name);
376377
netif_carrier_on(netdev);
377378
netif_tx_start_all_queues(netdev);
@@ -683,6 +684,15 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
683684
snprintf(netdev->name, sizeof(netdev->name), "lbk%d", n);
684685
}
685686

687+
if (is_otx2_sdp_rep(vf->pdev)) {
688+
int n;
689+
690+
n = vf->pcifunc & RVU_PFVF_FUNC_MASK;
691+
n -= 1;
692+
snprintf(netdev->name, sizeof(netdev->name), "sdp%d-%d",
693+
pdev->bus->number, n);
694+
}
695+
686696
err = register_netdev(netdev);
687697
if (err) {
688698
dev_err(dev, "Failed to register netdevice\n");

0 commit comments

Comments
 (0)