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: Hariprasad Kelam <hkelam@marvell.com> 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>
This commit is contained in:
parent
4c236d5dc8
commit
91c6945ea1
|
@ -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
|
||||||
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
|
||||||
|
|
|
@ -21,47 +21,11 @@
|
||||||
#include <linux/of_net.h>
|
#include <linux/of_net.h>
|
||||||
|
|
||||||
#include "cgx.h"
|
#include "cgx.h"
|
||||||
|
#include "rvu.h"
|
||||||
|
#include "lmac_common.h"
|
||||||
|
|
||||||
#define DRV_NAME "octeontx2-cgx"
|
#define DRV_NAME "Marvell-CGX/RPM"
|
||||||
#define DRV_STRING "Marvell OcteonTX2 CGX/MAC Driver"
|
#define DRV_STRING "Marvell CGX/RPM Driver"
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
struct mutex cmd_lock;
|
|
||||||
u64 resp;
|
|
||||||
struct cgx_link_user_info link_info;
|
|
||||||
struct cgx_event_cb event_cb;
|
|
||||||
spinlock_t event_cb_lock;
|
|
||||||
bool cmd_pend;
|
|
||||||
struct cgx *cgx;
|
|
||||||
u8 lmac_id;
|
|
||||||
char *name;
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
static LIST_HEAD(cgx_list);
|
static LIST_HEAD(cgx_list);
|
||||||
|
|
||||||
|
@ -77,22 +41,45 @@ static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool en);
|
||||||
/* Supported devices */
|
/* Supported devices */
|
||||||
static const struct pci_device_id cgx_id_table[] = {
|
static const struct pci_device_id cgx_id_table[] = {
|
||||||
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_CGX) },
|
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_CGX) },
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CN10K_RPM) },
|
||||||
{ 0, } /* end of table */
|
{ 0, } /* end of table */
|
||||||
};
|
};
|
||||||
|
|
||||||
MODULE_DEVICE_TABLE(pci, cgx_id_table);
|
MODULE_DEVICE_TABLE(pci, cgx_id_table);
|
||||||
|
|
||||||
static void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val)
|
static bool is_dev_rpm(void *cgxd)
|
||||||
{
|
{
|
||||||
writeq(val, cgx->reg_base + (lmac << 18) + offset);
|
struct cgx *cgx = cgxd;
|
||||||
|
|
||||||
|
return (cgx->pdev->device == PCI_DEVID_CN10K_RPM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset)
|
bool is_lmac_valid(struct cgx *cgx, int lmac_id)
|
||||||
{
|
{
|
||||||
return readq(cgx->reg_base + (lmac << 18) + offset);
|
return cgx && test_bit(lmac_id, &cgx->lmac_bmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx)
|
struct mac_ops *get_mac_ops(void *cgxd)
|
||||||
|
{
|
||||||
|
if (!cgxd)
|
||||||
|
return cgxd;
|
||||||
|
|
||||||
|
return ((struct cgx *)cgxd)->mac_ops;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val)
|
||||||
|
{
|
||||||
|
writeq(val, cgx->reg_base + (lmac << cgx->mac_ops->lmac_offset) +
|
||||||
|
offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset)
|
||||||
|
{
|
||||||
|
return readq(cgx->reg_base + (lmac << cgx->mac_ops->lmac_offset) +
|
||||||
|
offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx)
|
||||||
{
|
{
|
||||||
if (!cgx || lmac_id >= MAX_LMAC_PER_CGX)
|
if (!cgx || lmac_id >= MAX_LMAC_PER_CGX)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -186,8 +173,10 @@ static u64 mac2u64 (u8 *mac_addr)
|
||||||
int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
|
int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
|
||||||
{
|
{
|
||||||
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
|
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
|
||||||
|
struct mac_ops *mac_ops;
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
|
mac_ops = cgx_dev->mac_ops;
|
||||||
/* copy 6bytes from macaddr */
|
/* copy 6bytes from macaddr */
|
||||||
/* memcpy(&cfg, mac_addr, 6); */
|
/* memcpy(&cfg, mac_addr, 6); */
|
||||||
|
|
||||||
|
@ -206,8 +195,11 @@ int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
|
||||||
u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id)
|
u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id)
|
||||||
{
|
{
|
||||||
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
|
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
|
||||||
|
struct mac_ops *mac_ops;
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
|
mac_ops = cgx_dev->mac_ops;
|
||||||
|
|
||||||
cfg = cgx_read(cgx_dev, 0, CGXX_CMRX_RX_DMAC_CAM0 + lmac_id * 0x8);
|
cfg = cgx_read(cgx_dev, 0, CGXX_CMRX_RX_DMAC_CAM0 + lmac_id * 0x8);
|
||||||
return cfg & CGX_RX_DMAC_ADR_MASK;
|
return cfg & CGX_RX_DMAC_ADR_MASK;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +208,7 @@ int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind)
|
||||||
{
|
{
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
cgx_write(cgx, lmac_id, CGXX_CMRX_RX_ID_MAP, (pkind & 0x3F));
|
cgx_write(cgx, lmac_id, CGXX_CMRX_RX_ID_MAP, (pkind & 0x3F));
|
||||||
|
@ -238,7 +230,7 @@ int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable)
|
||||||
u8 lmac_type;
|
u8 lmac_type;
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
lmac_type = cgx_get_lmac_type(cgx, lmac_id);
|
lmac_type = cgx_get_lmac_type(cgx, lmac_id);
|
||||||
|
@ -263,11 +255,13 @@ int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable)
|
||||||
void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable)
|
void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable)
|
||||||
{
|
{
|
||||||
struct cgx *cgx = cgx_get_pdata(cgx_id);
|
struct cgx *cgx = cgx_get_pdata(cgx_id);
|
||||||
|
struct mac_ops *mac_ops;
|
||||||
u64 cfg = 0;
|
u64 cfg = 0;
|
||||||
|
|
||||||
if (!cgx)
|
if (!cgx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
mac_ops = cgx->mac_ops;
|
||||||
if (enable) {
|
if (enable) {
|
||||||
/* Enable promiscuous mode on LMAC */
|
/* Enable promiscuous mode on LMAC */
|
||||||
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_RX_DMAC_CTL0);
|
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_RX_DMAC_CTL0);
|
||||||
|
@ -299,6 +293,9 @@ void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable)
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
|
if (is_dev_rpm(cgx))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!cgx)
|
if (!cgx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -323,9 +320,11 @@ void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable)
|
||||||
|
|
||||||
int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat)
|
int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat)
|
||||||
{
|
{
|
||||||
|
struct mac_ops *mac_ops;
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
mac_ops = cgx->mac_ops;
|
||||||
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
*rx_stat = cgx_read(cgx, lmac_id, CGXX_CMRX_RX_STAT0 + (idx * 8));
|
*rx_stat = cgx_read(cgx, lmac_id, CGXX_CMRX_RX_STAT0 + (idx * 8));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -333,14 +332,21 @@ int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat)
|
||||||
|
|
||||||
int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat)
|
int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat)
|
||||||
{
|
{
|
||||||
|
struct mac_ops *mac_ops;
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
mac_ops = cgx->mac_ops;
|
||||||
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
*tx_stat = cgx_read(cgx, lmac_id, CGXX_CMRX_TX_STAT0 + (idx * 8));
|
*tx_stat = cgx_read(cgx, lmac_id, CGXX_CMRX_TX_STAT0 + (idx * 8));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u64 cgx_features_get(void *cgxd)
|
||||||
|
{
|
||||||
|
return ((struct cgx *)cgxd)->hw_features;
|
||||||
|
}
|
||||||
|
|
||||||
static int cgx_set_fec_stats_count(struct cgx_link_user_info *linfo)
|
static int cgx_set_fec_stats_count(struct cgx_link_user_info *linfo)
|
||||||
{
|
{
|
||||||
if (!linfo->fec)
|
if (!linfo->fec)
|
||||||
|
@ -400,7 +406,7 @@ int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable)
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_CFG);
|
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_CFG);
|
||||||
|
@ -417,7 +423,7 @@ int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable)
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
u64 cfg, last;
|
u64 cfg, last;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_CFG);
|
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_CFG);
|
||||||
|
@ -438,7 +444,10 @@ int cgx_lmac_get_pause_frm(void *cgxd, int lmac_id,
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
if (is_dev_rpm(cgx))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
|
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
|
||||||
|
@ -455,7 +464,10 @@ int cgx_lmac_set_pause_frm(void *cgxd, int lmac_id,
|
||||||
struct cgx *cgx = cgxd;
|
struct cgx *cgx = cgxd;
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
if (is_dev_rpm(cgx))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
|
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
|
||||||
|
@ -483,7 +495,10 @@ static void cgx_lmac_pause_frm_config(struct cgx *cgx, int lmac_id, bool enable)
|
||||||
{
|
{
|
||||||
u64 cfg;
|
u64 cfg;
|
||||||
|
|
||||||
if (!cgx || lmac_id >= cgx->lmac_count)
|
if (is_dev_rpm(cgx))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!is_lmac_valid(cgx, lmac_id))
|
||||||
return;
|
return;
|
||||||
if (enable) {
|
if (enable) {
|
||||||
/* Enable receive pause frames */
|
/* Enable receive pause frames */
|
||||||
|
@ -541,6 +556,9 @@ void cgx_lmac_ptp_config(void *cgxd, int lmac_id, bool enable)
|
||||||
if (!cgx)
|
if (!cgx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (is_dev_rpm(cgx))
|
||||||
|
return;
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
/* Enable inbound PTP timestamping */
|
/* Enable inbound PTP timestamping */
|
||||||
cfg = cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL);
|
cfg = cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL);
|
||||||
|
@ -563,7 +581,7 @@ void cgx_lmac_ptp_config(void *cgxd, int lmac_id, bool enable)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CGX Firmware interface low level support */
|
/* CGX Firmware interface low level support */
|
||||||
static int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac)
|
int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac)
|
||||||
{
|
{
|
||||||
struct cgx *cgx = lmac->cgx;
|
struct cgx *cgx = lmac->cgx;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
@ -611,8 +629,7 @@ unlock:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int cgx_fwi_cmd_generic(u64 req, u64 *resp,
|
int cgx_fwi_cmd_generic(u64 req, u64 *resp, struct cgx *cgx, int lmac_id)
|
||||||
struct cgx *cgx, int lmac_id)
|
|
||||||
{
|
{
|
||||||
struct lmac *lmac;
|
struct lmac *lmac;
|
||||||
int err;
|
int err;
|
||||||
|
@ -885,12 +902,16 @@ static inline bool cgx_event_is_linkevent(u64 event)
|
||||||
|
|
||||||
static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
|
static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
|
||||||
{
|
{
|
||||||
|
u64 event, offset, clear_bit;
|
||||||
struct lmac *lmac = data;
|
struct lmac *lmac = data;
|
||||||
struct cgx *cgx;
|
struct cgx *cgx;
|
||||||
u64 event;
|
|
||||||
|
|
||||||
cgx = lmac->cgx;
|
cgx = lmac->cgx;
|
||||||
|
|
||||||
|
/* Clear SW_INT for RPM and CMR_INT for CGX */
|
||||||
|
offset = cgx->mac_ops->int_register;
|
||||||
|
clear_bit = cgx->mac_ops->int_ena_bit;
|
||||||
|
|
||||||
event = cgx_read(cgx, lmac->lmac_id, CGX_EVENT_REG);
|
event = cgx_read(cgx, lmac->lmac_id, CGX_EVENT_REG);
|
||||||
|
|
||||||
if (!FIELD_GET(EVTREG_ACK, event))
|
if (!FIELD_GET(EVTREG_ACK, event))
|
||||||
|
@ -926,7 +947,7 @@ static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
|
||||||
* Ack the interrupt register as well.
|
* Ack the interrupt register as well.
|
||||||
*/
|
*/
|
||||||
cgx_write(lmac->cgx, lmac->lmac_id, CGX_EVENT_REG, 0);
|
cgx_write(lmac->cgx, lmac->lmac_id, CGX_EVENT_REG, 0);
|
||||||
cgx_write(lmac->cgx, lmac->lmac_id, CGXX_CMRX_INT, FW_CGX_INT);
|
cgx_write(lmac->cgx, lmac->lmac_id, offset, clear_bit);
|
||||||
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
@ -970,14 +991,16 @@ int cgx_get_fwdata_base(u64 *base)
|
||||||
{
|
{
|
||||||
u64 req = 0, resp;
|
u64 req = 0, resp;
|
||||||
struct cgx *cgx;
|
struct cgx *cgx;
|
||||||
|
int first_lmac;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
cgx = list_first_entry_or_null(&cgx_list, struct cgx, cgx_list);
|
cgx = list_first_entry_or_null(&cgx_list, struct cgx, cgx_list);
|
||||||
if (!cgx)
|
if (!cgx)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
|
first_lmac = find_first_bit(&cgx->lmac_bmap, MAX_LMAC_PER_CGX);
|
||||||
req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_FWD_BASE, req);
|
req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_FWD_BASE, req);
|
||||||
err = cgx_fwi_cmd_generic(req, &resp, cgx, 0);
|
err = cgx_fwi_cmd_generic(req, &resp, cgx, first_lmac);
|
||||||
if (!err)
|
if (!err)
|
||||||
*base = FIELD_GET(RESP_FWD_BASE, resp);
|
*base = FIELD_GET(RESP_FWD_BASE, resp);
|
||||||
|
|
||||||
|
@ -1056,10 +1079,11 @@ static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool enable)
|
||||||
|
|
||||||
static inline int cgx_fwi_read_version(u64 *resp, struct cgx *cgx)
|
static inline int cgx_fwi_read_version(u64 *resp, struct cgx *cgx)
|
||||||
{
|
{
|
||||||
|
int first_lmac = find_first_bit(&cgx->lmac_bmap, MAX_LMAC_PER_CGX);
|
||||||
u64 req = 0;
|
u64 req = 0;
|
||||||
|
|
||||||
req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_FW_VER, req);
|
req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_FW_VER, req);
|
||||||
return cgx_fwi_cmd_generic(req, resp, cgx, 0);
|
return cgx_fwi_cmd_generic(req, resp, cgx, first_lmac);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cgx_lmac_verify_fwi_version(struct cgx *cgx)
|
static int cgx_lmac_verify_fwi_version(struct cgx *cgx)
|
||||||
|
@ -1092,8 +1116,8 @@ static void cgx_lmac_linkup_work(struct work_struct *work)
|
||||||
struct device *dev = &cgx->pdev->dev;
|
struct device *dev = &cgx->pdev->dev;
|
||||||
int i, err;
|
int i, err;
|
||||||
|
|
||||||
/* Do Link up for all the lmacs */
|
/* Do Link up for all the enabled lmacs */
|
||||||
for (i = 0; i < cgx->lmac_count; i++) {
|
for_each_set_bit(i, &cgx->lmac_bmap, MAX_LMAC_PER_CGX) {
|
||||||
err = cgx_fwi_link_change(cgx, i, true);
|
err = cgx_fwi_link_change(cgx, i, true);
|
||||||
if (err)
|
if (err)
|
||||||
dev_info(dev, "cgx port %d:%d Link up command failed\n",
|
dev_info(dev, "cgx port %d:%d Link up command failed\n",
|
||||||
|
@ -1113,12 +1137,67 @@ int cgx_lmac_linkup_start(void *cgxd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cgx_configure_interrupt(struct cgx *cgx, struct lmac *lmac,
|
||||||
|
int cnt, bool req_free)
|
||||||
|
{
|
||||||
|
struct mac_ops *mac_ops = cgx->mac_ops;
|
||||||
|
u64 offset, ena_bit;
|
||||||
|
unsigned int irq;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
irq = pci_irq_vector(cgx->pdev, mac_ops->lmac_fwi +
|
||||||
|
cnt * mac_ops->irq_offset);
|
||||||
|
offset = mac_ops->int_set_reg;
|
||||||
|
ena_bit = mac_ops->int_ena_bit;
|
||||||
|
|
||||||
|
if (req_free) {
|
||||||
|
free_irq(irq, lmac);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = request_irq(irq, cgx_fwi_event_handler, 0, lmac->name, lmac);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
/* Enable interrupt */
|
||||||
|
cgx_write(cgx, lmac->lmac_id, offset, ena_bit);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cgx_get_nr_lmacs(void *cgxd)
|
||||||
|
{
|
||||||
|
struct cgx *cgx = cgxd;
|
||||||
|
|
||||||
|
return cgx_read(cgx, 0, CGXX_CMRX_RX_LMACS) & 0x7ULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 cgx_get_lmacid(void *cgxd, u8 lmac_index)
|
||||||
|
{
|
||||||
|
struct cgx *cgx = cgxd;
|
||||||
|
|
||||||
|
return cgx->lmac_idmap[lmac_index]->lmac_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long cgx_get_lmac_bmap(void *cgxd)
|
||||||
|
{
|
||||||
|
struct cgx *cgx = cgxd;
|
||||||
|
|
||||||
|
return cgx->lmac_bmap;
|
||||||
|
}
|
||||||
|
|
||||||
static int cgx_lmac_init(struct cgx *cgx)
|
static int cgx_lmac_init(struct cgx *cgx)
|
||||||
{
|
{
|
||||||
struct lmac *lmac;
|
struct lmac *lmac;
|
||||||
|
u64 lmac_list;
|
||||||
int i, err;
|
int i, err;
|
||||||
|
|
||||||
cgx->lmac_count = cgx_read(cgx, 0, CGXX_CMRX_RX_LMACS) & 0x7;
|
cgx->lmac_count = cgx->mac_ops->get_nr_lmacs(cgx);
|
||||||
|
/* lmac_list specifies which lmacs are enabled
|
||||||
|
* when bit n is set to 1, LMAC[n] is enabled
|
||||||
|
*/
|
||||||
|
if (cgx->mac_ops->non_contiguous_serdes_lane)
|
||||||
|
lmac_list = cgx_read(cgx, 0, CGXX_CMRX_RX_LMACS) & 0xFULL;
|
||||||
|
|
||||||
if (cgx->lmac_count > MAX_LMAC_PER_CGX)
|
if (cgx->lmac_count > MAX_LMAC_PER_CGX)
|
||||||
cgx->lmac_count = MAX_LMAC_PER_CGX;
|
cgx->lmac_count = MAX_LMAC_PER_CGX;
|
||||||
|
|
||||||
|
@ -1132,24 +1211,25 @@ static int cgx_lmac_init(struct cgx *cgx)
|
||||||
goto err_lmac_free;
|
goto err_lmac_free;
|
||||||
}
|
}
|
||||||
sprintf(lmac->name, "cgx_fwi_%d_%d", cgx->cgx_id, i);
|
sprintf(lmac->name, "cgx_fwi_%d_%d", cgx->cgx_id, i);
|
||||||
lmac->lmac_id = i;
|
if (cgx->mac_ops->non_contiguous_serdes_lane) {
|
||||||
|
lmac->lmac_id = __ffs64(lmac_list);
|
||||||
|
lmac_list &= ~BIT_ULL(lmac->lmac_id);
|
||||||
|
} else {
|
||||||
|
lmac->lmac_id = i;
|
||||||
|
}
|
||||||
|
|
||||||
lmac->cgx = cgx;
|
lmac->cgx = cgx;
|
||||||
init_waitqueue_head(&lmac->wq_cmd_cmplt);
|
init_waitqueue_head(&lmac->wq_cmd_cmplt);
|
||||||
mutex_init(&lmac->cmd_lock);
|
mutex_init(&lmac->cmd_lock);
|
||||||
spin_lock_init(&lmac->event_cb_lock);
|
spin_lock_init(&lmac->event_cb_lock);
|
||||||
err = request_irq(pci_irq_vector(cgx->pdev,
|
err = cgx_configure_interrupt(cgx, lmac, lmac->lmac_id, false);
|
||||||
CGX_LMAC_FWI + i * 9),
|
|
||||||
cgx_fwi_event_handler, 0, lmac->name, lmac);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto err_irq;
|
goto err_irq;
|
||||||
|
|
||||||
/* Enable interrupt */
|
|
||||||
cgx_write(cgx, lmac->lmac_id, CGXX_CMRX_INT_ENA_W1S,
|
|
||||||
FW_CGX_INT);
|
|
||||||
|
|
||||||
/* Add reference */
|
/* Add reference */
|
||||||
cgx->lmac_idmap[i] = lmac;
|
cgx->lmac_idmap[lmac->lmac_id] = lmac;
|
||||||
cgx_lmac_pause_frm_config(cgx, i, true);
|
cgx_lmac_pause_frm_config(cgx, lmac->lmac_id, true);
|
||||||
|
set_bit(lmac->lmac_id, &cgx->lmac_bmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cgx_lmac_verify_fwi_version(cgx);
|
return cgx_lmac_verify_fwi_version(cgx);
|
||||||
|
@ -1173,12 +1253,12 @@ static int cgx_lmac_exit(struct cgx *cgx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free all lmac related resources */
|
/* Free all lmac related resources */
|
||||||
for (i = 0; i < cgx->lmac_count; i++) {
|
for_each_set_bit(i, &cgx->lmac_bmap, MAX_LMAC_PER_CGX) {
|
||||||
cgx_lmac_pause_frm_config(cgx, i, false);
|
|
||||||
lmac = cgx->lmac_idmap[i];
|
lmac = cgx->lmac_idmap[i];
|
||||||
if (!lmac)
|
if (!lmac)
|
||||||
continue;
|
continue;
|
||||||
free_irq(pci_irq_vector(cgx->pdev, CGX_LMAC_FWI + i * 9), lmac);
|
cgx_lmac_pause_frm_config(cgx, lmac->lmac_id, false);
|
||||||
|
cgx_configure_interrupt(cgx, lmac, lmac->lmac_id, true);
|
||||||
kfree(lmac->name);
|
kfree(lmac->name);
|
||||||
kfree(lmac);
|
kfree(lmac);
|
||||||
}
|
}
|
||||||
|
@ -1186,6 +1266,27 @@ static int cgx_lmac_exit(struct cgx *cgx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cgx_populate_features(struct cgx *cgx)
|
||||||
|
{
|
||||||
|
if (is_dev_rpm(cgx))
|
||||||
|
cgx->hw_features = RVU_MAC_RPM;
|
||||||
|
else
|
||||||
|
cgx->hw_features = (RVU_LMAC_FEAT_FC | RVU_LMAC_FEAT_PTP);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct mac_ops cgx_mac_ops = {
|
||||||
|
.name = "cgx",
|
||||||
|
.csr_offset = 0,
|
||||||
|
.lmac_offset = 18,
|
||||||
|
.int_register = CGXX_CMRX_INT,
|
||||||
|
.int_set_reg = CGXX_CMRX_INT_ENA_W1S,
|
||||||
|
.irq_offset = 9,
|
||||||
|
.int_ena_bit = FW_CGX_INT,
|
||||||
|
.lmac_fwi = CGX_LMAC_FWI,
|
||||||
|
.non_contiguous_serdes_lane = false,
|
||||||
|
.get_nr_lmacs = cgx_get_nr_lmacs,
|
||||||
|
};
|
||||||
|
|
||||||
static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
|
@ -1199,6 +1300,12 @@ static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
|
|
||||||
pci_set_drvdata(pdev, cgx);
|
pci_set_drvdata(pdev, cgx);
|
||||||
|
|
||||||
|
/* Use mac_ops to get MAC specific features */
|
||||||
|
if (pdev->device == PCI_DEVID_CN10K_RPM)
|
||||||
|
cgx->mac_ops = rpm_get_mac_ops();
|
||||||
|
else
|
||||||
|
cgx->mac_ops = &cgx_mac_ops;
|
||||||
|
|
||||||
err = pci_enable_device(pdev);
|
err = pci_enable_device(pdev);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(dev, "Failed to enable PCI device\n");
|
dev_err(dev, "Failed to enable PCI device\n");
|
||||||
|
@ -1220,7 +1327,7 @@ static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
goto err_release_regions;
|
goto err_release_regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
nvec = CGX_NVEC;
|
nvec = pci_msix_vec_count(cgx->pdev);
|
||||||
err = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_MSIX);
|
err = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_MSIX);
|
||||||
if (err < 0 || err != nvec) {
|
if (err < 0 || err != nvec) {
|
||||||
dev_err(dev, "Request for %d msix vectors failed, err %d\n",
|
dev_err(dev, "Request for %d msix vectors failed, err %d\n",
|
||||||
|
@ -1244,6 +1351,8 @@ static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
|
|
||||||
cgx_link_usertable_init();
|
cgx_link_usertable_init();
|
||||||
|
|
||||||
|
cgx_populate_features(cgx);
|
||||||
|
|
||||||
err = cgx_lmac_init(cgx);
|
err = cgx_lmac_init(cgx);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_release_lmac;
|
goto err_release_lmac;
|
||||||
|
@ -1267,8 +1376,10 @@ static void cgx_remove(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
struct cgx *cgx = pci_get_drvdata(pdev);
|
struct cgx *cgx = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
cgx_lmac_exit(cgx);
|
if (cgx) {
|
||||||
list_del(&cgx->cgx_list);
|
cgx_lmac_exit(cgx);
|
||||||
|
list_del(&cgx->cgx_list);
|
||||||
|
}
|
||||||
pci_free_irq_vectors(pdev);
|
pci_free_irq_vectors(pdev);
|
||||||
pci_release_regions(pdev);
|
pci_release_regions(pdev);
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
|
|
|
@ -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 @@
|
||||||
#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 @@
|
||||||
#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);
|
||||||
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 */
|
||||||
|
|
96
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
Normal file
96
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/* 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) \
|
||||||
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 {
|
||||||
|
|
||||||
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 {
|
||||||
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
|
||||||
|
|
39
drivers/net/ethernet/marvell/octeontx2/af/rpm.c
Normal file
39
drivers/net/ethernet/marvell/octeontx2/af/rpm.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// 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);
|
||||||
|
}
|
23
drivers/net/ethernet/marvell/octeontx2/af/rpm.h
Normal file
23
drivers/net/ethernet/marvell/octeontx2/af/rpm.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/* 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,
|
||||||
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 \
|
||||||
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)
|
||||||
{
|
{
|
||||||
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)
|
||||||
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)
|
||||||
&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)
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
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,
|
||||||
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,
|
||||||
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 @@
|
||||||
#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)
|
||||||
{
|
{
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue