Commit 91c6945e authored by Hariprasad Kelam's avatar Hariprasad Kelam Committed by David S. Miller

octeontx2-af: cn10k: Add RPM MAC support

OcteonTx2's next gen platform the CN10K has RPM MAC which has a
different serdes when compared to CGX MAC. Though the underlying
HW is different, the CSR interface has been designed largely inline
with CGX MAC, with few exceptions though. So we are using the same
CGX driver for RPM MAC as well and will have a different set of APIs
for RPM where ever necessary.

This patch adds initial support for CN10K's RPM MAC i.e. the driver
registration, communication with firmware etc. For communication with
firmware, RPM provides a different IRQ when compared to CGX.
The CGX and RPM blocks support different features. Currently few
features like ptp, flowcontrol and higig are not supported by RPM. This
patch adds new mailbox message "CGX_FEATURES_GET" to get the list of
features supported by underlying MAC.

RPM has different implementations for RX/TX stats. Unlike CGX,
bar offset of stat registers are different. This patch adds
support to access the same and dump the values in debugfs.
Signed-off-by: default avatarHariprasad Kelam <hkelam@marvell.com>
Signed-off-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: default avatarGeetha sowjanya <gakula@marvell.com>
Signed-off-by: default avatarSunil Goutham <sgoutham@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4c236d5d
...@@ -10719,6 +10719,7 @@ M: Sunil Goutham <sgoutham@marvell.com> ...@@ -10719,6 +10719,7 @@ M: Sunil Goutham <sgoutham@marvell.com>
M: Linu Cherian <lcherian@marvell.com> M: Linu Cherian <lcherian@marvell.com>
M: Geetha sowjanya <gakula@marvell.com> M: Geetha sowjanya <gakula@marvell.com>
M: Jerin Jacob <jerinj@marvell.com> M: Jerin Jacob <jerinj@marvell.com>
M: hariprasad <hkelam@marvell.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
S: Supported S: Supported
F: Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst F: Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
......
...@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o ...@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
octeontx2_mbox-y := mbox.o rvu_trace.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 \ 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_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
rvu_cpt.o rvu_devlink.o rvu_cpt.o rvu_devlink.o rpm.o
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "mbox.h" #include "mbox.h"
#include "cgx_fw_if.h" #include "cgx_fw_if.h"
#include "rpm.h"
/* PCI device IDs */ /* PCI device IDs */
#define PCI_DEVID_OCTEONTX2_CGX 0xA059 #define PCI_DEVID_OCTEONTX2_CGX 0xA059
...@@ -40,18 +41,18 @@ ...@@ -40,18 +41,18 @@
#define FW_CGX_INT BIT_ULL(1) #define FW_CGX_INT BIT_ULL(1)
#define CGXX_CMRX_INT_ENA_W1S 0x058 #define CGXX_CMRX_INT_ENA_W1S 0x058
#define CGXX_CMRX_RX_ID_MAP 0x060 #define CGXX_CMRX_RX_ID_MAP 0x060
#define CGXX_CMRX_RX_STAT0 0x070 #define CGXX_CMRX_RX_STAT0 (0x070 + mac_ops->csr_offset)
#define CGXX_CMRX_RX_LMACS 0x128 #define CGXX_CMRX_RX_LMACS 0x128
#define CGXX_CMRX_RX_DMAC_CTL0 0x1F8 #define CGXX_CMRX_RX_DMAC_CTL0 (0x1F8 + mac_ops->csr_offset)
#define CGX_DMAC_CTL0_CAM_ENABLE BIT_ULL(3) #define CGX_DMAC_CTL0_CAM_ENABLE BIT_ULL(3)
#define CGX_DMAC_CAM_ACCEPT BIT_ULL(3) #define CGX_DMAC_CAM_ACCEPT BIT_ULL(3)
#define CGX_DMAC_MCAST_MODE BIT_ULL(1) #define CGX_DMAC_MCAST_MODE BIT_ULL(1)
#define CGX_DMAC_BCAST_MODE BIT_ULL(0) #define CGX_DMAC_BCAST_MODE BIT_ULL(0)
#define CGXX_CMRX_RX_DMAC_CAM0 0x200 #define CGXX_CMRX_RX_DMAC_CAM0 (0x200 + mac_ops->csr_offset)
#define CGX_DMAC_CAM_ADDR_ENABLE BIT_ULL(48) #define CGX_DMAC_CAM_ADDR_ENABLE BIT_ULL(48)
#define CGXX_CMRX_RX_DMAC_CAM1 0x400 #define CGXX_CMRX_RX_DMAC_CAM1 0x400
#define CGX_RX_DMAC_ADR_MASK GENMASK_ULL(47, 0) #define CGX_RX_DMAC_ADR_MASK GENMASK_ULL(47, 0)
#define CGXX_CMRX_TX_STAT0 0x700 #define CGXX_CMRX_TX_STAT0 (0x700 + mac_ops->csr_offset)
#define CGXX_SCRATCH0_REG 0x1050 #define CGXX_SCRATCH0_REG 0x1050
#define CGXX_SCRATCH1_REG 0x1058 #define CGXX_SCRATCH1_REG 0x1058
#define CGX_CONST 0x2000 #define CGX_CONST 0x2000
...@@ -86,7 +87,6 @@ ...@@ -86,7 +87,6 @@
#define CGX_CMD_TIMEOUT 2200 /* msecs */ #define CGX_CMD_TIMEOUT 2200 /* msecs */
#define DEFAULT_PAUSE_TIME 0x7FF #define DEFAULT_PAUSE_TIME 0x7FF
#define CGX_NVEC 37
#define CGX_LMAC_FWI 0 #define CGX_LMAC_FWI 0
enum cgx_nix_stat_type { enum cgx_nix_stat_type {
...@@ -157,5 +157,9 @@ int cgx_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp); ...@@ -157,5 +157,9 @@ int cgx_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp);
int cgx_get_phy_fec_stats(void *cgxd, int lmac_id); int cgx_get_phy_fec_stats(void *cgxd, int lmac_id);
int cgx_set_link_mode(void *cgxd, struct cgx_set_link_mode_args args, int cgx_set_link_mode(void *cgxd, struct cgx_set_link_mode_args args,
int cgx_id, int lmac_id); int cgx_id, int lmac_id);
u64 cgx_features_get(void *cgxd);
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);
#endif /* CGX_H */ #endif /* CGX_H */
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell OcteonTx2 RPM driver
*
* Copyright (C) 2020 Marvell.
*/
#ifndef LMAC_COMMON_H
#define LMAC_COMMON_H
#include "rvu.h"
#include "cgx.h"
/**
* struct lmac
* @wq_cmd_cmplt: waitq to keep the process blocked until cmd completion
* @cmd_lock: Lock to serialize the command interface
* @resp: command response
* @link_info: link related information
* @event_cb: callback for linkchange events
* @event_cb_lock: lock for serializing callback with unregister
* @cmd_pend: flag set before new command is started
* flag cleared after command response is received
* @cgx: parent cgx port
* @lmac_id: lmac port id
* @name: lmac port name
*/
struct lmac {
wait_queue_head_t wq_cmd_cmplt;
/* Lock to serialize the command interface */
struct mutex cmd_lock;
u64 resp;
struct cgx_link_user_info link_info;
struct cgx_event_cb event_cb;
/* lock for serializing callback with unregister */
spinlock_t event_cb_lock;
bool cmd_pend;
struct cgx *cgx;
u8 lmac_id;
char *name;
};
/* CGX & RPM has different feature set
* update the structure fields with different one
*/
struct mac_ops {
char *name;
/* Features like RXSTAT, TXSTAT, DMAC FILTER csrs differs by fixed
* bar offset for example
* CGX DMAC_CTL0 0x1f8
* RPM DMAC_CTL0 0x4ff8
*/
u64 csr_offset;
/* For ATF to send events to kernel, there is no dedicated interrupt
* defined hence CGX uses OVERFLOW bit in CMR_INT. RPM block supports
* SW_INT so that ATF triggers this interrupt after processing of
* requested command
*/
u64 int_register;
u64 int_set_reg;
/* lmac offset is different is RPM */
u8 lmac_offset;
u8 irq_offset;
u8 int_ena_bit;
u8 lmac_fwi;
bool non_contiguous_serdes_lane;
/* Incase of RPM get number of lmacs from RPMX_CMR_RX_LMACS[LMAC_EXIST]
* number of setbits in lmac_exist tells number of lmacs
*/
int (*get_nr_lmacs)(void *cgx);
};
struct cgx {
void __iomem *reg_base;
struct pci_dev *pdev;
u8 cgx_id;
u8 lmac_count;
struct lmac *lmac_idmap[MAX_LMAC_PER_CGX];
struct work_struct cgx_cmd_work;
struct workqueue_struct *cgx_cmd_workq;
struct list_head cgx_list;
u64 hw_features;
struct mac_ops *mac_ops;
unsigned long lmac_bmap; /* bitmap of enabled lmacs */
};
typedef struct cgx rpm_t;
/* Function Declarations */
void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val);
u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset);
struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx);
int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac);
int cgx_fwi_cmd_generic(u64 req, u64 *resp, struct cgx *cgx, int lmac_id);
bool is_lmac_valid(struct cgx *cgx, int lmac_id);
struct mac_ops *rpm_get_mac_ops(void);
#endif /* LMAC_COMMON_H */
...@@ -159,6 +159,8 @@ M(CGX_GET_PHY_FEC_STATS, 0x212, cgx_get_phy_fec_stats, msg_req, msg_rsp) \ ...@@ -159,6 +159,8 @@ M(CGX_GET_PHY_FEC_STATS, 0x212, cgx_get_phy_fec_stats, msg_req, msg_rsp) \
M(CGX_FW_DATA_GET, 0x213, cgx_get_aux_link_info, msg_req, cgx_fw_data) \ M(CGX_FW_DATA_GET, 0x213, cgx_get_aux_link_info, msg_req, cgx_fw_data) \
M(CGX_SET_LINK_MODE, 0x214, cgx_set_link_mode, cgx_set_link_mode_req,\ M(CGX_SET_LINK_MODE, 0x214, cgx_set_link_mode, cgx_set_link_mode_req,\
cgx_set_link_mode_rsp) \ cgx_set_link_mode_rsp) \
M(CGX_FEATURES_GET, 0x215, cgx_features_get, msg_req, \
cgx_features_info_msg) \
/* NPA mbox IDs (range 0x400 - 0x5FF) */ \ /* NPA mbox IDs (range 0x400 - 0x5FF) */ \
/* NPA mbox IDs (range 0x400 - 0x5FF) */ \ /* NPA mbox IDs (range 0x400 - 0x5FF) */ \
M(NPA_LF_ALLOC, 0x400, npa_lf_alloc, \ M(NPA_LF_ALLOC, 0x400, npa_lf_alloc, \
...@@ -367,7 +369,7 @@ struct get_hw_cap_rsp { ...@@ -367,7 +369,7 @@ struct get_hw_cap_rsp {
struct cgx_stats_rsp { struct cgx_stats_rsp {
struct mbox_msghdr hdr; struct mbox_msghdr hdr;
#define CGX_RX_STATS_COUNT 13 #define CGX_RX_STATS_COUNT 9
#define CGX_TX_STATS_COUNT 18 #define CGX_TX_STATS_COUNT 18
u64 rx_stats[CGX_RX_STATS_COUNT]; u64 rx_stats[CGX_RX_STATS_COUNT];
u64 tx_stats[CGX_TX_STATS_COUNT]; u64 tx_stats[CGX_TX_STATS_COUNT];
...@@ -484,6 +486,17 @@ struct cgx_set_link_mode_rsp { ...@@ -484,6 +486,17 @@ struct cgx_set_link_mode_rsp {
int status; int status;
}; };
#define RVU_LMAC_FEAT_FC BIT_ULL(0) /* pause frames */
#define RVU_LMAC_FEAT_PTP BIT_ULL(1) /* precison time protocol */
#define RVU_MAC_VERSION BIT_ULL(2)
#define RVU_MAC_CGX 0
#define RVU_MAC_RPM 1
struct cgx_features_info_msg {
struct mbox_msghdr hdr;
u64 lmac_features;
};
/* NPA mbox message formats */ /* NPA mbox message formats */
/* NPA mailbox error codes /* NPA mailbox error codes
......
// SPDX-License-Identifier: GPL-2.0
/* Marvell OcteonTx2 RPM driver
*
* Copyright (C) 2020 Marvell.
*
*/
#include "cgx.h"
#include "lmac_common.h"
static struct mac_ops rpm_mac_ops = {
.name = "rpm",
.csr_offset = 0x4e00,
.lmac_offset = 20,
.int_register = RPMX_CMRX_SW_INT,
.int_set_reg = RPMX_CMRX_SW_INT_ENA_W1S,
.irq_offset = 1,
.int_ena_bit = BIT_ULL(0),
.lmac_fwi = RPM_LMAC_FWI,
.non_contiguous_serdes_lane = true,
.get_nr_lmacs = rpm_get_nr_lmacs,
};
struct mac_ops *rpm_get_mac_ops(void)
{
return &rpm_mac_ops;
}
static u64 rpm_read(rpm_t *rpm, u64 lmac, u64 offset)
{
return cgx_read(rpm, lmac, offset);
}
int rpm_get_nr_lmacs(void *rpmd)
{
rpm_t *rpm = rpmd;
return hweight8(rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS) & 0xFULL);
}
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell OcteonTx2 RPM driver
*
* Copyright (C) 2020 Marvell.
*
*/
#ifndef RPM_H
#define RPM_H
/* PCI device IDs */
#define PCI_DEVID_CN10K_RPM 0xA060
/* Registers */
#define RPMX_CMRX_SW_INT 0x180
#define RPMX_CMRX_SW_INT_W1S 0x188
#define RPMX_CMRX_SW_INT_ENA_W1S 0x198
#define RPM_LMAC_FWI 0xa
/* Function Declarations */
int rpm_get_nr_lmacs(void *cgxd);
#endif /* RPM_H */
...@@ -635,6 +635,8 @@ void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, ...@@ -635,6 +635,8 @@ void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
int blkaddr, u16 src, struct mcam_entry *entry, int blkaddr, u16 src, struct mcam_entry *entry,
u8 *intf, u8 *ena); u8 *intf, u8 *ena);
bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature);
/* CPT APIs */ /* CPT APIs */
int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot); int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot);
......
...@@ -42,6 +42,20 @@ static struct _req_type __maybe_unused \ ...@@ -42,6 +42,20 @@ static struct _req_type __maybe_unused \
MBOX_UP_CGX_MESSAGES MBOX_UP_CGX_MESSAGES
#undef M #undef M
bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature)
{
u8 cgx_id, lmac_id;
void *cgxd;
if (!is_pf_cgxmapped(rvu, pf))
return 0;
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
cgxd = rvu_cgx_pdata(cgx_id, rvu);
return (cgx_features_get(cgxd) & feature);
}
/* Returns bitmap of mapped PFs */ /* Returns bitmap of mapped PFs */
static u16 cgxlmac_to_pfmap(struct rvu *rvu, u8 cgx_id, u8 lmac_id) static u16 cgxlmac_to_pfmap(struct rvu *rvu, u8 cgx_id, u8 lmac_id)
{ {
...@@ -92,9 +106,10 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu) ...@@ -92,9 +106,10 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu)
{ {
struct npc_pkind *pkind = &rvu->hw->pkind; struct npc_pkind *pkind = &rvu->hw->pkind;
int cgx_cnt_max = rvu->cgx_cnt_max; int cgx_cnt_max = rvu->cgx_cnt_max;
int cgx, lmac_cnt, lmac;
int pf = PF_CGXMAP_BASE; int pf = PF_CGXMAP_BASE;
unsigned long lmac_bmap;
int size, free_pkind; int size, free_pkind;
int cgx, lmac, iter;
if (!cgx_cnt_max) if (!cgx_cnt_max)
return 0; return 0;
...@@ -125,14 +140,17 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu) ...@@ -125,14 +140,17 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu)
for (cgx = 0; cgx < cgx_cnt_max; cgx++) { for (cgx = 0; cgx < cgx_cnt_max; cgx++) {
if (!rvu_cgx_pdata(cgx, rvu)) if (!rvu_cgx_pdata(cgx, rvu))
continue; continue;
lmac_cnt = cgx_get_lmac_cnt(rvu_cgx_pdata(cgx, rvu)); lmac_bmap = cgx_get_lmac_bmap(rvu_cgx_pdata(cgx, rvu));
for (lmac = 0; lmac < lmac_cnt; lmac++, pf++) { for_each_set_bit(iter, &lmac_bmap, MAX_LMAC_PER_CGX) {
lmac = cgx_get_lmacid(rvu_cgx_pdata(cgx, rvu),
iter);
rvu->pf2cgxlmac_map[pf] = cgxlmac_id_to_bmap(cgx, lmac); rvu->pf2cgxlmac_map[pf] = cgxlmac_id_to_bmap(cgx, lmac);
rvu->cgxlmac2pf_map[CGX_OFFSET(cgx) + lmac] = 1 << pf; rvu->cgxlmac2pf_map[CGX_OFFSET(cgx) + lmac] = 1 << pf;
free_pkind = rvu_alloc_rsrc(&pkind->rsrc); free_pkind = rvu_alloc_rsrc(&pkind->rsrc);
pkind->pfchan_map[free_pkind] = ((pf) & 0x3F) << 16; pkind->pfchan_map[free_pkind] = ((pf) & 0x3F) << 16;
rvu_map_cgx_nix_block(rvu, pf, cgx, lmac); rvu_map_cgx_nix_block(rvu, pf, cgx, lmac);
rvu->cgx_mapped_pfs++; rvu->cgx_mapped_pfs++;
pf++;
} }
} }
return 0; return 0;
...@@ -154,8 +172,10 @@ static int rvu_cgx_send_link_info(int cgx_id, int lmac_id, struct rvu *rvu) ...@@ -154,8 +172,10 @@ static int rvu_cgx_send_link_info(int cgx_id, int lmac_id, struct rvu *rvu)
&qentry->link_event.link_uinfo); &qentry->link_event.link_uinfo);
qentry->link_event.cgx_id = cgx_id; qentry->link_event.cgx_id = cgx_id;
qentry->link_event.lmac_id = lmac_id; qentry->link_event.lmac_id = lmac_id;
if (err) if (err) {
kfree(qentry);
goto skip_add; goto skip_add;
}
list_add_tail(&qentry->evq_node, &rvu->cgx_evq_head); list_add_tail(&qentry->evq_node, &rvu->cgx_evq_head);
skip_add: skip_add:
spin_unlock_irqrestore(&rvu->cgx_evq_lock, flags); spin_unlock_irqrestore(&rvu->cgx_evq_lock, flags);
...@@ -251,6 +271,7 @@ static void cgx_evhandler_task(struct work_struct *work) ...@@ -251,6 +271,7 @@ static void cgx_evhandler_task(struct work_struct *work)
static int cgx_lmac_event_handler_init(struct rvu *rvu) static int cgx_lmac_event_handler_init(struct rvu *rvu)
{ {
unsigned long lmac_bmap;
struct cgx_event_cb cb; struct cgx_event_cb cb;
int cgx, lmac, err; int cgx, lmac, err;
void *cgxd; void *cgxd;
...@@ -271,7 +292,8 @@ static int cgx_lmac_event_handler_init(struct rvu *rvu) ...@@ -271,7 +292,8 @@ static int cgx_lmac_event_handler_init(struct rvu *rvu)
cgxd = rvu_cgx_pdata(cgx, rvu); cgxd = rvu_cgx_pdata(cgx, rvu);
if (!cgxd) if (!cgxd)
continue; continue;
for (lmac = 0; lmac < cgx_get_lmac_cnt(cgxd); lmac++) { lmac_bmap = cgx_get_lmac_bmap(cgxd);
for_each_set_bit(lmac, &lmac_bmap, MAX_LMAC_PER_CGX) {
err = cgx_lmac_evh_register(&cb, cgxd, lmac); err = cgx_lmac_evh_register(&cb, cgxd, lmac);
if (err) if (err)
dev_err(rvu->dev, dev_err(rvu->dev,
...@@ -349,6 +371,7 @@ int rvu_cgx_init(struct rvu *rvu) ...@@ -349,6 +371,7 @@ int rvu_cgx_init(struct rvu *rvu)
int rvu_cgx_exit(struct rvu *rvu) int rvu_cgx_exit(struct rvu *rvu)
{ {
unsigned long lmac_bmap;
int cgx, lmac; int cgx, lmac;
void *cgxd; void *cgxd;
...@@ -356,7 +379,8 @@ int rvu_cgx_exit(struct rvu *rvu) ...@@ -356,7 +379,8 @@ int rvu_cgx_exit(struct rvu *rvu)
cgxd = rvu_cgx_pdata(cgx, rvu); cgxd = rvu_cgx_pdata(cgx, rvu);
if (!cgxd) if (!cgxd)
continue; continue;
for (lmac = 0; lmac < cgx_get_lmac_cnt(cgxd); lmac++) lmac_bmap = cgx_get_lmac_bmap(cgxd);
for_each_set_bit(lmac, &lmac_bmap, MAX_LMAC_PER_CGX)
cgx_lmac_evh_unregister(cgxd, lmac); cgx_lmac_evh_unregister(cgxd, lmac);
} }
...@@ -554,6 +578,9 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcifunc, bool enable) ...@@ -554,6 +578,9 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcifunc, bool enable)
u8 cgx_id, lmac_id; u8 cgx_id, lmac_id;
void *cgxd; void *cgxd;
if (!is_mac_feature_supported(rvu, pf, RVU_LMAC_FEAT_PTP))
return 0;
/* This msg is expected only from PFs that are mapped to CGX LMACs, /* This msg is expected only from PFs that are mapped to CGX LMACs,
* if received from other PF/VF simply ACK, nothing to do. * if received from other PF/VF simply ACK, nothing to do.
*/ */
...@@ -640,6 +667,24 @@ int rvu_mbox_handler_cgx_get_linkinfo(struct rvu *rvu, struct msg_req *req, ...@@ -640,6 +667,24 @@ int rvu_mbox_handler_cgx_get_linkinfo(struct rvu *rvu, struct msg_req *req,
return err; return err;
} }
int rvu_mbox_handler_cgx_features_get(struct rvu *rvu,
struct msg_req *req,
struct cgx_features_info_msg *rsp)
{
int pf = rvu_get_pf(req->hdr.pcifunc);
u8 cgx_idx, lmac;
void *cgxd;
if (!is_pf_cgxmapped(rvu, pf))
return 0;
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_idx, &lmac);
cgxd = rvu_cgx_pdata(cgx_idx, rvu);
rsp->lmac_features = cgx_features_get(cgxd);
return 0;
}
static int rvu_cgx_config_intlbk(struct rvu *rvu, u16 pcifunc, bool en) static int rvu_cgx_config_intlbk(struct rvu *rvu, u16 pcifunc, bool en)
{ {
int pf = rvu_get_pf(pcifunc); int pf = rvu_get_pf(pcifunc);
...@@ -675,6 +720,9 @@ int rvu_mbox_handler_cgx_cfg_pause_frm(struct rvu *rvu, ...@@ -675,6 +720,9 @@ int rvu_mbox_handler_cgx_cfg_pause_frm(struct rvu *rvu,
int pf = rvu_get_pf(req->hdr.pcifunc); int pf = rvu_get_pf(req->hdr.pcifunc);
u8 cgx_id, lmac_id; u8 cgx_id, lmac_id;
if (!is_mac_feature_supported(rvu, pf, RVU_LMAC_FEAT_FC))
return 0;
/* This msg is expected only from PF/VFs that are mapped to CGX LMACs, /* This msg is expected only from PF/VFs that are mapped to CGX LMACs,
* if received from other PF/VF simply ACK, nothing to do. * if received from other PF/VF simply ACK, nothing to do.
*/ */
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "rvu_reg.h" #include "rvu_reg.h"
#include "rvu.h" #include "rvu.h"
#include "cgx.h" #include "cgx.h"
#include "lmac_common.h"
#include "npc.h" #include "npc.h"
#define DEBUGFS_DIR_NAME "octeontx2" #define DEBUGFS_DIR_NAME "octeontx2"
...@@ -234,6 +235,8 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused) ...@@ -234,6 +235,8 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused)
{ {
struct rvu *rvu = filp->private; struct rvu *rvu = filp->private;
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
struct mac_ops *mac_ops;
int rvu_def_cgx_id = 0;
char cgx[10], lmac[10]; char cgx[10], lmac[10];
struct rvu_pfvf *pfvf; struct rvu_pfvf *pfvf;
int pf, domain, blkid; int pf, domain, blkid;
...@@ -241,7 +244,9 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused) ...@@ -241,7 +244,9 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused)
u16 pcifunc; u16 pcifunc;
domain = 2; domain = 2;
seq_puts(filp, "PCI dev\t\tRVU PF Func\tNIX block\tCGX\tLMAC\n"); mac_ops = get_mac_ops(rvu_cgx_pdata(rvu_def_cgx_id, rvu));
seq_printf(filp, "PCI dev\t\tRVU PF Func\tNIX block\t%s\tLMAC\n",
mac_ops->name);
for (pf = 0; pf < rvu->hw->total_pfs; pf++) { for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
if (!is_pf_cgxmapped(rvu, pf)) if (!is_pf_cgxmapped(rvu, pf))
continue; continue;
...@@ -262,7 +267,7 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused) ...@@ -262,7 +267,7 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused)
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id,
&lmac_id); &lmac_id);
sprintf(cgx, "CGX%d", cgx_id); sprintf(cgx, "%s%d", mac_ops->name, cgx_id);
sprintf(lmac, "LMAC%d", lmac_id); sprintf(lmac, "LMAC%d", lmac_id);
seq_printf(filp, "%s\t0x%x\t\tNIX%d\t\t%s\t%s\n", seq_printf(filp, "%s\t0x%x\t\tNIX%d\t\t%s\t%s\n",
dev_name(&pdev->dev), pcifunc, blkid, cgx, lmac); dev_name(&pdev->dev), pcifunc, blkid, cgx, lmac);
...@@ -1601,6 +1606,7 @@ static void rvu_dbg_npa_init(struct rvu *rvu) ...@@ -1601,6 +1606,7 @@ static void rvu_dbg_npa_init(struct rvu *rvu)
static int cgx_print_stats(struct seq_file *s, int lmac_id) static int cgx_print_stats(struct seq_file *s, int lmac_id)
{ {
struct cgx_link_user_info linfo; struct cgx_link_user_info linfo;
struct mac_ops *mac_ops;
void *cgxd = s->private; void *cgxd = s->private;
u64 ucast, mcast, bcast; u64 ucast, mcast, bcast;
int stat = 0, err = 0; int stat = 0, err = 0;
...@@ -1612,6 +1618,11 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id) ...@@ -1612,6 +1618,11 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
if (!rvu) if (!rvu)
return -ENODEV; return -ENODEV;
mac_ops = get_mac_ops(cgxd);
if (!mac_ops)
return 0;
/* Link status */ /* Link status */
seq_puts(s, "\n=======Link Status======\n\n"); seq_puts(s, "\n=======Link Status======\n\n");
err = cgx_get_link_info(cgxd, lmac_id, &linfo); err = cgx_get_link_info(cgxd, lmac_id, &linfo);
...@@ -1621,7 +1632,8 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id) ...@@ -1621,7 +1632,8 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
linfo.link_up ? "UP" : "DOWN", linfo.speed); linfo.link_up ? "UP" : "DOWN", linfo.speed);
/* Rx stats */ /* Rx stats */
seq_puts(s, "\n=======NIX RX_STATS(CGX port level)======\n\n"); seq_printf(s, "\n=======NIX RX_STATS(%s port level)======\n\n",
mac_ops->name);
ucast = PRINT_CGX_CUML_NIXRX_STATUS(RX_UCAST, "rx_ucast_frames"); ucast = PRINT_CGX_CUML_NIXRX_STATUS(RX_UCAST, "rx_ucast_frames");
if (err) if (err)
return err; return err;
...@@ -1643,7 +1655,8 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id) ...@@ -1643,7 +1655,8 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
return err; return err;
/* Tx stats */ /* Tx stats */
seq_puts(s, "\n=======NIX TX_STATS(CGX port level)======\n\n"); seq_printf(s, "\n=======NIX TX_STATS(%s port level)======\n\n",
mac_ops->name);
ucast = PRINT_CGX_CUML_NIXTX_STATUS(TX_UCAST, "tx_ucast_frames"); ucast = PRINT_CGX_CUML_NIXTX_STATUS(TX_UCAST, "tx_ucast_frames");
if (err) if (err)
return err; return err;
...@@ -1662,7 +1675,7 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id) ...@@ -1662,7 +1675,7 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
return err; return err;
/* Rx stats */ /* Rx stats */
seq_puts(s, "\n=======CGX RX_STATS======\n\n"); seq_printf(s, "\n=======%s RX_STATS======\n\n", mac_ops->name);
while (stat < CGX_RX_STATS_COUNT) { while (stat < CGX_RX_STATS_COUNT) {
err = cgx_get_rx_stats(cgxd, lmac_id, stat, &rx_stat); err = cgx_get_rx_stats(cgxd, lmac_id, stat, &rx_stat);
if (err) if (err)
...@@ -1673,7 +1686,7 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id) ...@@ -1673,7 +1686,7 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
/* Tx stats */ /* Tx stats */
stat = 0; stat = 0;
seq_puts(s, "\n=======CGX TX_STATS======\n\n"); seq_printf(s, "\n=======%s TX_STATS======\n\n", mac_ops->name);
while (stat < CGX_TX_STATS_COUNT) { while (stat < CGX_TX_STATS_COUNT) {
err = cgx_get_tx_stats(cgxd, lmac_id, stat, &tx_stat); err = cgx_get_tx_stats(cgxd, lmac_id, stat, &tx_stat);
if (err) if (err)
...@@ -1709,6 +1722,9 @@ RVU_DEBUG_SEQ_FOPS(cgx_stat, cgx_stat_display, NULL); ...@@ -1709,6 +1722,9 @@ RVU_DEBUG_SEQ_FOPS(cgx_stat, cgx_stat_display, NULL);
static void rvu_dbg_cgx_init(struct rvu *rvu) static void rvu_dbg_cgx_init(struct rvu *rvu)
{ {
struct mac_ops *mac_ops;
unsigned long lmac_bmap;
int rvu_def_cgx_id = 0;
int i, lmac_id; int i, lmac_id;
char dname[20]; char dname[20];
void *cgx; void *cgx;
...@@ -1716,17 +1732,24 @@ static void rvu_dbg_cgx_init(struct rvu *rvu) ...@@ -1716,17 +1732,24 @@ static void rvu_dbg_cgx_init(struct rvu *rvu)
if (!cgx_get_cgxcnt_max()) if (!cgx_get_cgxcnt_max())
return; return;
rvu->rvu_dbg.cgx_root = debugfs_create_dir("cgx", rvu->rvu_dbg.root); mac_ops = get_mac_ops(rvu_cgx_pdata(rvu_def_cgx_id, rvu));
if (!mac_ops)
return;
rvu->rvu_dbg.cgx_root = debugfs_create_dir(mac_ops->name,
rvu->rvu_dbg.root);
for (i = 0; i < cgx_get_cgxcnt_max(); i++) { for (i = 0; i < cgx_get_cgxcnt_max(); i++) {
cgx = rvu_cgx_pdata(i, rvu); cgx = rvu_cgx_pdata(i, rvu);
if (!cgx) if (!cgx)
continue; continue;
lmac_bmap = cgx_get_lmac_bmap(cgx);
/* cgx debugfs dir */ /* cgx debugfs dir */
sprintf(dname, "cgx%d", i); sprintf(dname, "%s%d", mac_ops->name, i);
rvu->rvu_dbg.cgx = debugfs_create_dir(dname, rvu->rvu_dbg.cgx = debugfs_create_dir(dname,
rvu->rvu_dbg.cgx_root); rvu->rvu_dbg.cgx_root);
for (lmac_id = 0; lmac_id < cgx_get_lmac_cnt(cgx); lmac_id++) {
for_each_set_bit(lmac_id, &lmac_bmap, MAX_LMAC_PER_CGX) {
/* lmac debugfs dir */ /* lmac debugfs dir */
sprintf(dname, "lmac%d", lmac_id); sprintf(dname, "lmac%d", lmac_id);
rvu->rvu_dbg.lmac = rvu->rvu_dbg.lmac =
...@@ -2307,9 +2330,18 @@ void rvu_dbg_init(struct rvu *rvu) ...@@ -2307,9 +2330,18 @@ void rvu_dbg_init(struct rvu *rvu)
debugfs_create_file("rsrc_alloc", 0444, rvu->rvu_dbg.root, rvu, debugfs_create_file("rsrc_alloc", 0444, rvu->rvu_dbg.root, rvu,
&rvu_dbg_rsrc_status_fops); &rvu_dbg_rsrc_status_fops);
debugfs_create_file("rvu_pf_cgx_map", 0444, rvu->rvu_dbg.root, rvu,
&rvu_dbg_rvu_pf_cgx_map_fops);
if (!cgx_get_cgxcnt_max())
goto create;
if (is_rvu_otx2(rvu))
debugfs_create_file("rvu_pf_cgx_map", 0444, rvu->rvu_dbg.root,
rvu, &rvu_dbg_rvu_pf_cgx_map_fops);
else
debugfs_create_file("rvu_pf_cgx_map", 0444, rvu->rvu_dbg.root,
rvu, &rvu_dbg_rvu_pf_cgx_map_fops);
create:
rvu_dbg_npa_init(rvu); rvu_dbg_npa_init(rvu);
rvu_dbg_nix_init(rvu, BLKADDR_NIX0); rvu_dbg_nix_init(rvu, BLKADDR_NIX0);
......
...@@ -3631,10 +3631,14 @@ static int rvu_nix_lf_ptp_tx_cfg(struct rvu *rvu, u16 pcifunc, bool enable) ...@@ -3631,10 +3631,14 @@ static int rvu_nix_lf_ptp_tx_cfg(struct rvu *rvu, u16 pcifunc, bool enable)
{ {
struct rvu_hwinfo *hw = rvu->hw; struct rvu_hwinfo *hw = rvu->hw;
struct rvu_block *block; struct rvu_block *block;
int blkaddr; int blkaddr, pf;
int nixlf; int nixlf;
u64 cfg; u64 cfg;
pf = rvu_get_pf(pcifunc);
if (!is_mac_feature_supported(rvu, pf, RVU_LMAC_FEAT_PTP))
return 0;
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc); blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
if (blkaddr < 0) if (blkaddr < 0)
return NIX_AF_ERR_AF_LF_INVALID; return NIX_AF_ERR_AF_LF_INVALID;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment