]> git.baikalelectronics.ru Git - kernel.git/commitdiff
octeontx2-af: cn10k: Add support for programmable channels
authorSubbaraya Sundeep <sbhatta@marvell.com>
Thu, 11 Feb 2021 15:58:29 +0000 (21:28 +0530)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Feb 2021 22:55:03 +0000 (14:55 -0800)
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 <sbhatta@marvell.com>
Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
MAINTAINERS
drivers/net/ethernet/marvell/octeontx2/af/Makefile
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
drivers/net/ethernet/marvell/octeontx2/af/cgx.h
drivers/net/ethernet/marvell/octeontx2/af/common.h
drivers/net/ethernet/marvell/octeontx2/af/rpm.h
drivers/net/ethernet/marvell/octeontx2/af/rvu.c
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c [new file with mode: 0644]
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h

index ab8939e72ed8ffcb8873253d270a2aa77be82b12..3914691fb4a653268e1b20634b7556a04ad3b099 100644 (file)
@@ -10720,6 +10720,7 @@ M:      Linu Cherian <lcherian@marvell.com>
 M:     Geetha sowjanya <gakula@marvell.com>
 M:     Jerin Jacob <jerinj@marvell.com>
 M:     hariprasad <hkelam@marvell.com>
+M:     Subbaraya Sundeep <sbhatta@marvell.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 F:     Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
index a6afbdeeaf305958955ad4e3ee69f468e45a1ee4..621cc5bf106aeaddfdd7ec0d0b7a9c9b8e5fd593 100644 (file)
@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 octeontx2_mbox-y := mbox.o rvu_trace.o
 octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
                  rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
-                 rvu_cpt.o rvu_devlink.o rpm.o
+                 rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o
index 7eccc35c14e29212472ad1f3d30c566b6fc0241b..70dff6fef83f2c5829d5312fffef5a930b7bcd1d 100644 (file)
@@ -123,6 +123,20 @@ void *cgx_get_pdata(int cgx_id)
        return NULL;
 }
 
+void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val)
+{
+       struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
+
+       cgx_write(cgx_dev, lmac_id, offset, val);
+}
+
+u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset)
+{
+       struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
+
+       return cgx_read(cgx_dev, lmac_id, offset);
+}
+
 int cgx_get_cgxid(void *cgxd)
 {
        struct cgx *cgx = cgxd;
index 301b830d262a8bc2231f9cc985033bbfd42cf868..8275a878ba1dc2fbded5cd34523cf2c9ebea5cad 100644 (file)
@@ -162,4 +162,6 @@ struct mac_ops *get_mac_ops(void *cgxd);
 int cgx_get_nr_lmacs(void *cgxd);
 u8 cgx_get_lmacid(void *cgxd, u8 lmac_index);
 unsigned long cgx_get_lmac_bmap(void *cgxd);
+void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val);
+u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset);
 #endif /* CGX_H */
index 17f6f42f445378bbdb9a7f66ed48525dada73ce6..0100e704461919338c8c1319238275848f1a96a7 100644 (file)
@@ -191,6 +191,9 @@ enum nix_scheduler {
 #define NIX_LINK_LBK(a)                        (12 + (a))
 #define NIX_CHAN_CGX_LMAC_CHX(a, b, c) (0x800 + 0x100 * (a) + 0x10 * (b) + (c))
 #define NIX_CHAN_LBK_CHX(a, b)         (0 + 0x100 * (a) + (b))
+#define NIX_CHAN_SDP_CH_START          (0x700ull)
+
+#define SDP_CHANNELS                   256
 
 /* NIX LSO format indices.
  * As of now TSO is the only one using, so statically assigning indices.
index 7f45c1c645bf018e910eee8e55596a70121952ab..1779e8b689e8abd438f07ddb3c96356125f31baf 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef RPM_H
 #define RPM_H
 
+#include <linux/bits.h>
+
 /* PCI device IDs */
 #define PCI_DEVID_CN10K_RPM            0xA060
 
 #define RPMX_CMRX_SW_INT                0x180
 #define RPMX_CMRX_SW_INT_W1S            0x188
 #define RPMX_CMRX_SW_INT_ENA_W1S        0x198
+#define RPMX_CMRX_LINK_CFG             0x1070
+
+#define RPMX_CMRX_LINK_RANGE_MASK      GENMASK_ULL(19, 16)
+#define RPMX_CMRX_LINK_BASE_MASK       GENMASK_ULL(11, 0)
 
 #define RPM_LMAC_FWI                   0xa
 
index 1729a2ad093e4e7fcdedc3ef26464c405bad2053..54844084dd1bbb4600ccbca6ce135dc3a5e08096 100644 (file)
@@ -1006,6 +1006,10 @@ cpt:
                rvu_scan_block(rvu, block);
        }
 
