Skip to content

Commit 11cbcfe

Browse files
rogerqdavem330
authored andcommitted
net: ethernet: ti: cpsw_ale: use regfields for number of Entries and Policers
Use regfields for number of ALE Entries and Policers. The variants that support Policers/Classifiers have the number of policers encoded in the ALE_STATUS register. Use that and show the number of Policers in the ALE info message. Signed-off-by: Roger Quadros <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bbfc7e2 commit 11cbcfe

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

drivers/net/ethernet/ti/cpsw_ale.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct cpsw_ale_dev_id {
103103
#define ALE_UCAST_TOUCHED 3
104104

105105
#define ALE_TABLE_SIZE_MULTIPLIER 1024
106-
#define ALE_STATUS_SIZE_MASK 0x1f
106+
#define ALE_POLICER_SIZE_MULTIPLIER 8
107107

108108
static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
109109
{
@@ -1303,6 +1303,9 @@ static const struct reg_field ale_fields_cpsw_nu[] = {
13031303
/* CPSW_ALE_IDVER_REG */
13041304
[MINOR_VER] = REG_FIELD(ALE_IDVER, 0, 7),
13051305
[MAJOR_VER] = REG_FIELD(ALE_IDVER, 8, 10),
1306+
/* CPSW_ALE_STATUS_REG */
1307+
[ALE_ENTRIES] = REG_FIELD(ALE_STATUS, 0, 7),
1308+
[ALE_POLICERS] = REG_FIELD(ALE_STATUS, 8, 15),
13061309
};
13071310

13081311
static const struct cpsw_ale_dev_id cpsw_ale_id_match[] = {
@@ -1402,8 +1405,8 @@ static int cpsw_ale_regfield_init(struct cpsw_ale *ale)
14021405

14031406
struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
14041407
{
1408+
u32 ale_entries, rev_major, rev_minor, policers;
14051409
const struct cpsw_ale_dev_id *ale_dev_id;
1406-
u32 ale_entries, rev_major, rev_minor;
14071410
struct cpsw_ale *ale;
14081411
int ret;
14091412

@@ -1447,9 +1450,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
14471450

14481451
if (ale->features & CPSW_ALE_F_STATUS_REG &&
14491452
!ale->params.ale_entries) {
1450-
ale_entries =
1451-
readl_relaxed(ale->params.ale_regs + ALE_STATUS) &
1452-
ALE_STATUS_SIZE_MASK;
1453+
regmap_field_read(ale->fields[ALE_ENTRIES], &ale_entries);
14531454
/* ALE available on newer NetCP switches has introduced
14541455
* a register, ALE_STATUS, to indicate the size of ALE
14551456
* table which shows the size as a multiple of 1024 entries.
@@ -1463,8 +1464,20 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
14631464
ale_entries *= ALE_TABLE_SIZE_MULTIPLIER;
14641465
ale->params.ale_entries = ale_entries;
14651466
}
1467+
1468+
if (ale->features & CPSW_ALE_F_STATUS_REG &&
1469+
!ale->params.num_policers) {
1470+
regmap_field_read(ale->fields[ALE_POLICERS], &policers);
1471+
if (!policers)
1472+
return ERR_PTR(-EINVAL);
1473+
1474+
policers *= ALE_POLICER_SIZE_MULTIPLIER;
1475+
ale->params.num_policers = policers;
1476+
}
1477+
14661478
dev_info(ale->params.dev,
1467-
"ALE Table size %ld\n", ale->params.ale_entries);
1479+
"ALE Table size %ld, Policers %ld\n", ale->params.ale_entries,
1480+
ale->params.num_policers);
14681481

14691482
/* set default bits for existing h/w */
14701483
ale->port_mask_bits = ale->params.ale_ports;

drivers/net/ethernet/ti/cpsw_ale.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct cpsw_ale_params {
1515
void __iomem *ale_regs;
1616
unsigned long ale_ageout; /* in secs */
1717
unsigned long ale_entries;
18+
unsigned long num_policers;
1819
unsigned long ale_ports;
1920
/* NU Switch has specific handling as number of bits in ALE entries
2021
* are different than other versions of ALE. Also there are specific
@@ -33,6 +34,8 @@ struct regmap;
3334
enum ale_fields {
3435
MINOR_VER,
3536
MAJOR_VER,
37+
ALE_ENTRIES,
38+
ALE_POLICERS,
3639
/* terminator */
3740
ALE_FIELDS_MAX,
3841
};

0 commit comments

Comments
 (0)