diff options
author | Mandy Lavi <mandy.lavi@freescale.com> | 2013-07-03 16:20:07 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-07-18 21:41:58 (GMT) |
commit | 21035f1927a4bf52af5c8d1352a5656ceca9217a (patch) | |
tree | 817b7b2de17474c1d44b0ce2592a3119134c2354 /drivers/net/ethernet/freescale/fman | |
parent | 943c9fd9774ddadda953ea08c0b197489f8fa0ba (diff) | |
download | linux-fsl-qoriq-21035f1927a4bf52af5c8d1352a5656ceca9217a.tar.xz |
fmd: exposed muram free size through sysfs
Signed-off-by: Mandy Lavi <mandy.lavi@freescale.com>
Change-Id: I69b5d2f92045daa71fd8dd6765596397fe736ef5
Reviewed-on: http://git.am.freescale.net:8181/3292
Reviewed-by: Bucur Madalin-Cristian-B32716 <madalin.bucur@freescale.com>
Reviewed-by: Hamciuc Bogdan-BHAMCIU1 <bogdan.hamciuc@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/fman')
-rw-r--r-- | drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_sysfs_fm.c | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.h b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.h index 37c52c7..7cfe3e6 100644 --- a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.h +++ b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_fm.h @@ -228,6 +228,7 @@ typedef struct { struct device_attribute *dev_pcd_attr_stats; struct device_attribute *dev_pcd_attr_regs; + struct device_attribute *dev_attr_muram_free_size; struct qman_fq *hc_tx_conf_fq, *hc_tx_err_fq, *hc_tx_fq; } t_LnxWrpFmDev; diff --git a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_sysfs_fm.c b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_sysfs_fm.c index 2cfc0b9..9237688 100644 --- a/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_sysfs_fm.c +++ b/drivers/net/ethernet/freescale/fman/src/wrapper/lnxwrp_sysfs_fm.c @@ -308,6 +308,37 @@ static ssize_t show_fm_stats(struct device *dev, return n; } +static ssize_t show_fm_muram_free_size(struct device *dev, + struct device_attribute *attr, char *buf) +{ + t_LnxWrpFmDev *p_LnxWrpFmDev = NULL; + unsigned long flags = 0; + unsigned n = 0; + uint64_t muram_free_size = 0; + + if (attr == NULL || buf == NULL || dev == NULL) + return -EINVAL; + + p_LnxWrpFmDev = (t_LnxWrpFmDev *) dev_get_drvdata(dev); + if (WARN_ON(p_LnxWrpFmDev == NULL)) + return -EINVAL; + + if (!p_LnxWrpFmDev->active || !p_LnxWrpFmDev->h_Dev) + return -EIO; + + muram_free_size = FM_MURAM_GetFreeMemSize(p_LnxWrpFmDev->h_MuramDev); + + local_irq_save(flags); + + n = snprintf(buf, PAGE_SIZE, "\tFM %d muram_free_size: %lld\n", + p_LnxWrpFmDev->id, muram_free_size); + + local_irq_restore(flags); + + return n; +} + + static ssize_t show_fm_pcd_stats(struct device *dev, struct device_attribute *attr, char *buf) { @@ -530,6 +561,7 @@ static ssize_t show_pcd_regs(struct device *dev, static DEVICE_ATTR(fm_regs, S_IRUGO, show_fm_regs, NULL); static DEVICE_ATTR(fm_pcd_regs, S_IRUGO, show_pcd_regs, NULL); +static DEVICE_ATTR(fm_muram_free_size, S_IRUGO, show_fm_muram_free_size, NULL); int fm_sysfs_create(struct device *dev) { @@ -543,6 +575,7 @@ int fm_sysfs_create(struct device *dev) /* store to remove them when module is disabled */ p_LnxWrpFmDev->dev_attr_regs = &dev_attr_fm_regs; p_LnxWrpFmDev->dev_pcd_attr_regs = &dev_attr_fm_pcd_regs; + p_LnxWrpFmDev->dev_attr_muram_free_size = &dev_attr_fm_muram_free_size; /* Create sysfs statistics group for FM module */ if (sysfs_create_group(&dev->kobj, &fm_dev_stats_attr_grp) != 0) @@ -553,6 +586,10 @@ int fm_sysfs_create(struct device *dev) device_create_file(dev, &dev_attr_fm_pcd_regs) != 0) return -EIO; + /* muram free size */ + if (device_create_file(dev, &dev_attr_fm_muram_free_size) != 0 ) + return -EIO; + return 0; } @@ -570,4 +607,5 @@ void fm_sysfs_destroy(struct device *dev) sysfs_remove_group(&dev->kobj, &fm_dev_stats_attr_grp); device_remove_file(dev, p_LnxWrpFmDev->dev_attr_regs); device_remove_file(dev, p_LnxWrpFmDev->dev_pcd_attr_regs); + device_remove_file(dev, p_LnxWrpFmDev->dev_attr_muram_free_size); } |