+       err = rvu_set_channels_base(rvu);
+       if (err)
+               goto msix_err;
+
        err = rvu_npc_init(rvu);
        if (err)
                goto npc_err;
@@ -1025,6 +1029,8 @@ cpt:
        if (err)
                goto nix_err;
 
+       rvu_program_channels(rvu);
+
        return 0;
 
 nix_err:
@@ -2721,8 +2727,6 @@ static void rvu_enable_afvf_intr(struct rvu *rvu)
        rvupf_write64(rvu, RVU_PF_VFME_INT_ENA_W1SX(1), INTR_MASK(vfs - 64));
 }
 
-#define PCI_DEVID_OCTEONTX2_LBK 0xA061
-
 int rvu_get_num_lbk_chans(void)
 {
        struct pci_dev *pdev;
index d39fbefdd2844b1696ac3f8bdb3002caba87538c..7bebc85b29ce5d5abb7a908f06471e764cfef576 100644 (file)
 #include "common.h"
 #include "mbox.h"
 #include "npc.h"
+#include "rvu_reg.h"
 
 /* PCI device IDs */
 #define        PCI_DEVID_OCTEONTX2_RVU_AF              0xA065
+#define        PCI_DEVID_OCTEONTX2_LBK                 0xA061
 
 /* Subsystem Device ID */
 #define PCI_SUBSYS_DEVID_96XX                  0xB200
@@ -305,6 +307,7 @@ struct hw_cap {
        bool    nix_tx_link_bp;          /* Can link backpressure TL queues ? */
        bool    nix_rx_multicast;        /* Rx packet replication support */
        bool    per_pf_mbox_regs; /* PF mbox specified in per PF registers ? */
+       bool    programmable_chans; /* Channels programmable ? */
 };
 
 struct rvu_hwinfo {
@@ -313,9 +316,14 @@ struct rvu_hwinfo {
        u16     max_vfs_per_pf; /* Max VFs that can be attached to a PF */
        u8      cgx;
        u8      lmac_per_cgx;
+       u16     cgx_chan_base;  /* CGX base channel number */
+       u16     lbk_chan_base;  /* LBK base channel number */
+       u16     sdp_chan_base;  /* SDP base channel number */
+       u16     cpt_chan_base;  /* CPT base channel number */
        u8      cgx_links;
        u8      lbk_links;
        u8      sdp_links;
+       u8      cpt_links;      /* Number of CPT links */
        u8      npc_kpus;          /* No of parser units */
        u8      npc_pkinds;        /* No of port kinds */
        u8      npc_intfs;         /* No of interfaces */
@@ -499,6 +507,38 @@ static inline bool is_rvu_otx2(struct rvu *rvu)
                midr == PCI_REVISION_ID_95XXMM);
 }
 
+static inline u16 rvu_nix_chan_cgx(struct rvu *rvu, u8 cgxid,
+                                  u8 lmacid, u8 chan)
+{
+       u64 nix_const = rvu_read64(rvu, BLKADDR_NIX0, NIX_AF_CONST);
+       u16 cgx_chans = nix_const & 0xFFULL;
+       struct rvu_hwinfo *hw = rvu->hw;
+
+       if (!hw->cap.programmable_chans)
+               return NIX_CHAN_CGX_LMAC_CHX(cgxid, lmacid, chan);
+
+       return rvu->hw->cgx_chan_base +
+               (cgxid * hw->lmac_per_cgx + lmacid) * cgx_chans + chan;
+}
+
+static inline u16 rvu_nix_chan_lbk(struct rvu *rvu, u8 lbkid,
+                                  u8 chan)
+{
+       u64 nix_const = rvu_read64(rvu, BLKADDR_NIX0, NIX_AF_CONST);
+       u16 lbk_chans = (nix_const >> 16) & 0xFFULL;
+       struct rvu_hwinfo *hw = rvu->hw;
+
+       if (!hw->cap.programmable_chans)
+               return NIX_CHAN_LBK_CHX(lbkid, chan);
+
+       return rvu->hw->lbk_chan_base + lbkid * lbk_chans + chan;
+}
+
+static inline u16 rvu_nix_chan_cpt(struct rvu *rvu, u8 chan)
+{
+       return rvu->hw->cpt_chan_base + chan;
+}
+
 /* Function Prototypes
  * RVU
  */
@@ -640,6 +680,10 @@ bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature);
 /* CPT APIs */
 int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot);
 
