Skip to content

Commit 7938a0d

Browse files
Karicheri, Muralidharandavem330
authored andcommitted
net: netcp: ale: use ale_status to size the ale table
ALE h/w on newer version of NetCP (K2E/L/G) does provide a ALE_STATUS register for the size of the ALE Table implemented in h/w. Currently for example we set ALE Table size to 1024 for NetCP ALE on K2E even though the ALE Status/Documentation shows it has 8192 entries. So take advantage of this register to read the size of ALE table supported and use that value in the driver for the newer version of NetCP ALE. For NetCP lite, ALE Table size is much less (64) and indicated by a size of zero in ALE_STATUS. So use that as a default for now. While at it, also fix the ale table size on 10G switch to 2048 per User guide http://www.ti.com/lit/ug/spruhj5/spruhj5.pdf Signed-off-by: Murali Karicheri <[email protected]> Signed-off-by: Sekhar Nori <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ca47130 commit 7938a0d

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

drivers/net/ethernet/ti/cpsw_ale.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
/* ALE Registers */
3535
#define ALE_IDVER 0x00
36+
#define ALE_STATUS 0x04
3637
#define ALE_CONTROL 0x08
3738
#define ALE_PRESCALE 0x10
3839
#define ALE_UNKNOWNVLAN 0x18
@@ -58,6 +59,10 @@
5859
#define ALE_UCAST_OUI 2
5960
#define ALE_UCAST_TOUCHED 3
6061

62+
#define ALE_TABLE_SIZE_MULTIPLIER 1024
63+
#define ALE_STATUS_SIZE_MASK 0x1f
64+
#define ALE_TABLE_SIZE_DEFAULT 64
65+
6166
static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
6267
{
6368
int idx;
@@ -728,7 +733,7 @@ static void cpsw_ale_timer(unsigned long arg)
728733

729734
void cpsw_ale_start(struct cpsw_ale *ale)
730735
{
731-
u32 rev;
736+
u32 rev, ale_entries;
732737

733738
rev = __raw_readl(ale->params.ale_regs + ALE_IDVER);
734739
if (!ale->params.major_ver_mask)
@@ -740,6 +745,30 @@ void cpsw_ale_start(struct cpsw_ale *ale)
740745
ALE_VERSION_MAJOR(rev, ale->params.major_ver_mask),
741746
ALE_VERSION_MINOR(rev));
742747

748+
if (!ale->params.ale_entries) {
749+
ale_entries =
750+
__raw_readl(ale->params.ale_regs + ALE_STATUS) &
751+
ALE_STATUS_SIZE_MASK;
752+
/* ALE available on newer NetCP switches has introduced
753+
* a register, ALE_STATUS, to indicate the size of ALE
754+
* table which shows the size as a multiple of 1024 entries.
755+
* For these, params.ale_entries will be set to zero. So
756+
* read the register and update the value of ale_entries.
757+
* ALE table on NetCP lite, is much smaller and is indicated
758+
* by a value of zero in ALE_STATUS. So use a default value
759+
* of ALE_TABLE_SIZE_DEFAULT for this. Caller is expected
760+
* to set the value of ale_entries for all other versions
761+
* of ALE.
762+
*/
763+
if (!ale_entries)
764+
ale_entries = ALE_TABLE_SIZE_DEFAULT;
765+
else
766+
ale_entries *= ALE_TABLE_SIZE_MULTIPLIER;
767+
ale->params.ale_entries = ale_entries;
768+
}
769+
dev_info(ale->params.dev,
770+
"ALE Table size %ld\n", ale->params.ale_entries);
771+
743772
if (ale->params.nu_switch_ale) {
744773
/* Separate registers for unknown vlan configuration.
745774
* Also there are N bits, where N is number of ale

drivers/net/ethernet/ti/netcp_ethss.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
#define GBENU_CPTS_OFFSET 0x1d000
8282
#define GBENU_ALE_OFFSET 0x1e000
8383
#define GBENU_HOST_PORT_NUM 0
84-
#define GBENU_NUM_ALE_ENTRIES 1024
8584
#define GBENU_SGMII_MODULE_SIZE 0x100
8685

8786
/* 10G Ethernet SS defines */
@@ -103,7 +102,7 @@
103102
#define XGBE10_ALE_OFFSET 0x700
104103
#define XGBE10_HW_STATS_OFFSET 0x800
105104
#define XGBE10_HOST_PORT_NUM 0
106-
#define XGBE10_NUM_ALE_ENTRIES 1024
105+
#define XGBE10_NUM_ALE_ENTRIES 2048
107106

108107
#define GBE_TIMER_INTERVAL (HZ / 2)
109108

@@ -3441,7 +3440,6 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
34413440
gbe_dev->ale_reg = gbe_dev->switch_regs + GBENU_ALE_OFFSET;
34423441
gbe_dev->ale_ports = gbe_dev->max_num_ports;
34433442
gbe_dev->host_port = GBENU_HOST_PORT_NUM;
3444-
gbe_dev->ale_entries = GBE13_NUM_ALE_ENTRIES;
34453443
gbe_dev->stats_en_mask = (1 << (gbe_dev->max_num_ports)) - 1;
34463444

34473445
/* Subsystem registers */

0 commit comments

Comments
 (0)