* [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection
@ 2015-07-23 13:32 WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 1/6] net: netcp: Fixes the use of spin_lock_bh in timer function WingMan Kwok
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: WingMan Kwok @ 2015-07-23 13:32 UTC (permalink / raw)
To: davem, m-karicheri2, netdev, linux-kernel; +Cc: WingMan Kwok
This patch set contains bug fixes and enhencements of hw ethernet
statistics processing on TI's Keystone2 CPSW ethernet switches.
WingMan Kwok (6):
net: netcp: Fixes the use of spin_lock_bh in timer function
net: netcp: Fixes hw statistics module base setting error
net: netcp: Fixes error in oversized memory allocation for statistics
storage
net: netcp: Consolidates statistics collection code
net: netcp: Fixes to CPSW statistics collection
net: netcp: Adds missing statistics for K2L and K2E
drivers/net/ethernet/ti/netcp_ethss.c | 399 ++++++++++++++++++++++++++-------
1 file changed, 324 insertions(+), 75 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [net-next PATCH v0 1/6] net: netcp: Fixes the use of spin_lock_bh in timer function
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
@ 2015-07-23 13:32 ` WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 2/6] net: netcp: Fixes hw statistics module base setting error WingMan Kwok
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: WingMan Kwok @ 2015-07-23 13:32 UTC (permalink / raw)
To: davem, m-karicheri2, netdev, linux-kernel; +Cc: WingMan Kwok
This patch fixes a bug in which the timer routine synchronized
against the ethtool-triggered statistics updates with spin_lock_bh().
A timer function is itself a bottom-half, so this should be
spin_lock().
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
drivers/net/ethernet/ti/netcp_ethss.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 9b7e0a3..cabf977 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2189,14 +2189,15 @@ static void netcp_ethss_timer(unsigned long arg)
netcp_ethss_update_link_state(gbe_dev, slave, NULL);
}
- spin_lock_bh(&gbe_dev->hw_stats_lock);
+ /* A timer runs as a BH, no need to block them */
+ spin_lock(&gbe_dev->hw_stats_lock);
if (gbe_dev->ss_version == GBE_SS_VERSION_14)
gbe_update_stats_ver14(gbe_dev, NULL);
else
gbe_update_stats(gbe_dev, NULL);
- spin_unlock_bh(&gbe_dev->hw_stats_lock);
+ spin_unlock(&gbe_dev->hw_stats_lock);
gbe_dev->timer.expires = jiffies + GBE_TIMER_INTERVAL;
add_timer(&gbe_dev->timer);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [net-next PATCH v0 2/6] net: netcp: Fixes hw statistics module base setting error
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 1/6] net: netcp: Fixes the use of spin_lock_bh in timer function WingMan Kwok
@ 2015-07-23 13:32 ` WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 3/6] net: netcp: Fixes error in oversized memory allocation for statistics storage WingMan Kwok
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: WingMan Kwok @ 2015-07-23 13:32 UTC (permalink / raw)
To: davem, m-karicheri2, netdev, linux-kernel; +Cc: WingMan Kwok
This patch fixes error in the setting of the hw statistics
module base for K2HK platform. In K2HK although there are
4 hw statistics modules, but only 2 are visible at a time.
Thus when setting up the pointers to the base of the
corresponding hw statistics modules, modules 0 and 2 should
point to one base, while modules 1 and 3 should point to the
other.
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
drivers/net/ethernet/ti/netcp_ethss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index cabf977..b954856 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2675,10 +2675,14 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
gbe_dev->sgmii_port_regs = gbe_dev->ss_regs + GBE13_SGMII_MODULE_OFFSET;
gbe_dev->host_port_regs = gbe_dev->switch_regs + GBE13_HOST_PORT_OFFSET;
+ /* K2HK has only 2 hw stats modules visible at a time, so
+ * module 0 & 2 points to one base and
+ * module 1 & 3 points to the other base
+ */
for (i = 0; i < gbe_dev->max_num_slaves; i++) {
gbe_dev->hw_stats_regs[i] =
gbe_dev->switch_regs + GBE13_HW_STATS_OFFSET +
- (GBE_HW_STATS_REG_MAP_SZ * i);
+ (GBE_HW_STATS_REG_MAP_SZ * (i & 0x1));
}
gbe_dev->ale_reg = gbe_dev->switch_regs + GBE13_ALE_OFFSET;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [net-next PATCH v0 3/6] net: netcp: Fixes error in oversized memory allocation for statistics storage
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 1/6] net: netcp: Fixes the use of spin_lock_bh in timer function WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 2/6] net: netcp: Fixes hw statistics module base setting error WingMan Kwok
@ 2015-07-23 13:32 ` WingMan Kwok
2015-07-23 14:01 ` Murali Karicheri
2015-07-23 13:32 ` [net-next PATCH v0 4/6] net: netcp: Consolidates statistics collection code WingMan Kwok
` (3 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: WingMan Kwok @ 2015-07-23 13:32 UTC (permalink / raw)
To: davem, m-karicheri2, netdev, linux-kernel; +Cc: WingMan Kwok
The CPSW driver keeps internally some, but not all, of
the statistics available in the hw statistics modules. Furthermore,
some of the locations in the hw statistics modules are reserved and
contain no useful information. Prior to this patch, the driver
allocates memory of the size of the the whole hw statistics modules,
instead of the size of statistics-entries-interested-in (i.e. et_stats),
for internal storage. This patch fixes that.
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
drivers/net/ethernet/ti/netcp_ethss.c | 42 ++++++++++++++++-----------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index b954856..a1f16e1 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2555,10 +2555,12 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
}
gbe_dev->xgbe_serdes_regs = regs;
+ gbe_dev->et_stats = xgbe10_et_stats;
+ gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
+
gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
- XGBE10_NUM_STAT_ENTRIES *
- (gbe_dev->max_num_ports) * sizeof(u64),
- GFP_KERNEL);
+ gbe_dev->num_et_stats * sizeof(u64),
+ GFP_KERNEL);
if (!gbe_dev->hw_stats) {
dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
return -ENOMEM;
@@ -2577,8 +2579,6 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
gbe_dev->ale_ports = gbe_dev->max_num_ports;
gbe_dev->host_port = XGBE10_HOST_PORT_NUM;
gbe_dev->ale_entries = XGBE10_NUM_ALE_ENTRIES;
- gbe_dev->et_stats = xgbe10_et_stats;
- gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
gbe_dev->stats_en_mask = (1 << (gbe_dev->max_num_ports)) - 1;
/* Subsystem registers */
@@ -2663,10 +2663,12 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
}
gbe_dev->switch_regs = regs;
+ gbe_dev->et_stats = gbe13_et_stats;
+ gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
+
gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
- GBE13_NUM_HW_STAT_ENTRIES *
- gbe_dev->max_num_slaves * sizeof(u64),
- GFP_KERNEL);
+ gbe_dev->num_et_stats * sizeof(u64),
+ GFP_KERNEL);
if (!gbe_dev->hw_stats) {
dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
return -ENOMEM;
@@ -2689,8 +2691,6 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
gbe_dev->ale_ports = gbe_dev->max_num_ports;
gbe_dev->host_port = GBE13_HOST_PORT_NUM;
gbe_dev->ale_entries = GBE13_NUM_ALE_ENTRIES;
- gbe_dev->et_stats = gbe13_et_stats;
- gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
gbe_dev->stats_en_mask = GBE13_REG_VAL_STAT_ENABLE_ALL;
/* Subsystem registers */
@@ -2717,10 +2717,18 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
void __iomem *regs;
int i, ret;
+ gbe_dev->et_stats = gbenu_et_stats;
+
+ if (IS_SS_ID_NU(gbe_dev))
+ gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
+ (gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE);
+ else
+ gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
+ GBENU_ET_STATS_PORT_SIZE;
+
gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
- GBENU_NUM_HW_STAT_ENTRIES *
- (gbe_dev->max_num_ports) * sizeof(u64),
- GFP_KERNEL);
+ gbe_dev->num_et_stats * sizeof(u64),
+ GFP_KERNEL);
if (!gbe_dev->hw_stats) {
dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
return -ENOMEM;
@@ -2753,16 +2761,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
gbe_dev->ale_ports = gbe_dev->max_num_ports;
gbe_dev->host_port = GBENU_HOST_PORT_NUM;
gbe_dev->ale_entries = GBE13_NUM_ALE_ENTRIES;
- gbe_dev->et_stats = gbenu_et_stats;
gbe_dev->stats_en_mask = (1 << (gbe_dev->max_num_ports)) - 1;
- if (IS_SS_ID_NU(gbe_dev))
- gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
- (gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE);
- else
- gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
- GBENU_ET_STATS_PORT_SIZE;
-
/* Subsystem registers */
GBENU_SET_REG_OFS(gbe_dev, ss_regs, id_ver);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [net-next PATCH v0 4/6] net: netcp: Consolidates statistics collection code
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
` (2 preceding siblings ...)
2015-07-23 13:32 ` [net-next PATCH v0 3/6] net: netcp: Fixes error in oversized memory allocation for statistics storage WingMan Kwok
@ 2015-07-23 13:32 ` WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 5/6] net: netcp: Fixes to CPSW statistics collection WingMan Kwok
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: WingMan Kwok @ 2015-07-23 13:32 UTC (permalink / raw)
To: davem, m-karicheri2, netdev, linux-kernel; +Cc: WingMan Kwok
Different Keystone2 platforms have different number and
layouts of hw statistics modules. This patch consolidates
the statistics processing of different Keystone2 platforms
for easy maintenance.
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
drivers/net/ethernet/ti/netcp_ethss.c | 99 ++++++++++++++++++---------------
1 file changed, 54 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index a1f16e1..aadca02 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -1554,70 +1554,79 @@ static int keystone_get_sset_count(struct net_device *ndev, int stringset)
}
}
-static void gbe_update_stats(struct gbe_priv *gbe_dev, uint64_t *data)
+static inline void gbe_update_hw_stats_entry(struct gbe_priv *gbe_dev,
+ int et_stats_entry)
{
void __iomem *base = NULL;
u32 __iomem *p;
u32 tmp = 0;
+
+ /* The hw_stats_regs pointers are already
+ * properly set to point to the right base:
+ */
+ base = gbe_dev->hw_stats_regs[gbe_dev->et_stats[et_stats_entry].type];
+ p = base + gbe_dev->et_stats[et_stats_entry].offset;
+ tmp = readl(p);
+ gbe_dev->hw_stats[et_stats_entry] += tmp;
+
+ /* write-to-decrement:
+ * new register value = old register value - write value
+ */
+ writel(tmp, p);
+}
+
+static void gbe_update_stats(struct gbe_priv *gbe_dev, uint64_t *data)
+{
int i;
for (i = 0; i < gbe_dev->num_et_stats; i++) {
- base = gbe_dev->hw_stats_regs[gbe_dev->et_stats[i].type];
- p = base + gbe_dev->et_stats[i].offset;
- tmp = readl(p);
- gbe_dev->hw_stats[i] = gbe_dev->hw_stats[i] + tmp;
+ gbe_update_hw_stats_entry(gbe_dev, i);
+
if (data)
data[i] = gbe_dev->hw_stats[i];
- /* write-to-decrement:
- * new register value = old register value - write value
- */
- writel(tmp, p);
}
}
-static void gbe_update_stats_ver14(struct gbe_priv *gbe_dev, uint64_t *data)
+static inline void gbe_stats_mod_visible_ver14(struct gbe_priv *gbe_dev,
+ int stats_mod)
{
- void __iomem *gbe_statsa = gbe_dev->hw_stats_regs[0];
- void __iomem *gbe_statsb = gbe_dev->hw_stats_regs[1];
- u64 *hw_stats = &gbe_dev->hw_stats[0];
- void __iomem *base = NULL;
- u32 __iomem *p;
- u32 tmp = 0, val, pair_size = (gbe_dev->num_et_stats / 2);
- int i, j, pair;
+ u32 val;
- for (pair = 0; pair < 2; pair++) {
- val = readl(GBE_REG_ADDR(gbe_dev, switch_regs, stat_port_en));
+ val = readl(GBE_REG_ADDR(gbe_dev, switch_regs, stat_port_en));
- if (pair == 0)
- val &= ~GBE_STATS_CD_SEL;
- else
- val |= GBE_STATS_CD_SEL;
+ switch (stats_mod) {
+ case GBE_STATSA_MODULE:
+ case GBE_STATSB_MODULE:
+ val &= ~GBE_STATS_CD_SEL;
+ break;
+ case GBE_STATSC_MODULE:
+ case GBE_STATSD_MODULE:
+ val |= GBE_STATS_CD_SEL;
+ break;
+ default:
+ return;
+ }
+
+ /* make the stat module visible */
+ writel(val, GBE_REG_ADDR(gbe_dev, switch_regs, stat_port_en));
+}
- /* make the stat modules visible */
- writel(val, GBE_REG_ADDR(gbe_dev, switch_regs, stat_port_en));
+static void gbe_update_stats_ver14(struct gbe_priv *gbe_dev, uint64_t *data)
+{
+ u32 half_num_et_stats = (gbe_dev->num_et_stats / 2);
+ int et_entry, j, pair;
- for (i = 0; i < pair_size; i++) {
- j = pair * pair_size + i;
- switch (gbe_dev->et_stats[j].type) {
- case GBE_STATSA_MODULE:
- case GBE_STATSC_MODULE:
- base = gbe_statsa;
- break;
- case GBE_STATSB_MODULE:
- case GBE_STATSD_MODULE:
- base = gbe_statsb;
- break;
- }
+ for (pair = 0; pair < 2; pair++) {
+ gbe_stats_mod_visible_ver14(gbe_dev, (pair ?
+ GBE_STATSC_MODULE :
+ GBE_STATSA_MODULE));
+
+ for (j = 0; j < half_num_et_stats; j++) {
+ et_entry = pair * half_num_et_stats + j;
+ gbe_update_hw_stats_entry(gbe_dev, et_entry);
- p = base + gbe_dev->et_stats[j].offset;
- tmp = readl(p);
- hw_stats[j] += tmp;
if (data)
- data[j] = hw_stats[j];
- /* write-to-decrement:
- * new register value = old register value - write value
- */
- writel(tmp, p);
+ data[et_entry] = gbe_dev->hw_stats[et_entry];
}
}
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [net-next PATCH v0 5/6] net: netcp: Fixes to CPSW statistics collection
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
` (3 preceding siblings ...)
2015-07-23 13:32 ` [net-next PATCH v0 4/6] net: netcp: Consolidates statistics collection code WingMan Kwok
@ 2015-07-23 13:32 ` WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 6/6] net: netcp: Adds missing statistics for K2L and K2E WingMan Kwok
2015-07-27 7:18 ` [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection David Miller
6 siblings, 0 replies; 9+ messages in thread
From: WingMan Kwok @ 2015-07-23 13:32 UTC (permalink / raw)
To: davem, m-karicheri2, netdev, linux-kernel; +Cc: WingMan Kwok
In certain applications it's beneficial to allow the CPSW h/w
stats counters to continue to increment even while the kernel
polls them. This patch implements this behavior for both 1G
and 10G ethernet subsystem modules.
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
drivers/net/ethernet/ti/netcp_ethss.c | 86 ++++++++++++++++++++++++++++-----
1 file changed, 75 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index aadca02..e2ef7ba 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -646,6 +646,7 @@ struct gbe_priv {
bool enable_ale;
u8 max_num_slaves;
u8 max_num_ports; /* max_num_slaves + 1 */
+ u8 num_stats_mods;
struct netcp_tx_pipe tx_pipe;
int host_port;
@@ -675,6 +676,7 @@ struct gbe_priv {
struct net_device *dummy_ndev;
u64 *hw_stats;
+ u32 *hw_stats_prev;
const struct netcp_ethtool_stat *et_stats;
int num_et_stats;
/* Lock for updating the hwstats */
@@ -1554,25 +1556,37 @@ static int keystone_get_sset_count(struct net_device *ndev, int stringset)
}
}
+static void gbe_reset_mod_stats(struct gbe_priv *gbe_dev, int stats_mod)
+{
+ void __iomem *base = gbe_dev->hw_stats_regs[stats_mod];
+ u32 __iomem *p_stats_entry;
+ int i;
+
+ for (i = 0; i < gbe_dev->num_et_stats; i++) {
+ if (gbe_dev->et_stats[i].type == stats_mod) {
+ p_stats_entry = base + gbe_dev->et_stats[i].offset;
+ gbe_dev->hw_stats[i] = 0;
+ gbe_dev->hw_stats_prev[i] = readl(p_stats_entry);
+ }
+ }
+}
+
static inline void gbe_update_hw_stats_entry(struct gbe_priv *gbe_dev,
int et_stats_entry)
{
void __iomem *base = NULL;
- u32 __iomem *p;
- u32 tmp = 0;
+ u32 __iomem *p_stats_entry;
+ u32 curr, delta;
/* The hw_stats_regs pointers are already
* properly set to point to the right base:
*/
base = gbe_dev->hw_stats_regs[gbe_dev->et_stats[et_stats_entry].type];
- p = base + gbe_dev->et_stats[et_stats_entry].offset;
- tmp = readl(p);
- gbe_dev->hw_stats[et_stats_entry] += tmp;
-
- /* write-to-decrement:
- * new register value = old register value - write value
- */
- writel(tmp, p);
+ p_stats_entry = base + gbe_dev->et_stats[et_stats_entry].offset;
+ curr = readl(p_stats_entry);
+ delta = curr - gbe_dev->hw_stats_prev[et_stats_entry];
+ gbe_dev->hw_stats_prev[et_stats_entry] = curr;
+ gbe_dev->hw_stats[et_stats_entry] += delta;
}
static void gbe_update_stats(struct gbe_priv *gbe_dev, uint64_t *data)
@@ -1611,6 +1625,12 @@ static inline void gbe_stats_mod_visible_ver14(struct gbe_priv *gbe_dev,
writel(val, GBE_REG_ADDR(gbe_dev, switch_regs, stat_port_en));
}
+static void gbe_reset_mod_stats_ver14(struct gbe_priv *gbe_dev, int stats_mod)
+{
+ gbe_stats_mod_visible_ver14(gbe_dev, stats_mod);
+ gbe_reset_mod_stats(gbe_dev, stats_mod);
+}
+
static void gbe_update_stats_ver14(struct gbe_priv *gbe_dev, uint64_t *data)
{
u32 half_num_et_stats = (gbe_dev->num_et_stats / 2);
@@ -2564,6 +2584,7 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
}
gbe_dev->xgbe_serdes_regs = regs;
+ gbe_dev->num_stats_mods = gbe_dev->max_num_ports;
gbe_dev->et_stats = xgbe10_et_stats;
gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
@@ -2575,6 +2596,16 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
return -ENOMEM;
}
+ gbe_dev->hw_stats_prev =
+ devm_kzalloc(gbe_dev->dev,
+ gbe_dev->num_et_stats * sizeof(u32),
+ GFP_KERNEL);
+ if (!gbe_dev->hw_stats_prev) {
+ dev_err(gbe_dev->dev,
+ "hw_stats_prev memory allocation failed\n");
+ return -ENOMEM;
+ }
+
gbe_dev->ss_version = XGBE_SS_VERSION_10;
gbe_dev->sgmii_port_regs = gbe_dev->ss_regs +
XGBE10_SGMII_MODULE_OFFSET;
@@ -2672,6 +2703,7 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
}
gbe_dev->switch_regs = regs;
+ gbe_dev->num_stats_mods = gbe_dev->max_num_slaves;
gbe_dev->et_stats = gbe13_et_stats;
gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
@@ -2683,6 +2715,16 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
return -ENOMEM;
}
+ gbe_dev->hw_stats_prev =
+ devm_kzalloc(gbe_dev->dev,
+ gbe_dev->num_et_stats * sizeof(u32),
+ GFP_KERNEL);
+ if (!gbe_dev->hw_stats_prev) {
+ dev_err(gbe_dev->dev,
+ "hw_stats_prev memory allocation failed\n");
+ return -ENOMEM;
+ }
+
gbe_dev->sgmii_port_regs = gbe_dev->ss_regs + GBE13_SGMII_MODULE_OFFSET;
gbe_dev->host_port_regs = gbe_dev->switch_regs + GBE13_HOST_PORT_OFFSET;
@@ -2726,6 +2768,7 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
void __iomem *regs;
int i, ret;
+ gbe_dev->num_stats_mods = gbe_dev->max_num_ports;
gbe_dev->et_stats = gbenu_et_stats;
if (IS_SS_ID_NU(gbe_dev))
@@ -2743,6 +2786,16 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
return -ENOMEM;
}
+ gbe_dev->hw_stats_prev =
+ devm_kzalloc(gbe_dev->dev,
+ gbe_dev->num_et_stats * sizeof(u32),
+ GFP_KERNEL);
+ if (!gbe_dev->hw_stats_prev) {
+ dev_err(gbe_dev->dev,
+ "hw_stats_prev memory allocation failed\n");
+ return -ENOMEM;
+ }
+
ret = of_address_to_resource(node, GBENU_SM_REG_INDEX, &res);
if (ret) {
dev_err(gbe_dev->dev,
@@ -2801,7 +2854,7 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
struct cpsw_ale_params ale_params;
struct gbe_priv *gbe_dev;
u32 slave_num;
- int ret = 0;
+ int i, ret = 0;
if (!node) {
dev_err(dev, "device tree info unavailable\n");
@@ -2949,6 +3002,15 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
/* initialize host port */
gbe_init_host_port(gbe_dev);
+ spin_lock_bh(&gbe_dev->hw_stats_lock);
+ for (i = 0; i < gbe_dev->num_stats_mods; i++) {
+ if (gbe_dev->ss_version == GBE_SS_VERSION_14)
+ gbe_reset_mod_stats_ver14(gbe_dev, i);
+ else
+ gbe_reset_mod_stats(gbe_dev, i);
+ }
+ spin_unlock_bh(&gbe_dev->hw_stats_lock);
+
init_timer(&gbe_dev->timer);
gbe_dev->timer.data = (unsigned long)gbe_dev;
gbe_dev->timer.function = netcp_ethss_timer;
@@ -2960,6 +3022,8 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
quit:
if (gbe_dev->hw_stats)
devm_kfree(dev, gbe_dev->hw_stats);
+ if (gbe_dev->hw_stats_prev)
+ devm_kfree(dev, gbe_dev->hw_stats_prev);
cpsw_ale_destroy(gbe_dev->ale);
if (gbe_dev->ss_regs)
devm_iounmap(dev, gbe_dev->ss_regs);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [net-next PATCH v0 6/6] net: netcp: Adds missing statistics for K2L and K2E
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
` (4 preceding siblings ...)
2015-07-23 13:32 ` [net-next PATCH v0 5/6] net: netcp: Fixes to CPSW statistics collection WingMan Kwok
@ 2015-07-23 13:32 ` WingMan Kwok
2015-07-27 7:18 ` [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection David Miller
6 siblings, 0 replies; 9+ messages in thread
From: WingMan Kwok @ 2015-07-23 13:32 UTC (permalink / raw)
To: davem, m-karicheri2, netdev, linux-kernel; +Cc: WingMan Kwok
This patch adds the missing statistics for the host
and slave ports of the CPSW on K2L and K2E platforms.
Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
---
drivers/net/ethernet/ti/netcp_ethss.c | 177 ++++++++++++++++++++++++++++++++-
1 file changed, 174 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index e2ef7ba..7782120 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -876,7 +876,7 @@ static const struct netcp_ethtool_stat gbe13_et_stats[] = {
};
/* This is the size of entries in GBENU_STATS_HOST */
-#define GBENU_ET_STATS_HOST_SIZE 33
+#define GBENU_ET_STATS_HOST_SIZE 52
#define GBENU_STATS_HOST(field) \
{ \
@@ -885,8 +885,8 @@ static const struct netcp_ethtool_stat gbe13_et_stats[] = {
offsetof(struct gbenu_hw_stats, field) \
}
-/* This is the size of entries in GBENU_STATS_HOST */
-#define GBENU_ET_STATS_PORT_SIZE 46
+/* This is the size of entries in GBENU_STATS_PORT */
+#define GBENU_ET_STATS_PORT_SIZE 65
#define GBENU_STATS_P1(field) \
{ \
@@ -978,7 +978,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_HOST(ale_unknown_mcast_bytes),
GBENU_STATS_HOST(ale_unknown_bcast),
GBENU_STATS_HOST(ale_unknown_bcast_bytes),
+ GBENU_STATS_HOST(ale_pol_match),
+ GBENU_STATS_HOST(ale_pol_match_red),
+ GBENU_STATS_HOST(ale_pol_match_yellow),
GBENU_STATS_HOST(tx_mem_protect_err),
+ GBENU_STATS_HOST(tx_pri0_drop),
+ GBENU_STATS_HOST(tx_pri1_drop),
+ GBENU_STATS_HOST(tx_pri2_drop),
+ GBENU_STATS_HOST(tx_pri3_drop),
+ GBENU_STATS_HOST(tx_pri4_drop),
+ GBENU_STATS_HOST(tx_pri5_drop),
+ GBENU_STATS_HOST(tx_pri6_drop),
+ GBENU_STATS_HOST(tx_pri7_drop),
+ GBENU_STATS_HOST(tx_pri0_drop_bcnt),
+ GBENU_STATS_HOST(tx_pri1_drop_bcnt),
+ GBENU_STATS_HOST(tx_pri2_drop_bcnt),
+ GBENU_STATS_HOST(tx_pri3_drop_bcnt),
+ GBENU_STATS_HOST(tx_pri4_drop_bcnt),
+ GBENU_STATS_HOST(tx_pri5_drop_bcnt),
+ GBENU_STATS_HOST(tx_pri6_drop_bcnt),
+ GBENU_STATS_HOST(tx_pri7_drop_bcnt),
/* GBENU Module 1 */
GBENU_STATS_P1(rx_good_frames),
GBENU_STATS_P1(rx_broadcast_frames),
@@ -1025,7 +1044,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P1(ale_unknown_mcast_bytes),
GBENU_STATS_P1(ale_unknown_bcast),
GBENU_STATS_P1(ale_unknown_bcast_bytes),
+ GBENU_STATS_P1(ale_pol_match),
+ GBENU_STATS_P1(ale_pol_match_red),
+ GBENU_STATS_P1(ale_pol_match_yellow),
GBENU_STATS_P1(tx_mem_protect_err),
+ GBENU_STATS_P1(tx_pri0_drop),
+ GBENU_STATS_P1(tx_pri1_drop),
+ GBENU_STATS_P1(tx_pri2_drop),
+ GBENU_STATS_P1(tx_pri3_drop),
+ GBENU_STATS_P1(tx_pri4_drop),
+ GBENU_STATS_P1(tx_pri5_drop),
+ GBENU_STATS_P1(tx_pri6_drop),
+ GBENU_STATS_P1(tx_pri7_drop),
+ GBENU_STATS_P1(tx_pri0_drop_bcnt),
+ GBENU_STATS_P1(tx_pri1_drop_bcnt),
+ GBENU_STATS_P1(tx_pri2_drop_bcnt),
+ GBENU_STATS_P1(tx_pri3_drop_bcnt),
+ GBENU_STATS_P1(tx_pri4_drop_bcnt),
+ GBENU_STATS_P1(tx_pri5_drop_bcnt),
+ GBENU_STATS_P1(tx_pri6_drop_bcnt),
+ GBENU_STATS_P1(tx_pri7_drop_bcnt),
/* GBENU Module 2 */
GBENU_STATS_P2(rx_good_frames),
GBENU_STATS_P2(rx_broadcast_frames),
@@ -1072,7 +1110,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P2(ale_unknown_mcast_bytes),
GBENU_STATS_P2(ale_unknown_bcast),
GBENU_STATS_P2(ale_unknown_bcast_bytes),
+ GBENU_STATS_P2(ale_pol_match),
+ GBENU_STATS_P2(ale_pol_match_red),
+ GBENU_STATS_P2(ale_pol_match_yellow),
GBENU_STATS_P2(tx_mem_protect_err),
+ GBENU_STATS_P2(tx_pri0_drop),
+ GBENU_STATS_P2(tx_pri1_drop),
+ GBENU_STATS_P2(tx_pri2_drop),
+ GBENU_STATS_P2(tx_pri3_drop),
+ GBENU_STATS_P2(tx_pri4_drop),
+ GBENU_STATS_P2(tx_pri5_drop),
+ GBENU_STATS_P2(tx_pri6_drop),
+ GBENU_STATS_P2(tx_pri7_drop),
+ GBENU_STATS_P2(tx_pri0_drop_bcnt),
+ GBENU_STATS_P2(tx_pri1_drop_bcnt),
+ GBENU_STATS_P2(tx_pri2_drop_bcnt),
+ GBENU_STATS_P2(tx_pri3_drop_bcnt),
+ GBENU_STATS_P2(tx_pri4_drop_bcnt),
+ GBENU_STATS_P2(tx_pri5_drop_bcnt),
+ GBENU_STATS_P2(tx_pri6_drop_bcnt),
+ GBENU_STATS_P2(tx_pri7_drop_bcnt),
/* GBENU Module 3 */
GBENU_STATS_P3(rx_good_frames),
GBENU_STATS_P3(rx_broadcast_frames),
@@ -1119,7 +1176,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P3(ale_unknown_mcast_bytes),
GBENU_STATS_P3(ale_unknown_bcast),
GBENU_STATS_P3(ale_unknown_bcast_bytes),
+ GBENU_STATS_P3(ale_pol_match),
+ GBENU_STATS_P3(ale_pol_match_red),
+ GBENU_STATS_P3(ale_pol_match_yellow),
GBENU_STATS_P3(tx_mem_protect_err),
+ GBENU_STATS_P3(tx_pri0_drop),
+ GBENU_STATS_P3(tx_pri1_drop),
+ GBENU_STATS_P3(tx_pri2_drop),
+ GBENU_STATS_P3(tx_pri3_drop),
+ GBENU_STATS_P3(tx_pri4_drop),
+ GBENU_STATS_P3(tx_pri5_drop),
+ GBENU_STATS_P3(tx_pri6_drop),
+ GBENU_STATS_P3(tx_pri7_drop),
+ GBENU_STATS_P3(tx_pri0_drop_bcnt),
+ GBENU_STATS_P3(tx_pri1_drop_bcnt),
+ GBENU_STATS_P3(tx_pri2_drop_bcnt),
+ GBENU_STATS_P3(tx_pri3_drop_bcnt),
+ GBENU_STATS_P3(tx_pri4_drop_bcnt),
+ GBENU_STATS_P3(tx_pri5_drop_bcnt),
+ GBENU_STATS_P3(tx_pri6_drop_bcnt),
+ GBENU_STATS_P3(tx_pri7_drop_bcnt),
/* GBENU Module 4 */
GBENU_STATS_P4(rx_good_frames),
GBENU_STATS_P4(rx_broadcast_frames),
@@ -1166,7 +1242,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P4(ale_unknown_mcast_bytes),
GBENU_STATS_P4(ale_unknown_bcast),
GBENU_STATS_P4(ale_unknown_bcast_bytes),
+ GBENU_STATS_P4(ale_pol_match),
+ GBENU_STATS_P4(ale_pol_match_red),
+ GBENU_STATS_P4(ale_pol_match_yellow),
GBENU_STATS_P4(tx_mem_protect_err),
+ GBENU_STATS_P4(tx_pri0_drop),
+ GBENU_STATS_P4(tx_pri1_drop),
+ GBENU_STATS_P4(tx_pri2_drop),
+ GBENU_STATS_P4(tx_pri3_drop),
+ GBENU_STATS_P4(tx_pri4_drop),
+ GBENU_STATS_P4(tx_pri5_drop),
+ GBENU_STATS_P4(tx_pri6_drop),
+ GBENU_STATS_P4(tx_pri7_drop),
+ GBENU_STATS_P4(tx_pri0_drop_bcnt),
+ GBENU_STATS_P4(tx_pri1_drop_bcnt),
+ GBENU_STATS_P4(tx_pri2_drop_bcnt),
+ GBENU_STATS_P4(tx_pri3_drop_bcnt),
+ GBENU_STATS_P4(tx_pri4_drop_bcnt),
+ GBENU_STATS_P4(tx_pri5_drop_bcnt),
+ GBENU_STATS_P4(tx_pri6_drop_bcnt),
+ GBENU_STATS_P4(tx_pri7_drop_bcnt),
/* GBENU Module 5 */
GBENU_STATS_P5(rx_good_frames),
GBENU_STATS_P5(rx_broadcast_frames),
@@ -1213,7 +1308,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P5(ale_unknown_mcast_bytes),
GBENU_STATS_P5(ale_unknown_bcast),
GBENU_STATS_P5(ale_unknown_bcast_bytes),
+ GBENU_STATS_P5(ale_pol_match),
+ GBENU_STATS_P5(ale_pol_match_red),
+ GBENU_STATS_P5(ale_pol_match_yellow),
GBENU_STATS_P5(tx_mem_protect_err),
+ GBENU_STATS_P5(tx_pri0_drop),
+ GBENU_STATS_P5(tx_pri1_drop),
+ GBENU_STATS_P5(tx_pri2_drop),
+ GBENU_STATS_P5(tx_pri3_drop),
+ GBENU_STATS_P5(tx_pri4_drop),
+ GBENU_STATS_P5(tx_pri5_drop),
+ GBENU_STATS_P5(tx_pri6_drop),
+ GBENU_STATS_P5(tx_pri7_drop),
+ GBENU_STATS_P5(tx_pri0_drop_bcnt),
+ GBENU_STATS_P5(tx_pri1_drop_bcnt),
+ GBENU_STATS_P5(tx_pri2_drop_bcnt),
+ GBENU_STATS_P5(tx_pri3_drop_bcnt),
+ GBENU_STATS_P5(tx_pri4_drop_bcnt),
+ GBENU_STATS_P5(tx_pri5_drop_bcnt),
+ GBENU_STATS_P5(tx_pri6_drop_bcnt),
+ GBENU_STATS_P5(tx_pri7_drop_bcnt),
/* GBENU Module 6 */
GBENU_STATS_P6(rx_good_frames),
GBENU_STATS_P6(rx_broadcast_frames),
@@ -1260,7 +1374,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P6(ale_unknown_mcast_bytes),
GBENU_STATS_P6(ale_unknown_bcast),
GBENU_STATS_P6(ale_unknown_bcast_bytes),
+ GBENU_STATS_P6(ale_pol_match),
+ GBENU_STATS_P6(ale_pol_match_red),
+ GBENU_STATS_P6(ale_pol_match_yellow),
GBENU_STATS_P6(tx_mem_protect_err),
+ GBENU_STATS_P6(tx_pri0_drop),
+ GBENU_STATS_P6(tx_pri1_drop),
+ GBENU_STATS_P6(tx_pri2_drop),
+ GBENU_STATS_P6(tx_pri3_drop),
+ GBENU_STATS_P6(tx_pri4_drop),
+ GBENU_STATS_P6(tx_pri5_drop),
+ GBENU_STATS_P6(tx_pri6_drop),
+ GBENU_STATS_P6(tx_pri7_drop),
+ GBENU_STATS_P6(tx_pri0_drop_bcnt),
+ GBENU_STATS_P6(tx_pri1_drop_bcnt),
+ GBENU_STATS_P6(tx_pri2_drop_bcnt),
+ GBENU_STATS_P6(tx_pri3_drop_bcnt),
+ GBENU_STATS_P6(tx_pri4_drop_bcnt),
+ GBENU_STATS_P6(tx_pri5_drop_bcnt),
+ GBENU_STATS_P6(tx_pri6_drop_bcnt),
+ GBENU_STATS_P6(tx_pri7_drop_bcnt),
/* GBENU Module 7 */
GBENU_STATS_P7(rx_good_frames),
GBENU_STATS_P7(rx_broadcast_frames),
@@ -1307,7 +1440,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P7(ale_unknown_mcast_bytes),
GBENU_STATS_P7(ale_unknown_bcast),
GBENU_STATS_P7(ale_unknown_bcast_bytes),
+ GBENU_STATS_P7(ale_pol_match),
+ GBENU_STATS_P7(ale_pol_match_red),
+ GBENU_STATS_P7(ale_pol_match_yellow),
GBENU_STATS_P7(tx_mem_protect_err),
+ GBENU_STATS_P7(tx_pri0_drop),
+ GBENU_STATS_P7(tx_pri1_drop),
+ GBENU_STATS_P7(tx_pri2_drop),
+ GBENU_STATS_P7(tx_pri3_drop),
+ GBENU_STATS_P7(tx_pri4_drop),
+ GBENU_STATS_P7(tx_pri5_drop),
+ GBENU_STATS_P7(tx_pri6_drop),
+ GBENU_STATS_P7(tx_pri7_drop),
+ GBENU_STATS_P7(tx_pri0_drop_bcnt),
+ GBENU_STATS_P7(tx_pri1_drop_bcnt),
+ GBENU_STATS_P7(tx_pri2_drop_bcnt),
+ GBENU_STATS_P7(tx_pri3_drop_bcnt),
+ GBENU_STATS_P7(tx_pri4_drop_bcnt),
+ GBENU_STATS_P7(tx_pri5_drop_bcnt),
+ GBENU_STATS_P7(tx_pri6_drop_bcnt),
+ GBENU_STATS_P7(tx_pri7_drop_bcnt),
/* GBENU Module 8 */
GBENU_STATS_P8(rx_good_frames),
GBENU_STATS_P8(rx_broadcast_frames),
@@ -1354,7 +1506,26 @@ static const struct netcp_ethtool_stat gbenu_et_stats[] = {
GBENU_STATS_P8(ale_unknown_mcast_bytes),
GBENU_STATS_P8(ale_unknown_bcast),
GBENU_STATS_P8(ale_unknown_bcast_bytes),
+ GBENU_STATS_P8(ale_pol_match),
+ GBENU_STATS_P8(ale_pol_match_red),
+ GBENU_STATS_P8(ale_pol_match_yellow),
GBENU_STATS_P8(tx_mem_protect_err),
+ GBENU_STATS_P8(tx_pri0_drop),
+ GBENU_STATS_P8(tx_pri1_drop),
+ GBENU_STATS_P8(tx_pri2_drop),
+ GBENU_STATS_P8(tx_pri3_drop),
+ GBENU_STATS_P8(tx_pri4_drop),
+ GBENU_STATS_P8(tx_pri5_drop),
+ GBENU_STATS_P8(tx_pri6_drop),
+ GBENU_STATS_P8(tx_pri7_drop),
+ GBENU_STATS_P8(tx_pri0_drop_bcnt),
+ GBENU_STATS_P8(tx_pri1_drop_bcnt),
+ GBENU_STATS_P8(tx_pri2_drop_bcnt),
+ GBENU_STATS_P8(tx_pri3_drop_bcnt),
+ GBENU_STATS_P8(tx_pri4_drop_bcnt),
+ GBENU_STATS_P8(tx_pri5_drop_bcnt),
+ GBENU_STATS_P8(tx_pri6_drop_bcnt),
+ GBENU_STATS_P8(tx_pri7_drop_bcnt),
};
#define XGBE_STATS0_INFO(field) \
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [net-next PATCH v0 3/6] net: netcp: Fixes error in oversized memory allocation for statistics storage
2015-07-23 13:32 ` [net-next PATCH v0 3/6] net: netcp: Fixes error in oversized memory allocation for statistics storage WingMan Kwok
@ 2015-07-23 14:01 ` Murali Karicheri
0 siblings, 0 replies; 9+ messages in thread
From: Murali Karicheri @ 2015-07-23 14:01 UTC (permalink / raw)
To: WingMan Kwok, davem, netdev, linux-kernel
On 07/23/2015 09:32 AM, WingMan Kwok wrote:
> The CPSW driver keeps internally some, but not all, of
> the statistics available in the hw statistics modules. Furthermore,
> some of the locations in the hw statistics modules are reserved and
> contain no useful information. Prior to this patch, the driver
> allocates memory of the size of the the whole hw statistics modules,
> instead of the size of statistics-entries-interested-in (i.e. et_stats),
> for internal storage. This patch fixes that.
>
> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
> ---
> drivers/net/ethernet/ti/netcp_ethss.c | 42 ++++++++++++++++-----------------
> 1 file changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index b954856..a1f16e1 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -2555,10 +2555,12 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
> }
> gbe_dev->xgbe_serdes_regs = regs;
>
> + gbe_dev->et_stats = xgbe10_et_stats;
> + gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
> +
> gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
> - XGBE10_NUM_STAT_ENTRIES *
> - (gbe_dev->max_num_ports) * sizeof(u64),
> -
GFP_KERNEL);
Looks like XGBE10_NUM_STAT_ENTRIES is used only here and this is being
replaced. So could you please remove the #define as well? same for other
instances if any below.
> + gbe_dev->num_et_stats * sizeof(u64),
> + GFP_KERNEL);
> if (!gbe_dev->hw_stats) {
> dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
> return -ENOMEM;
> @@ -2577,8 +2579,6 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
> gbe_dev->ale_ports = gbe_dev->max_num_ports;
> gbe_dev->host_port = XGBE10_HOST_PORT_NUM;
> gbe_dev->ale_entries = XGBE10_NUM_ALE_ENTRIES;
> - gbe_dev->et_stats = xgbe10_et_stats;
> - gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
> gbe_dev->stats_en_mask = (1 << (gbe_dev->max_num_ports)) - 1;
>
> /* Subsystem registers */
> @@ -2663,10 +2663,12 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
> }
> gbe_dev->switch_regs = regs;
>
> + gbe_dev->et_stats = gbe13_et_stats;
> + gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
> +
> gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
> - GBE13_NUM_HW_STAT_ENTRIES *
> - gbe_dev->max_num_slaves * sizeof(u64),
> - GFP_KERNEL);
> + gbe_dev->num_et_stats * sizeof(u64),
> + GFP_KERNEL);
> if (!gbe_dev->hw_stats) {
> dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
> return -ENOMEM;
> @@ -2689,8 +2691,6 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
> gbe_dev->ale_ports = gbe_dev->max_num_ports;
> gbe_dev->host_port = GBE13_HOST_PORT_NUM;
> gbe_dev->ale_entries = GBE13_NUM_ALE_ENTRIES;
> - gbe_dev->et_stats = gbe13_et_stats;
> - gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
> gbe_dev->stats_en_mask = GBE13_REG_VAL_STAT_ENABLE_ALL;
>
> /* Subsystem registers */
> @@ -2717,10 +2717,18 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
> void __iomem *regs;
> int i, ret;
>
> + gbe_dev->et_stats = gbenu_et_stats;
> +
> + if (IS_SS_ID_NU(gbe_dev))
> + gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
> + (gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE);
> + else
> + gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
> + GBENU_ET_STATS_PORT_SIZE;
> +
> gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
> - GBENU_NUM_HW_STAT_ENTRIES *
> - (gbe_dev->max_num_ports) * sizeof(u64),
> - GFP_KERNEL);
> + gbe_dev->num_et_stats * sizeof(u64),
> + GFP_KERNEL);
> if (!gbe_dev->hw_stats) {
> dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
> return -ENOMEM;
> @@ -2753,16 +2761,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
> gbe_dev->ale_ports = gbe_dev->max_num_ports;
> gbe_dev->host_port = GBENU_HOST_PORT_NUM;
> gbe_dev->ale_entries = GBE13_NUM_ALE_ENTRIES;
> - gbe_dev->et_stats = gbenu_et_stats;
> gbe_dev->stats_en_mask = (1 << (gbe_dev->max_num_ports)) - 1;
>
> - if (IS_SS_ID_NU(gbe_dev))
> - gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
> - (gbe_dev->max_num_slaves * GBENU_ET_STATS_PORT_SIZE);
> - else
> - gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
> - GBENU_ET_STATS_PORT_SIZE;
> -
> /* Subsystem registers */
> GBENU_SET_REG_OFS(gbe_dev, ss_regs, id_ver);
>
>
--
Murali Karicheri
Linux Kernel, Keystone
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
` (5 preceding siblings ...)
2015-07-23 13:32 ` [net-next PATCH v0 6/6] net: netcp: Adds missing statistics for K2L and K2E WingMan Kwok
@ 2015-07-27 7:18 ` David Miller
6 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2015-07-27 7:18 UTC (permalink / raw)
To: w-kwok2; +Cc: m-karicheri2, netdev, linux-kernel
From: WingMan Kwok <w-kwok2@ti.com>
Date: Thu, 23 Jul 2015 09:32:42 -0400
> This patch set contains bug fixes and enhencements of hw ethernet
> statistics processing on TI's Keystone2 CPSW ethernet switches.
Applied, thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-07-27 7:18 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-23 13:32 [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 1/6] net: netcp: Fixes the use of spin_lock_bh in timer function WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 2/6] net: netcp: Fixes hw statistics module base setting error WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 3/6] net: netcp: Fixes error in oversized memory allocation for statistics storage WingMan Kwok
2015-07-23 14:01 ` Murali Karicheri
2015-07-23 13:32 ` [net-next PATCH v0 4/6] net: netcp: Consolidates statistics collection code WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 5/6] net: netcp: Fixes to CPSW statistics collection WingMan Kwok
2015-07-23 13:32 ` [net-next PATCH v0 6/6] net: netcp: Adds missing statistics for K2L and K2E WingMan Kwok
2015-07-27 7:18 ` [net-next PATCH v0 0/6] net: netcp: Bug fixes of CPSW statistics collection David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).