Commit b574bf0c authored by Grygorii Strashko's avatar Grygorii Strashko Committed by David S. Miller

net: ethernet: ti: ale: add cpsw_ale_get_num_entries api

Add cpsw_ale_get_num_entries() API to return number of ALE table entries
and update existing drivers to use it.
Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c4f33417
...@@ -572,13 +572,14 @@ static int am65_cpsw_nway_reset(struct net_device *ndev) ...@@ -572,13 +572,14 @@ static int am65_cpsw_nway_reset(struct net_device *ndev)
static int am65_cpsw_get_regs_len(struct net_device *ndev) static int am65_cpsw_get_regs_len(struct net_device *ndev)
{ {
struct am65_cpsw_common *common = am65_ndev_to_common(ndev); struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
u32 i, regdump_len = 0; u32 ale_entries, i, regdump_len = 0;
ale_entries = cpsw_ale_get_num_entries(common->ale);
for (i = 0; i < ARRAY_SIZE(am65_cpsw_regdump); i++) { for (i = 0; i < ARRAY_SIZE(am65_cpsw_regdump); i++) {
if (am65_cpsw_regdump[i].hdr.module_id == if (am65_cpsw_regdump[i].hdr.module_id ==
AM65_CPSW_REGDUMP_MOD_CPSW_ALE_TBL) { AM65_CPSW_REGDUMP_MOD_CPSW_ALE_TBL) {
regdump_len += sizeof(struct am65_cpsw_regdump_hdr); regdump_len += sizeof(struct am65_cpsw_regdump_hdr);
regdump_len += common->ale->params.ale_entries * regdump_len += ale_entries *
ALE_ENTRY_WORDS * sizeof(u32); ALE_ENTRY_WORDS * sizeof(u32);
continue; continue;
} }
...@@ -592,10 +593,11 @@ static void am65_cpsw_get_regs(struct net_device *ndev, ...@@ -592,10 +593,11 @@ static void am65_cpsw_get_regs(struct net_device *ndev,
struct ethtool_regs *regs, void *p) struct ethtool_regs *regs, void *p)
{ {
struct am65_cpsw_common *common = am65_ndev_to_common(ndev); struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
u32 i, j, pos, *reg = p; u32 ale_entries, i, j, pos, *reg = p;
/* update CPSW IP version */ /* update CPSW IP version */
regs->version = AM65_CPSW_REGDUMP_VER; regs->version = AM65_CPSW_REGDUMP_VER;
ale_entries = cpsw_ale_get_num_entries(common->ale);
pos = 0; pos = 0;
for (i = 0; i < ARRAY_SIZE(am65_cpsw_regdump); i++) { for (i = 0; i < ARRAY_SIZE(am65_cpsw_regdump); i++) {
...@@ -603,7 +605,7 @@ static void am65_cpsw_get_regs(struct net_device *ndev, ...@@ -603,7 +605,7 @@ static void am65_cpsw_get_regs(struct net_device *ndev,
if (am65_cpsw_regdump[i].hdr.module_id == if (am65_cpsw_regdump[i].hdr.module_id ==
AM65_CPSW_REGDUMP_MOD_CPSW_ALE_TBL) { AM65_CPSW_REGDUMP_MOD_CPSW_ALE_TBL) {
u32 ale_tbl_len = common->ale->params.ale_entries * u32 ale_tbl_len = ale_entries *
ALE_ENTRY_WORDS * sizeof(u32) + ALE_ENTRY_WORDS * sizeof(u32) +
sizeof(struct am65_cpsw_regdump_hdr); sizeof(struct am65_cpsw_regdump_hdr);
reg[pos++] = ale_tbl_len; reg[pos++] = ale_tbl_len;
......
...@@ -1079,3 +1079,8 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) ...@@ -1079,3 +1079,8 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
data += ALE_ENTRY_WORDS; data += ALE_ENTRY_WORDS;
} }
} }
u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale)
{
return ale ? ale->params.ale_entries : 0;
}
...@@ -119,6 +119,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control); ...@@ -119,6 +119,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
int control, int value); int control, int value);
void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data); void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale);
static inline int cpsw_ale_get_vlan_p0_untag(struct cpsw_ale *ale, u16 vid) static inline int cpsw_ale_get_vlan_p0_untag(struct cpsw_ale *ale, u16 vid)
{ {
......
...@@ -339,7 +339,8 @@ int cpsw_get_regs_len(struct net_device *ndev) ...@@ -339,7 +339,8 @@ int cpsw_get_regs_len(struct net_device *ndev)
{ {
struct cpsw_common *cpsw = ndev_to_cpsw(ndev); struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
return cpsw->data.ale_entries * ALE_ENTRY_WORDS * sizeof(u32); return cpsw_ale_get_num_entries(cpsw->ale) *
ALE_ENTRY_WORDS * sizeof(u32);
} }
void cpsw_get_regs(struct net_device *ndev, struct ethtool_regs *regs, void *p) void cpsw_get_regs(struct net_device *ndev, struct ethtool_regs *regs, void *p)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment