Skip to content

Commit 1cf814a

Browse files
committed
Merge branch 'net-ethernet-ti-ale-add-static-configuration'
Grygorii Strashko says: ==================== net: ethernet: ti: ale: add static configuration As existing, as newly introduced CPSW ALE versions have differences in supported features and ALE table formats. Especially it's actual for the recent AM65x/J721E/J7200 and future AM64x SoCs, which supports more features like: auto-aging, classifiers, Link aggregation, additional HW filtering, etc. The existing ALE configuration interface is not practical in terms of adding new features and requires consumers to program a lot static parameters. And any attempt to add new features will case endless adding and maintaining different combination of flags and options. Because CPSW ALE configuration is static and fixed for SoC (or set of SoC), It is reasonable to add support for static ALE configurations inside ALE module. This series introduces static ALE configuration table for different ALE variants and provides option for consumers to select required ALE configuration by providing ALE const char *dev_id identifier (Patch 2). And all existing driver have been switched to use new approach (Patches 3-6). After this ALE HW auto-ageing feature can be enabled for AM65x CPSW ALE variant (Patch 7). Finally, Patches 8-9 introduces tables to describe the ALE VLAN entries fields as the ALE VLAN entries are too much differ between different TI CPSW ALE versions. So, handling them using flags, defines and get/set functions are became over-complicated. Patch 1 - is preparation patch Changes in v3: - fixed comment for Patch 2 Changes in v2: - fixed sparse warnings v2: https://lore.kernel.org/patchwork/cover/1301684/ v1: https://lore.kernel.org/patchwork/cover/1301048/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents c4f3341 + 06c5c91 commit 1cf814a

File tree

11 files changed

+388
-99
lines changed

11 files changed

+388
-99
lines changed

drivers/net/ethernet/ti/am65-cpsw-ethtool.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,14 @@ static int am65_cpsw_nway_reset(struct net_device *ndev)
572572
static int am65_cpsw_get_regs_len(struct net_device *ndev)
573573
{
574574
struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
575-
u32 i, regdump_len = 0;
575+
u32 ale_entries, i, regdump_len = 0;
576576

577+
ale_entries = cpsw_ale_get_num_entries(common->ale);
577578
for (i = 0; i < ARRAY_SIZE(am65_cpsw_regdump); i++) {
578579
if (am65_cpsw_regdump[i].hdr.module_id ==
579580
AM65_CPSW_REGDUMP_MOD_CPSW_ALE_TBL) {
580581
regdump_len += sizeof(struct am65_cpsw_regdump_hdr);
581-
regdump_len += common->ale->params.ale_entries *
582+
regdump_len += ale_entries *
582583
ALE_ENTRY_WORDS * sizeof(u32);
583584
continue;
584585
}
@@ -592,18 +593,19 @@ static void am65_cpsw_get_regs(struct net_device *ndev,
592593
struct ethtool_regs *regs, void *p)
593594
{
594595
struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
595-
u32 i, j, pos, *reg = p;
596+
u32 ale_entries, i, j, pos, *reg = p;
596597

597598
/* update CPSW IP version */
598599
regs->version = AM65_CPSW_REGDUMP_VER;
600+
ale_entries = cpsw_ale_get_num_entries(common->ale);
599601

600602
pos = 0;
601603
for (i = 0; i < ARRAY_SIZE(am65_cpsw_regdump); i++) {
602604
reg[pos++] = am65_cpsw_regdump[i].hdr.module_id;
603605

604606
if (am65_cpsw_regdump[i].hdr.module_id ==
605607
AM65_CPSW_REGDUMP_MOD_CPSW_ALE_TBL) {
606-
u32 ale_tbl_len = common->ale->params.ale_entries *
608+
u32 ale_tbl_len = ale_entries *
607609
ALE_ENTRY_WORDS * sizeof(u32) +
608610
sizeof(struct am65_cpsw_regdump_hdr);
609611
reg[pos++] = ale_tbl_len;

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include <linux/clk.h>
89
#include <linux/etherdevice.h>
910
#include <linux/if_vlan.h>
1011
#include <linux/interrupt.h>
@@ -2038,6 +2039,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
20382039
struct am65_cpsw_common *common;
20392040
struct device_node *node;
20402041
struct resource *res;
2042+
struct clk *clk;
20412043
int ret, i;
20422044

20432045
common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL);
@@ -2086,6 +2088,16 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
20862088
if (!common->ports)
20872089
return -ENOMEM;
20882090

2091+
clk = devm_clk_get(dev, "fck");
2092+
if (IS_ERR(clk)) {
2093+
ret = PTR_ERR(clk);
2094+
2095+
if (ret != -EPROBE_DEFER)
2096+
dev_err(dev, "error getting fck clock %d\n", ret);
2097+
return ret;
2098+
}
2099+
common->bus_freq = clk_get_rate(clk);
2100+
20892101
pm_runtime_enable(dev);
20902102
ret = pm_runtime_get_sync(dev);
20912103
if (ret < 0) {
@@ -2131,10 +2143,10 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
21312143
/* init common data */
21322144
ale_params.dev = dev;
21332145
ale_params.ale_ageout = AM65_CPSW_ALE_AGEOUT_DEFAULT;
2134-
ale_params.ale_entries = 0;
21352146
ale_params.ale_ports = common->port_num + 1;
21362147
ale_params.ale_regs = common->cpsw_base + AM65_CPSW_NU_ALE_BASE;
2137-
ale_params.nu_switch_ale = true;
2148+
ale_params.dev_id = "am65x-cpsw2g";
2149+
ale_params.bus_freq = common->bus_freq;
21382150

21392151
common->ale = cpsw_ale_create(&ale_params);
21402152
if (IS_ERR(common->ale)) {

drivers/net/ethernet/ti/am65-cpsw-nuss.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct am65_cpsw_common {
106106

107107
u32 nuss_ver;
108108
u32 cpsw_ver;
109+
unsigned long bus_freq;
109110
bool pf_p0_rx_ptype_rrobin;
110111
struct am65_cpts *cpts;
111112
int est_enabled;

drivers/net/ethernet/ti/cpsw.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,12 +1278,6 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
12781278
}
12791279
data->channels = prop;
12801280

1281-
if (of_property_read_u32(node, "ale_entries", &prop)) {
1282-
dev_err(&pdev->dev, "Missing ale_entries property in the DT.\n");
1283-
return -EINVAL;
1284-
}
1285-
data->ale_entries = prop;
1286-
12871281
if (of_property_read_u32(node, "bd_ram_size", &prop)) {
12881282
dev_err(&pdev->dev, "Missing bd_ram_size property in the DT.\n");
12891283
return -EINVAL;

0 commit comments

Comments
 (0)