Skip to content

Commit 242da43

Browse files
Subbaraya Sundeepdavem330
authored andcommitted
octeontx2-af: cn10k: Add support for programmable channels
NIX uses unique channel numbers to identify the packet sources/sinks like CGX,LBK and SDP. The channel numbers assigned to each block are hardwired in CN9xxx silicon. The fixed channel numbers in CN9xxx are: 0x0 | a << 8 | b - LBK(0..3)_CH(0..63) 0x0 | a << 8 - Reserved 0x700 | a - SDP_CH(0..255) 0x800 | a << 8 | b << 4 | c - CGX(0..7)_LMAC(0..3)_CH(0..15) All the channels in the above fixed enumerator(with maximum number of blocks) are not required since some chips have less number of blocks. For CN10K silicon the channel numbers need to be programmed by software in each block with the base channel number and range of channels. This patch calculates and assigns the channel numbers to efficiently distribute the channel number range(0-4095) among all the blocks. The assignment is made based on the actual number of blocks present and also contiguously leaving no holes. The channel numbers remaining after the math are used as new CPT replay channels present in CN10K. Also since channel numbers are not fixed the transmit channel link number needed by AF consumers is calculated by AF and sent along with nix_lf_alloc mailbox response. Signed-off-by: Subbaraya Sundeep <[email protected]> Signed-off-by: Geetha sowjanya <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 91c6945 commit 242da43

File tree

12 files changed

+360
-17
lines changed

12 files changed

+360
-17
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10720,6 +10720,7 @@ M: Linu Cherian <[email protected]>
1072010720
M: Geetha sowjanya <[email protected]>
1072110721
M: Jerin Jacob <[email protected]>
1072210722
M: hariprasad <[email protected]>
10723+
M: Subbaraya Sundeep <[email protected]>
1072310724
1072410725
S: Supported
1072510726
F: Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst

drivers/net/ethernet/marvell/octeontx2/af/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
1010
octeontx2_mbox-y := mbox.o rvu_trace.o
1111
octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
1212
rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
13-
rvu_cpt.o rvu_devlink.o rpm.o
13+
rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ void *cgx_get_pdata(int cgx_id)
123123
return NULL;
124124
}
125125

126+
void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val)
127+
{
128+
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
129+
130+
cgx_write(cgx_dev, lmac_id, offset, val);
131+
}
132+
133+
u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset)
134+
{
135+
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
136+
137+
return cgx_read(cgx_dev, lmac_id, offset);
138+
}
139+
126140
int cgx_get_cgxid(void *cgxd)
127141
{
128142
struct cgx *cgx = cgxd;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,6 @@ struct mac_ops *get_mac_ops(void *cgxd);
162162
int cgx_get_nr_lmacs(void *cgxd);
163163
u8 cgx_get_lmacid(void *cgxd, u8 lmac_index);
164164
unsigned long cgx_get_lmac_bmap(void *cgxd);
165+
void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val);
166+
u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset);
165167
#endif /* CGX_H */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ enum nix_scheduler {
191191
#define NIX_LINK_LBK(a) (12 + (a))
192192
#define NIX_CHAN_CGX_LMAC_CHX(a, b, c) (0x800 + 0x100 * (a) + 0x10 * (b) + (c))
193193
#define NIX_CHAN_LBK_CHX(a, b) (0 + 0x100 * (a) + (b))
194+
#define NIX_CHAN_SDP_CH_START (0x700ull)
195+
196+
#define SDP_CHANNELS 256
194197

195198
/* NIX LSO format indices.
196199
* As of now TSO is the only one using, so statically assigning indices.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
#ifndef RPM_H
99
#define RPM_H
1010

11+
#include <linux/bits.h>
12+
1113
/* PCI device IDs */
1214
#define PCI_DEVID_CN10K_RPM 0xA060
1315

1416
/* Registers */
1517
#define RPMX_CMRX_SW_INT 0x180
1618
#define RPMX_CMRX_SW_INT_W1S 0x188
1719
#define RPMX_CMRX_SW_INT_ENA_W1S 0x198
20+
#define RPMX_CMRX_LINK_CFG 0x1070
21+
22+
#define RPMX_CMRX_LINK_RANGE_MASK GENMASK_ULL(19, 16)
23+
#define RPMX_CMRX_LINK_BASE_MASK GENMASK_ULL(11, 0)
1824

1925
#define RPM_LMAC_FWI 0xa
2026

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,10 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
10061006
rvu_scan_block(rvu, block);
10071007
}
10081008

1009+
err = rvu_set_channels_base(rvu);
1010+
if (err)
1011+
goto msix_err;
1012+
10091013
err = rvu_npc_init(rvu);
10101014
if (err)
10111015
goto npc_err;
@@ -1025,6 +1029,8 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
10251029
if (err)
10261030
goto nix_err;
10271031

1032+
rvu_program_channels(rvu);
1033+
10281034
return 0;
10291035

10301036
nix_err:
@@ -2721,8 +2727,6 @@ static void rvu_enable_afvf_intr(struct rvu *rvu)
27212727
rvupf_write64(rvu, RVU_PF_VFME_INT_ENA_W1SX(1), INTR_MASK(vfs - 64));
27222728
}
27232729

2724-
#define PCI_DEVID_OCTEONTX2_LBK 0xA061
2725-
27262730
int rvu_get_num_lbk_chans(void)
27272731
{
27282732
struct pci_dev *pdev;

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
#include "common.h"
2020
#include "mbox.h"
2121
#include "npc.h"
22+
#include "rvu_reg.h"
2223

2324
/* PCI device IDs */
2425
#define PCI_DEVID_OCTEONTX2_RVU_AF 0xA065
26+
#define PCI_DEVID_OCTEONTX2_LBK 0xA061
2527

2628
/* Subsystem Device ID */
2729
#define PCI_SUBSYS_DEVID_96XX 0xB200
@@ -305,6 +307,7 @@ struct hw_cap {
305307
bool nix_tx_link_bp; /* Can link backpressure TL queues ? */
306308
bool nix_rx_multicast; /* Rx packet replication support */
307309
bool per_pf_mbox_regs; /* PF mbox specified in per PF registers ? */
310+
bool programmable_chans; /* Channels programmable ? */
308311
};
309312

310313
struct rvu_hwinfo {
@@ -313,9 +316,14 @@ struct rvu_hwinfo {
313316
u16 max_vfs_per_pf; /* Max VFs that can be attached to a PF */
314317
u8 cgx;
315318
u8 lmac_per_cgx;
319+
u16 cgx_chan_base; /* CGX base channel number */
320+
u16 lbk_chan_base; /* LBK base channel number */
321+
u16 sdp_chan_base; /* SDP base channel number */
322+
u16 cpt_chan_base; /* CPT base channel number */
316323
u8 cgx_links;
317324
u8 lbk_links;
318325
u8 sdp_links;
326+
u8 cpt_links; /* Number of CPT links */
319327
u8 npc_kpus; /* No of parser units */
320328
u8 npc_pkinds; /* No of port kinds */
321329
u8 npc_intfs; /* No of interfaces */
@@ -499,6 +507,38 @@ static inline bool is_rvu_otx2(struct rvu *rvu)
499507
midr == PCI_REVISION_ID_95XXMM);
500508
}
501509

510+
static inline u16 rvu_nix_chan_cgx(struct rvu *rvu, u8 cgxid,
511+
u8 lmacid, u8 chan)
512+
{
513+
u64 nix_const = rvu_read64(rvu, BLKADDR_NIX0, NIX_AF_CONST);
514+
u16 cgx_chans = nix_const & 0xFFULL;
515+
struct rvu_hwinfo *hw = rvu->hw;
516+
517+
if (!hw->cap.programmable_chans)
518+
return NIX_CHAN_CGX_LMAC_CHX(cgxid, lmacid, chan);
519+
520+
return rvu->hw->cgx_chan_base +
521+
(cgxid * hw->lmac_per_cgx + lmacid) * cgx_chans + chan;
522+
}
523+
524+
static inline u16 rvu_nix_chan_lbk(struct rvu *rvu, u8 lbkid,
525+
u8 chan)
526+
{
527+
u64 nix_const = rvu_read64(rvu, BLKADDR_NIX0, NIX_AF_CONST);
528+
u16 lbk_chans = (nix_const >> 16) & 0xFFULL;
529+
struct rvu_hwinfo *hw = rvu->hw;
530+
531+
if (!hw->cap.programmable_chans)
532+
return NIX_CHAN_LBK_CHX(lbkid, chan);
533+
534+
return rvu->hw->lbk_chan_base + lbkid * lbk_chans + chan;
535+
}
536+
537+
static inline u16 rvu_nix_chan_cpt(struct rvu *rvu, u8 chan)
538+
{
539+
return rvu->hw->cpt_chan_base + chan;
540+
}
541+
502542
/* Function Prototypes
503543
* RVU
504544
*/
@@ -640,6 +680,10 @@ bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature);
640680
/* CPT APIs */
641681
int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot);
642682

683+
/* CN10K RVU */
684+
int rvu_set_channels_base(struct rvu *rvu);
685+
void rvu_program_channels(struct rvu *rvu);
686+
643687
#ifdef CONFIG_DEBUG_FS
644688
void rvu_dbg_init(struct rvu *rvu);
645689
void rvu_dbg_exit(struct rvu *rvu);

0 commit comments

Comments
 (0)