+/* CN10K RVU */
+int rvu_set_channels_base(struct rvu *rvu);
+void rvu_program_channels(struct rvu *rvu);
+
 #ifdef CONFIG_DEBUG_FS
 void rvu_dbg_init(struct rvu *rvu);
 void rvu_dbg_exit(struct rvu *rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c
new file mode 100644 (file)
index 0000000..7d9e71c
--- /dev/null
@@ -0,0 +1,261 @@
+// SPDX-License-Identifier: GPL-2.0
+/*  Marvell RPM CN10K driver
+ *
+ * Copyright (C) 2020 Marvell.
+ */
+
+#include <linux/bitfield.h>
+#include <linux/pci.h>
+#include "rvu.h"
+#include "cgx.h"
+#include "rvu_reg.h"
+
+int rvu_set_channels_base(struct rvu *rvu)
+{
+       struct rvu_hwinfo *hw = rvu->hw;
+       u16 cpt_chan_base;
+       u64 nix_const;
+       int blkaddr;
+
+       blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+       if (blkaddr < 0)
+               return blkaddr;
+
+       nix_const = rvu_read64(rvu, blkaddr, NIX_AF_CONST);
+
+       hw->cgx = (nix_const >> 12) & 0xFULL;
+       hw->lmac_per_cgx = (nix_const >> 8) & 0xFULL;
+       hw->cgx_links = hw->cgx * hw->lmac_per_cgx;
+       hw->lbk_links = (nix_const >> 24) & 0xFULL;
+       hw->cpt_links = (nix_const >> 44) & 0xFULL;
+       hw->sdp_links = 1;
+
+       hw->cgx_chan_base = NIX_CHAN_CGX_LMAC_CHX(0, 0, 0);
+       hw->lbk_chan_base = NIX_CHAN_LBK_CHX(0, 0);
+       hw->sdp_chan_base = NIX_CHAN_SDP_CH_START;
+
+       /* No Programmable channels */
+       if (!(nix_const & BIT_ULL(60)))
+               return 0;
+
+       hw->cap.programmable_chans = true;
+
+       /* If programmable channels are present then configure
+        * 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.
+        */
+       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;
+
+       cpt_chan_base = hw->cgx_chan_base + hw->cgx_links *
+                               (nix_const & 0xFFULL);
+
+       /* Out of 4096 channels start CPT from 2048 so
+        * that MSB for CPT channels is always set
+        */
+       if (cpt_chan_base <= 0x800) {
+               hw->cpt_chan_base = 0x800;
+       } else {
+               dev_err(rvu->dev,
+                       "CPT channels could not fit in the range 2048-4095\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+#define LBK_CONNECT_NIXX(a)            (0x0 + (a))
+
+static void __rvu_lbk_set_chans(struct rvu *rvu, void __iomem *base,
+                               u64 offset, int lbkid, u16 chans)
+{
+       struct rvu_hwinfo *hw = rvu->hw;
+       u64 cfg;
+
+       cfg = readq(base + offset);
+       cfg &= ~(LBK_LINK_CFG_RANGE_MASK |
+                LBK_LINK_CFG_ID_MASK | LBK_LINK_CFG_BASE_MASK);
+       cfg |=  FIELD_PREP(LBK_LINK_CFG_RANGE_MASK, ilog2(chans));
+       cfg |=  FIELD_PREP(LBK_LINK_CFG_ID_MASK, lbkid);
+       cfg |=  FIELD_PREP(LBK_LINK_CFG_BASE_MASK, hw->lbk_chan_base);
+
+       writeq(cfg, base + offset);
+}
+
+static void rvu_lbk_set_channels(struct rvu *rvu)
+{
+       struct pci_dev *pdev = NULL;
+       void __iomem *base;
+       u64 lbk_const;
+       u8 src, dst;
+       u16 chans;
+
+       /* To loopback packets between multiple NIX blocks
+        * mutliple LBK blocks are needed. With two NIX blocks,
+        * four LBK blocks are needed and each LBK block
+        * source and destination are as follows:
+        * LBK0 - source NIX0 and destination NIX1
+        * LBK1 - source NIX0 and destination NIX1
+        * LBK2 - source NIX1 and destination NIX0
+        * LBK3 - source NIX1 and destination NIX1
+        * As per the HRM channel numbers should be programmed as:
+        * P2X and X2P of LBK0 as same
+        * P2X and X2P of LBK3 as same
+        * P2X of LBK1 and X2P of LBK2 as same
+        * P2X of LBK2 and X2P of LBK1 as same
+        */
+       while (true) {
+               pdev = pci_get_device(PCI_VENDOR_ID_CAVIUM,
+                                     PCI_DEVID_OCTEONTX2_LBK, pdev);
+               if (!pdev)
+                       return;
+
+               base = pci_ioremap_bar(pdev, 0);
+               if (!base)
+                       goto err_put;
+
+               lbk_const = readq(base + LBK_CONST);
+               chans = FIELD_GET(LBK_CONST_CHANS, lbk_const);
+               dst = FIELD_GET(LBK_CONST_DST, lbk_const);
+               src = FIELD_GET(LBK_CONST_SRC, lbk_const);
+
+               if (src == dst) {
+                       if (src == LBK_CONNECT_NIXX(0)) { /* LBK0 */
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_X2P,
+                                                   0, chans);
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_P2X,
+                                                   0, chans);
+                       } else if (src == LBK_CONNECT_NIXX(1)) { /* LBK3 */
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_X2P,
+                                                   1, chans);
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_P2X,
+                                                   1, chans);
+                       }
+               } else {
+                       if (src == LBK_CONNECT_NIXX(0)) { /* LBK1 */
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_X2P,
+                                                   0, chans);
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_P2X,
+                                                   1, chans);
+                       } else if (src == LBK_CONNECT_NIXX(1)) { /* LBK2 */
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_X2P,
+                                                   1, chans);
+                               __rvu_lbk_set_chans(rvu, base, LBK_LINK_CFG_P2X,
+                                                   0, chans);
+                       }
+               }
+               iounmap(base);
+       }
+err_put:
+       pci_dev_put(pdev);
+}
+
+static void __rvu_nix_set_channels(struct rvu *rvu, int blkaddr)
+{
+       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;
+       int link, nix_link = 0;
+       u16 start;
+       u64 cfg;
+
+       cgx_chans = nix_const & 0xFFULL;
+       lbk_chans = (nix_const >> 16) & 0xFFULL;
+       sdp_chans = SDP_CHANNELS;
+       cpt_chans = (nix_const >> 32) & 0xFFFULL;
+
+       start = hw->cgx_chan_base;
+       for (link = 0; link < hw->cgx_links; link++, nix_link++) {
+               cfg = rvu_read64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link));
+               cfg &= ~(NIX_AF_LINKX_BASE_MASK | NIX_AF_LINKX_RANGE_MASK);
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_RANGE_MASK, ilog2(cgx_chans));
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_BASE_MASK, start);
+               rvu_write64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link), cfg);
+               start += cgx_chans;
+       }
+
+       start = hw->lbk_chan_base;
+       for (link = 0; link < hw->lbk_links; link++, nix_link++) {
+               cfg = rvu_read64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link));
+               cfg &= ~(NIX_AF_LINKX_BASE_MASK | NIX_AF_LINKX_RANGE_MASK);
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_RANGE_MASK, ilog2(lbk_chans));
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_BASE_MASK, start);
+               rvu_write64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link), cfg);
+               start += lbk_chans;
+       }
+
+       start = hw->sdp_chan_base;
+       for (link = 0; link < hw->sdp_links; link++, nix_link++) {
+               cfg = rvu_read64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link));
+               cfg &= ~(NIX_AF_LINKX_BASE_MASK | NIX_AF_LINKX_RANGE_MASK);
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_RANGE_MASK, ilog2(sdp_chans));
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_BASE_MASK, start);
+               rvu_write64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link), cfg);
+               start += sdp_chans;
+       }
+
+       start = hw->cpt_chan_base;
+       for (link = 0; link < hw->cpt_links; link++, nix_link++) {
+               cfg = rvu_read64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link));
+               cfg &= ~(NIX_AF_LINKX_BASE_MASK | NIX_AF_LINKX_RANGE_MASK);
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_RANGE_MASK, ilog2(cpt_chans));
+               cfg |=  FIELD_PREP(NIX_AF_LINKX_BASE_MASK, start);
+               rvu_write64(rvu, blkaddr, NIX_AF_LINKX_CFG(nix_link), cfg);
+               start += cpt_chans;
+       }
+}
+
+static void rvu_nix_set_channels(struct rvu *rvu)
+{
+       int blkaddr = 0;
+
+       blkaddr = rvu_get_next_nix_blkaddr(rvu, blkaddr);
+       while (blkaddr) {
+               __rvu_nix_set_channels(rvu, blkaddr);
+               blkaddr = rvu_get_next_nix_blkaddr(rvu, blkaddr);
+       }
+}
+
+static void __rvu_rpm_set_channels(int cgxid, int lmacid, u16 base)
+{
+       u64 cfg;
+
+       cfg = cgx_lmac_read(cgxid, lmacid, RPMX_CMRX_LINK_CFG);
+       cfg &= ~(RPMX_CMRX_LINK_BASE_MASK | RPMX_CMRX_LINK_RANGE_MASK);
+
+       /* There is no read-only constant register to read
+        * the number of channels for LMAC and it is always 16.
+        */
+       cfg |=  FIELD_PREP(RPMX_CMRX_LINK_RANGE_MASK, ilog2(16));
+       cfg |=  FIELD_PREP(RPMX_CMRX_LINK_BASE_MASK, base);
+       cgx_lmac_write(cgxid, lmacid, RPMX_CMRX_LINK_CFG, cfg);
+}
+
+static void rvu_rpm_set_channels(struct rvu *rvu)
+{
+       struct rvu_hwinfo *hw = rvu->hw;
+       u16 base = hw->cgx_chan_base;
+       int cgx, lmac;
+
+       for (cgx = 0; cgx < rvu->cgx_cnt_max; cgx++) {
+               for (lmac = 0; lmac < hw->lmac_per_cgx; lmac++) {
+                       __rvu_rpm_set_channels(cgx, lmac, base);
+                       base += 16;
+               }
+       }
+}
+
+void rvu_program_channels(struct rvu *rvu)
+{
+       struct rvu_hwinfo *hw = rvu->hw;
+
+       if (!hw->cap.programmable_chans)
+               return;
+
+       rvu_nix_set_channels(rvu);
+       rvu_lbk_set_channels(rvu);
+       rvu_rpm_set_channels(rvu);
+}
index 0c9b1c37a8c6fd68afecbcf8e263b2496604b3cd..cf9e88c6b89e537a5fca17a21a260d02d45bc395 100644 (file)
@@ -233,7 +233,7 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf)
                                "PF_Func 0x%x: Invalid pkind\n", pcifunc);
                        return -EINVAL;
                }
-               pfvf->rx_chan_base = NIX_CHAN_CGX_LMAC_CHX(cgx_id, lmac_id, 0);
+               pfvf->rx_chan_base = rvu_nix_chan_cgx(rvu, cgx_id, lmac_id, 0);
                pfvf->tx_chan_base = pfvf->rx_chan_base;
                pfvf->rx_chan_cnt = 1;
                pfvf->tx_chan_cnt = 1;
@@ -262,10 +262,10 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf)
                 * loopback channels.Therefore if odd number of AF VFs are
                 * enabled then the last VF remains with no pair.
                 */
-               pfvf->rx_chan_base = NIX_CHAN_LBK_CHX(lbkid, vf);
+               pfvf->rx_chan_base = rvu_nix_chan_lbk(rvu, lbkid, vf);
                pfvf->tx_chan_base = vf & 0x1 ?
-                                       NIX_CHAN_LBK_CHX(lbkid, vf - 1) :
-                                       NIX_CHAN_LBK_CHX(lbkid, vf + 1);
+                                       rvu_nix_chan_lbk(rvu, lbkid, vf - 1) :
+                                       rvu_nix_chan_lbk(rvu, lbkid, vf + 1);
                pfvf->rx_chan_cnt = 1;
                pfvf->tx_chan_cnt = 1;
                rvu_npc_install_promisc_entry(rvu, pcifunc, nixlf,
@@ -3389,14 +3389,6 @@ static int rvu_nix_block_init(struct rvu *rvu, struct nix_hw *nix_hw)
        if (err)
                return err;
 
-       /* Set num of links of each type */
-       cfg = rvu_read64(rvu, blkaddr, NIX_AF_CONST);
-       hw->cgx = (cfg >> 12) & 0xF;
-       hw->lmac_per_cgx = (cfg >> 8) & 0xF;
-       hw->cgx_links = hw->cgx * hw->lmac_per_cgx;
-       hw->lbk_links = (cfg >> 24) & 0xF;
-       hw->sdp_links = 1;
-
        /* Initialize admin queue */
        err = nix_aq_init(rvu, block);
        if (err)
index 5cf9b7a907ae05d2576331b4c2a6ee6f01a812fa..04bb0803a5c506fd2f9445c37d9882c6dc9f4669 100644 (file)
@@ -102,9 +102,9 @@ int npc_mcam_verify_channel(struct rvu *rvu, u16 pcifunc, u8 intf, u16 channel)
                        return -EINVAL;
        } else {
                rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
-               base = NIX_CHAN_CGX_LMAC_CHX(cgx_id, lmac_id, 0x0);
+               base = rvu_nix_chan_cgx(rvu, cgx_id, lmac_id, 0x0);
                /* CGX mapped functions has maximum of 16 channels */
-               end = NIX_CHAN_CGX_LMAC_CHX(cgx_id, lmac_id, 0xF);
+               end = rvu_nix_chan_cgx(rvu, cgx_id, lmac_id, 0xF);
        }
 
        if (channel < base || channel > end)
