Skip to content

Commit

Permalink
octeontx2-af: cn10k: Fix SDP base channel number
Browse files Browse the repository at this point in the history
As per hardware the base channel number configured
for programmable channels of a block must be multiple
of number of channels of that block. This condition
is not met for SDP base channel currently. Hence this
patch ensures all the base channel numbers of all
blocks are multiple of number of channels present in
the blocks. Also instead of hardcoding SDP number
of channels the same is read from the NIX_AF_CONST1
register.

Fixes: 242da43 ("octeontx2-af: cn10k: Add support for programmable")
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Subbaraya Sundeep authored and David S. Miller committed Aug 22, 2021
1 parent e8fb4df commit 477b53f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 0 additions & 2 deletions drivers/net/ethernet/marvell/octeontx2/af/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ enum nix_scheduler {
#define NIX_CHAN_LBK_CHX(a, b) (0 + 0x100 * (a) + (b))
#define NIX_CHAN_SDP_CH_START (0x700ull)

#define SDP_CHANNELS 256

/* The mask is to extract lower 10-bits of channel number
* which CPT will pass to X2P.
*/
Expand Down
31 changes: 22 additions & 9 deletions drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,18 @@ void rvu_reset_lmt_map_tbl(struct rvu *rvu, u16 pcifunc)

int rvu_set_channels_base(struct rvu *rvu)
{
u16 nr_lbk_chans, nr_sdp_chans, nr_cgx_chans, nr_cpt_chans;
u16 sdp_chan_base, cgx_chan_base, cpt_chan_base;
struct rvu_hwinfo *hw = rvu->hw;
u16 cpt_chan_base;
u64 nix_const;
u64 nix_const, nix_const1;
int blkaddr;

blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
if (blkaddr < 0)
return blkaddr;

nix_const = rvu_read64(rvu, blkaddr, NIX_AF_CONST);
nix_const1 = rvu_read64(rvu, blkaddr, NIX_AF_CONST1);

hw->cgx = (nix_const >> 12) & 0xFULL;
hw->lmac_per_cgx = (nix_const >> 8) & 0xFULL;
Expand All @@ -244,14 +246,24 @@ int rvu_set_channels_base(struct rvu *rvu)
* channels such that all channel numbers are contiguous
* leaving no holes. This way the new CPT channels can be
* accomodated. The order of channel numbers assigned is
* LBK, SDP, CGX and CPT.
* LBK, SDP, CGX and CPT. Also the base channel number
* of a block must be multiple of number of channels
* of the block.
*/
hw->sdp_chan_base = hw->lbk_chan_base + hw->lbk_links *
((nix_const >> 16) & 0xFFULL);
hw->cgx_chan_base = hw->sdp_chan_base + hw->sdp_links * SDP_CHANNELS;
nr_lbk_chans = (nix_const >> 16) & 0xFFULL;
nr_sdp_chans = nix_const1 & 0xFFFULL;
nr_cgx_chans = nix_const & 0xFFULL;
nr_cpt_chans = (nix_const >> 32) & 0xFFFULL;

cpt_chan_base = hw->cgx_chan_base + hw->cgx_links *
(nix_const & 0xFFULL);
sdp_chan_base = hw->lbk_chan_base + hw->lbk_links * nr_lbk_chans;
/* Round up base channel to multiple of number of channels */
hw->sdp_chan_base = ALIGN(sdp_chan_base, nr_sdp_chans);

cgx_chan_base = hw->sdp_chan_base + hw->sdp_links * nr_sdp_chans;
hw->cgx_chan_base = ALIGN(cgx_chan_base, nr_cgx_chans);

cpt_chan_base = hw->cgx_chan_base + hw->cgx_links * nr_cgx_chans;
hw->cpt_chan_base = ALIGN(cpt_chan_base, nr_cpt_chans);

/* Out of 4096 channels start CPT from 2048 so
* that MSB for CPT channels is always set
Expand Down Expand Up @@ -355,6 +367,7 @@ static void rvu_lbk_set_channels(struct rvu *rvu)

static void __rvu_nix_set_channels(struct rvu *rvu, int blkaddr)
{
u64 nix_const1 = rvu_read64(rvu, blkaddr, NIX_AF_CONST1);
u64 nix_const = rvu_read64(rvu, blkaddr, NIX_AF_CONST);
u16 cgx_chans, lbk_chans, sdp_chans, cpt_chans;
struct rvu_hwinfo *hw = rvu->hw;
Expand All @@ -364,7 +377,7 @@ static void __rvu_nix_set_channels(struct rvu *rvu, int blkaddr)

cgx_chans = nix_const & 0xFFULL;
lbk_chans = (nix_const >> 16) & 0xFFULL;
sdp_chans = SDP_CHANNELS;
sdp_chans = nix_const1 & 0xFFFULL;
cpt_chans = (nix_const >> 32) & 0xFFFULL;

start = hw->cgx_chan_base;
Expand Down

0 comments on commit 477b53f

Please sign in to comment.