nvethernet: Add debug capabilities

- Dumps the descriptor dump to kernel trace buffer.
- Enable/Disable descriptor dump through sysfs.
- Dumps the register/structure dump to kernel log.

Bug 200737108

Change-Id: Ica30a881adcbd7c86771a6b441b6ffcbf813ac17
Signed-off-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2556684
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Rakesh Goyal <rgoyal@nvidia.com>
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Bhadram Varka
2021-07-09 18:31:41 +05:30
committed by Revanth Kumar Uppala
parent 4318bd4ebb
commit f972af3192
5 changed files with 126 additions and 1 deletions

View File

@@ -22,7 +22,7 @@ ccflags-y += -DLINUX_IVC -DUPDATED_PAD_CAL \
-I$(srctree.nvidia)/drivers/net/ethernet/nvidia/nvethernet/nvethernetrm/include \
-I$(srctree.nvidia)/drivers/net/ethernet/nvidia/nvethernet/nvethernetrm/osi/common/include
ccflags-y += -DMACSEC_SUPPORT -DNET30 -DMACSEC_DEBUG
ccflags-y += -DMACSEC_SUPPORT -DNET30 -DMACSEC_DEBUG -DOSI_DMA_DEBUG
nvethernet-objs:= ether_linux.o \
osd.o \
@@ -48,6 +48,7 @@ nvethernet-objs:= ether_linux.o \
$(OSI_DMA)/eqos_dma.o \
$(OSI_DMA)/eqos_desc.o \
$(OSI_DMA)/mgbe_desc.o \
$(OSI_DMA)/debug.o \
$(OSI_CORE)/mgbe_mmc.o \
$(OSI_CORE)/frp.o \
$(OSI_CORE)/vlan_filter.o

View File

@@ -1085,6 +1085,9 @@ int ether_handle_priv_ioctl(struct net_device *ndev,
struct phy_device *phydev = ndev->phydev;
struct ether_ifr_data ifdata;
struct osi_core_priv_data *osi_core = pdata->osi_core;
#ifdef OSI_DMA_DEBUG
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
#endif
int ret = -EOPNOTSUPP;
struct osi_ioctl ioctl_data = {};
@@ -1229,6 +1232,16 @@ int ether_handle_priv_ioctl(struct net_device *ndev,
case ETHER_PAD_CALIBRATION:
ret = ether_pad_calibration(ndev, ifdata.if_flags);
break;
#ifdef OSI_DMA_DEBUG
case ETHER_REGISTER_DUMP:
osi_dma->ioctl_data.cmd = OSI_DMA_IOCTL_CMD_REG_DUMP;
ret = osi_dma_ioctl(osi_dma);
break;
case ETHER_STRUCTURE_DUMP:
osi_dma->ioctl_data.cmd = OSI_DMA_IOCTL_CMD_STRUCTS_DUMP;
ret = osi_dma_ioctl(osi_dma);
break;
#endif
default:
break;
}

View File

@@ -71,6 +71,8 @@
#define ETHER_READ_REG 53
#define ETHER_WRITE_REG 54
#define ETHER_PAD_CALIBRATION 55
#define ETHER_REGISTER_DUMP 56
#define ETHER_STRUCTURE_DUMP 57
/** @} */

View File

@@ -497,6 +497,47 @@ static void osd_transmit_complete(void *priv, void *buffer, unsigned long dmaadd
}
#ifdef OSI_DMA_DEBUG
/**
* @brief Dumps the data to trace buffer
*
* @param[in] osi_dma: OSI DMA private data.
* @param[in] type: Type of data to be dump.
* @param[in] fmt: Data format.
*/
static void osd_printf(struct osi_dma_priv_data *osi_dma,
unsigned int type,
const char *fmt, ...)
{
char buf[512];
va_list args;
va_start(args, fmt);
vsprintf(buf, fmt, args);
switch (type) {
case OSI_DMA_DEBUG_DESC:
#if 0
/**
* TODO: trace_printk resulted in kernel warning GVS failure.
* Add support for writing to a file
*/
trace_printk("%s", buf);
#endif
pr_err("%s", buf);
break;
case OSI_DMA_DEBUG_REG:
case OSI_DMA_DEBUG_STRUCTS:
pr_err("%s", buf);
break;
default:
pr_err("Unsupported debug type\n");
break;
}
va_end(args);
}
#endif
void ether_assign_osd_ops(struct osi_core_priv_data *osi_core,
struct osi_dma_priv_data *osi_dma)
{
@@ -511,6 +552,9 @@ void ether_assign_osd_ops(struct osi_core_priv_data *osi_core,
osi_dma->osd_ops.realloc_buf = osd_realloc_buf;
osi_dma->osd_ops.ops_log = osd_log;
osi_dma->osd_ops.udelay = osd_udelay;
#ifdef OSI_DMA_DEBUG
osi_dma->osd_ops.printf = osd_printf;
#endif
}
/**

View File

@@ -21,6 +21,68 @@
#define EOQS_MAX_REGISTER_ADDRESS 0x12FC
#endif
#ifdef OSI_DMA_DEBUG
/**
* @brief Shows the current setting of descriptor dump
*
* @param[in] dev: Device data.
* @param[in] attr: Device attribute
* @param[in] buf: Buffer to store the current MAC loopback setting
*/
static ssize_t ether_desc_dump_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev);
struct ether_priv_data *pdata = netdev_priv(ndev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
return scnprintf(buf, PAGE_SIZE, "%s\n",
(osi_dma->enable_desc_dump == 1U) ?
"enabled" : "disabled");
}
/**
* @brief Set the user setting for enable_desc_dump
*
* Algorithm: This is used to update osi_dma->enable_desc_dump
*
* @param[in] dev: Device data.
* @param[in] attr: Device attribute
* @param[in] buf: Buffer which contains the user settings of MAC loopback
* @param[in] size: size of buffer
*
* @return size of buffer.
*/
static ssize_t ether_desc_dump_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev);
struct ether_priv_data *pdata = netdev_priv(ndev);
struct osi_dma_priv_data *osi_dma = pdata->osi_dma;
if (strncmp(buf, "enable", 6) == 0U) {
osi_dma->enable_desc_dump = 1U;
} else if (strncmp(buf, "disable", 7) == 0U) {
osi_dma->enable_desc_dump = 0U;
} else {
dev_err(pdata->dev,
"Invalid entry. Valid Entries are enable or disable\n");
}
return size;
}
/**
* @brief Sysfs attribute for enable descriptor dump
*
*/
static DEVICE_ATTR(desc_dump_enable, (S_IRUGO | S_IWUSR),
ether_desc_dump_show,
ether_desc_dump_store);
#endif /* OSI_DMA_DEBUG */
/**
* @brief Shows the current setting of MAC loopback
*
@@ -2210,6 +2272,9 @@ static DEVICE_ATTR(ptp_sync, (S_IRUGO | S_IWUSR),
* @brief Attributes for nvethernet sysfs
*/
static struct attribute *ether_sysfs_attrs[] = {
#ifdef OSI_DMA_DEBUG
&dev_attr_desc_dump_enable.attr,
#endif
&dev_attr_mac_loopback.attr,
&dev_attr_ptp_mode.attr,
&dev_attr_ptp_sync.attr,