index 78395c740c39f9346a42b565a469f2e4854566d4..2460d71c4f871e57d5a25535ba572170b4f80757 100644 (file)
 #define NIX_AF_RX_NPC_MIRROR_RCV       (0x4720)
 #define NIX_AF_RX_NPC_MIRROR_DROP      (0x4730)
 #define NIX_AF_RX_ACTIVE_CYCLES_PCX(a) (0x4800 | (a) << 16)
+#define NIX_AF_LINKX_CFG(a)            (0x4010 | (a) << 17)
 
 #define NIX_PRIV_AF_INT_CFG            (0x8000000)
 #define NIX_PRIV_LFX_CFG               (0x8000010)
 #define NIX_PRIV_LFX_INT_CFG           (0x8000020)
 #define NIX_AF_RVU_LF_CFG_DEBUG                (0x8000030)
 
+#define NIX_AF_LINKX_BASE_MASK         GENMASK_ULL(11, 0)
+#define NIX_AF_LINKX_RANGE_MASK                GENMASK_ULL(19, 16)
+
 /* SSO */
 #define SSO_AF_CONST                   (0x1000)
 #define SSO_AF_CONST1                  (0x1008)
                (0x00F00 | (a) << 5 | (b) << 4)
 #define NDC_AF_BANKX_HIT_PC(a)         (0x01000 | (a) << 3)
 #define NDC_AF_BANKX_MISS_PC(a)                (0x01100 | (a) << 3)
+
+/* LBK */
+#define LBK_CONST                      (0x10ull)
+#define LBK_LINK_CFG_P2X               (0x400ull)
+#define LBK_LINK_CFG_X2P               (0x408ull)
+#define LBK_CONST_CHANS                        GENMASK_ULL(47, 32)
+#define LBK_CONST_DST                  GENMASK_ULL(31, 28)
+#define LBK_CONST_SRC                  GENMASK_ULL(27, 24)
+#define LBK_LINK_CFG_RANGE_MASK                GENMASK_ULL(19, 16)
+#define LBK_LINK_CFG_ID_MASK           GENMASK_ULL(11, 6)
+#define LBK_LINK_CFG_BASE_MASK         GENMASK_ULL(5, 0)
+
 #endif /* RVU_REG_H */