* [PATCH net-next 01/15] net: sparx5: add support for lan969x SKU's and core clock
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-22 8:57 ` Simon Horman
2024-10-21 13:58 ` [PATCH net-next 02/15] net: sparx5: change spx5_wr to spx5_rmw in cal update() Daniel Machon
` (13 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
In preparation for lan969x, add lan969x SKU's (Stock Keeping Unit) to
sparx5_target_chiptype and set the core clock frequency for these
throughout. Lan969x only supports a core clock frequency of 328MHz.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
.../ethernet/microchip/sparx5/sparx5_calendar.c | 17 +++++++++++
.../net/ethernet/microchip/sparx5/sparx5_main.c | 14 +++++++++
.../net/ethernet/microchip/sparx5/sparx5_main.h | 35 +++++++++++++++-------
drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 6 ++++
4 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
index b2a8d04ab509..1ae56194637f 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
@@ -53,6 +53,22 @@ static u32 sparx5_target_bandwidth(struct sparx5 *sparx5)
case SPX5_TARGET_CT_7558:
case SPX5_TARGET_CT_7558TSN:
return 201000;
+ case SPX5_TARGET_CT_LAN9691VAO:
+ return 46000;
+ case SPX5_TARGET_CT_LAN9694RED:
+ case SPX5_TARGET_CT_LAN9694TSN:
+ case SPX5_TARGET_CT_LAN9694:
+ return 68000;
+ case SPX5_TARGET_CT_LAN9696RED:
+ case SPX5_TARGET_CT_LAN9696TSN:
+ case SPX5_TARGET_CT_LAN9692VAO:
+ case SPX5_TARGET_CT_LAN9696:
+ return 88000;
+ case SPX5_TARGET_CT_LAN9698RED:
+ case SPX5_TARGET_CT_LAN9698TSN:
+ case SPX5_TARGET_CT_LAN9693VAO:
+ case SPX5_TARGET_CT_LAN9698:
+ return 101000;
default:
return 0;
}
@@ -74,6 +90,7 @@ static u32 sparx5_clk_to_bandwidth(enum sparx5_core_clockfreq cclock)
{
switch (cclock) {
case SPX5_CORE_CLOCK_250MHZ: return 83000; /* 250000 / 3 */
+ case SPX5_CORE_CLOCK_328MHZ: return 109375; /* 328000 / 3 */
case SPX5_CORE_CLOCK_500MHZ: return 166000; /* 500000 / 3 */
case SPX5_CORE_CLOCK_625MHZ: return 208000; /* 625000 / 3 */
default: return 0;
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index d1e9bc030c80..f48b5769e1b3 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -475,6 +475,20 @@ static int sparx5_init_coreclock(struct sparx5 *sparx5)
else if (sparx5->coreclock == SPX5_CORE_CLOCK_250MHZ)
freq = 0; /* Not supported */
break;
+ case SPX5_TARGET_CT_LAN9694:
+ case SPX5_TARGET_CT_LAN9691VAO:
+ case SPX5_TARGET_CT_LAN9694TSN:
+ case SPX5_TARGET_CT_LAN9694RED:
+ case SPX5_TARGET_CT_LAN9696:
+ case SPX5_TARGET_CT_LAN9692VAO:
+ case SPX5_TARGET_CT_LAN9696TSN:
+ case SPX5_TARGET_CT_LAN9696RED:
+ case SPX5_TARGET_CT_LAN9698:
+ case SPX5_TARGET_CT_LAN9693VAO:
+ case SPX5_TARGET_CT_LAN9698TSN:
+ case SPX5_TARGET_CT_LAN9698RED:
+ freq = SPX5_CORE_CLOCK_328MHZ;
+ break;
default:
dev_err(sparx5->dev, "Target (%#04x) not supported\n",
sparx5->target_ct);
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index 364ae92969bc..f117cf65cf8c 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -26,16 +26,28 @@
/* Target chip type */
enum spx5_target_chiptype {
- SPX5_TARGET_CT_7546 = 0x7546, /* SparX-5-64 Enterprise */
- SPX5_TARGET_CT_7549 = 0x7549, /* SparX-5-90 Enterprise */
- SPX5_TARGET_CT_7552 = 0x7552, /* SparX-5-128 Enterprise */
- SPX5_TARGET_CT_7556 = 0x7556, /* SparX-5-160 Enterprise */
- SPX5_TARGET_CT_7558 = 0x7558, /* SparX-5-200 Enterprise */
- SPX5_TARGET_CT_7546TSN = 0x47546, /* SparX-5-64i Industrial */
- SPX5_TARGET_CT_7549TSN = 0x47549, /* SparX-5-90i Industrial */
- SPX5_TARGET_CT_7552TSN = 0x47552, /* SparX-5-128i Industrial */
- SPX5_TARGET_CT_7556TSN = 0x47556, /* SparX-5-160i Industrial */
- SPX5_TARGET_CT_7558TSN = 0x47558, /* SparX-5-200i Industrial */
+ SPX5_TARGET_CT_7546 = 0x7546, /* SparX-5-64 Enterprise */
+ SPX5_TARGET_CT_7549 = 0x7549, /* SparX-5-90 Enterprise */
+ SPX5_TARGET_CT_7552 = 0x7552, /* SparX-5-128 Enterprise */
+ SPX5_TARGET_CT_7556 = 0x7556, /* SparX-5-160 Enterprise */
+ SPX5_TARGET_CT_7558 = 0x7558, /* SparX-5-200 Enterprise */
+ SPX5_TARGET_CT_7546TSN = 0x47546, /* SparX-5-64i Industrial */
+ SPX5_TARGET_CT_7549TSN = 0x47549, /* SparX-5-90i Industrial */
+ SPX5_TARGET_CT_7552TSN = 0x47552, /* SparX-5-128i Industrial */
+ SPX5_TARGET_CT_7556TSN = 0x47556, /* SparX-5-160i Industrial */
+ SPX5_TARGET_CT_7558TSN = 0x47558, /* SparX-5-200i Industrial */
+ SPX5_TARGET_CT_LAN9694 = 0x9694, /* lan969x-40 */
+ SPX5_TARGET_CT_LAN9691VAO = 0x9691, /* lan969x-40-VAO */
+ SPX5_TARGET_CT_LAN9694TSN = 0x9695, /* lan969x-40-TSN */
+ SPX5_TARGET_CT_LAN9694RED = 0x969A, /* lan969x-40-RED */
+ SPX5_TARGET_CT_LAN9696 = 0x9696, /* lan969x-60 */
+ SPX5_TARGET_CT_LAN9692VAO = 0x9692, /* lan969x-65-VAO */
+ SPX5_TARGET_CT_LAN9696TSN = 0x9697, /* lan969x-60-TSN */
+ SPX5_TARGET_CT_LAN9696RED = 0x969B, /* lan969x-60-RED */
+ SPX5_TARGET_CT_LAN9698 = 0x9698, /* lan969x-100 */
+ SPX5_TARGET_CT_LAN9693VAO = 0x9693, /* lan969x-100-VAO */
+ SPX5_TARGET_CT_LAN9698TSN = 0x9699, /* lan969x-100-TSN */
+ SPX5_TARGET_CT_LAN9698RED = 0x969C, /* lan969x-100-RED */
};
enum sparx5_port_max_tags {
@@ -192,6 +204,7 @@ struct sparx5_port {
enum sparx5_core_clockfreq {
SPX5_CORE_CLOCK_DEFAULT, /* Defaults to the highest supported frequency */
SPX5_CORE_CLOCK_250MHZ, /* 250MHZ core clock frequency */
+ SPX5_CORE_CLOCK_328MHZ, /* 328MHZ core clock frequency */
SPX5_CORE_CLOCK_500MHZ, /* 500MHZ core clock frequency */
SPX5_CORE_CLOCK_625MHZ, /* 625MHZ core clock frequency */
};
@@ -641,6 +654,8 @@ static inline u32 sparx5_clk_period(enum sparx5_core_clockfreq cclock)
switch (cclock) {
case SPX5_CORE_CLOCK_250MHZ:
return 4000;
+ case SPX5_CORE_CLOCK_328MHZ:
+ return 3048;
case SPX5_CORE_CLOCK_500MHZ:
return 2000;
case SPX5_CORE_CLOCK_625MHZ:
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
index 9b15e44f9e64..a511f14312f1 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
@@ -38,6 +38,9 @@ static u64 sparx5_ptp_get_1ppm(struct sparx5 *sparx5)
case SPX5_CORE_CLOCK_250MHZ:
res = 2301339409586;
break;
+ case SPX5_CORE_CLOCK_328MHZ:
+ res = 1756832768924;
+ break;
case SPX5_CORE_CLOCK_500MHZ:
res = 1150669704793;
break;
@@ -60,6 +63,9 @@ static u64 sparx5_ptp_get_nominal_value(struct sparx5 *sparx5)
case SPX5_CORE_CLOCK_250MHZ:
res = 0x1FF0000000000000;
break;
+ case SPX5_CORE_CLOCK_328MHZ:
+ res = 0x18604697DD0F9B5B;
+ break;
case SPX5_CORE_CLOCK_500MHZ:
res = 0x0FF8000000000000;
break;
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH net-next 01/15] net: sparx5: add support for lan969x SKU's and core clock
2024-10-21 13:58 ` [PATCH net-next 01/15] net: sparx5: add support for lan969x SKU's and core clock Daniel Machon
@ 2024-10-22 8:57 ` Simon Horman
0 siblings, 0 replies; 36+ messages in thread
From: Simon Horman @ 2024-10-22 8:57 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
On Mon, Oct 21, 2024 at 03:58:38PM +0200, Daniel Machon wrote:
> In preparation for lan969x, add lan969x SKU's (Stock Keeping Unit) to
> sparx5_target_chiptype and set the core clock frequency for these
> throughout. Lan969x only supports a core clock frequency of 328MHz.
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
...
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> index d1e9bc030c80..f48b5769e1b3 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> @@ -475,6 +475,20 @@ static int sparx5_init_coreclock(struct sparx5 *sparx5)
> else if (sparx5->coreclock == SPX5_CORE_CLOCK_250MHZ)
> freq = 0; /* Not supported */
> break;
> + case SPX5_TARGET_CT_LAN9694:
> + case SPX5_TARGET_CT_LAN9691VAO:
> + case SPX5_TARGET_CT_LAN9694TSN:
> + case SPX5_TARGET_CT_LAN9694RED:
> + case SPX5_TARGET_CT_LAN9696:
> + case SPX5_TARGET_CT_LAN9692VAO:
> + case SPX5_TARGET_CT_LAN9696TSN:
> + case SPX5_TARGET_CT_LAN9696RED:
> + case SPX5_TARGET_CT_LAN9698:
> + case SPX5_TARGET_CT_LAN9693VAO:
> + case SPX5_TARGET_CT_LAN9698TSN:
> + case SPX5_TARGET_CT_LAN9698RED:
> + freq = SPX5_CORE_CLOCK_328MHZ;
> + break;
Hi Daniel,
It is addressed in patch 12/15, but until then pol_upd_int will
be used uninitialised later on in this function when this case it hit.
Flagged by Smatch.
> default:
> dev_err(sparx5->dev, "Target (%#04x) not supported\n",
> sparx5->target_ct);
...
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH net-next 02/15] net: sparx5: change spx5_wr to spx5_rmw in cal update()
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 01/15] net: sparx5: add support for lan969x SKU's and core clock Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 03/15] net: sparx5: change frequency calculation for SDLB's Daniel Machon
` (12 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
In preparation for lan969x, use spx5_rmw() for enabling the update of
the calendar. This is required to not overwrite the DSM_TAXI_CAL_CFG
register, as an additional write will be added before this one, in a
subsequent patch.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
index 1ae56194637f..edc03b6ebf34 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
@@ -546,9 +546,10 @@ static int sparx5_dsm_calendar_update(struct sparx5 *sparx5, u32 taxi,
u32 idx;
u32 cal_len = sparx5_dsm_cal_len(data->schedule), len;
- spx5_wr(DSM_TAXI_CAL_CFG_CAL_PGM_ENA_SET(1),
- sparx5,
- DSM_TAXI_CAL_CFG(taxi));
+ spx5_rmw(DSM_TAXI_CAL_CFG_CAL_PGM_ENA_SET(1),
+ DSM_TAXI_CAL_CFG_CAL_PGM_ENA,
+ sparx5,
+ DSM_TAXI_CAL_CFG(taxi));
for (idx = 0; idx < cal_len; idx++) {
spx5_rmw(DSM_TAXI_CAL_CFG_CAL_IDX_SET(idx),
DSM_TAXI_CAL_CFG_CAL_IDX,
@@ -559,9 +560,10 @@ static int sparx5_dsm_calendar_update(struct sparx5 *sparx5, u32 taxi,
sparx5,
DSM_TAXI_CAL_CFG(taxi));
}
- spx5_wr(DSM_TAXI_CAL_CFG_CAL_PGM_ENA_SET(0),
- sparx5,
- DSM_TAXI_CAL_CFG(taxi));
+ spx5_rmw(DSM_TAXI_CAL_CFG_CAL_PGM_ENA_SET(0),
+ DSM_TAXI_CAL_CFG_CAL_PGM_ENA,
+ sparx5,
+ DSM_TAXI_CAL_CFG(taxi));
len = DSM_TAXI_CAL_CFG_CAL_CUR_LEN_GET(spx5_rd(sparx5,
DSM_TAXI_CAL_CFG(taxi)));
if (len != cal_len - 1)
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH net-next 03/15] net: sparx5: change frequency calculation for SDLB's
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 01/15] net: sparx5: add support for lan969x SKU's and core clock Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 02/15] net: sparx5: change spx5_wr to spx5_rmw in cal update() Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 04/15] net: sparx5: add sparx5 context pointer to a few functions Daniel Machon
` (11 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
In preparation for lan969x, rework the function that calculates the SDLB
(Service Dual Leacky Bucket) clock. This is required, as the
HSCH_SYS_CLK_PER register is Sparx5-exclusive. Instead derive the clock
from the core clock, using the sparx5_clk_period() function. The clock
stays the same before and after this patch, only now,
sparx5_sdlb_clk_hz_get() can be used for lan969x too.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/sparx5/sparx5_main.h | 2 +-
drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c | 10 +++-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index f117cf65cf8c..2a3b4e855590 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -552,7 +552,7 @@ struct sparx5_sdlb_group *sparx5_get_sdlb_group(int idx);
int sparx5_sdlb_pup_token_get(struct sparx5 *sparx5, u32 pup_interval,
u64 rate);
-int sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5);
+u64 sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5);
int sparx5_sdlb_group_get_by_rate(struct sparx5 *sparx5, u32 rate, u32 burst);
int sparx5_sdlb_group_get_by_index(struct sparx5 *sparx5, u32 idx, u32 *group);
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c b/drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c
index df1d15600aad..98a3f44c569c 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c
@@ -25,17 +25,13 @@ struct sparx5_sdlb_group *sparx5_get_sdlb_group(int idx)
return &sdlb_groups[idx];
}
-int sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5)
+u64 sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5)
{
- u32 clk_per_100ps;
u64 clk_hz;
- clk_per_100ps = HSCH_SYS_CLK_PER_100PS_GET(spx5_rd(sparx5,
- HSCH_SYS_CLK_PER));
- if (!clk_per_100ps)
- clk_per_100ps = SPX5_CLK_PER_100PS_DEFAULT;
+ clk_hz = (10 * 1000 * 1000) /
+ (sparx5_clk_period(sparx5->coreclock) / 100);
- clk_hz = (10 * 1000 * 1000) / clk_per_100ps;
return clk_hz *= 1000;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH net-next 04/15] net: sparx5: add sparx5 context pointer to a few functions
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (2 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 03/15] net: sparx5: change frequency calculation for SDLB's Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 05/15] net: sparx5: add registers required by lan969x Daniel Machon
` (10 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
In preparation for lan969x, add the sparx5 context pointer to certain
IFH (Internal Frame Header) functions. This is required, as the
is_sparx5() function will be used here in a subsequent patch.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 2 +-
drivers/net/ethernet/microchip/sparx5/sparx5_main.h | 11 +++++++----
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c | 9 ++++++---
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 13 ++++++++-----
4 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
index 88f7509f0980..0027144a2af2 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
@@ -154,7 +154,7 @@ static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx
skb = rx->skb[fdma->dcb_index][fdma->db_index];
skb_put(skb, fdma_db_len_get(db_hw));
/* Now do the normal processing of the skb */
- sparx5_ifh_parse((u32 *)skb->data, &fi);
+ sparx5_ifh_parse(sparx5, (u32 *)skb->data, &fi);
/* Map to port netdev */
port = fi.src_port < sparx5->data->consts->n_ports ?
sparx5->ports[fi.src_port] :
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index 2a3b4e855590..15f5d38776c4 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -401,7 +401,7 @@ struct frame_info {
};
void sparx5_xtr_flush(struct sparx5 *sparx5, u8 grp);
-void sparx5_ifh_parse(u32 *ifh, struct frame_info *info);
+void sparx5_ifh_parse(struct sparx5 *sparx5, u32 *ifh, struct frame_info *info);
irqreturn_t sparx5_xtr_handler(int irq, void *_priv);
netdev_tx_t sparx5_port_xmit_impl(struct sk_buff *skb, struct net_device *dev);
int sparx5_manual_injection_mode(struct sparx5 *sparx5);
@@ -469,10 +469,13 @@ static inline int sparx5_dcb_init(struct sparx5 *sparx5)
#endif
/* sparx5_netdev.c */
-void sparx5_set_port_ifh_timestamp(void *ifh_hdr, u64 timestamp);
+void sparx5_set_port_ifh_timestamp(struct sparx5 *sparx5, void *ifh_hdr,
+ u64 timestamp);
void sparx5_set_port_ifh_rew_op(void *ifh_hdr, u32 rew_op);
-void sparx5_set_port_ifh_pdu_type(void *ifh_hdr, u32 pdu_type);
-void sparx5_set_port_ifh_pdu_w16_offset(void *ifh_hdr, u32 pdu_w16_offset);
+void sparx5_set_port_ifh_pdu_type(struct sparx5 *sparx5, void *ifh_hdr,
+ u32 pdu_type);
+void sparx5_set_port_ifh_pdu_w16_offset(struct sparx5 *sparx5, void *ifh_hdr,
+ u32 pdu_w16_offset);
void sparx5_set_port_ifh(struct sparx5 *sparx5, void *ifh_hdr, u16 portno);
bool sparx5_netdevice_check(const struct net_device *dev);
struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno);
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
index d4e9986ef16a..a94d9a540bd3 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
@@ -81,17 +81,20 @@ void sparx5_set_port_ifh_rew_op(void *ifh_hdr, u32 rew_op)
ifh_encode_bitfield(ifh_hdr, rew_op, VSTAX + 32, 10);
}
-void sparx5_set_port_ifh_pdu_type(void *ifh_hdr, u32 pdu_type)
+void sparx5_set_port_ifh_pdu_type(struct sparx5 *sparx5, void *ifh_hdr,
+ u32 pdu_type)
{
ifh_encode_bitfield(ifh_hdr, pdu_type, 191, 4);
}
-void sparx5_set_port_ifh_pdu_w16_offset(void *ifh_hdr, u32 pdu_w16_offset)
+void sparx5_set_port_ifh_pdu_w16_offset(struct sparx5 *sparx5, void *ifh_hdr,
+ u32 pdu_w16_offset)
{
ifh_encode_bitfield(ifh_hdr, pdu_w16_offset, 195, 6);
}
-void sparx5_set_port_ifh_timestamp(void *ifh_hdr, u64 timestamp)
+void sparx5_set_port_ifh_timestamp(struct sparx5 *sparx5, void *ifh_hdr,
+ u64 timestamp)
{
ifh_encode_bitfield(ifh_hdr, timestamp, 232, 40);
}
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
index 5bfa86a71ac8..57fa9ff9dfce 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
@@ -32,7 +32,7 @@ void sparx5_xtr_flush(struct sparx5 *sparx5, u8 grp)
spx5_wr(0, sparx5, QS_XTR_FLUSH);
}
-void sparx5_ifh_parse(u32 *ifh, struct frame_info *info)
+void sparx5_ifh_parse(struct sparx5 *sparx5, u32 *ifh, struct frame_info *info)
{
u8 *xtr_hdr = (u8 *)ifh;
@@ -72,7 +72,7 @@ static void sparx5_xtr_grp(struct sparx5 *sparx5, u8 grp, bool byte_swap)
ifh[i] = spx5_rd(sparx5, QS_XTR_RD(grp));
/* Decode IFH (what's needed) */
- sparx5_ifh_parse(ifh, &fi);
+ sparx5_ifh_parse(sparx5, ifh, &fi);
/* Map to port netdev */
port = fi.src_port < sparx5->data->consts->n_ports ?
@@ -242,9 +242,12 @@ netdev_tx_t sparx5_port_xmit_impl(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_BUSY;
sparx5_set_port_ifh_rew_op(ifh, SPARX5_SKB_CB(skb)->rew_op);
- sparx5_set_port_ifh_pdu_type(ifh, SPARX5_SKB_CB(skb)->pdu_type);
- sparx5_set_port_ifh_pdu_w16_offset(ifh, SPARX5_SKB_CB(skb)->pdu_w16_offset);
- sparx5_set_port_ifh_timestamp(ifh, SPARX5_SKB_CB(skb)->ts_id);
+ sparx5_set_port_ifh_pdu_type(sparx5, ifh,
+ SPARX5_SKB_CB(skb)->pdu_type);
+ sparx5_set_port_ifh_pdu_w16_offset(sparx5, ifh,
+ SPARX5_SKB_CB(skb)->pdu_w16_offset);
+ sparx5_set_port_ifh_timestamp(sparx5, ifh,
+ SPARX5_SKB_CB(skb)->ts_id);
}
skb_tx_timestamp(skb);
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH net-next 05/15] net: sparx5: add registers required by lan969x
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (3 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 04/15] net: sparx5: add sparx5 context pointer to a few functions Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 17:33 ` Maxime Chevallier
2024-10-21 13:58 ` [PATCH net-next 06/15] net: lan969x: add match data for lan969x Daniel Machon
` (9 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Lan969x will require a few additional registers for certain operations.
Some are shared, some are not. Add these.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
.../ethernet/microchip/sparx5/sparx5_main_regs.h | 132 +++++++++++++++++++++
1 file changed, 132 insertions(+)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h
index 0e8b18bcf179..34cfbc719ca5 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h
@@ -2666,6 +2666,44 @@ extern const struct sparx5_regs *regs;
#define CPU_PROC_CTRL_ACP_DISABLE_GET(x)\
FIELD_GET(CPU_PROC_CTRL_ACP_DISABLE, x)
+/* DEV1G:PHASE_DETECTOR_CTRL:PHAD_CTRL */
+#define DEV2G5_PHAD_CTRL(t, g) \
+ __REG(TARGET_DEV2G5, t, regs->tsize[TC_DEV2G5], 200, g, 2, \
+ regs->gsize[GW_DEV2G5_PHASE_DETECTOR_CTRL], 0, 0, 1, 4)
+
+#define DEV2G5_PHAD_CTRL_PHAD_ENA\
+ BIT(regs->fpos[FP_DEV2G5_PHAD_CTRL_PHAD_ENA])
+#define DEV2G5_PHAD_CTRL_PHAD_ENA_SET(x)\
+ spx5_field_prep(DEV2G5_PHAD_CTRL_PHAD_ENA, x)
+#define DEV2G5_PHAD_CTRL_PHAD_ENA_GET(x)\
+ spx5_field_get(DEV2G5_PHAD_CTRL_PHAD_ENA, x)
+
+/* LAN969X ONLY */
+#define DEV2G5_PHAD_CTRL_DIV_CFG GENMASK(11, 9)
+#define DEV2G5_PHAD_CTRL_DIV_CFG_SET(x)\
+ FIELD_PREP(DEV2G5_PHAD_CTRL_DIV_CFG, x)
+#define DEV2G5_PHAD_CTRL_DIV_CFG_GET(x)\
+ FIELD_GET(DEV2G5_PHAD_CTRL_DIV_CFG, x)
+
+/* DEV1G:PHASE_DETECTOR_CTRL:PHAD_CTRL */
+#define DEV2G5_PHAD_CTRL(t, g) \
+ __REG(TARGET_DEV2G5, t, regs->tsize[TC_DEV2G5], 200, g, 2, \
+ regs->gsize[GW_DEV2G5_PHASE_DETECTOR_CTRL], 0, 0, 1, 4)
+
+#define DEV2G5_PHAD_CTRL_PHAD_ENA\
+ BIT(regs->fpos[FP_DEV2G5_PHAD_CTRL_PHAD_ENA])
+#define DEV2G5_PHAD_CTRL_PHAD_ENA_SET(x)\
+ spx5_field_prep(DEV2G5_PHAD_CTRL_PHAD_ENA, x)
+#define DEV2G5_PHAD_CTRL_PHAD_ENA_GET(x)\
+ spx5_field_get(DEV2G5_PHAD_CTRL_PHAD_ENA, x)
+
+/* LAN969X ONLY */
+#define DEV2G5_PHAD_CTRL_DIV_CFG GENMASK(11, 9)
+#define DEV2G5_PHAD_CTRL_DIV_CFG_SET(x)\
+ FIELD_PREP(DEV2G5_PHAD_CTRL_DIV_CFG, x)
+#define DEV2G5_PHAD_CTRL_DIV_CFG_GET(x)\
+ FIELD_GET(DEV2G5_PHAD_CTRL_DIV_CFG, x)
+
/* DEV10G:MAC_CFG_STATUS:MAC_ENA_CFG */
#define DEV10G_MAC_ENA_CFG(t) \
__REG(TARGET_DEV10G, t, regs->tsize[TC_DEV10G], 0, 0, 1, 60, 0, 0, 1, \
@@ -2869,6 +2907,11 @@ extern const struct sparx5_regs *regs;
#define DEV10G_DEV_RST_CTRL_MAC_RX_RST_GET(x)\
FIELD_GET(DEV10G_DEV_RST_CTRL_MAC_RX_RST, x)
+/* DEV10G:DEV_CFG_STATUS:PTP_STAMPER_CFG */
+#define DEV10G_PTP_STAMPER_CFG(t) \
+ __REG(TARGET_DEV10G, t, regs->tsize[TC_DEV10G], 436, 0, 1, 52, 20, 0, \
+ 1, 4)
+
/* DEV10G:PCS25G_CFG_STATUS:PCS25G_CFG */
#define DEV10G_PCS25G_CFG(t) \
__REG(TARGET_DEV10G, t, regs->tsize[TC_DEV10G], 488, 0, 1, 32, 0, 0, 1,\
@@ -4267,6 +4310,11 @@ extern const struct sparx5_regs *regs;
#define DEV5G_DEV_RST_CTRL_MAC_RX_RST_GET(x)\
FIELD_GET(DEV5G_DEV_RST_CTRL_MAC_RX_RST, x)
+/* DEV10G:DEV_CFG_STATUS:PTP_STAMPER_CFG */
+#define DEV5G_PTP_STAMPER_CFG(t) \
+ __REG(TARGET_DEV5G, t, regs->tsize[TC_DEV5G], 436, 0, 1, 52, 20, 0, 1, \
+ 4)
+
/* DSM:RAM_CTRL:RAM_INIT */
#define DSM_RAM_INIT \
__REG(TARGET_DSM, 0, 1, 0, 0, 1, 4, 0, 0, 1, 4)
@@ -4444,6 +4492,27 @@ extern const struct sparx5_regs *regs;
#define DSM_TAXI_CAL_CFG_CAL_PGM_ENA_GET(x)\
FIELD_GET(DSM_TAXI_CAL_CFG_CAL_PGM_ENA, x)
+/* LAN969X ONLY */
+#define DSM_TAXI_CAL_CFG_CAL_SEL_STAT BIT(23)
+#define DSM_TAXI_CAL_CFG_CAL_SEL_STAT_SET(x)\
+ FIELD_PREP(DSM_TAXI_CAL_CFG_CAL_SEL_STAT, x)
+#define DSM_TAXI_CAL_CFG_CAL_SEL_STAT_GET(x)\
+ FIELD_GET(DSM_TAXI_CAL_CFG_CAL_SEL_STAT, x)
+
+/* LAN969X ONLY */
+#define DSM_TAXI_CAL_CFG_CAL_SWITCH BIT(22)
+#define DSM_TAXI_CAL_CFG_CAL_SWITCH_SET(x)\
+ FIELD_PREP(DSM_TAXI_CAL_CFG_CAL_SWITCH, x)
+#define DSM_TAXI_CAL_CFG_CAL_SWITCH_GET(x)\
+ FIELD_GET(DSM_TAXI_CAL_CFG_CAL_SWITCH, x)
+
+/* LAN969X ONLY */
+#define DSM_TAXI_CAL_CFG_CAL_PGM_SEL BIT(21)
+#define DSM_TAXI_CAL_CFG_CAL_PGM_SEL_SET(x)\
+ FIELD_PREP(DSM_TAXI_CAL_CFG_CAL_PGM_SEL, x)
+#define DSM_TAXI_CAL_CFG_CAL_PGM_SEL_GET(x)\
+ FIELD_GET(DSM_TAXI_CAL_CFG_CAL_PGM_SEL, x)
+
/* EACL:ES2_KEY_SELECT_PROFILE:VCAP_ES2_KEY_SEL */
#define EACL_VCAP_ES2_KEY_SEL(g, r) \
__REG(TARGET_EACL, 0, 1, regs->gaddr[GA_EACL_ES2_KEY_SELECT_PROFILE], \
@@ -6720,6 +6789,69 @@ extern const struct sparx5_regs *regs;
regs->gcnt[GC_PTP_PHASE_DETECTOR_CTRL], \
regs->gsize[GW_PTP_PHASE_DETECTOR_CTRL], 4, 0, 1, 4)
+/* LAN969X ONLY */
+/* DEVCPU_PTP:PTP_TS_FIFO:PTP_TWOSTEP_CTRL */
+#define PTP_PTP_TWOSTEP_CTRL \
+ __REG(TARGET_PTP, 0, 1, 612, 0, 1, 16, 0, 0, 1, 4)
+
+#define PTP_PTP_TWOSTEP_CTRL_PTP_OVWR_ENA BIT(12)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_OVWR_ENA_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_CTRL_PTP_OVWR_ENA, x)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_OVWR_ENA_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_CTRL_PTP_OVWR_ENA, x)
+
+#define PTP_PTP_TWOSTEP_CTRL_PTP_NXT BIT(11)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_NXT_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_CTRL_PTP_NXT, x)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_NXT_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_CTRL_PTP_NXT, x)
+
+#define PTP_PTP_TWOSTEP_CTRL_PTP_VLD BIT(10)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_VLD_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_CTRL_PTP_VLD, x)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_VLD_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_CTRL_PTP_VLD, x)
+
+#define PTP_PTP_TWOSTEP_CTRL_STAMP_TX BIT(9)
+#define PTP_PTP_TWOSTEP_CTRL_STAMP_TX_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_CTRL_STAMP_TX, x)
+#define PTP_PTP_TWOSTEP_CTRL_STAMP_TX_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_CTRL_STAMP_TX, x)
+
+#define PTP_PTP_TWOSTEP_CTRL_STAMP_PORT GENMASK(8, 1)
+#define PTP_PTP_TWOSTEP_CTRL_STAMP_PORT_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_CTRL_STAMP_PORT, x)
+#define PTP_PTP_TWOSTEP_CTRL_STAMP_PORT_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_CTRL_STAMP_PORT, x)
+
+#define PTP_PTP_TWOSTEP_CTRL_PTP_OVFL BIT(0)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_OVFL_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_CTRL_PTP_OVFL, x)
+#define PTP_PTP_TWOSTEP_CTRL_PTP_OVFL_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_CTRL_PTP_OVFL, x)
+
+/* LAN969X ONLY */
+/* DEVCPU_PTP:PTP_TS_FIFO:PTP_TWOSTEP_STAMP_NSEC */
+#define PTP_PTP_TWOSTEP_STAMP_NSEC \
+ __REG(TARGET_PTP, 0, 1, 612, 0, 1, 16, 4, 0, 1, 4)
+
+#define PTP_PTP_TWOSTEP_STAMP_NSEC_STAMP_NSEC GENMASK(29, 0)
+#define PTP_PTP_TWOSTEP_STAMP_NSEC_STAMP_NSEC_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_STAMP_NSEC_STAMP_NSEC, x)
+#define PTP_PTP_TWOSTEP_STAMP_NSEC_STAMP_NSEC_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_STAMP_NSEC_STAMP_NSEC, x)
+
+/* LAN969X ONLY */
+/* DEVCPU_PTP:PTP_TS_FIFO:PTP_TWOSTEP_STAMP_SUBNS */
+#define PTP_PTP_TWOSTEP_STAMP_SUBNS \
+ __REG(TARGET_PTP, 0, 1, 612, 0, 1, 16, 8, 0, 1, 4)
+
+#define PTP_PTP_TWOSTEP_STAMP_SUBNS_STAMP_SUB_NSEC GENMASK(7, 0)
+#define PTP_PTP_TWOSTEP_STAMP_SUBNS_STAMP_SUB_NSEC_SET(x)\
+ FIELD_PREP(PTP_PTP_TWOSTEP_STAMP_SUBNS_STAMP_SUB_NSEC, x)
+#define PTP_PTP_TWOSTEP_STAMP_SUBNS_STAMP_SUB_NSEC_GET(x)\
+ FIELD_GET(PTP_PTP_TWOSTEP_STAMP_SUBNS_STAMP_SUB_NSEC, x)
+
/* QFWD:SYSTEM:SWITCH_PORT_MODE */
#define QFWD_SWITCH_PORT_MODE(r) \
__REG(TARGET_QFWD, 0, 1, 0, 0, 1, 340, 0, r, \
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH net-next 05/15] net: sparx5: add registers required by lan969x
2024-10-21 13:58 ` [PATCH net-next 05/15] net: sparx5: add registers required by lan969x Daniel Machon
@ 2024-10-21 17:33 ` Maxime Chevallier
2024-10-21 19:10 ` Daniel Machon
0 siblings, 1 reply; 36+ messages in thread
From: Maxime Chevallier @ 2024-10-21 17:33 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, netdev, linux-arm-kernel,
linux-kernel, devicetree
Hello Daniel,
On Mon, 21 Oct 2024 15:58:42 +0200
Daniel Machon <daniel.machon@microchip.com> wrote:
> Lan969x will require a few additional registers for certain operations.
> Some are shared, some are not. Add these.
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
[...]
> +#define PTP_PTP_TWOSTEP_STAMP_SUBNS_STAMP_SUB_NSEC GENMASK(7, 0)
I understand that this is partly autogenerated, however the naming for
this register in particular seems very redundant... Is there any way
this could be improved ?
Thanks,
Maxime
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH net-next 05/15] net: sparx5: add registers required by lan969x
2024-10-21 17:33 ` Maxime Chevallier
@ 2024-10-21 19:10 ` Daniel Machon
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 19:10 UTC (permalink / raw)
To: Maxime Chevallier
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, netdev, linux-arm-kernel,
linux-kernel, devicetree
> Hello Daniel,
>
> On Mon, 21 Oct 2024 15:58:42 +0200
> Daniel Machon <daniel.machon@microchip.com> wrote:
>
> > Lan969x will require a few additional registers for certain operations.
> > Some are shared, some are not. Add these.
> >
> > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> > Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
>
> [...]
>
> > +#define PTP_PTP_TWOSTEP_STAMP_SUBNS_STAMP_SUB_NSEC GENMASK(7, 0)
>
> I understand that this is partly autogenerated, however the naming for
> this register in particular seems very redundant... Is there any way
> this could be improved ?
>
> Thanks,
>
> Maxime
>
Yes, this might be a new candidate for "the longest name in the kernel"
award.
This particular register is a concatenation of: PTP (target) PTP_TS_FIFO
(register group) PTP_TWOSTEP_STAMP_SUBNS (register) STAMP_SUB_NSEC
(field), and as you can see the register group part is already removed.
That said, the tool for generating this, can be tweaked to rename
registers if required - I will do that here :-)
Thanks!
/Daniel
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH net-next 06/15] net: lan969x: add match data for lan969x
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (4 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 05/15] net: sparx5: add registers required by lan969x Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-23 1:32 ` kernel test robot
` (2 more replies)
2024-10-21 13:58 ` [PATCH net-next 07/15] net: lan969x: add register diffs to match data Daniel Machon
` (8 subsequent siblings)
14 siblings, 3 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Add match data for lan969x, with initial fields for iomap, iomap_size
and ioranges. Add new Kconfig symbol CONFIG_LAN969X_CONFIG for compiling
the lan969x driver.
It has been decided to give lan969x its own Kconfig symbol, as a
considerable amount of code is needed, beside the Sparx5 code, to add
full chip support (and more will be added in future series). Also this
makes it possible to compile Sparx5 without lan969x.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
MAINTAINERS | 7 ++
drivers/net/ethernet/microchip/Kconfig | 1 +
drivers/net/ethernet/microchip/Makefile | 1 +
drivers/net/ethernet/microchip/lan969x/Kconfig | 5 ++
drivers/net/ethernet/microchip/lan969x/Makefile | 13 +++
drivers/net/ethernet/microchip/lan969x/lan969x.c | 103 +++++++++++++++++++++++
drivers/net/ethernet/microchip/lan969x/lan969x.h | 15 ++++
7 files changed, 145 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index d678a58c0205..0612af9196fd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15188,6 +15188,13 @@ S: Maintained
F: Documentation/devicetree/bindings/interrupt-controller/microchip,lan966x-oic.yaml
F: drivers/irqchip/irq-lan966x-oic.c
+MICROCHIP LAN969X ETHERNET DRIVER
+M: Daniel Machon <daniel.machon@microchip.com>
+M: UNGLinuxDriver@microchip.com
+L: netdev@vger.kernel.org
+S: Maintained
+F: drivers/net/ethernet/microchip/lan969x/*
+
MICROCHIP LCDFB DRIVER
M: Nicolas Ferre <nicolas.ferre@microchip.com>
L: linux-fbdev@vger.kernel.org
diff --git a/drivers/net/ethernet/microchip/Kconfig b/drivers/net/ethernet/microchip/Kconfig
index ee046468652c..73832fb2bc32 100644
--- a/drivers/net/ethernet/microchip/Kconfig
+++ b/drivers/net/ethernet/microchip/Kconfig
@@ -59,6 +59,7 @@ config LAN743X
source "drivers/net/ethernet/microchip/lan865x/Kconfig"
source "drivers/net/ethernet/microchip/lan966x/Kconfig"
+source "drivers/net/ethernet/microchip/lan969x/Kconfig"
source "drivers/net/ethernet/microchip/sparx5/Kconfig"
source "drivers/net/ethernet/microchip/vcap/Kconfig"
source "drivers/net/ethernet/microchip/fdma/Kconfig"
diff --git a/drivers/net/ethernet/microchip/Makefile b/drivers/net/ethernet/microchip/Makefile
index 3c65baed9fd8..7770df82200f 100644
--- a/drivers/net/ethernet/microchip/Makefile
+++ b/drivers/net/ethernet/microchip/Makefile
@@ -11,6 +11,7 @@ lan743x-objs := lan743x_main.o lan743x_ethtool.o lan743x_ptp.o
obj-$(CONFIG_LAN865X) += lan865x/
obj-$(CONFIG_LAN966X_SWITCH) += lan966x/
+obj-$(CONFIG_LAN969X_SWITCH) += lan969x/
obj-$(CONFIG_SPARX5_SWITCH) += sparx5/
obj-$(CONFIG_VCAP) += vcap/
obj-$(CONFIG_FDMA) += fdma/
diff --git a/drivers/net/ethernet/microchip/lan969x/Kconfig b/drivers/net/ethernet/microchip/lan969x/Kconfig
new file mode 100644
index 000000000000..9bf65187f20c
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan969x/Kconfig
@@ -0,0 +1,5 @@
+config LAN969X_SWITCH
+ tristate "Lan969x switch driver"
+ select SPARX5_SWITCH
+ help
+ This driver supports the lan969x family of network switch devices.
diff --git a/drivers/net/ethernet/microchip/lan969x/Makefile b/drivers/net/ethernet/microchip/lan969x/Makefile
new file mode 100644
index 000000000000..3755202536e1
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan969x/Makefile
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for the Microchip lan969x network device drivers.
+#
+
+obj-$(CONFIG_LAN969X_SWITCH) += lan969x-switch.o
+
+lan969x-switch-y := lan969x.o
+
+# Provide include files
+ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/sparx5
+ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
+ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.c b/drivers/net/ethernet/microchip/lan969x/lan969x.c
new file mode 100644
index 000000000000..32f4c1001482
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.c
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Microchip lan969x Switch driver
+ *
+ * Copyright (c) 2024 Microchip Technology Inc. and its subsidiaries.
+ */
+
+#include "lan969x.h"
+
+static const struct sparx5_main_io_resource lan969x_main_iomap[] = {
+ { TARGET_CPU, 0xc0000, 0 }, /* 0xe00c0000 */
+ { TARGET_FDMA, 0xc0400, 0 }, /* 0xe00c0400 */
+ { TARGET_GCB, 0x2010000, 1 }, /* 0xe2010000 */
+ { TARGET_QS, 0x2030000, 1 }, /* 0xe2030000 */
+ { TARGET_PTP, 0x2040000, 1 }, /* 0xe2040000 */
+ { TARGET_ANA_ACL, 0x2050000, 1 }, /* 0xe2050000 */
+ { TARGET_LRN, 0x2060000, 1 }, /* 0xe2060000 */
+ { TARGET_VCAP_SUPER, 0x2080000, 1 }, /* 0xe2080000 */
+ { TARGET_QSYS, 0x20a0000, 1 }, /* 0xe20a0000 */
+ { TARGET_QFWD, 0x20b0000, 1 }, /* 0xe20b0000 */
+ { TARGET_XQS, 0x20c0000, 1 }, /* 0xe20c0000 */
+ { TARGET_VCAP_ES2, 0x20d0000, 1 }, /* 0xe20d0000 */
+ { TARGET_VCAP_ES0, 0x20e0000, 1 }, /* 0xe20e0000 */
+ { TARGET_ANA_AC_POL, 0x2200000, 1 }, /* 0xe2200000 */
+ { TARGET_QRES, 0x2280000, 1 }, /* 0xe2280000 */
+ { TARGET_EACL, 0x22c0000, 1 }, /* 0xe22c0000 */
+ { TARGET_ANA_CL, 0x2400000, 1 }, /* 0xe2400000 */
+ { TARGET_ANA_L3, 0x2480000, 1 }, /* 0xe2480000 */
+ { TARGET_ANA_AC_SDLB, 0x2500000, 1 }, /* 0xe2500000 */
+ { TARGET_HSCH, 0x2580000, 1 }, /* 0xe2580000 */
+ { TARGET_REW, 0x2600000, 1 }, /* 0xe2600000 */
+ { TARGET_ANA_L2, 0x2800000, 1 }, /* 0xe2800000 */
+ { TARGET_ANA_AC, 0x2900000, 1 }, /* 0xe2900000 */
+ { TARGET_VOP, 0x2a00000, 1 }, /* 0xe2a00000 */
+ { TARGET_DEV2G5, 0x3004000, 1 }, /* 0xe3004000 */
+ { TARGET_DEV10G, 0x3008000, 1 }, /* 0xe3008000 */
+ { TARGET_PCS10G_BR, 0x300c000, 1 }, /* 0xe300c000 */
+ { TARGET_DEV2G5 + 1, 0x3010000, 1 }, /* 0xe3010000 */
+ { TARGET_DEV2G5 + 2, 0x3014000, 1 }, /* 0xe3014000 */
+ { TARGET_DEV2G5 + 3, 0x3018000, 1 }, /* 0xe3018000 */
+ { TARGET_DEV2G5 + 4, 0x301c000, 1 }, /* 0xe301c000 */
+ { TARGET_DEV10G + 1, 0x3020000, 1 }, /* 0xe3020000 */
+ { TARGET_PCS10G_BR + 1, 0x3024000, 1 }, /* 0xe3024000 */
+ { TARGET_DEV2G5 + 5, 0x3028000, 1 }, /* 0xe3028000 */
+ { TARGET_DEV2G5 + 6, 0x302c000, 1 }, /* 0xe302c000 */
+ { TARGET_DEV2G5 + 7, 0x3030000, 1 }, /* 0xe3030000 */
+ { TARGET_DEV2G5 + 8, 0x3034000, 1 }, /* 0xe3034000 */
+ { TARGET_DEV10G + 2, 0x3038000, 1 }, /* 0xe3038000 */
+ { TARGET_PCS10G_BR + 2, 0x303c000, 1 }, /* 0xe303c000 */
+ { TARGET_DEV2G5 + 9, 0x3040000, 1 }, /* 0xe3040000 */
+ { TARGET_DEV5G, 0x3044000, 1 }, /* 0xe3044000 */
+ { TARGET_PCS5G_BR, 0x3048000, 1 }, /* 0xe3048000 */
+ { TARGET_DEV2G5 + 10, 0x304c000, 1 }, /* 0xe304c000 */
+ { TARGET_DEV2G5 + 11, 0x3050000, 1 }, /* 0xe3050000 */
+ { TARGET_DEV2G5 + 12, 0x3054000, 1 }, /* 0xe3054000 */
+ { TARGET_DEV10G + 3, 0x3058000, 1 }, /* 0xe3058000 */
+ { TARGET_PCS10G_BR + 3, 0x305c000, 1 }, /* 0xe305c000 */
+ { TARGET_DEV2G5 + 13, 0x3060000, 1 }, /* 0xe3060000 */
+ { TARGET_DEV5G + 1, 0x3064000, 1 }, /* 0xe3064000 */
+ { TARGET_PCS5G_BR + 1, 0x3068000, 1 }, /* 0xe3068000 */
+ { TARGET_DEV2G5 + 14, 0x306c000, 1 }, /* 0xe306c000 */
+ { TARGET_DEV2G5 + 15, 0x3070000, 1 }, /* 0xe3070000 */
+ { TARGET_DEV2G5 + 16, 0x3074000, 1 }, /* 0xe3074000 */
+ { TARGET_DEV10G + 4, 0x3078000, 1 }, /* 0xe3078000 */
+ { TARGET_PCS10G_BR + 4, 0x307c000, 1 }, /* 0xe307c000 */
+ { TARGET_DEV2G5 + 17, 0x3080000, 1 }, /* 0xe3080000 */
+ { TARGET_DEV5G + 2, 0x3084000, 1 }, /* 0xe3084000 */
+ { TARGET_PCS5G_BR + 2, 0x3088000, 1 }, /* 0xe3088000 */
+ { TARGET_DEV2G5 + 18, 0x308c000, 1 }, /* 0xe308c000 */
+ { TARGET_DEV2G5 + 19, 0x3090000, 1 }, /* 0xe3090000 */
+ { TARGET_DEV2G5 + 20, 0x3094000, 1 }, /* 0xe3094000 */
+ { TARGET_DEV10G + 5, 0x3098000, 1 }, /* 0xe3098000 */
+ { TARGET_PCS10G_BR + 5, 0x309c000, 1 }, /* 0xe309c000 */
+ { TARGET_DEV2G5 + 21, 0x30a0000, 1 }, /* 0xe30a0000 */
+ { TARGET_DEV5G + 3, 0x30a4000, 1 }, /* 0xe30a4000 */
+ { TARGET_PCS5G_BR + 3, 0x30a8000, 1 }, /* 0xe30a8000 */
+ { TARGET_DEV2G5 + 22, 0x30ac000, 1 }, /* 0xe30ac000 */
+ { TARGET_DEV2G5 + 23, 0x30b0000, 1 }, /* 0xe30b0000 */
+ { TARGET_DEV2G5 + 24, 0x30b4000, 1 }, /* 0xe30b4000 */
+ { TARGET_DEV10G + 6, 0x30b8000, 1 }, /* 0xe30b8000 */
+ { TARGET_PCS10G_BR + 6, 0x30bc000, 1 }, /* 0xe30bc000 */
+ { TARGET_DEV2G5 + 25, 0x30c0000, 1 }, /* 0xe30c0000 */
+ { TARGET_DEV10G + 7, 0x30c4000, 1 }, /* 0xe30c4000 */
+ { TARGET_PCS10G_BR + 7, 0x30c8000, 1 }, /* 0xe30c8000 */
+ { TARGET_DEV2G5 + 26, 0x30cc000, 1 }, /* 0xe30cc000 */
+ { TARGET_DEV10G + 8, 0x30d0000, 1 }, /* 0xe30d0000 */
+ { TARGET_PCS10G_BR + 8, 0x30d4000, 1 }, /* 0xe30d4000 */
+ { TARGET_DEV2G5 + 27, 0x30d8000, 1 }, /* 0xe30d8000 */
+ { TARGET_DEV10G + 9, 0x30dc000, 1 }, /* 0xe30dc000 */
+ { TARGET_PCS10G_BR + 9, 0x30e0000, 1 }, /* 0xe30e0000 */
+ { TARGET_DSM, 0x30ec000, 1 }, /* 0xe30ec000 */
+ { TARGET_PORT_CONF, 0x30f0000, 1 }, /* 0xe30f0000 */
+ { TARGET_ASM, 0x3200000, 1 }, /* 0xe3200000 */
+};
+
+const struct sparx5_match_data lan969x_desc = {
+ .iomap = lan969x_main_iomap,
+ .iomap_size = ARRAY_SIZE(lan969x_main_iomap),
+ .ioranges = 2,
+};
+
+MODULE_DESCRIPTION("Microchip lan969x switch driver");
+MODULE_AUTHOR("Daniel Machon <daniel.machon@microchip.com>");
+MODULE_LICENSE("Dual MIT/GPL");
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.h b/drivers/net/ethernet/microchip/lan969x/lan969x.h
new file mode 100644
index 000000000000..ba6d351f45c8
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* Microchip lan969x Switch driver
+ *
+ * Copyright (c) 2024 Microchip Technology Inc. and its subsidiaries.
+ */
+
+#ifndef __LAN969X_H__
+#define __LAN969X_H__
+
+#include "sparx5_main.h"
+
+/* lan969x.c */
+extern const struct sparx5_match_data lan969x_desc;
+
+#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH net-next 06/15] net: lan969x: add match data for lan969x
2024-10-21 13:58 ` [PATCH net-next 06/15] net: lan969x: add match data for lan969x Daniel Machon
@ 2024-10-23 1:32 ` kernel test robot
2024-10-23 20:53 ` kernel test robot
2024-10-24 15:52 ` kernel test robot
2 siblings, 0 replies; 36+ messages in thread
From: kernel test robot @ 2024-10-23 1:32 UTC (permalink / raw)
To: Daniel Machon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: Paul Gazzillo, Necip Fazil Yildiran, oe-kbuild-all, netdev,
linux-arm-kernel, linux-kernel, devicetree
Hi Daniel,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 30d9d8f6a2d7e44a9f91737dd409dbc87ac6f6b7]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Machon/net-sparx5-add-support-for-lan969x-SKU-s-and-core-clock/20241021-220557
base: 30d9d8f6a2d7e44a9f91737dd409dbc87ac6f6b7
patch link: https://lore.kernel.org/r/20241021-sparx5-lan969x-switch-driver-2-v1-6-c8c49ef21e0f%40microchip.com
patch subject: [PATCH net-next 06/15] net: lan969x: add match data for lan969x
config: nios2-kismet-CONFIG_SPARX5_SWITCH-CONFIG_LAN969X_SWITCH-0-0 (https://download.01.org/0day-ci/archive/20241023/202410230843.lGLDpveC-lkp@intel.com/config)
reproduce: (https://download.01.org/0day-ci/archive/20241023/202410230843.lGLDpveC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410230843.lGLDpveC-lkp@intel.com/
kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for SPARX5_SWITCH when selected by LAN969X_SWITCH
WARNING: unmet direct dependencies detected for SPARX5_SWITCH
Depends on [n]: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_MICROCHIP [=y] && NET_SWITCHDEV [=n] && HAS_IOMEM [=y] && OF [=y] && (ARCH_SPARX5 || COMPILE_TEST [=n]) && PTP_1588_CLOCK_OPTIONAL [=y] && (BRIDGE [=n] || BRIDGE [=n]=n [=n])
Selected by [y]:
- LAN969X_SWITCH [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_MICROCHIP [=y]
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 06/15] net: lan969x: add match data for lan969x
2024-10-21 13:58 ` [PATCH net-next 06/15] net: lan969x: add match data for lan969x Daniel Machon
2024-10-23 1:32 ` kernel test robot
@ 2024-10-23 20:53 ` kernel test robot
2024-10-24 15:52 ` kernel test robot
2 siblings, 0 replies; 36+ messages in thread
From: kernel test robot @ 2024-10-23 20:53 UTC (permalink / raw)
To: Daniel Machon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: oe-kbuild-all, netdev, linux-arm-kernel, linux-kernel, devicetree
Hi Daniel,
kernel test robot noticed the following build errors:
[auto build test ERROR on 30d9d8f6a2d7e44a9f91737dd409dbc87ac6f6b7]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Machon/net-sparx5-add-support-for-lan969x-SKU-s-and-core-clock/20241021-220557
base: 30d9d8f6a2d7e44a9f91737dd409dbc87ac6f6b7
patch link: https://lore.kernel.org/r/20241021-sparx5-lan969x-switch-driver-2-v1-6-c8c49ef21e0f%40microchip.com
patch subject: [PATCH net-next 06/15] net: lan969x: add match data for lan969x
config: arm64-randconfig-002-20241024 (https://download.01.org/0day-ci/archive/20241024/202410240405.kPh7im63-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241024/202410240405.kPh7im63-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410240405.kPh7im63-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c: In function 'sparx5_fdma_rx_get_frame':
>> drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c:178:20: error: 'struct sk_buff' has no member named 'offload_fwd_mark'
178 | skb->offload_fwd_mark = 1;
| ^~
--
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c: In function 'sparx5_xtr_grp':
>> drivers/net/ethernet/microchip/sparx5/sparx5_packet.c:154:20: error: 'struct sk_buff' has no member named 'offload_fwd_mark'
154 | skb->offload_fwd_mark = 1;
| ^~
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SPARX5_SWITCH
Depends on [n]: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_MICROCHIP [=y] && NET_SWITCHDEV [=n] && HAS_IOMEM [=y] && OF [=y] && (ARCH_SPARX5 [=y] || COMPILE_TEST [=y]) && PTP_1588_CLOCK_OPTIONAL [=m] && (BRIDGE [=m] || BRIDGE [=m]=n [=n])
Selected by [m]:
- LAN969X_SWITCH [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_MICROCHIP [=y]
vim +178 drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
10615907e9b51c Steen Hegelund 2021-08-19 141
10615907e9b51c Steen Hegelund 2021-08-19 142 static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx)
10615907e9b51c Steen Hegelund 2021-08-19 143 {
e8218f7a9f4425 Daniel Machon 2024-09-02 144 struct fdma *fdma = &rx->fdma;
10615907e9b51c Steen Hegelund 2021-08-19 145 struct sparx5_port *port;
8fec1cea941d32 Daniel Machon 2024-09-02 146 struct fdma_db *db_hw;
10615907e9b51c Steen Hegelund 2021-08-19 147 struct frame_info fi;
10615907e9b51c Steen Hegelund 2021-08-19 148 struct sk_buff *skb;
10615907e9b51c Steen Hegelund 2021-08-19 149
10615907e9b51c Steen Hegelund 2021-08-19 150 /* Check if the DCB is done */
4ff58c394715ee Daniel Machon 2024-09-02 151 db_hw = fdma_db_next_get(fdma);
4ff58c394715ee Daniel Machon 2024-09-02 152 if (unlikely(!fdma_db_is_done(db_hw)))
10615907e9b51c Steen Hegelund 2021-08-19 153 return false;
e8218f7a9f4425 Daniel Machon 2024-09-02 154 skb = rx->skb[fdma->dcb_index][fdma->db_index];
4ff58c394715ee Daniel Machon 2024-09-02 155 skb_put(skb, fdma_db_len_get(db_hw));
10615907e9b51c Steen Hegelund 2021-08-19 156 /* Now do the normal processing of the skb */
aa7dfc6611fae2 Daniel Machon 2024-10-21 157 sparx5_ifh_parse(sparx5, (u32 *)skb->data, &fi);
10615907e9b51c Steen Hegelund 2021-08-19 158 /* Map to port netdev */
3f9e46347a466a Daniel Machon 2024-10-04 159 port = fi.src_port < sparx5->data->consts->n_ports ?
3f9e46347a466a Daniel Machon 2024-10-04 160 sparx5->ports[fi.src_port] :
3f9e46347a466a Daniel Machon 2024-10-04 161 NULL;
10615907e9b51c Steen Hegelund 2021-08-19 162 if (!port || !port->ndev) {
10615907e9b51c Steen Hegelund 2021-08-19 163 dev_err(sparx5->dev, "Data on inactive port %d\n", fi.src_port);
10615907e9b51c Steen Hegelund 2021-08-19 164 sparx5_xtr_flush(sparx5, XTR_QUEUE);
10615907e9b51c Steen Hegelund 2021-08-19 165 return false;
10615907e9b51c Steen Hegelund 2021-08-19 166 }
10615907e9b51c Steen Hegelund 2021-08-19 167 skb->dev = port->ndev;
10615907e9b51c Steen Hegelund 2021-08-19 168 skb_pull(skb, IFH_LEN * sizeof(u32));
10615907e9b51c Steen Hegelund 2021-08-19 169 if (likely(!(skb->dev->features & NETIF_F_RXFCS)))
10615907e9b51c Steen Hegelund 2021-08-19 170 skb_trim(skb, skb->len - ETH_FCS_LEN);
70dfe25cd8666d Horatiu Vultur 2022-03-04 171
70dfe25cd8666d Horatiu Vultur 2022-03-04 172 sparx5_ptp_rxtstamp(sparx5, skb, fi.timestamp);
10615907e9b51c Steen Hegelund 2021-08-19 173 skb->protocol = eth_type_trans(skb, skb->dev);
10615907e9b51c Steen Hegelund 2021-08-19 174 /* Everything we see on an interface that is in the HW bridge
10615907e9b51c Steen Hegelund 2021-08-19 175 * has already been forwarded
10615907e9b51c Steen Hegelund 2021-08-19 176 */
10615907e9b51c Steen Hegelund 2021-08-19 177 if (test_bit(port->portno, sparx5->bridge_mask))
10615907e9b51c Steen Hegelund 2021-08-19 @178 skb->offload_fwd_mark = 1;
10615907e9b51c Steen Hegelund 2021-08-19 179 skb->dev->stats.rx_bytes += skb->len;
10615907e9b51c Steen Hegelund 2021-08-19 180 skb->dev->stats.rx_packets++;
10615907e9b51c Steen Hegelund 2021-08-19 181 rx->packets++;
10615907e9b51c Steen Hegelund 2021-08-19 182 netif_receive_skb(skb);
10615907e9b51c Steen Hegelund 2021-08-19 183 return true;
10615907e9b51c Steen Hegelund 2021-08-19 184 }
10615907e9b51c Steen Hegelund 2021-08-19 185
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 06/15] net: lan969x: add match data for lan969x
2024-10-21 13:58 ` [PATCH net-next 06/15] net: lan969x: add match data for lan969x Daniel Machon
2024-10-23 1:32 ` kernel test robot
2024-10-23 20:53 ` kernel test robot
@ 2024-10-24 15:52 ` kernel test robot
2 siblings, 0 replies; 36+ messages in thread
From: kernel test robot @ 2024-10-24 15:52 UTC (permalink / raw)
To: Daniel Machon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: oe-kbuild-all, netdev, linux-arm-kernel, linux-kernel, devicetree
Hi Daniel,
kernel test robot noticed the following build errors:
[auto build test ERROR on 30d9d8f6a2d7e44a9f91737dd409dbc87ac6f6b7]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Machon/net-sparx5-add-support-for-lan969x-SKU-s-and-core-clock/20241021-220557
base: 30d9d8f6a2d7e44a9f91737dd409dbc87ac6f6b7
patch link: https://lore.kernel.org/r/20241021-sparx5-lan969x-switch-driver-2-v1-6-c8c49ef21e0f%40microchip.com
patch subject: [PATCH net-next 06/15] net: lan969x: add match data for lan969x
config: m68k-randconfig-r121-20241024 (https://download.01.org/0day-ci/archive/20241024/202410242319.ShJiPqSp-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20241024/202410242319.ShJiPqSp-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410242319.ShJiPqSp-lkp@intel.com/
All errors (new ones prefixed by >>):
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_init':
>> sparx5_vcap_impl.c:(.text+0x4632): undefined reference to `vcap_port_debugfs'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_destroy':
>> sparx5_vcap_impl.c:(.text+0x4d24): undefined reference to `vcap_del_rules'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_es2_get_port_ipv4_keysets':
>> sparx5_vcap_impl.c:(.text+0x38): undefined reference to `vcap_keyset_list_add'
>> m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x50): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x68): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x80): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x98): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_ingress_add_default_fields':
>> sparx5_vcap_impl.c:(.text+0x114): undefined reference to `vcap_lookup_keyfield'
>> m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x142): undefined reference to `vcap_rule_add_key_u32'
>> m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x1a6): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x1d2): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x21e): undefined reference to `vcap_rule_add_key_bit'
>> m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x268): undefined reference to `vcap_rule_add_key_u72'
>> m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x288): undefined reference to `vcap_keyset_name'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_add_default_fields':
>> sparx5_vcap_impl.c:(.text+0x31e): undefined reference to `vcap_rule_add_key_u32'
>> m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x358): undefined reference to `vcap_lookup_keyfield'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x368): undefined reference to `vcap_rule_add_key_u32'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x3b6): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0x3d4): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_es0_get_port_keysets.isra.0':
sparx5_vcap_impl.c:(.text+0x704): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_es2_get_port_keysets.isra.0':
sparx5_vcap_impl.c:(.text+0xadc): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0xb3c): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0xb98): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: sparx5_vcap_impl.c:(.text+0xbc2): undefined reference to `vcap_keyset_list_add'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o:sparx5_vcap_impl.c:(.text+0xc42): more undefined references to `vcap_keyset_list_add' follow
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_validate_keyset':
>> sparx5_vcap_impl.c:(.text+0x214e): undefined reference to `vcap_keyset_name'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.o: in function `sparx5_vcap_init':
>> sparx5_vcap_impl.c:(.text+0x464a): undefined reference to `vcap_debugfs'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_select_protocol_keyset':
>> sparx5_tc_flower.c:(.text+0x2b8): undefined reference to `vcap_keyfieldset'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_replace':
>> sparx5_tc_flower.c:(.text+0x1c58): undefined reference to `vcap_rule_add_action_u32'
>> m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1ffc): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_handler_basic_usage':
>> sparx5_tc_flower.c:(.text+0x5a): undefined reference to `vcap_rule_add_key_u32'
>> m68k-linux-ld: sparx5_tc_flower.c:(.text+0xd2): undefined reference to `vcap_rule_add_key_u32'
>> m68k-linux-ld: sparx5_tc_flower.c:(.text+0x11e): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x168): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x190): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1b4): undefined reference to `vcap_rule_add_key_bit'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_select_protocol_keyset':
>> sparx5_tc_flower.c:(.text+0x264): undefined reference to `vcap_rule_find_keysets'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x3ca): undefined reference to `vcap_set_rule_set_keyset'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x402): undefined reference to `vcap_rule_mod_key_u32'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_handler_vlan_usage':
sparx5_tc_flower.c:(.text+0x476): undefined reference to `vcap_tc_flower_handler_vlan_usage'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x4ec): undefined reference to `vcap_rule_add_key_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x50e): undefined reference to `vcap_rule_add_key_u32'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_handler_control_usage':
sparx5_tc_flower.c:(.text+0x5a2): undefined reference to `vcap_rule_add_key_u32'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_handler_cvlan_usage':
sparx5_tc_flower.c:(.text+0x842): undefined reference to `vcap_tc_flower_handler_cvlan_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_destroy.isra.0':
sparx5_tc_flower.c:(.text+0x8a6): undefined reference to `vcap_lookup_rule_by_cookie'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x8c0): undefined reference to `vcap_get_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x8da): undefined reference to `vcap_find_actionfield'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x94c): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x95a): undefined reference to `vcap_del_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xa4a): undefined reference to `vcap_del_rule'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_simplify_rule.isra.0':
sparx5_tc_flower.c:(.text+0xace): undefined reference to `vcap_rule_rem_key'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xb0e): undefined reference to `vcap_rule_rem_key'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xb2a): undefined reference to `vcap_rule_rem_key'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xb68): undefined reference to `vcap_rule_rem_key'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_action_vlan_modify.isra.0':
sparx5_tc_flower.c:(.text+0xbb8): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_add_rule_link.isra.0':
sparx5_tc_flower.c:(.text+0xce2): undefined reference to `vcap_find_admin'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xcfa): undefined reference to `vcap_chain_offset'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xd5a): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xd74): undefined reference to `vcap_rule_add_action_bit'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xd92): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xdc8): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_set_actionset.isra.0':
sparx5_tc_flower.c:(.text+0xe4e): undefined reference to `vcap_set_rule_set_actionset'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_add_rule_counter.isra.0':
sparx5_tc_flower.c:(.text+0xeba): undefined reference to `vcap_rule_mod_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xed2): undefined reference to `vcap_rule_set_counter_id'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xef6): undefined reference to `vcap_rule_mod_action_u32'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_add_rule_copy':
sparx5_tc_flower.c:(.text+0xf64): undefined reference to `vcap_copy_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xf96): undefined reference to `vcap_filter_rule_keys'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xfa2): undefined reference to `vcap_set_rule_set_keyset'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xfc8): undefined reference to `vcap_rule_mod_key_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xfd4): undefined reference to `vcap_set_rule_set_actionset'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0xfe6): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1016): undefined reference to `vcap_val_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1026): undefined reference to `vcap_add_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1054): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x106a): undefined reference to `vcap_keyset_name'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1090): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x10bc): undefined reference to `vcap_set_tc_exterr'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x10c8): undefined reference to `vcap_free_rule'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_action_check.isra.0':
sparx5_tc_flower.c:(.text+0x122c): undefined reference to `vcap_is_last_chain'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x12fc): undefined reference to `vcap_is_next_lookup'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_template_create':
sparx5_tc_flower.c:(.text+0x14f0): undefined reference to `vcap_admin_rule_count'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1570): undefined reference to `vcap_alloc_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x15cc): undefined reference to `vcap_rule_find_keysets'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x15e4): undefined reference to `vcap_select_min_rule_keyset'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1648): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x169c): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1736): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1766): undefined reference to `vcap_free_rule'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower_replace':
sparx5_tc_flower.c:(.text+0x183c): undefined reference to `vcap_alloc_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1890): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x18da): undefined reference to `vcap_rule_add_key_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x18ec): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1990): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x19a8): undefined reference to `vcap_rule_add_key_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1ad8): undefined reference to `vcap_rule_add_action_bit'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1af4): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1b56): undefined reference to `vcap_val_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1b68): undefined reference to `vcap_add_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1bb8): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1bf2): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1cbc): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1cf6): undefined reference to `vcap_rule_add_action_u72'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1ee4): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1f32): undefined reference to `vcap_free_rule'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1f94): undefined reference to `vcap_rule_add_key_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1fcc): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x1fea): undefined reference to `vcap_rule_add_action_bit'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x203c): undefined reference to `vcap_rule_add_action_bit'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x2054): undefined reference to `vcap_rule_add_action_u32'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x2092): undefined reference to `vcap_set_rule_set_keyset'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x2110): undefined reference to `vcap_set_tc_exterr'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x211a): undefined reference to `vcap_free_rule'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o: in function `sparx5_tc_flower':
sparx5_tc_flower.c:(.text+0x224e): undefined reference to `vcap_find_admin'
m68k-linux-ld: sparx5_tc_flower.c:(.text+0x2378): undefined reference to `vcap_get_rule_count_by_cookie'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o:(.rodata+0x986): undefined reference to `vcap_tc_flower_handler_ipv4_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o:(.rodata+0x98a): undefined reference to `vcap_tc_flower_handler_ipv6_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o:(.rodata+0x98e): undefined reference to `vcap_tc_flower_handler_portnum_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o:(.rodata+0x99a): undefined reference to `vcap_tc_flower_handler_ethaddr_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o:(.rodata+0x9a2): undefined reference to `vcap_tc_flower_handler_arp_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o:(.rodata+0x9ce): undefined reference to `vcap_tc_flower_handler_tcp_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.o:(.rodata+0x9d2): undefined reference to `vcap_tc_flower_handler_ip_usage'
m68k-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.o: in function `sparx5_tc_matchall_replace':
sparx5_tc_matchall.c:(.text+0x13e): undefined reference to `vcap_enable_lookups'
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SPARX5_SWITCH
Depends on [n]: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_MICROCHIP [=y] && NET_SWITCHDEV [=y] && HAS_IOMEM [=y] && OF [=n] && (ARCH_SPARX5 || COMPILE_TEST [=y]) && PTP_1588_CLOCK_OPTIONAL [=y] && (BRIDGE [=y] || BRIDGE [=y]=n [=n])
Selected by [y]:
- LAN969X_SWITCH [=y] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_MICROCHIP [=y]
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [y]:
- RESOURCE_KUNIT_TEST [=y] && RUNTIME_TESTING_MENU [=y] && KUNIT [=y]
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH net-next 07/15] net: lan969x: add register diffs to match data
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (5 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 06/15] net: lan969x: add match data for lan969x Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 08/15] net: lan969x: add constants " Daniel Machon
` (7 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Add new file lan969x_regs.c that defines all the register differences
for lan969x, and add it to the lan969x match data.
GW_DEV2G5_PHASE_DETECTOR_CTRL, FP_DEV2G5_PHAD_CTRL_PHAD_ENA and
FP_DEV2G5_PHAD_CTRL_PHAD_FAILED are required by the new register macros
which was introduced earlier. Add these for Sparx5 also.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/lan969x/Makefile | 2 +-
drivers/net/ethernet/microchip/lan969x/lan969x.c | 12 ++
drivers/net/ethernet/microchip/lan969x/lan969x.h | 10 +
.../net/ethernet/microchip/lan969x/lan969x_regs.c | 223 +++++++++++++++++++++
.../net/ethernet/microchip/sparx5/sparx5_regs.c | 5 +-
.../net/ethernet/microchip/sparx5/sparx5_regs.h | 5 +-
6 files changed, 254 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan969x/Makefile b/drivers/net/ethernet/microchip/lan969x/Makefile
index 3755202536e1..41bf66b9fef5 100644
--- a/drivers/net/ethernet/microchip/lan969x/Makefile
+++ b/drivers/net/ethernet/microchip/lan969x/Makefile
@@ -5,7 +5,7 @@
obj-$(CONFIG_LAN969X_SWITCH) += lan969x-switch.o
-lan969x-switch-y := lan969x.o
+lan969x-switch-y := lan969x_regs.o lan969x.o
# Provide include files
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/sparx5
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.c b/drivers/net/ethernet/microchip/lan969x/lan969x.c
index 32f4c1001482..d99c1396e16a 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.c
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.c
@@ -92,10 +92,22 @@ static const struct sparx5_main_io_resource lan969x_main_iomap[] = {
{ TARGET_ASM, 0x3200000, 1 }, /* 0xe3200000 */
};
+static const struct sparx5_regs lan969x_regs = {
+ .tsize = lan969x_tsize,
+ .gaddr = lan969x_gaddr,
+ .gcnt = lan969x_gcnt,
+ .gsize = lan969x_gsize,
+ .raddr = lan969x_raddr,
+ .rcnt = lan969x_rcnt,
+ .fpos = lan969x_fpos,
+ .fsize = lan969x_fsize,
+};
+
const struct sparx5_match_data lan969x_desc = {
.iomap = lan969x_main_iomap,
.iomap_size = ARRAY_SIZE(lan969x_main_iomap),
.ioranges = 2,
+ .regs = &lan969x_regs,
};
MODULE_DESCRIPTION("Microchip lan969x switch driver");
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.h b/drivers/net/ethernet/microchip/lan969x/lan969x.h
index ba6d351f45c8..9059b0dc954c 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.h
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.h
@@ -12,4 +12,14 @@
/* lan969x.c */
extern const struct sparx5_match_data lan969x_desc;
+/* lan969x_regs.c */
+extern const unsigned int lan969x_tsize[TSIZE_LAST];
+extern const unsigned int lan969x_raddr[RADDR_LAST];
+extern const unsigned int lan969x_rcnt[RCNT_LAST];
+extern const unsigned int lan969x_gaddr[GADDR_LAST];
+extern const unsigned int lan969x_gcnt[GCNT_LAST];
+extern const unsigned int lan969x_gsize[GSIZE_LAST];
+extern const unsigned int lan969x_fpos[FPOS_LAST];
+extern const unsigned int lan969x_fsize[FSIZE_LAST];
+
#endif
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x_regs.c b/drivers/net/ethernet/microchip/lan969x/lan969x_regs.c
new file mode 100644
index 000000000000..aacd3c897477
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x_regs.c
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Microchip lan969x Switch driver
+ *
+ * Copyright (c) 2024 Microchip Technology Inc.
+ */
+
+/* This file is autogenerated by cml-utils 2024-09-30 11:48:29 +0200.
+ * Commit ID: 9d07b8d19363f3cd3590ddb3f7a2e2768e16524b
+ */
+
+#include "lan969x.h"
+#include "sparx5_regs.h"
+
+const unsigned int lan969x_tsize[TSIZE_LAST] = {
+ [TC_DEV10G] = 10,
+ [TC_DEV2G5] = 28,
+ [TC_DEV5G] = 4,
+ [TC_PCS10G_BR] = 10,
+ [TC_PCS5G_BR] = 4,
+};
+
+const unsigned int lan969x_raddr[RADDR_LAST] = {
+ [RA_CPU_PROC_CTRL] = 160,
+ [RA_GCB_SOFT_RST] = 12,
+ [RA_GCB_HW_SGPIO_TO_SD_MAP_CFG] = 20,
+};
+
+const unsigned int lan969x_rcnt[RCNT_LAST] = {
+ [RC_ANA_AC_OWN_UPSID] = 1,
+ [RC_ANA_ACL_VCAP_S2_CFG] = 35,
+ [RC_ANA_ACL_OWN_UPSID] = 1,
+ [RC_ANA_CL_OWN_UPSID] = 1,
+ [RC_ANA_L2_OWN_UPSID] = 1,
+ [RC_ASM_PORT_CFG] = 32,
+ [RC_DSM_BUF_CFG] = 32,
+ [RC_DSM_DEV_TX_STOP_WM_CFG] = 32,
+ [RC_DSM_RX_PAUSE_CFG] = 32,
+ [RC_DSM_MAC_CFG] = 32,
+ [RC_DSM_MAC_ADDR_BASE_HIGH_CFG] = 30,
+ [RC_DSM_MAC_ADDR_BASE_LOW_CFG] = 30,
+ [RC_DSM_TAXI_CAL_CFG] = 6,
+ [RC_GCB_HW_SGPIO_TO_SD_MAP_CFG] = 30,
+ [RC_HSCH_PORT_MODE] = 35,
+ [RC_QFWD_SWITCH_PORT_MODE] = 35,
+ [RC_QSYS_PAUSE_CFG] = 35,
+ [RC_QSYS_ATOP] = 35,
+ [RC_QSYS_FWD_PRESSURE] = 35,
+ [RC_QSYS_CAL_AUTO] = 4,
+ [RC_REW_OWN_UPSID] = 1,
+ [RC_REW_RTAG_ETAG_CTRL] = 35,
+};
+
+const unsigned int lan969x_gaddr[GADDR_LAST] = {
+ [GA_ANA_AC_RAM_CTRL] = 202000,
+ [GA_ANA_AC_PS_COMMON] = 202880,
+ [GA_ANA_AC_MIRROR_PROBE] = 203232,
+ [GA_ANA_AC_SRC] = 201728,
+ [GA_ANA_AC_PGID] = 131072,
+ [GA_ANA_AC_TSN_SF] = 202028,
+ [GA_ANA_AC_TSN_SF_CFG] = 148480,
+ [GA_ANA_AC_TSN_SF_STATUS] = 147936,
+ [GA_ANA_AC_SG_ACCESS] = 202032,
+ [GA_ANA_AC_SG_CONFIG] = 202752,
+ [GA_ANA_AC_SG_STATUS] = 147952,
+ [GA_ANA_AC_SG_STATUS_STICKY] = 202044,
+ [GA_ANA_AC_STAT_GLOBAL_CFG_PORT] = 202048,
+ [GA_ANA_AC_STAT_CNT_CFG_PORT] = 204800,
+ [GA_ANA_AC_STAT_GLOBAL_CFG_ACL] = 202068,
+ [GA_ANA_ACL_COMMON] = 8192,
+ [GA_ANA_ACL_KEY_SEL] = 9204,
+ [GA_ANA_ACL_CNT_B] = 4096,
+ [GA_ANA_ACL_STICKY] = 10852,
+ [GA_ANA_AC_POL_POL_ALL_CFG] = 17504,
+ [GA_ANA_AC_POL_COMMON_BDLB] = 19464,
+ [GA_ANA_AC_POL_COMMON_BUM_SLB] = 19472,
+ [GA_ANA_AC_SDLB_LBGRP_TBL] = 31788,
+ [GA_ANA_CL_PORT] = 65536,
+ [GA_ANA_CL_COMMON] = 87040,
+ [GA_ANA_L2_COMMON] = 561928,
+ [GA_ANA_L3_COMMON] = 370752,
+ [GA_ANA_L3_VLAN_ARP_L3MC_STICKY] = 368580,
+ [GA_ASM_CFG] = 18304,
+ [GA_ASM_PFC_TIMER_CFG] = 15568,
+ [GA_ASM_LBK_WM_CFG] = 15596,
+ [GA_ASM_LBK_MISC_CFG] = 15608,
+ [GA_ASM_RAM_CTRL] = 15684,
+ [GA_EACL_ES2_KEY_SELECT_PROFILE] = 36864,
+ [GA_EACL_CNT_TBL] = 30720,
+ [GA_EACL_POL_CFG] = 38400,
+ [GA_EACL_ES2_STICKY] = 29072,
+ [GA_EACL_RAM_CTRL] = 29112,
+ [GA_GCB_SIO_CTRL] = 560,
+ [GA_HSCH_HSCH_DWRR] = 36480,
+ [GA_HSCH_HSCH_MISC] = 36608,
+ [GA_HSCH_HSCH_LEAK_LISTS] = 37256,
+ [GA_HSCH_SYSTEM] = 37384,
+ [GA_HSCH_MMGT] = 36260,
+ [GA_HSCH_TAS_CONFIG] = 37696,
+ [GA_PTP_PTP_CFG] = 512,
+ [GA_PTP_PTP_TOD_DOMAINS] = 528,
+ [GA_PTP_PHASE_DETECTOR_CTRL] = 628,
+ [GA_QSYS_CALCFG] = 2164,
+ [GA_QSYS_RAM_CTRL] = 2204,
+ [GA_REW_COMMON] = 98304,
+ [GA_REW_PORT] = 49152,
+ [GA_REW_VOE_PORT_LM_CNT] = 90112,
+ [GA_REW_RAM_CTRL] = 93992,
+ [GA_VOP_RAM_CTRL] = 16368,
+ [GA_XQS_SYSTEM] = 5744,
+ [GA_XQS_QLIMIT_SHR] = 6912,
+};
+
+const unsigned int lan969x_gcnt[GCNT_LAST] = {
+ [GC_ANA_AC_SRC] = 67,
+ [GC_ANA_AC_PGID] = 1054,
+ [GC_ANA_AC_TSN_SF_CFG] = 256,
+ [GC_ANA_AC_STAT_CNT_CFG_PORT] = 35,
+ [GC_ANA_ACL_KEY_SEL] = 99,
+ [GC_ANA_ACL_CNT_A] = 1024,
+ [GC_ANA_ACL_CNT_B] = 1024,
+ [GC_ANA_AC_SDLB_LBGRP_TBL] = 5,
+ [GC_ANA_AC_SDLB_LBSET_TBL] = 496,
+ [GC_ANA_CL_PORT] = 35,
+ [GC_ANA_L2_ISDX_LIMIT] = 256,
+ [GC_ANA_L2_ISDX] = 1024,
+ [GC_ANA_L3_VLAN] = 4608,
+ [GC_ASM_DEV_STATISTICS] = 30,
+ [GC_EACL_ES2_KEY_SELECT_PROFILE] = 68,
+ [GC_EACL_CNT_TBL] = 512,
+ [GC_GCB_SIO_CTRL] = 1,
+ [GC_HSCH_HSCH_CFG] = 1120,
+ [GC_HSCH_HSCH_DWRR] = 32,
+ [GC_PTP_PTP_PINS] = 8,
+ [GC_PTP_PHASE_DETECTOR_CTRL] = 8,
+ [GC_REW_PORT] = 35,
+ [GC_REW_VOE_PORT_LM_CNT] = 240,
+};
+
+const unsigned int lan969x_gsize[GSIZE_LAST] = {
+ [GW_ANA_AC_SRC] = 4,
+ [GW_ANA_L2_COMMON] = 712,
+ [GW_ASM_CFG] = 1092,
+ [GW_CPU_CPU_REGS] = 180,
+ [GW_DEV2G5_PHASE_DETECTOR_CTRL] = 12,
+ [GW_FDMA_FDMA] = 448,
+ [GW_GCB_CHIP_REGS] = 180,
+ [GW_HSCH_TAS_CONFIG] = 16,
+ [GW_PTP_PHASE_DETECTOR_CTRL] = 12,
+ [GW_QSYS_PAUSE_CFG] = 988,
+};
+
+const unsigned int lan969x_fpos[FPOS_LAST] = {
+ [FP_CPU_PROC_CTRL_AARCH64_MODE_ENA] = 7,
+ [FP_CPU_PROC_CTRL_L2_RST_INVALIDATE_DIS] = 6,
+ [FP_CPU_PROC_CTRL_L1_RST_INVALIDATE_DIS] = 5,
+ [FP_CPU_PROC_CTRL_BE_EXCEP_MODE] = 4,
+ [FP_CPU_PROC_CTRL_VINITHI] = 3,
+ [FP_CPU_PROC_CTRL_CFGTE] = 2,
+ [FP_CPU_PROC_CTRL_CP15S_DISABLE] = 1,
+ [FP_CPU_PROC_CTRL_PROC_CRYPTO_DISABLE] = 0,
+ [FP_CPU_PROC_CTRL_L2_FLUSH_REQ] = 8,
+ [FP_DEV2G5_PHAD_CTRL_PHAD_ENA] = 5,
+ [FP_DEV2G5_PHAD_CTRL_PHAD_FAILED] = 3,
+ [FP_FDMA_CH_CFG_CH_XTR_STATUS_MODE] = 5,
+ [FP_FDMA_CH_CFG_CH_INTR_DB_EOF_ONLY] = 4,
+ [FP_FDMA_CH_CFG_CH_INJ_PORT] = 3,
+ [FP_PTP_PTP_PIN_CFG_PTP_PIN_ACTION] = 27,
+ [FP_PTP_PTP_PIN_CFG_PTP_PIN_SYNC] = 25,
+ [FP_PTP_PTP_PIN_CFG_PTP_PIN_INV_POL] = 24,
+ [FP_PTP_PHAD_CTRL_PHAD_ENA] = 5,
+ [FP_PTP_PHAD_CTRL_PHAD_FAILED] = 3,
+};
+
+const unsigned int lan969x_fsize[FSIZE_LAST] = {
+ [FW_ANA_AC_PROBE_PORT_CFG_PROBE_PORT_MASK] = 30,
+ [FW_ANA_AC_SRC_CFG_PORT_MASK] = 30,
+ [FW_ANA_AC_PGID_CFG_PORT_MASK] = 30,
+ [FW_ANA_AC_TSN_SF_PORT_NUM] = 7,
+ [FW_ANA_AC_TSN_SF_CFG_TSN_SGID] = 8,
+ [FW_ANA_AC_TSN_SF_STATUS_TSN_SFID] = 8,
+ [FW_ANA_AC_SG_ACCESS_CTRL_SGID] = 8,
+ [FW_ANA_AC_PORT_SGE_CFG_MASK] = 17,
+ [FW_ANA_AC_SDLB_XLB_START_LBSET_START] = 9,
+ [FW_ANA_AC_SDLB_LBGRP_MISC_THRES_SHIFT] = 3,
+ [FW_ANA_AC_SDLB_LBGRP_STATE_TBL_PUP_LBSET_NEXT] = 9,
+ [FW_ANA_AC_SDLB_XLB_NEXT_LBSET_NEXT] = 9,
+ [FW_ANA_AC_SDLB_XLB_NEXT_LBGRP] = 3,
+ [FW_ANA_AC_SDLB_INH_LBSET_ADDR_INH_LBSET_ADDR] = 9,
+ [FW_ANA_L2_AUTO_LRN_CFG_AUTO_LRN_ENA] = 30,
+ [FW_ANA_L2_DLB_CFG_DLB_IDX] = 9,
+ [FW_ANA_L2_TSN_CFG_TSN_SFID] = 8,
+ [FW_ANA_L3_VLAN_MASK_CFG_VLAN_PORT_MASK] = 30,
+ [FW_FDMA_CH_CFG_CH_DCB_DB_CNT] = 2,
+ [FW_GCB_HW_SGPIO_TO_SD_MAP_CFG_SGPIO_TO_SD_SEL] = 7,
+ [FW_HSCH_SE_CFG_SE_DWRR_CNT] = 5,
+ [FW_HSCH_SE_CONNECT_SE_LEAK_LINK] = 14,
+ [FW_HSCH_SE_DLB_SENSE_SE_DLB_DPORT] = 6,
+ [FW_HSCH_HSCH_CFG_CFG_CFG_SE_IDX] = 11,
+ [FW_HSCH_HSCH_LEAK_CFG_LEAK_FIRST] = 14,
+ [FW_HSCH_FLUSH_CTRL_FLUSH_PORT] = 6,
+ [FW_HSCH_FLUSH_CTRL_FLUSH_HIER] = 14,
+ [FW_LRN_COMMON_ACCESS_CTRL_CPU_ACCESS_DIRECT_ROW] = 13,
+ [FW_LRN_MAC_ACCESS_CFG_3_MAC_ENTRY_ISDX_LIMIT_IDX] = 8,
+ [FW_LRN_AUTOAGE_CFG_2_NEXT_ROW] = 13,
+ [FW_PTP_PTP_PIN_INTR_INTR_PTP] = 8,
+ [FW_PTP_PTP_PIN_INTR_ENA_INTR_PTP_ENA] = 8,
+ [FW_PTP_PTP_INTR_IDENT_INTR_PTP_IDENT] = 8,
+ [FW_PTP_PTP_PIN_CFG_PTP_PIN_SELECT] = 3,
+ [FW_QFWD_FRAME_COPY_CFG_FRMC_PORT_VAL] = 6,
+ [FW_QRES_RES_CFG_WM_HIGH] = 11,
+ [FW_QRES_RES_STAT_MAXUSE] = 19,
+ [FW_QRES_RES_STAT_CUR_INUSE] = 19,
+ [FW_QSYS_PAUSE_CFG_PAUSE_START] = 11,
+ [FW_QSYS_PAUSE_CFG_PAUSE_STOP] = 11,
+ [FW_QSYS_ATOP_ATOP] = 11,
+ [FW_QSYS_ATOP_TOT_CFG_ATOP_TOT] = 11,
+ [FW_REW_RTAG_ETAG_CTRL_IPE_TBL] = 6,
+ [FW_XQS_STAT_CFG_STAT_VIEW] = 10,
+ [FW_XQS_QLIMIT_SHR_TOP_CFG_QLIMIT_SHR_TOP] = 14,
+ [FW_XQS_QLIMIT_SHR_ATOP_CFG_QLIMIT_SHR_ATOP] = 14,
+ [FW_XQS_QLIMIT_SHR_CTOP_CFG_QLIMIT_SHR_CTOP] = 14,
+ [FW_XQS_QLIMIT_SHR_QLIM_CFG_QLIMIT_SHR_QLIM] = 14,
+};
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_regs.c b/drivers/net/ethernet/microchip/sparx5/sparx5_regs.c
index 1db212ce3df7..220e81b714d4 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_regs.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_regs.c
@@ -4,7 +4,7 @@
* Copyright (c) 2024 Microchip Technology Inc.
*/
-/* This file is autogenerated by cml-utils 2024-09-24 14:02:24 +0200.
+/* This file is autogenerated by cml-utils 2024-09-30 11:48:29 +0200.
* Commit ID: 9d07b8d19363f3cd3590ddb3f7a2e2768e16524b
*/
@@ -140,6 +140,7 @@ const unsigned int sparx5_gsize[GSIZE_LAST] = {
[GW_ANA_L2_COMMON] = 700,
[GW_ASM_CFG] = 1088,
[GW_CPU_CPU_REGS] = 204,
+ [GW_DEV2G5_PHASE_DETECTOR_CTRL] = 8,
[GW_FDMA_FDMA] = 428,
[GW_GCB_CHIP_REGS] = 424,
[GW_HSCH_TAS_CONFIG] = 12,
@@ -157,6 +158,8 @@ const unsigned int sparx5_fpos[FPOS_LAST] = {
[FP_CPU_PROC_CTRL_CP15S_DISABLE] = 6,
[FP_CPU_PROC_CTRL_PROC_CRYPTO_DISABLE] = 5,
[FP_CPU_PROC_CTRL_L2_FLUSH_REQ] = 1,
+ [FP_DEV2G5_PHAD_CTRL_PHAD_ENA] = 7,
+ [FP_DEV2G5_PHAD_CTRL_PHAD_FAILED] = 6,
[FP_FDMA_CH_CFG_CH_XTR_STATUS_MODE] = 7,
[FP_FDMA_CH_CFG_CH_INTR_DB_EOF_ONLY] = 6,
[FP_FDMA_CH_CFG_CH_INJ_PORT] = 5,
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_regs.h b/drivers/net/ethernet/microchip/sparx5/sparx5_regs.h
index c4e8b581c1f3..ea28130c2341 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_regs.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_regs.h
@@ -4,7 +4,7 @@
* Copyright (c) 2024 Microchip Technology Inc.
*/
-/* This file is autogenerated by cml-utils 2024-09-24 14:02:24 +0200.
+/* This file is autogenerated by cml-utils 2024-09-30 11:48:29 +0200.
* Commit ID: 9d07b8d19363f3cd3590ddb3f7a2e2768e16524b
*/
@@ -151,6 +151,7 @@ enum sparx5_gsize_enum {
GW_ANA_L2_COMMON,
GW_ASM_CFG,
GW_CPU_CPU_REGS,
+ GW_DEV2G5_PHASE_DETECTOR_CTRL,
GW_FDMA_FDMA,
GW_GCB_CHIP_REGS,
GW_HSCH_TAS_CONFIG,
@@ -169,6 +170,8 @@ enum sparx5_fpos_enum {
FP_CPU_PROC_CTRL_CP15S_DISABLE,
FP_CPU_PROC_CTRL_PROC_CRYPTO_DISABLE,
FP_CPU_PROC_CTRL_L2_FLUSH_REQ,
+ FP_DEV2G5_PHAD_CTRL_PHAD_ENA,
+ FP_DEV2G5_PHAD_CTRL_PHAD_FAILED,
FP_FDMA_CH_CFG_CH_XTR_STATUS_MODE,
FP_FDMA_CH_CFG_CH_INTR_DB_EOF_ONLY,
FP_FDMA_CH_CFG_CH_INJ_PORT,
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH net-next 08/15] net: lan969x: add constants to match data
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (6 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 07/15] net: lan969x: add register diffs to match data Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 09/15] net: lan969x: add lan969x ops " Daniel Machon
` (6 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Add the lan969x constants to match data. These are already used
throughout the Sparx5 code (introduced in earlier series [1]), so no
need to update any code use.
[1] https://lore.kernel.org/netdev/20241004-b4-sparx5-lan969x-switch-driver-v2-0-d3290f581663@microchip.com/
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/lan969x/lan969x.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.c b/drivers/net/ethernet/microchip/lan969x/lan969x.c
index d99c1396e16a..0671347e2258 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.c
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.c
@@ -103,11 +103,32 @@ static const struct sparx5_regs lan969x_regs = {
.fsize = lan969x_fsize,
};
+static const struct sparx5_consts lan969x_consts = {
+ .n_ports = 30,
+ .n_ports_all = 35,
+ .n_hsch_l1_elems = 32,
+ .n_hsch_queues = 4,
+ .n_lb_groups = 5,
+ .n_pgids = 1054, /* (1024 + n_ports) */
+ .n_sio_clks = 1,
+ .n_own_upsids = 1,
+ .n_auto_cals = 4,
+ .n_filters = 256,
+ .n_gates = 256,
+ .n_sdlbs = 496,
+ .n_dsm_cal_taxis = 5,
+ .buf_size = 1572864,
+ .qres_max_prio_idx = 315,
+ .qres_max_colour_idx = 323,
+ .tod_pin = 4,
+};
+
const struct sparx5_match_data lan969x_desc = {
.iomap = lan969x_main_iomap,
.iomap_size = ARRAY_SIZE(lan969x_main_iomap),
.ioranges = 2,
.regs = &lan969x_regs,
+ .consts = &lan969x_consts,
};
MODULE_DESCRIPTION("Microchip lan969x switch driver");
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH net-next 09/15] net: lan969x: add lan969x ops to match data
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (7 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 08/15] net: lan969x: add constants " Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 10/15] net: lan969x: add PTP handler function Daniel Machon
` (5 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Add a bunch of small lan969x ops in bulk. These ops are explained in
detail in a previous series [1].
[1] https://lore.kernel.org/netdev/20241004-b4-sparx5-lan969x-switch-driver-v2-8-d3290f581663@microchip.com/
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/lan969x/lan969x.c | 122 +++++++++++++++++++++++
drivers/net/ethernet/microchip/lan969x/lan969x.h | 28 ++++++
2 files changed, 150 insertions(+)
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.c b/drivers/net/ethernet/microchip/lan969x/lan969x.c
index 0671347e2258..c92f04647f12 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.c
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.c
@@ -6,6 +6,9 @@
#include "lan969x.h"
+#define LAN969X_SDLB_GRP_CNT 5
+#define LAN969X_HSCH_LEAK_GRP_CNT 4
+
static const struct sparx5_main_io_resource lan969x_main_iomap[] = {
{ TARGET_CPU, 0xc0000, 0 }, /* 0xe00c0000 */
{ TARGET_FDMA, 0xc0400, 0 }, /* 0xe00c0400 */
@@ -92,6 +95,112 @@ static const struct sparx5_main_io_resource lan969x_main_iomap[] = {
{ TARGET_ASM, 0x3200000, 1 }, /* 0xe3200000 */
};
+static struct sparx5_sdlb_group lan969x_sdlb_groups[LAN969X_SDLB_GRP_CNT] = {
+ { 1000000000, 8192 / 2, 64 }, /* 1 G */
+ { 500000000, 8192 / 2, 64 }, /* 500 M */
+ { 100000000, 8192 / 4, 64 }, /* 100 M */
+ { 50000000, 8192 / 4, 64 }, /* 50 M */
+ { 5000000, 8192 / 8, 64 }, /* 10 M */
+};
+
+static u32 lan969x_hsch_max_group_rate[LAN969X_HSCH_LEAK_GRP_CNT] = {
+ 655355, 1048568, 6553550, 10485680
+};
+
+static struct sparx5_sdlb_group *lan969x_get_sdlb_group(int idx)
+{
+ return &lan969x_sdlb_groups[idx];
+}
+
+static u32 lan969x_get_hsch_max_group_rate(int grp)
+{
+ return lan969x_hsch_max_group_rate[grp];
+}
+
+static u32 lan969x_get_dev_mode_bit(struct sparx5 *sparx5, int port)
+{
+ if (lan969x_port_is_2g5(port) || lan969x_port_is_5g(port))
+ return port;
+
+ /* 10G */
+ switch (port) {
+ case 0:
+ return 12;
+ case 4:
+ return 13;
+ case 8:
+ return 14;
+ case 12:
+ return 0;
+ default:
+ return port;
+ }
+}
+
+static u32 lan969x_port_dev_mapping(struct sparx5 *sparx5, int port)
+{
+ if (lan969x_port_is_5g(port)) {
+ switch (port) {
+ case 9:
+ return 0;
+ case 13:
+ return 1;
+ case 17:
+ return 2;
+ case 21:
+ return 3;
+ }
+ }
+
+ if (lan969x_port_is_10g(port)) {
+ switch (port) {
+ case 0:
+ return 0;
+ case 4:
+ return 1;
+ case 8:
+ return 2;
+ case 12:
+ return 3;
+ case 16:
+ return 4;
+ case 20:
+ return 5;
+ case 24:
+ return 6;
+ case 25:
+ return 7;
+ case 26:
+ return 8;
+ case 27:
+ return 9;
+ }
+ }
+
+ /* 2g5 port */
+ return port;
+}
+
+static int lan969x_port_mux_set(struct sparx5 *sparx5, struct sparx5_port *port,
+ struct sparx5_port_config *conf)
+{
+ u32 portno = port->portno;
+ u32 inst;
+
+ if (port->conf.portmode == conf->portmode)
+ return 0; /* Nothing to do */
+
+ switch (conf->portmode) {
+ case PHY_INTERFACE_MODE_QSGMII: /* QSGMII: 4x2G5 devices. Mode Q' */
+ inst = (portno - portno % 4) / 4;
+ spx5_rmw(BIT(inst), BIT(inst), sparx5, PORT_CONF_QSGMII_ENA);
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
static const struct sparx5_regs lan969x_regs = {
.tsize = lan969x_tsize,
.gaddr = lan969x_gaddr,
@@ -123,12 +232,25 @@ static const struct sparx5_consts lan969x_consts = {
.tod_pin = 4,
};
+static const struct sparx5_ops lan969x_ops = {
+ .is_port_2g5 = &lan969x_port_is_2g5,
+ .is_port_5g = &lan969x_port_is_5g,
+ .is_port_10g = &lan969x_port_is_10g,
+ .is_port_25g = &lan969x_port_is_25g,
+ .get_port_dev_index = &lan969x_port_dev_mapping,
+ .get_port_dev_bit = &lan969x_get_dev_mode_bit,
+ .get_hsch_max_group_rate = &lan969x_get_hsch_max_group_rate,
+ .get_sdlb_group = &lan969x_get_sdlb_group,
+ .set_port_mux = &lan969x_port_mux_set,
+};
+
const struct sparx5_match_data lan969x_desc = {
.iomap = lan969x_main_iomap,
.iomap_size = ARRAY_SIZE(lan969x_main_iomap),
.ioranges = 2,
.regs = &lan969x_regs,
.consts = &lan969x_consts,
+ .ops = &lan969x_ops,
};
MODULE_DESCRIPTION("Microchip lan969x switch driver");
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.h b/drivers/net/ethernet/microchip/lan969x/lan969x.h
index 9059b0dc954c..36a19de7faa2 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.h
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.h
@@ -22,4 +22,32 @@ extern const unsigned int lan969x_gsize[GSIZE_LAST];
extern const unsigned int lan969x_fpos[FPOS_LAST];
extern const unsigned int lan969x_fsize[FSIZE_LAST];
+static inline bool lan969x_port_is_2g5(int portno)
+{
+ return portno == 1 || portno == 2 || portno == 3 ||
+ portno == 5 || portno == 6 || portno == 7 ||
+ portno == 10 || portno == 11 || portno == 14 ||
+ portno == 15 || portno == 18 || portno == 19 ||
+ portno == 22 || portno == 23;
+}
+
+static inline bool lan969x_port_is_5g(int portno)
+{
+ return portno == 9 || portno == 13 || portno == 17 ||
+ portno == 21;
+}
+
+static inline bool lan969x_port_is_10g(int portno)
+{
+ return portno == 0 || portno == 4 || portno == 8 ||
+ portno == 12 || portno == 16 || portno == 20 ||
+ portno == 24 || portno == 25 || portno == 26 ||
+ portno == 27;
+}
+
+static inline bool lan969x_port_is_25g(int portno)
+{
+ return false;
+}
+
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH net-next 10/15] net: lan969x: add PTP handler function
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (8 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 09/15] net: lan969x: add lan969x ops " Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 17:46 ` Maxime Chevallier
2024-10-21 13:58 ` [PATCH net-next 11/15] net: lan969x: add function for calculating the DSM calendar Daniel Machon
` (4 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Add PTP IRQ handler for lan969x. This is required, as the PTP registers
are placed in two different targets on Sparx5 and lan969x. The
implementation is otherwise the same as on Sparx5.
Also, expose sparx5_get_hwtimestamp() for use by lan969x.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/lan969x/lan969x.c | 90 ++++++++++++++++++++++
.../net/ethernet/microchip/sparx5/sparx5_main.h | 5 ++
drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 7 +-
3 files changed, 99 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.c b/drivers/net/ethernet/microchip/lan969x/lan969x.c
index c92f04647f12..692b81e829ef 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.c
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.c
@@ -201,6 +201,95 @@ static int lan969x_port_mux_set(struct sparx5 *sparx5, struct sparx5_port *port,
return 0;
}
+static irqreturn_t lan969x_ptp_irq_handler(int irq, void *args)
+{
+ int budget = SPARX5_MAX_PTP_ID;
+ struct sparx5 *sparx5 = args;
+
+ while (budget--) {
+ struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
+ struct skb_shared_hwtstamps shhwtstamps;
+ struct sparx5_port *port;
+ struct timespec64 ts;
+ unsigned long flags;
+ u32 val, id, txport;
+ u32 delay;
+
+ val = spx5_rd(sparx5, PTP_PTP_TWOSTEP_CTRL);
+
+ /* Check if a timestamp can be retrieved */
+ if (!(val & PTP_PTP_TWOSTEP_CTRL_PTP_VLD))
+ break;
+
+ WARN_ON(val & PTP_PTP_TWOSTEP_CTRL_PTP_OVFL);
+
+ if (!(val & PTP_PTP_TWOSTEP_CTRL_STAMP_TX))
+ continue;
+
+ /* Retrieve the ts Tx port */
+ txport = PTP_PTP_TWOSTEP_CTRL_STAMP_PORT_GET(val);
+
+ /* Retrieve its associated skb */
+ port = sparx5->ports[txport];
+
+ /* Retrieve the delay */
+ delay = spx5_rd(sparx5, PTP_PTP_TWOSTEP_STAMP_NSEC);
+ delay = PTP_PTP_TWOSTEP_STAMP_NSEC_STAMP_NSEC_GET(delay);
+
+ /* Get next timestamp from fifo, which needs to be the
+ * rx timestamp which represents the id of the frame
+ */
+ spx5_rmw(PTP_PTP_TWOSTEP_CTRL_PTP_NXT_SET(1),
+ PTP_PTP_TWOSTEP_CTRL_PTP_NXT,
+ sparx5, PTP_PTP_TWOSTEP_CTRL);
+
+ val = spx5_rd(sparx5, PTP_PTP_TWOSTEP_CTRL);
+
+ /* Check if a timestamp can be retrieved */
+ if (!(val & PTP_PTP_TWOSTEP_CTRL_PTP_VLD))
+ break;
+
+ /* Read RX timestamping to get the ID */
+ id = spx5_rd(sparx5, PTP_PTP_TWOSTEP_STAMP_NSEC);
+ id <<= 8;
+ id |= spx5_rd(sparx5, PTP_PTP_TWOSTEP_STAMP_SUBNS);
+
+ spin_lock_irqsave(&port->tx_skbs.lock, flags);
+ skb_queue_walk_safe(&port->tx_skbs, skb, skb_tmp) {
+ if (SPARX5_SKB_CB(skb)->ts_id != id)
+ continue;
+
+ __skb_unlink(skb, &port->tx_skbs);
+ skb_match = skb;
+ break;
+ }
+ spin_unlock_irqrestore(&port->tx_skbs.lock, flags);
+
+ /* Next ts */
+ spx5_rmw(PTP_PTP_TWOSTEP_CTRL_PTP_NXT_SET(1),
+ PTP_PTP_TWOSTEP_CTRL_PTP_NXT,
+ sparx5, PTP_PTP_TWOSTEP_CTRL);
+
+ if (WARN_ON(!skb_match))
+ continue;
+
+ spin_lock(&sparx5->ptp_ts_id_lock);
+ sparx5->ptp_skbs--;
+ spin_unlock(&sparx5->ptp_ts_id_lock);
+
+ /* Get the h/w timestamp */
+ sparx5_get_hwtimestamp(sparx5, &ts, delay);
+
+ /* Set the timestamp in the skb */
+ shhwtstamps.hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
+ skb_tstamp_tx(skb_match, &shhwtstamps);
+
+ dev_kfree_skb_any(skb_match);
+ }
+
+ return IRQ_HANDLED;
+}
+
static const struct sparx5_regs lan969x_regs = {
.tsize = lan969x_tsize,
.gaddr = lan969x_gaddr,
@@ -242,6 +331,7 @@ static const struct sparx5_ops lan969x_ops = {
.get_hsch_max_group_rate = &lan969x_get_hsch_max_group_rate,
.get_sdlb_group = &lan969x_get_sdlb_group,
.set_port_mux = &lan969x_port_mux_set,
+ .ptp_irq_handler = &lan969x_ptp_irq_handler,
};
const struct sparx5_match_data lan969x_desc = {
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index 15f5d38776c4..3f66045c57ef 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -114,6 +114,8 @@ enum sparx5_vlan_port_type {
#define SPX5_DSM_CAL_LEN 64
#define SPX5_DSM_CAL_MAX_DEVS_PER_TAXI 13
+#define SPARX5_MAX_PTP_ID 512
+
struct sparx5;
struct sparx5_calendar_data {
@@ -499,6 +501,9 @@ void sparx5_ptp_txtstamp_release(struct sparx5_port *port,
struct sk_buff *skb);
irqreturn_t sparx5_ptp_irq_handler(int irq, void *args);
int sparx5_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
+void sparx5_get_hwtimestamp(struct sparx5 *sparx5,
+ struct timespec64 *ts,
+ u32 nsec);
/* sparx5_vcap_impl.c */
int sparx5_vcap_init(struct sparx5 *sparx5);
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
index a511f14312f1..9568e21e1c0e 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
@@ -275,9 +275,9 @@ void sparx5_ptp_txtstamp_release(struct sparx5_port *port,
spin_unlock_irqrestore(&sparx5->ptp_ts_id_lock, flags);
}
-static void sparx5_get_hwtimestamp(struct sparx5 *sparx5,
- struct timespec64 *ts,
- u32 nsec)
+void sparx5_get_hwtimestamp(struct sparx5 *sparx5,
+ struct timespec64 *ts,
+ u32 nsec)
{
/* Read current PTP time to get seconds */
const struct sparx5_consts *consts = sparx5->data->consts;
@@ -305,6 +305,7 @@ static void sparx5_get_hwtimestamp(struct sparx5 *sparx5,
spin_unlock_irqrestore(&sparx5->ptp_clock_lock, flags);
}
+EXPORT_SYMBOL_GPL(sparx5_get_hwtimestamp);
irqreturn_t sparx5_ptp_irq_handler(int irq, void *args)
{
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH net-next 10/15] net: lan969x: add PTP handler function
2024-10-21 13:58 ` [PATCH net-next 10/15] net: lan969x: add PTP handler function Daniel Machon
@ 2024-10-21 17:46 ` Maxime Chevallier
2024-10-21 19:12 ` Daniel Machon
0 siblings, 1 reply; 36+ messages in thread
From: Maxime Chevallier @ 2024-10-21 17:46 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, netdev, linux-arm-kernel,
linux-kernel, devicetree
Hi Daniel,
On Mon, 21 Oct 2024 15:58:47 +0200
Daniel Machon <daniel.machon@microchip.com> wrote:
> Add PTP IRQ handler for lan969x. This is required, as the PTP registers
> are placed in two different targets on Sparx5 and lan969x. The
> implementation is otherwise the same as on Sparx5.
>
> Also, expose sparx5_get_hwtimestamp() for use by lan969x.
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
[...]
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
> index 15f5d38776c4..3f66045c57ef 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
> @@ -114,6 +114,8 @@ enum sparx5_vlan_port_type {
> #define SPX5_DSM_CAL_LEN 64
> #define SPX5_DSM_CAL_MAX_DEVS_PER_TAXI 13
>
> +#define SPARX5_MAX_PTP_ID 512
> +
Sorry if I somehow missed it, but if you define SPARX5_MAX_PTP_ID here,
you probably don't need it to be also defined in sparx5_ptp.c as well ?
Thanks,
Maxime
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 10/15] net: lan969x: add PTP handler function
2024-10-21 17:46 ` Maxime Chevallier
@ 2024-10-21 19:12 ` Daniel Machon
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 19:12 UTC (permalink / raw)
To: Maxime Chevallier
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, netdev, linux-arm-kernel,
linux-kernel, devicetree
Hi Maxime,
> Hi Daniel,
>
> On Mon, 21 Oct 2024 15:58:47 +0200
> Daniel Machon <daniel.machon@microchip.com> wrote:
>
> > Add PTP IRQ handler for lan969x. This is required, as the PTP registers
> > are placed in two different targets on Sparx5 and lan969x. The
> > implementation is otherwise the same as on Sparx5.
> >
> > Also, expose sparx5_get_hwtimestamp() for use by lan969x.
> >
> > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> > Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
>
> [...]
>
> > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
> > index 15f5d38776c4..3f66045c57ef 100644
> > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
> > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
> > @@ -114,6 +114,8 @@ enum sparx5_vlan_port_type {
> > #define SPX5_DSM_CAL_LEN 64
> > #define SPX5_DSM_CAL_MAX_DEVS_PER_TAXI 13
> >
> > +#define SPARX5_MAX_PTP_ID 512
> > +
>
> Sorry if I somehow missed it, but if you define SPARX5_MAX_PTP_ID here,
> you probably don't need it to be also defined in sparx5_ptp.c as well ?
>
> Thanks,
>
> Maxime
You are right. It should definitely be removed from sparx5_ptp.c
Will fix it in v2. Thanks!
/Daniel
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH net-next 11/15] net: lan969x: add function for calculating the DSM calendar
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (9 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 10/15] net: lan969x: add PTP handler function Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 17:51 ` Maxime Chevallier
2024-10-21 13:58 ` [PATCH net-next 12/15] net: sparx5: use is_sparx5() macro throughout Daniel Machon
` (3 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Lan969x has support for RedBox / HSR / PRP (not implemented yet). In
order to accommodate for this in the future, we need to give lan969x it's
own function for calculating the DSM calendar.
The function calculates the calendar for each taxi bus. The calendar is
used for bandwidth allocation towards the ports attached to the taxi
bus. A calendar configuration consists of up-to 64 slots, which may be
allocated to ports or left unused. Each slot accounts for 1 clock cycle.
Also expose sparx5_cal_speed_to_value(), sparx5_get_port_cal_speed,
sparx5_cal_bw and SPX5_DSM_CAL_EMPTY for use by lan969x.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/lan969x/Makefile | 2 +-
drivers/net/ethernet/microchip/lan969x/lan969x.c | 1 +
drivers/net/ethernet/microchip/lan969x/lan969x.h | 3 +
.../ethernet/microchip/lan969x/lan969x_calendar.c | 190 +++++++++++++++++++++
.../ethernet/microchip/sparx5/sparx5_calendar.c | 20 +--
.../net/ethernet/microchip/sparx5/sparx5_main.h | 15 ++
6 files changed, 214 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan969x/Makefile b/drivers/net/ethernet/microchip/lan969x/Makefile
index 41bf66b9fef5..56ba96388483 100644
--- a/drivers/net/ethernet/microchip/lan969x/Makefile
+++ b/drivers/net/ethernet/microchip/lan969x/Makefile
@@ -5,7 +5,7 @@
obj-$(CONFIG_LAN969X_SWITCH) += lan969x-switch.o
-lan969x-switch-y := lan969x_regs.o lan969x.o
+lan969x-switch-y := lan969x_regs.o lan969x.o lan969x_calendar.o
# Provide include files
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/sparx5
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.c b/drivers/net/ethernet/microchip/lan969x/lan969x.c
index 692b81e829ef..bd0725393e2b 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.c
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.c
@@ -332,6 +332,7 @@ static const struct sparx5_ops lan969x_ops = {
.get_sdlb_group = &lan969x_get_sdlb_group,
.set_port_mux = &lan969x_port_mux_set,
.ptp_irq_handler = &lan969x_ptp_irq_handler,
+ .dsm_calendar_calc = &lan969x_dsm_calendar_calc,
};
const struct sparx5_match_data lan969x_desc = {
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x.h b/drivers/net/ethernet/microchip/lan969x/lan969x.h
index 36a19de7faa2..e2b1b474e908 100644
--- a/drivers/net/ethernet/microchip/lan969x/lan969x.h
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x.h
@@ -50,4 +50,7 @@ static inline bool lan969x_port_is_25g(int portno)
return false;
}
+/* lan969x_calendar.c */
+int lan969x_dsm_calendar_calc(struct sparx5 *sparx5, u32 taxi,
+ struct sparx5_calendar_data *data);
#endif
diff --git a/drivers/net/ethernet/microchip/lan969x/lan969x_calendar.c b/drivers/net/ethernet/microchip/lan969x/lan969x_calendar.c
new file mode 100644
index 000000000000..96d552c788f6
--- /dev/null
+++ b/drivers/net/ethernet/microchip/lan969x/lan969x_calendar.c
@@ -0,0 +1,190 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Microchip lan969x Switch driver
+ *
+ * Copyright (c) 2024 Microchip Technology Inc. and its subsidiaries.
+ */
+
+#include "lan969x.h"
+
+#define LAN969X_DSM_CAL_DEVS_PER_TAXI 10
+#define LAN969X_DSM_CAL_TAXIS 5
+
+enum lan969x_dsm_cal_dev {
+ DSM_CAL_DEV_2G5,
+ DSM_CAL_DEV_5G,
+ DSM_CAL_DEV_10G,
+ DSM_CAL_DEV_OTHER, /* 1G or less */
+ DSM_CAL_DEV_MAX
+};
+
+/* Each entry in the following struct defines properties for a given speed
+ * (10G, 5G, 2.5G, or 1G or less).
+ */
+struct lan969x_dsm_cal_dev_speed {
+ /* Number of devices that requires this speed. */
+ u32 n_devs;
+
+ /* Array of devices that requires this speed. */
+ u32 devs[LAN969X_DSM_CAL_DEVS_PER_TAXI];
+
+ /* Number of slots required for one device running this speed. */
+ u32 n_slots;
+
+ /* Gap between two slots for one device running this speed. */
+ u32 gap;
+};
+
+static u32
+lan969x_taxi_ports[LAN969X_DSM_CAL_TAXIS][LAN969X_DSM_CAL_DEVS_PER_TAXI] = {
+ { 0, 4, 1, 2, 3, 5, 6, 7, 28, 29 },
+ { 8, 12, 9, 13, 10, 11, 14, 15, 99, 99 },
+ { 16, 20, 17, 21, 18, 19, 22, 23, 99, 99 },
+ { 24, 25, 99, 99, 99, 99, 99, 99, 99, 99 },
+ { 26, 27, 99, 99, 99, 99, 99, 99, 99, 99 }
+};
+
+static int lan969x_dsm_cal_idx_find_next_free(u32 *calendar, u32 cal_len,
+ u32 *cal_idx)
+{
+ if (*cal_idx >= cal_len)
+ return -EINVAL;
+
+ do {
+ if (calendar[*cal_idx] == SPX5_DSM_CAL_EMPTY)
+ return 0;
+
+ (*cal_idx)++;
+ } while (*cal_idx < cal_len);
+
+ return -ENOENT;
+}
+
+static enum lan969x_dsm_cal_dev lan969x_dsm_cal_get_dev(int speed)
+{
+ return (speed == 10000 ? DSM_CAL_DEV_10G :
+ speed == 5000 ? DSM_CAL_DEV_5G :
+ speed == 2500 ? DSM_CAL_DEV_2G5 :
+ DSM_CAL_DEV_OTHER);
+}
+
+static int lan969x_dsm_cal_get_speed(enum lan969x_dsm_cal_dev dev)
+{
+ return (dev == DSM_CAL_DEV_10G ? 10000 :
+ dev == DSM_CAL_DEV_5G ? 5000 :
+ dev == DSM_CAL_DEV_2G5 ? 2500 :
+ 1000);
+}
+
+int lan969x_dsm_calendar_calc(struct sparx5 *sparx5, u32 taxi,
+ struct sparx5_calendar_data *data)
+{
+ struct lan969x_dsm_cal_dev_speed dev_speeds[DSM_CAL_DEV_MAX] = {};
+ u32 cal_len, n_slots, taxi_bw, n_devs = 0, required_bw = 0;
+ struct lan969x_dsm_cal_dev_speed *speed;
+
+ /* Maximum bandwidth for this taxi */
+ taxi_bw = (128 * 1000000) / sparx5_clk_period(sparx5->coreclock);
+
+ memcpy(data->taxi_ports, &lan969x_taxi_ports[taxi],
+ LAN969X_DSM_CAL_DEVS_PER_TAXI * sizeof(u32));
+
+ for (int i = 0; i < LAN969X_DSM_CAL_DEVS_PER_TAXI; i++) {
+ u32 portno = data->taxi_ports[i];
+ enum sparx5_cal_bw bw;
+
+ bw = sparx5_get_port_cal_speed(sparx5, portno);
+
+ if (portno < sparx5->data->consts->n_ports_all)
+ data->taxi_speeds[i] = sparx5_cal_speed_to_value(bw);
+ else
+ data->taxi_speeds[i] = 0;
+ }
+
+ /* Determine the different port types (10G, 5G, 2.5G, <= 1G) in the
+ * this taxi map.
+ */
+ for (int i = 0; i < LAN969X_DSM_CAL_DEVS_PER_TAXI; i++) {
+ u32 taxi_speed = data->taxi_speeds[i];
+ enum lan969x_dsm_cal_dev dev;
+
+ if (taxi_speed == 0)
+ continue;
+
+ required_bw += taxi_speed;
+
+ dev = lan969x_dsm_cal_get_dev(taxi_speed);
+ speed = &dev_speeds[dev];
+ speed->devs[speed->n_devs++] = i;
+ n_devs++;
+ }
+
+ if (required_bw > taxi_bw) {
+ pr_err("Required bandwidth: %u is higher than total taxi bandwidth: %u",
+ required_bw, taxi_bw);
+ return -EINVAL;
+ }
+
+ if (n_devs == 0) {
+ data->schedule[0] = SPX5_DSM_CAL_EMPTY;
+ return 0;
+ }
+
+ cal_len = n_devs;
+
+ /* Search for a calendar length that fits all active devices. */
+ while (cal_len < SPX5_DSM_CAL_LEN) {
+ u32 bw_per_slot = taxi_bw / cal_len;
+
+ n_slots = 0;
+
+ for (int i = 0; i < DSM_CAL_DEV_MAX; i++) {
+ speed = &dev_speeds[i];
+
+ if (speed->n_devs == 0)
+ continue;
+
+ required_bw = lan969x_dsm_cal_get_speed(i);
+ speed->n_slots = DIV_ROUND_UP(required_bw, bw_per_slot);
+
+ if (speed->n_slots)
+ speed->gap = DIV_ROUND_UP(cal_len,
+ speed->n_slots);
+ else
+ speed->gap = 0;
+
+ n_slots += speed->n_slots * speed->n_devs;
+ }
+
+ if (n_slots <= cal_len)
+ break; /* Found a suitable calendar length. */
+
+ /* Not good enough yet. */
+ cal_len = n_slots;
+ }
+
+ if (cal_len > SPX5_DSM_CAL_LEN) {
+ pr_err("Invalid length: %u for taxi: %u", cal_len, taxi);
+ return -EINVAL;
+ }
+
+ for (u32 i = 0; i < SPX5_DSM_CAL_LEN; i++)
+ data->schedule[i] = SPX5_DSM_CAL_EMPTY;
+
+ /* Place the remaining devices */
+ for (u32 i = 0; i < DSM_CAL_DEV_MAX; i++) {
+ speed = &dev_speeds[i];
+ for (u32 dev = 0; dev < speed->n_devs; dev++) {
+ u32 idx = 0;
+
+ for (n_slots = 0; n_slots < speed->n_slots; n_slots++) {
+ lan969x_dsm_cal_idx_find_next_free(data->schedule,
+ cal_len,
+ &idx);
+ data->schedule[idx] = speed->devs[dev];
+ idx += speed->gap;
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
index edc03b6ebf34..64c5ed70cc6b 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
@@ -15,7 +15,6 @@
#define SPX5_CALBITS_PER_PORT 3 /* Bit per port in calendar register */
/* DSM calendar information */
-#define SPX5_DSM_CAL_EMPTY 0xFFFF
#define SPX5_DSM_CAL_TAXIS 8
#define SPX5_DSM_CAL_BW_LOSS 553
@@ -74,18 +73,6 @@ static u32 sparx5_target_bandwidth(struct sparx5 *sparx5)
}
}
-/* This is used in calendar configuration */
-enum sparx5_cal_bw {
- SPX5_CAL_SPEED_NONE = 0,
- SPX5_CAL_SPEED_1G = 1,
- SPX5_CAL_SPEED_2G5 = 2,
- SPX5_CAL_SPEED_5G = 3,
- SPX5_CAL_SPEED_10G = 4,
- SPX5_CAL_SPEED_25G = 5,
- SPX5_CAL_SPEED_0G5 = 6,
- SPX5_CAL_SPEED_12G5 = 7
-};
-
static u32 sparx5_clk_to_bandwidth(enum sparx5_core_clockfreq cclock)
{
switch (cclock) {
@@ -98,7 +85,7 @@ static u32 sparx5_clk_to_bandwidth(enum sparx5_core_clockfreq cclock)
return 0;
}
-static u32 sparx5_cal_speed_to_value(enum sparx5_cal_bw speed)
+u32 sparx5_cal_speed_to_value(enum sparx5_cal_bw speed)
{
switch (speed) {
case SPX5_CAL_SPEED_1G: return 1000;
@@ -111,6 +98,7 @@ static u32 sparx5_cal_speed_to_value(enum sparx5_cal_bw speed)
default: return 0;
}
}
+EXPORT_SYMBOL_GPL(sparx5_cal_speed_to_value);
static u32 sparx5_bandwidth_to_calendar(u32 bw)
{
@@ -128,8 +116,7 @@ static u32 sparx5_bandwidth_to_calendar(u32 bw)
}
}
-static enum sparx5_cal_bw sparx5_get_port_cal_speed(struct sparx5 *sparx5,
- u32 portno)
+enum sparx5_cal_bw sparx5_get_port_cal_speed(struct sparx5 *sparx5, u32 portno)
{
struct sparx5_port *port;
@@ -163,6 +150,7 @@ static enum sparx5_cal_bw sparx5_get_port_cal_speed(struct sparx5 *sparx5,
return SPX5_CAL_SPEED_NONE;
return sparx5_bandwidth_to_calendar(port->conf.bandwidth);
}
+EXPORT_SYMBOL_GPL(sparx5_get_port_cal_speed);
/* Auto configure the QSYS calendar based on port configuration */
int sparx5_config_auto_calendar(struct sparx5 *sparx5)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index 3f66045c57ef..1828e2a7d610 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -63,6 +63,18 @@ enum sparx5_vlan_port_type {
SPX5_VLAN_PORT_TYPE_S_CUSTOM /* S-port using custom type */
};
+/* This is used in calendar configuration */
+enum sparx5_cal_bw {
+ SPX5_CAL_SPEED_NONE = 0,
+ SPX5_CAL_SPEED_1G = 1,
+ SPX5_CAL_SPEED_2G5 = 2,
+ SPX5_CAL_SPEED_5G = 3,
+ SPX5_CAL_SPEED_10G = 4,
+ SPX5_CAL_SPEED_25G = 5,
+ SPX5_CAL_SPEED_0G5 = 6,
+ SPX5_CAL_SPEED_12G5 = 7
+};
+
#define SPX5_PORTS 65
#define SPX5_PORTS_ALL 70 /* Total number of ports */
@@ -113,6 +125,7 @@ enum sparx5_vlan_port_type {
#define SPX5_DSM_CAL_LEN 64
#define SPX5_DSM_CAL_MAX_DEVS_PER_TAXI 13
+#define SPX5_DSM_CAL_EMPTY 0xFFFF
#define SPARX5_MAX_PTP_ID 512
@@ -454,6 +467,8 @@ int sparx5_config_auto_calendar(struct sparx5 *sparx5);
int sparx5_config_dsm_calendar(struct sparx5 *sparx5);
int sparx5_dsm_calendar_calc(struct sparx5 *sparx5, u32 taxi,
struct sparx5_calendar_data *data);
+u32 sparx5_cal_speed_to_value(enum sparx5_cal_bw speed);
+enum sparx5_cal_bw sparx5_get_port_cal_speed(struct sparx5 *sparx5, u32 portno);
/* sparx5_ethtool.c */
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH net-next 11/15] net: lan969x: add function for calculating the DSM calendar
2024-10-21 13:58 ` [PATCH net-next 11/15] net: lan969x: add function for calculating the DSM calendar Daniel Machon
@ 2024-10-21 17:51 ` Maxime Chevallier
2024-10-21 19:13 ` Daniel Machon
0 siblings, 1 reply; 36+ messages in thread
From: Maxime Chevallier @ 2024-10-21 17:51 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, netdev, linux-arm-kernel,
linux-kernel, devicetree
Hi Daniel,
On Mon, 21 Oct 2024 15:58:48 +0200
Daniel Machon <daniel.machon@microchip.com> wrote:
> Lan969x has support for RedBox / HSR / PRP (not implemented yet). In
> order to accommodate for this in the future, we need to give lan969x it's
> own function for calculating the DSM calendar.
>
> The function calculates the calendar for each taxi bus. The calendar is
> used for bandwidth allocation towards the ports attached to the taxi
> bus. A calendar configuration consists of up-to 64 slots, which may be
> allocated to ports or left unused. Each slot accounts for 1 clock cycle.
>
> Also expose sparx5_cal_speed_to_value(), sparx5_get_port_cal_speed,
> sparx5_cal_bw and SPX5_DSM_CAL_EMPTY for use by lan969x.
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
[...]
> + /* Place the remaining devices */
> + for (u32 i = 0; i < DSM_CAL_DEV_MAX; i++) {
> + speed = &dev_speeds[i];
> + for (u32 dev = 0; dev < speed->n_devs; dev++) {
> + u32 idx = 0;
> +
> + for (n_slots = 0; n_slots < speed->n_slots; n_slots++) {
> + lan969x_dsm_cal_idx_find_next_free(data->schedule,
> + cal_len,
> + &idx);
You're not checking the return of lan969x_dsm_cal_idx_find_next_free(),
can this be a problem ?
Thanks,
Maxime
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 11/15] net: lan969x: add function for calculating the DSM calendar
2024-10-21 17:51 ` Maxime Chevallier
@ 2024-10-21 19:13 ` Daniel Machon
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 19:13 UTC (permalink / raw)
To: Maxime Chevallier
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, netdev, linux-arm-kernel,
linux-kernel, devicetree
Hi Maxime,
> Hi Daniel,
>
> On Mon, 21 Oct 2024 15:58:48 +0200
> Daniel Machon <daniel.machon@microchip.com> wrote:
>
> > Lan969x has support for RedBox / HSR / PRP (not implemented yet). In
> > order to accommodate for this in the future, we need to give lan969x it's
> > own function for calculating the DSM calendar.
> >
> > The function calculates the calendar for each taxi bus. The calendar is
> > used for bandwidth allocation towards the ports attached to the taxi
> > bus. A calendar configuration consists of up-to 64 slots, which may be
> > allocated to ports or left unused. Each slot accounts for 1 clock cycle.
> >
> > Also expose sparx5_cal_speed_to_value(), sparx5_get_port_cal_speed,
> > sparx5_cal_bw and SPX5_DSM_CAL_EMPTY for use by lan969x.
> >
> > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> > Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
>
> [...]
>
> > + /* Place the remaining devices */
> > + for (u32 i = 0; i < DSM_CAL_DEV_MAX; i++) {
> > + speed = &dev_speeds[i];
> > + for (u32 dev = 0; dev < speed->n_devs; dev++) {
> > + u32 idx = 0;
> > +
> > + for (n_slots = 0; n_slots < speed->n_slots; n_slots++) {
> > + lan969x_dsm_cal_idx_find_next_free(data->schedule,
> > + cal_len,
> > + &idx);
>
> You're not checking the return of lan969x_dsm_cal_idx_find_next_free(),
> can this be a problem ?
>
> Thanks,
>
> Maxime
Yes, it should be checked as we have a finite number of calendar slots.
Will fix in v2. Thanks!
/Daniel
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH net-next 12/15] net: sparx5: use is_sparx5() macro throughout
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (10 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 11/15] net: lan969x: add function for calculating the DSM calendar Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 13/15] dt-bindings: net: add compatible strings for lan969x SKU's Daniel Machon
` (2 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Use the is_sparx5() macro (introduced in earlier series [1]), in places
where we need to handle things a bit differently on lan969x.
These places are:
- in sparx5_dsm_calendar_update() we need to switch the calendar
from a to b on lan969x.
- in sparx5_init_coreclock() we need to set the policer update
internal (pol_upd_int) to 820 for the new core clock frequency on
lan969x.
- in sparx5_start() we need to make sure the HSCH_SYS_CLK_PER
register is only touched on Sparx5.
- in sparx5_start() we need to disable VCAP and FDMA for lan969x
(will come in later series).
- in sparx5_mirror_port_get() we must make sure the
ANA_AC_PROBE_PORT_CFG1 register is only read on Sparx5.
- sparx5_netdev.c and sparx5_packet.c we need to use different IFH
(Internal Frame Header) offsets for lan969x.
- in sparx5_port_fifo_sz() we must bail out on lan969x.
- in sparx5_port_config_low_set() we must configure the phase
detection registers.
- in sparx5_port_config() and sparx5_port_init() we must do some
additional configuration of the port devices.
- in sparx5_dwrr_conf_set() we must derive the scheduling layer
[1] https://lore.kernel.org/netdev/20241004-b4-sparx5-lan969x-switch-driver-v2-8-d3290f581663@microchip.com/
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
.../ethernet/microchip/sparx5/sparx5_calendar.c | 21 +++++++++-
.../net/ethernet/microchip/sparx5/sparx5_main.c | 24 ++++++-----
.../net/ethernet/microchip/sparx5/sparx5_mirror.c | 10 ++++-
.../net/ethernet/microchip/sparx5/sparx5_netdev.c | 17 ++++----
.../net/ethernet/microchip/sparx5/sparx5_packet.c | 3 +-
.../net/ethernet/microchip/sparx5/sparx5_port.c | 46 ++++++++++++++++++++++
drivers/net/ethernet/microchip/sparx5/sparx5_qos.c | 3 +-
7 files changed, 102 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
index 64c5ed70cc6b..5fe941c66c17 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
@@ -531,8 +531,18 @@ static int sparx5_dsm_calendar_check(struct sparx5 *sparx5,
static int sparx5_dsm_calendar_update(struct sparx5 *sparx5, u32 taxi,
struct sparx5_calendar_data *data)
{
- u32 idx;
- u32 cal_len = sparx5_dsm_cal_len(data->schedule), len;
+ u32 cal_len = sparx5_dsm_cal_len(data->schedule), len, idx;
+
+ if (!is_sparx5(sparx5)) {
+ u32 val, act;
+
+ val = spx5_rd(sparx5, DSM_TAXI_CAL_CFG(taxi));
+ act = DSM_TAXI_CAL_CFG_CAL_SEL_STAT_GET(val);
+
+ spx5_rmw(DSM_TAXI_CAL_CFG_CAL_PGM_SEL_SET(!act),
+ DSM_TAXI_CAL_CFG_CAL_PGM_SEL,
+ sparx5, DSM_TAXI_CAL_CFG(taxi));
+ }
spx5_rmw(DSM_TAXI_CAL_CFG_CAL_PGM_ENA_SET(1),
DSM_TAXI_CAL_CFG_CAL_PGM_ENA,
@@ -556,6 +566,13 @@ static int sparx5_dsm_calendar_update(struct sparx5 *sparx5, u32 taxi,
DSM_TAXI_CAL_CFG(taxi)));
if (len != cal_len - 1)
goto update_err;
+
+ if (!is_sparx5(sparx5)) {
+ spx5_rmw(DSM_TAXI_CAL_CFG_CAL_SWITCH_SET(1),
+ DSM_TAXI_CAL_CFG_CAL_SWITCH,
+ sparx5, DSM_TAXI_CAL_CFG(taxi));
+ }
+
return 0;
update_err:
dev_err(sparx5->dev, "Incorrect calendar length: %u\n", len);
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index f48b5769e1b3..5c986c373b3e 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -532,14 +532,18 @@ static int sparx5_init_coreclock(struct sparx5 *sparx5)
sparx5, CLKGEN_LCPLL1_CORE_CLK_CFG);
}
+ if (!is_sparx5(sparx5))
+ pol_upd_int = 820; // SPX5_CORE_CLOCK_328MHZ
+
/* Update state with chosen frequency */
sparx5->coreclock = freq;
clk_period = sparx5_clk_period(freq);
- spx5_rmw(HSCH_SYS_CLK_PER_100PS_SET(clk_period / 100),
- HSCH_SYS_CLK_PER_100PS,
- sparx5,
- HSCH_SYS_CLK_PER);
+ if (is_sparx5(sparx5))
+ spx5_rmw(HSCH_SYS_CLK_PER_100PS_SET(clk_period / 100),
+ HSCH_SYS_CLK_PER_100PS,
+ sparx5,
+ HSCH_SYS_CLK_PER);
spx5_rmw(ANA_AC_POL_BDLB_DLB_CTRL_CLK_PERIOD_01NS_SET(clk_period / 100),
ANA_AC_POL_BDLB_DLB_CTRL_CLK_PERIOD_01NS,
@@ -729,15 +733,17 @@ static int sparx5_start(struct sparx5 *sparx5)
if (err)
return err;
- err = sparx5_vcap_init(sparx5);
- if (err) {
- sparx5_unregister_notifier_blocks(sparx5);
- return err;
+ if (is_sparx5(sparx5)) {
+ err = sparx5_vcap_init(sparx5);
+ if (err) {
+ sparx5_unregister_notifier_blocks(sparx5);
+ return err;
+ }
}
/* Start Frame DMA with fallback to register based INJ/XTR */
err = -ENXIO;
- if (sparx5->fdma_irq >= 0) {
+ if (sparx5->fdma_irq >= 0 && is_sparx5(sparx5)) {
if (GCB_CHIP_ID_REV_ID_GET(sparx5->chip_id) > 0)
err = devm_request_threaded_irq(sparx5->dev,
sparx5->fdma_irq,
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_mirror.c b/drivers/net/ethernet/microchip/sparx5/sparx5_mirror.c
index 15db423be4aa..93483337f84c 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_mirror.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_mirror.c
@@ -24,8 +24,14 @@ static u32 sparx5_mirror_to_dir(bool ingress)
/* Get ports belonging to this mirror */
static u64 sparx5_mirror_port_get(struct sparx5 *sparx5, u32 idx)
{
- return (u64)spx5_rd(sparx5, ANA_AC_PROBE_PORT_CFG1(idx)) << 32 |
- spx5_rd(sparx5, ANA_AC_PROBE_PORT_CFG(idx));
+ u64 val;
+
+ val = spx5_rd(sparx5, ANA_AC_PROBE_PORT_CFG(idx));
+
+ if (is_sparx5(sparx5))
+ val |= (u64)spx5_rd(sparx5, ANA_AC_PROBE_PORT_CFG1(idx)) << 32;
+
+ return val;
}
/* Add port to mirror (only front ports) */
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
index a94d9a540bd3..1d34af78166a 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
@@ -64,16 +64,16 @@ void sparx5_set_port_ifh(struct sparx5 *sparx5, void *ifh_hdr, u16 portno)
/* MISC.CPU_MASK/DPORT = Destination port */
ifh_encode_bitfield(ifh_hdr, portno, 29, 8);
/* MISC.PIPELINE_PT */
- ifh_encode_bitfield(ifh_hdr, 16, 37, 5);
+ ifh_encode_bitfield(ifh_hdr, is_sparx5(sparx5) ? 16 : 17, 37, 5);
/* MISC.PIPELINE_ACT */
ifh_encode_bitfield(ifh_hdr, 1, 42, 3);
/* FWD.SRC_PORT = CPU */
ifh_encode_bitfield(ifh_hdr, sparx5_get_pgid(sparx5, SPX5_PORT_CPU_0),
- 46, 7);
+ 46, is_sparx5(sparx5) ? 7 : 6);
/* FWD.SFLOW_ID (disable SFlow sampling) */
- ifh_encode_bitfield(ifh_hdr, 124, 57, 7);
+ ifh_encode_bitfield(ifh_hdr, 124, is_sparx5(sparx5) ? 57 : 56, 7);
/* FWD.UPDATE_FCS = Enable. Enforce update of FCS. */
- ifh_encode_bitfield(ifh_hdr, 1, 67, 1);
+ ifh_encode_bitfield(ifh_hdr, 1, is_sparx5(sparx5) ? 67 : 66, 1);
}
void sparx5_set_port_ifh_rew_op(void *ifh_hdr, u32 rew_op)
@@ -84,19 +84,22 @@ void sparx5_set_port_ifh_rew_op(void *ifh_hdr, u32 rew_op)
void sparx5_set_port_ifh_pdu_type(struct sparx5 *sparx5, void *ifh_hdr,
u32 pdu_type)
{
- ifh_encode_bitfield(ifh_hdr, pdu_type, 191, 4);
+ ifh_encode_bitfield(ifh_hdr, pdu_type, is_sparx5(sparx5) ? 191 : 190,
+ 4);
}
void sparx5_set_port_ifh_pdu_w16_offset(struct sparx5 *sparx5, void *ifh_hdr,
u32 pdu_w16_offset)
{
- ifh_encode_bitfield(ifh_hdr, pdu_w16_offset, 195, 6);
+ ifh_encode_bitfield(ifh_hdr, pdu_w16_offset,
+ is_sparx5(sparx5) ? 195 : 194, 6);
}
void sparx5_set_port_ifh_timestamp(struct sparx5 *sparx5, void *ifh_hdr,
u64 timestamp)
{
- ifh_encode_bitfield(ifh_hdr, timestamp, 232, 40);
+ ifh_encode_bitfield(ifh_hdr, timestamp, 232,
+ is_sparx5(sparx5) ? 40 : 38);
}
static int sparx5_port_open(struct net_device *ndev)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
index 57fa9ff9dfce..b6f635d85820 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
@@ -43,7 +43,8 @@ void sparx5_ifh_parse(struct sparx5 *sparx5, u32 *ifh, struct frame_info *info)
((u32)xtr_hdr[29] << 8) |
((u32)xtr_hdr[30] << 0);
fwd = (fwd >> 5);
- info->src_port = FIELD_GET(GENMASK(7, 1), fwd);
+ info->src_port = spx5_field_get(GENMASK(is_sparx5(sparx5) ? 7 : 6, 1),
+ fwd);
/*
* Bit 270-271 are occasionally unexpectedly set by the hardware,
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_port.c b/drivers/net/ethernet/microchip/sparx5/sparx5_port.c
index 0b38b4cb0929..1401761c6251 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_port.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_port.c
@@ -476,6 +476,9 @@ static int sparx5_port_fifo_sz(struct sparx5 *sparx5,
u32 mac_width = 8;
u32 addition = 0;
+ if (!is_sparx5(sparx5))
+ return 0;
+
switch (speed) {
case SPEED_25000:
return 0;
@@ -921,6 +924,20 @@ static int sparx5_port_config_low_set(struct sparx5 *sparx5,
sparx5,
DEV2G5_DEV_RST_CTRL(port->portno));
+ /* Enable PHAD_CTRL for better timestamping */
+ if (!is_sparx5(sparx5)) {
+ for (int i = 0; i < 2; ++i) {
+ /* Divide the port clock by three for the two
+ * phase detection registers.
+ */
+ spx5_rmw(DEV2G5_PHAD_CTRL_DIV_CFG_SET(3) |
+ DEV2G5_PHAD_CTRL_PHAD_ENA_SET(1),
+ DEV2G5_PHAD_CTRL_DIV_CFG |
+ DEV2G5_PHAD_CTRL_PHAD_ENA,
+ sparx5, DEV2G5_PHAD_CTRL(port->portno, i));
+ }
+ }
+
return 0;
}
@@ -978,6 +995,7 @@ int sparx5_port_config(struct sparx5 *sparx5,
struct sparx5_port_config *conf)
{
bool high_speed_dev = sparx5_is_baser(conf->portmode);
+ const struct sparx5_ops *ops = sparx5->data->ops;
int err, urgency, stop_wm;
err = sparx5_port_verify_speed(sparx5, port, conf);
@@ -993,6 +1011,13 @@ int sparx5_port_config(struct sparx5 *sparx5,
if (err)
return err;
+ if (!is_sparx5(sparx5) && ops->is_port_10g(port->portno) &&
+ conf->speed < SPEED_10000)
+ spx5_rmw(DSM_DEV_TX_STOP_WM_CFG_DEV10G_SHADOW_ENA_SET(1),
+ DSM_DEV_TX_STOP_WM_CFG_DEV10G_SHADOW_ENA,
+ sparx5,
+ DSM_DEV_TX_STOP_WM_CFG(port->portno));
+
/* Set the DSM stop watermark */
stop_wm = sparx5_port_fifo_sz(sparx5, port->portno, conf->speed);
spx5_rmw(DSM_DEV_TX_STOP_WM_CFG_DEV_TX_STOP_WM_SET(stop_wm),
@@ -1144,6 +1169,27 @@ int sparx5_port_init(struct sparx5 *sparx5,
DEV25G_PCS25G_SD_CFG(pix));
}
+ if (!is_sparx5(sparx5)) {
+ void __iomem *inst;
+ u32 dev, tinst;
+
+ if (ops->is_port_10g(port->portno)) {
+ dev = sparx5_to_high_dev(sparx5, port->portno);
+ tinst = sparx5_port_dev_index(sparx5, port->portno);
+ inst = spx5_inst_get(sparx5, dev, tinst);
+
+ spx5_inst_wr(5, inst,
+ DEV10G_PTP_STAMPER_CFG(port->portno));
+ } else if (ops->is_port_5g(port->portno)) {
+ dev = sparx5_to_high_dev(sparx5, port->portno);
+ tinst = sparx5_port_dev_index(sparx5, port->portno);
+ inst = spx5_inst_get(sparx5, dev, tinst);
+
+ spx5_inst_wr(5, inst,
+ DEV5G_PTP_STAMPER_CFG(port->portno));
+ }
+ }
+
return 0;
}
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c b/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
index d065f8c40d37..e580670f3992 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
@@ -367,9 +367,10 @@ static u32 sparx5_weight_to_hw_cost(u32 weight_min, u32 weight)
static int sparx5_dwrr_conf_set(struct sparx5_port *port,
struct sparx5_dwrr *dwrr)
{
+ u32 layer = is_sparx5(port->sparx5) ? 2 : 1;
int i;
- spx5_rmw(HSCH_HSCH_CFG_CFG_HSCH_LAYER_SET(2) |
+ spx5_rmw(HSCH_HSCH_CFG_CFG_HSCH_LAYER_SET(layer) |
HSCH_HSCH_CFG_CFG_CFG_SE_IDX_SET(port->portno),
HSCH_HSCH_CFG_CFG_HSCH_LAYER | HSCH_HSCH_CFG_CFG_CFG_SE_IDX,
port->sparx5, HSCH_HSCH_CFG_CFG);
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH net-next 13/15] dt-bindings: net: add compatible strings for lan969x SKU's
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (11 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 12/15] net: sparx5: use is_sparx5() macro throughout Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-22 6:11 ` Krzysztof Kozlowski
2024-10-21 13:58 ` [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target Daniel Machon
2024-10-21 13:58 ` [PATCH net-next 15/15] net: sparx5: add feature support Daniel Machon
14 siblings, 1 reply; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Add compatible strings for the twelve different lan969x SKU's (Stock
Keeping Unit) that we need to support. We need to support all of them,
as we are going to use them in the driver, for deriving the devicetree
target in a subsequent patch.
Also, add myself as a maintainer.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
.../bindings/net/microchip,sparx5-switch.yaml | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml b/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml
index fcafef8d5a33..c38f0bd9a481 100644
--- a/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml
+++ b/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml
@@ -9,6 +9,7 @@ title: Microchip Sparx5 Ethernet switch controller
maintainers:
- Steen Hegelund <steen.hegelund@microchip.com>
- Lars Povlsen <lars.povlsen@microchip.com>
+ - Daniel Machon <daniel.machon@microchip.com>
description: |
The SparX-5 Enterprise Ethernet switch family provides a rich set of
@@ -34,7 +35,21 @@ properties:
pattern: "^switch@[0-9a-f]+$"
compatible:
- const: microchip,sparx5-switch
+ items:
+ - enum:
+ - microchip,sparx5-switch
+ - microchip,lan9691-switch
+ - microchip,lan9692-switch
+ - microchip,lan9693-switch
+ - microchip,lan9694-switch
+ - microchip,lan9695-switch
+ - microchip,lan9696-switch
+ - microchip,lan9697-switch
+ - microchip,lan9698-switch
+ - microchip,lan9699-switch
+ - microchip,lan969a-switch
+ - microchip,lan969b-switch
+ - microchip,lan969c-switch
reg:
items:
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH net-next 13/15] dt-bindings: net: add compatible strings for lan969x SKU's
2024-10-21 13:58 ` [PATCH net-next 13/15] dt-bindings: net: add compatible strings for lan969x SKU's Daniel Machon
@ 2024-10-22 6:11 ` Krzysztof Kozlowski
0 siblings, 0 replies; 36+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-22 6:11 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
On Mon, Oct 21, 2024 at 03:58:50PM +0200, Daniel Machon wrote:
> Add compatible strings for the twelve different lan969x SKU's (Stock
> Keeping Unit) that we need to support. We need to support all of them,
> as we are going to use them in the driver, for deriving the devicetree
> target in a subsequent patch.
>
> Also, add myself as a maintainer.
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> ---
> .../bindings/net/microchip,sparx5-switch.yaml | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml b/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml
> index fcafef8d5a33..c38f0bd9a481 100644
> --- a/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml
> +++ b/Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml
> @@ -9,6 +9,7 @@ title: Microchip Sparx5 Ethernet switch controller
> maintainers:
> - Steen Hegelund <steen.hegelund@microchip.com>
> - Lars Povlsen <lars.povlsen@microchip.com>
> + - Daniel Machon <daniel.machon@microchip.com>
>
> description: |
> The SparX-5 Enterprise Ethernet switch family provides a rich set of
> @@ -34,7 +35,21 @@ properties:
> pattern: "^switch@[0-9a-f]+$"
>
> compatible:
> - const: microchip,sparx5-switch
> + items:
> + - enum:
> + - microchip,sparx5-switch
Keep alphabetical order.
> + - microchip,lan9691-switch
> + - microchip,lan9692-switch
> + - microchip,lan9693-switch
> + - microchip,lan9694-switch
> + - microchip,lan9695-switch
> + - microchip,lan9696-switch
> + - microchip,lan9697-switch
> + - microchip,lan9698-switch
> + - microchip,lan9699-switch
> + - microchip,lan969a-switch
> + - microchip,lan969b-switch
> + - microchip,lan969c-switch
All of them use the same match data, so they are compatible? I have
doubts this is necessary in the first place. Your commit description about
driver does not help me. You need them because you are going to use
them? Yeah, it would be surprising otherwise. :)
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (12 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 13/15] dt-bindings: net: add compatible strings for lan969x SKU's Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
2024-10-22 6:09 ` Krzysztof Kozlowski
` (2 more replies)
2024-10-21 13:58 ` [PATCH net-next 15/15] net: sparx5: add feature support Daniel Machon
14 siblings, 3 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
that we support, and verify that the devicetree target is supported by
the chip target.
Each SKU supports different bandwidths and features (see [1] for
details). We want to be able to run a SKU with a lower bandwidth and/or
feature set, than what is supported by the actual chip. In order to
accomplish this we:
- add new field sparx5->target_dt that reflects the target from the
devicetree (compatible string).
- compare the devicetree target with the actual chip target. If the
bandwidth and features provided by the devicetree target is
supported by the chip, we approve - otherwise reject.
- set the core clock and features based on the devicetree target
[1] https://www.microchip.com/en-us/product/lan9698
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
.../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
.../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
3 files changed, 193 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
index 3435ca86dd70..8fe302415563 100644
--- a/drivers/net/ethernet/microchip/sparx5/Makefile
+++ b/drivers/net/ethernet/microchip/sparx5/Makefile
@@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
# Provide include files
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
+ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index 5c986c373b3e..edbe639d98c5 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -24,6 +24,8 @@
#include <linux/types.h>
#include <linux/reset.h>
+#include "lan969x.h" /* lan969x_desc */
+
#include "sparx5_main_regs.h"
#include "sparx5_main.h"
#include "sparx5_port.h"
@@ -227,6 +229,168 @@ bool is_sparx5(struct sparx5 *sparx5)
}
}
+/* Set the devicetree target based on the compatible string */
+static int sparx5_set_target_dt(struct sparx5 *sparx5)
+{
+ struct device_node *node = sparx5->pdev->dev.of_node;
+
+ if (is_sparx5(sparx5))
+ /* For Sparx5 the devicetree target is always the chip target */
+ sparx5->target_dt = sparx5->target_ct;
+ else if (of_device_is_compatible(node, "microchip,lan9691-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9691VAO;
+ else if (of_device_is_compatible(node, "microchip,lan9692-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9692VAO;
+ else if (of_device_is_compatible(node, "microchip,lan9693-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9693VAO;
+ else if (of_device_is_compatible(node, "microchip,lan9694-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9694;
+ else if (of_device_is_compatible(node, "microchip,lan9695-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9694TSN;
+ else if (of_device_is_compatible(node, "microchip,lan9696-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9696;
+ else if (of_device_is_compatible(node, "microchip,lan9697-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9696TSN;
+ else if (of_device_is_compatible(node, "microchip,lan9698-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9698;
+ else if (of_device_is_compatible(node, "microchip,lan9699-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9698TSN;
+ else if (of_device_is_compatible(node, "microchip,lan969a-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9694RED;
+ else if (of_device_is_compatible(node, "microchip,lan969b-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9696RED;
+ else if (of_device_is_compatible(node, "microchip,lan969c-switch"))
+ sparx5->target_dt = SPX5_TARGET_CT_LAN9698RED;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
+/* Compare the devicetree target with the chip target.
+ * Make sure the chip target supports the features and bandwidth requested
+ * from the devicetree target.
+ */
+static int sparx5_verify_target(struct sparx5 *sparx5)
+{
+ switch (sparx5->target_dt) {
+ case SPX5_TARGET_CT_7546:
+ case SPX5_TARGET_CT_7549:
+ case SPX5_TARGET_CT_7552:
+ case SPX5_TARGET_CT_7556:
+ case SPX5_TARGET_CT_7558:
+ case SPX5_TARGET_CT_7546TSN:
+ case SPX5_TARGET_CT_7549TSN:
+ case SPX5_TARGET_CT_7552TSN:
+ case SPX5_TARGET_CT_7556TSN:
+ case SPX5_TARGET_CT_7558TSN:
+ return 0;
+ case SPX5_TARGET_CT_LAN9698RED:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9696RED:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9696RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9694RED:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9694RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9698TSN:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9696TSN:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9696TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9694TSN:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9694TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9694RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9693VAO:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9693VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9692VAO:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9692VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9693VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9691VAO:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9691VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9692VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9693VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9694TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9694RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9698:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9698 ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9693VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9696:
+ if (sparx5->target_ct == SPX5_TARGET_CT_LAN9696 ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698 ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9692VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9693VAO ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9696TSN ||
+ sparx5->target_ct == SPX5_TARGET_CT_LAN9698TSN)
+ return 0;
+ break;
+
+ case SPX5_TARGET_CT_LAN9694:
+ return 0;
+
+ default:
+ pr_err("Unknown target: %x", sparx5->target_dt);
+ return -EINVAL;
+ }
+
+ pr_err("Chip target: %x does not support the target: %x",
+ sparx5->target_ct, sparx5->target_dt);
+
+ return -EINVAL;
+}
+
static int sparx5_create_targets(struct sparx5 *sparx5)
{
const struct sparx5_main_io_resource *iomap = sparx5->data->iomap;
@@ -441,7 +605,7 @@ static int sparx5_init_coreclock(struct sparx5 *sparx5)
* If 'VTSS_CORE_CLOCK_DEFAULT' then the highest supported
* freq. is used
*/
- switch (sparx5->target_ct) {
+ switch (sparx5->target_dt) {
case SPX5_TARGET_CT_7546:
if (sparx5->coreclock == SPX5_CORE_CLOCK_DEFAULT)
freq = SPX5_CORE_CLOCK_250MHZ;
@@ -491,7 +655,7 @@ static int sparx5_init_coreclock(struct sparx5 *sparx5)
break;
default:
dev_err(sparx5->dev, "Target (%#04x) not supported\n",
- sparx5->target_ct);
+ sparx5->target_dt);
return -ENODEV;
}
@@ -512,7 +676,7 @@ static int sparx5_init_coreclock(struct sparx5 *sparx5)
default:
dev_err(sparx5->dev,
"%d coreclock not supported on (%#04x)\n",
- sparx5->coreclock, sparx5->target_ct);
+ sparx5->coreclock, sparx5->target_dt);
return -EINVAL;
}
@@ -914,6 +1078,16 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
sparx5->target_ct = (enum spx5_target_chiptype)
GCB_CHIP_ID_PART_ID_GET(sparx5->chip_id);
+ /* Set the devicetree target based on the compatible string. */
+ err = sparx5_set_target_dt(sparx5);
+ if (err)
+ goto cleanup_config;
+
+ /* Verify that the chip target supports the devicetree target */
+ err = sparx5_verify_target(sparx5);
+ if (err)
+ goto cleanup_config;
+
/* Initialize Switchcore and internal RAMs */
err = sparx5_init_switchcore(sparx5);
if (err) {
@@ -1051,6 +1225,20 @@ static const struct sparx5_match_data sparx5_desc = {
static const struct of_device_id mchp_sparx5_match[] = {
{ .compatible = "microchip,sparx5-switch", .data = &sparx5_desc },
+#ifdef CONFIG_LAN969X_SWITCH
+ { .compatible = "microchip,lan9691-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9692-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9693-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9694-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9695-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9696-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9697-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9698-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan9699-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan969a-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan969b-switch", .data = &lan969x_desc },
+ { .compatible = "microchip,lan969c-switch", .data = &lan969x_desc },
+#endif
{ }
};
MODULE_DEVICE_TABLE(of, mchp_sparx5_match);
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index 1828e2a7d610..8a2b74d0bd35 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -337,6 +337,7 @@ struct sparx5 {
struct device *dev;
u32 chip_id;
enum spx5_target_chiptype target_ct;
+ enum spx5_target_chiptype target_dt; /* target from devicetree */
void __iomem *regs[NUM_TARGETS];
int port_count;
struct mutex lock; /* MAC reg lock */
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-21 13:58 ` [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target Daniel Machon
@ 2024-10-22 6:09 ` Krzysztof Kozlowski
2024-10-22 8:32 ` Daniel Machon
2024-10-22 8:50 ` Simon Horman
2024-10-23 8:14 ` Krzysztof Kozlowski
2 siblings, 1 reply; 36+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-22 6:09 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
On Mon, Oct 21, 2024 at 03:58:51PM +0200, Daniel Machon wrote:
> @@ -227,6 +229,168 @@ bool is_sparx5(struct sparx5 *sparx5)
> }
> }
>
> +/* Set the devicetree target based on the compatible string */
> +static int sparx5_set_target_dt(struct sparx5 *sparx5)
> +{
> + struct device_node *node = sparx5->pdev->dev.of_node;
> +
> + if (is_sparx5(sparx5))
> + /* For Sparx5 the devicetree target is always the chip target */
> + sparx5->target_dt = sparx5->target_ct;
> + else if (of_device_is_compatible(node, "microchip,lan9691-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9691VAO;
> + else if (of_device_is_compatible(node, "microchip,lan9692-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9692VAO;
> + else if (of_device_is_compatible(node, "microchip,lan9693-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9693VAO;
> + else if (of_device_is_compatible(node, "microchip,lan9694-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694;
> + else if (of_device_is_compatible(node, "microchip,lan9695-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694TSN;
> + else if (of_device_is_compatible(node, "microchip,lan9696-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696;
> + else if (of_device_is_compatible(node, "microchip,lan9697-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696TSN;
> + else if (of_device_is_compatible(node, "microchip,lan9698-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698;
> + else if (of_device_is_compatible(node, "microchip,lan9699-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698TSN;
> + else if (of_device_is_compatible(node, "microchip,lan969a-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694RED;
> + else if (of_device_is_compatible(node, "microchip,lan969b-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696RED;
> + else if (of_device_is_compatible(node, "microchip,lan969c-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698RED;
Do not re-implement match data.
>
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-22 6:09 ` Krzysztof Kozlowski
@ 2024-10-22 8:32 ` Daniel Machon
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-22 8:32 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
Hi Krzysztof,
> On Mon, Oct 21, 2024 at 03:58:51PM +0200, Daniel Machon wrote:
> > @@ -227,6 +229,168 @@ bool is_sparx5(struct sparx5 *sparx5)
> > }
> > }
> >
> > +/* Set the devicetree target based on the compatible string */
> > +static int sparx5_set_target_dt(struct sparx5 *sparx5)
> > +{
> > + struct device_node *node = sparx5->pdev->dev.of_node;
> > +
> > + if (is_sparx5(sparx5))
> > + /* For Sparx5 the devicetree target is always the chip target */
> > + sparx5->target_dt = sparx5->target_ct;
> > + else if (of_device_is_compatible(node, "microchip,lan9691-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9691VAO;
> > + else if (of_device_is_compatible(node, "microchip,lan9692-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9692VAO;
> > + else if (of_device_is_compatible(node, "microchip,lan9693-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9693VAO;
> > + else if (of_device_is_compatible(node, "microchip,lan9694-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9694;
> > + else if (of_device_is_compatible(node, "microchip,lan9695-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9694TSN;
> > + else if (of_device_is_compatible(node, "microchip,lan9696-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9696;
> > + else if (of_device_is_compatible(node, "microchip,lan9697-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9696TSN;
> > + else if (of_device_is_compatible(node, "microchip,lan9698-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9698;
> > + else if (of_device_is_compatible(node, "microchip,lan9699-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9698TSN;
> > + else if (of_device_is_compatible(node, "microchip,lan969a-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9694RED;
> > + else if (of_device_is_compatible(node, "microchip,lan969b-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9696RED;
> > + else if (of_device_is_compatible(node, "microchip,lan969c-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9698RED;
>
> Do not re-implement match data.
>
> >
Thank you for your feedback.
I will get rid of this function and instread create match data structs
for each SKU.
/Daniel
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-21 13:58 ` [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target Daniel Machon
2024-10-22 6:09 ` Krzysztof Kozlowski
@ 2024-10-22 8:50 ` Simon Horman
2024-10-22 12:08 ` Daniel Machon
2024-10-23 8:14 ` Krzysztof Kozlowski
2 siblings, 1 reply; 36+ messages in thread
From: Simon Horman @ 2024-10-22 8:50 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
On Mon, Oct 21, 2024 at 03:58:51PM +0200, Daniel Machon wrote:
> Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
> that we support, and verify that the devicetree target is supported by
> the chip target.
>
> Each SKU supports different bandwidths and features (see [1] for
> details). We want to be able to run a SKU with a lower bandwidth and/or
> feature set, than what is supported by the actual chip. In order to
> accomplish this we:
>
> - add new field sparx5->target_dt that reflects the target from the
> devicetree (compatible string).
>
> - compare the devicetree target with the actual chip target. If the
> bandwidth and features provided by the devicetree target is
> supported by the chip, we approve - otherwise reject.
>
> - set the core clock and features based on the devicetree target
>
> [1] https://www.microchip.com/en-us/product/lan9698
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> ---
> drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
> .../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
> .../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
> 3 files changed, 193 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
> index 3435ca86dd70..8fe302415563 100644
> --- a/drivers/net/ethernet/microchip/sparx5/Makefile
> +++ b/drivers/net/ethernet/microchip/sparx5/Makefile
> @@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
> # Provide include files
> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
> +ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> index 5c986c373b3e..edbe639d98c5 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> @@ -24,6 +24,8 @@
> #include <linux/types.h>
> #include <linux/reset.h>
>
> +#include "lan969x.h" /* lan969x_desc */
> +
Hi Daniel,
Perhaps this will change when Krzysztof's comment elsewhere in this thread
is addressed. But as it stands the construction in the above two hunks
appears to cause a build failure.
CC drivers/net/ethernet/microchip/sparx5/sparx5_main.o
In file included from drivers/net/ethernet/microchip/sparx5/sparx5_main.c:27:
./drivers/net/ethernet/microchip/lan969x/lan969x.h:10:10: fatal error: sparx5_main.h: No such file or directory
10 | #include "sparx5_main.h"
| ^~~~~~~~~~~~~~~
My preference would be to move away from adding -I directives and, rather,
use relative includes as is common practice in Networking drivers (at least).
...
--
pw-bot: changes-requested
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-22 8:50 ` Simon Horman
@ 2024-10-22 12:08 ` Daniel Machon
2024-10-22 13:35 ` Simon Horman
0 siblings, 1 reply; 36+ messages in thread
From: Daniel Machon @ 2024-10-22 12:08 UTC (permalink / raw)
To: Simon Horman
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
Hi Simon,
> > Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
> > that we support, and verify that the devicetree target is supported by
> > the chip target.
> >
> > Each SKU supports different bandwidths and features (see [1] for
> > details). We want to be able to run a SKU with a lower bandwidth and/or
> > feature set, than what is supported by the actual chip. In order to
> > accomplish this we:
> >
> > - add new field sparx5->target_dt that reflects the target from the
> > devicetree (compatible string).
> >
> > - compare the devicetree target with the actual chip target. If the
> > bandwidth and features provided by the devicetree target is
> > supported by the chip, we approve - otherwise reject.
> >
> > - set the core clock and features based on the devicetree target
> >
> > [1] https://www.microchip.com/en-us/product/lan9698
> >
> > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> > Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> > ---
> > drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
> > .../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
> > .../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
> > 3 files changed, 193 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
> > index 3435ca86dd70..8fe302415563 100644
> > --- a/drivers/net/ethernet/microchip/sparx5/Makefile
> > +++ b/drivers/net/ethernet/microchip/sparx5/Makefile
> > @@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
> > # Provide include files
> > ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
> > ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
> > +ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
> > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > index 5c986c373b3e..edbe639d98c5 100644
> > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > @@ -24,6 +24,8 @@
> > #include <linux/types.h>
> > #include <linux/reset.h>
> >
> > +#include "lan969x.h" /* lan969x_desc */
> > +
>
> Hi Daniel,
>
> Perhaps this will change when Krzysztof's comment elsewhere in this thread
> is addressed. But as it stands the construction in the above two hunks
> appears to cause a build failure.
>
> CC drivers/net/ethernet/microchip/sparx5/sparx5_main.o
> In file included from drivers/net/ethernet/microchip/sparx5/sparx5_main.c:27:
> ./drivers/net/ethernet/microchip/lan969x/lan969x.h:10:10: fatal error: sparx5_main.h: No such file or directory
> 10 | #include "sparx5_main.h"
> | ^~~~~~~~~~~~~~~
>
> My preference would be to move away from adding -I directives and, rather,
> use relative includes as is common practice in Networking drivers (at least).
>
> ...
>
> --
> pw-bot: changes-requested
I didn't see this build failure when I ran my tests, nor did the NIPA
tests reveal it. I can only reproduce it if I point to the microchip
subdir when building - but maybe that's what you did too?
Anyway, I will skip the -I includes and resort to relative includes, as
per your request. Thanks.
/Daniel
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-22 12:08 ` Daniel Machon
@ 2024-10-22 13:35 ` Simon Horman
0 siblings, 0 replies; 36+ messages in thread
From: Simon Horman @ 2024-10-22 13:35 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
On Tue, Oct 22, 2024 at 12:08:42PM +0000, Daniel Machon wrote:
> Hi Simon,
>
> > > Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
> > > that we support, and verify that the devicetree target is supported by
> > > the chip target.
> > >
> > > Each SKU supports different bandwidths and features (see [1] for
> > > details). We want to be able to run a SKU with a lower bandwidth and/or
> > > feature set, than what is supported by the actual chip. In order to
> > > accomplish this we:
> > >
> > > - add new field sparx5->target_dt that reflects the target from the
> > > devicetree (compatible string).
> > >
> > > - compare the devicetree target with the actual chip target. If the
> > > bandwidth and features provided by the devicetree target is
> > > supported by the chip, we approve - otherwise reject.
> > >
> > > - set the core clock and features based on the devicetree target
> > >
> > > [1] https://www.microchip.com/en-us/product/lan9698
> > >
> > > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> > > Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> > > ---
> > > drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
> > > .../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
> > > .../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
> > > 3 files changed, 193 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
> > > index 3435ca86dd70..8fe302415563 100644
> > > --- a/drivers/net/ethernet/microchip/sparx5/Makefile
> > > +++ b/drivers/net/ethernet/microchip/sparx5/Makefile
> > > @@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
> > > # Provide include files
> > > ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
> > > ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
> > > +ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
> > > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > > index 5c986c373b3e..edbe639d98c5 100644
> > > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > > @@ -24,6 +24,8 @@
> > > #include <linux/types.h>
> > > #include <linux/reset.h>
> > >
> > > +#include "lan969x.h" /* lan969x_desc */
> > > +
> >
> > Hi Daniel,
> >
> > Perhaps this will change when Krzysztof's comment elsewhere in this thread
> > is addressed. But as it stands the construction in the above two hunks
> > appears to cause a build failure.
> >
> > CC drivers/net/ethernet/microchip/sparx5/sparx5_main.o
> > In file included from drivers/net/ethernet/microchip/sparx5/sparx5_main.c:27:
> > ./drivers/net/ethernet/microchip/lan969x/lan969x.h:10:10: fatal error: sparx5_main.h: No such file or directory
> > 10 | #include "sparx5_main.h"
> > | ^~~~~~~~~~~~~~~
> >
> > My preference would be to move away from adding -I directives and, rather,
> > use relative includes as is common practice in Networking drivers (at least).
> >
> > ...
> >
> > --
> > pw-bot: changes-requested
>
> I didn't see this build failure when I ran my tests, nor did the NIPA
> tests reveal it. I can only reproduce it if I point to the microchip
> subdir when building - but maybe that's what you did too?
>
> Anyway, I will skip the -I includes and resort to relative includes, as
> per your request. Thanks.
Thanks Daniel,
Yes I did see the problem when pointing to the subdir.
But I was also able to see it without doing so when
using a config based on tinyconfigi on x86_64.
I can dig further if you like, or provide that config.
But I did see that relative includes (or an extra -I)
resolved the problem.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-21 13:58 ` [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target Daniel Machon
2024-10-22 6:09 ` Krzysztof Kozlowski
2024-10-22 8:50 ` Simon Horman
@ 2024-10-23 8:14 ` Krzysztof Kozlowski
2024-10-23 11:00 ` Daniel Machon
2 siblings, 1 reply; 36+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-23 8:14 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
On Mon, Oct 21, 2024 at 03:58:51PM +0200, Daniel Machon wrote:
> Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
> that we support, and verify that the devicetree target is supported by
> the chip target.
>
> Each SKU supports different bandwidths and features (see [1] for
> details). We want to be able to run a SKU with a lower bandwidth and/or
> feature set, than what is supported by the actual chip. In order to
> accomplish this we:
>
> - add new field sparx5->target_dt that reflects the target from the
> devicetree (compatible string).
>
> - compare the devicetree target with the actual chip target. If the
> bandwidth and features provided by the devicetree target is
> supported by the chip, we approve - otherwise reject.
>
> - set the core clock and features based on the devicetree target
>
> [1] https://www.microchip.com/en-us/product/lan9698
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> ---
> drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
> .../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
> .../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
> 3 files changed, 193 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
> index 3435ca86dd70..8fe302415563 100644
> --- a/drivers/net/ethernet/microchip/sparx5/Makefile
> +++ b/drivers/net/ethernet/microchip/sparx5/Makefile
> @@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
> # Provide include files
> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
> +ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> index 5c986c373b3e..edbe639d98c5 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> @@ -24,6 +24,8 @@
> #include <linux/types.h>
> #include <linux/reset.h>
>
> +#include "lan969x.h" /* lan969x_desc */
> +
> #include "sparx5_main_regs.h"
> #include "sparx5_main.h"
> #include "sparx5_port.h"
> @@ -227,6 +229,168 @@ bool is_sparx5(struct sparx5 *sparx5)
> }
> }
>
> +/* Set the devicetree target based on the compatible string */
> +static int sparx5_set_target_dt(struct sparx5 *sparx5)
> +{
> + struct device_node *node = sparx5->pdev->dev.of_node;
> +
> + if (is_sparx5(sparx5))
> + /* For Sparx5 the devicetree target is always the chip target */
> + sparx5->target_dt = sparx5->target_ct;
> + else if (of_device_is_compatible(node, "microchip,lan9691-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9691VAO;
> + else if (of_device_is_compatible(node, "microchip,lan9692-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9692VAO;
> + else if (of_device_is_compatible(node, "microchip,lan9693-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9693VAO;
> + else if (of_device_is_compatible(node, "microchip,lan9694-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694;
> + else if (of_device_is_compatible(node, "microchip,lan9695-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694TSN;
> + else if (of_device_is_compatible(node, "microchip,lan9696-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696;
> + else if (of_device_is_compatible(node, "microchip,lan9697-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696TSN;
> + else if (of_device_is_compatible(node, "microchip,lan9698-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698;
> + else if (of_device_is_compatible(node, "microchip,lan9699-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698TSN;
> + else if (of_device_is_compatible(node, "microchip,lan969a-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694RED;
> + else if (of_device_is_compatible(node, "microchip,lan969b-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696RED;
> + else if (of_device_is_compatible(node, "microchip,lan969c-switch"))
> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698RED;
> + else
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> +/* Compare the devicetree target with the chip target.
> + * Make sure the chip target supports the features and bandwidth requested
> + * from the devicetree target.
> + */
> +static int sparx5_verify_target(struct sparx5 *sparx5)
> +{
> + switch (sparx5->target_dt) {
> + case SPX5_TARGET_CT_7546:
> + case SPX5_TARGET_CT_7549:
> + case SPX5_TARGET_CT_7552:
> + case SPX5_TARGET_CT_7556:
> + case SPX5_TARGET_CT_7558:
> + case SPX5_TARGET_CT_7546TSN:
> + case SPX5_TARGET_CT_7549TSN:
> + case SPX5_TARGET_CT_7552TSN:
> + case SPX5_TARGET_CT_7556TSN:
> + case SPX5_TARGET_CT_7558TSN:
> + return 0;
All this is weird. Why would you verify? You were matched, it cannot be
mis-matching.
> + case SPX5_TARGET_CT_LAN9698RED:
> + if (sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
What is "ct"? sorry, all this code is a big no.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-23 8:14 ` Krzysztof Kozlowski
@ 2024-10-23 11:00 ` Daniel Machon
2024-10-23 12:06 ` Krzysztof Kozlowski
0 siblings, 1 reply; 36+ messages in thread
From: Daniel Machon @ 2024-10-23 11:00 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
Hi Krzysztof,
> > Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
> > that we support, and verify that the devicetree target is supported by
> > the chip target.
> >
> > Each SKU supports different bandwidths and features (see [1] for
> > details). We want to be able to run a SKU with a lower bandwidth and/or
> > feature set, than what is supported by the actual chip. In order to
> > accomplish this we:
> >
> > - add new field sparx5->target_dt that reflects the target from the
> > devicetree (compatible string).
> >
> > - compare the devicetree target with the actual chip target. If the
> > bandwidth and features provided by the devicetree target is
> > supported by the chip, we approve - otherwise reject.
> >
> > - set the core clock and features based on the devicetree target
> >
> > [1] https://www.microchip.com/en-us/product/lan9698
> >
> > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> > Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> > ---
> > drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
> > .../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
> > .../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
> > 3 files changed, 193 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
> > index 3435ca86dd70..8fe302415563 100644
> > --- a/drivers/net/ethernet/microchip/sparx5/Makefile
> > +++ b/drivers/net/ethernet/microchip/sparx5/Makefile
> > @@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
> > # Provide include files
> > ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
> > ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
> > +ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
> > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > index 5c986c373b3e..edbe639d98c5 100644
> > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> > @@ -24,6 +24,8 @@
> > #include <linux/types.h>
> > #include <linux/reset.h>
> >
> > +#include "lan969x.h" /* lan969x_desc */
> > +
> > #include "sparx5_main_regs.h"
> > #include "sparx5_main.h"
> > #include "sparx5_port.h"
> > @@ -227,6 +229,168 @@ bool is_sparx5(struct sparx5 *sparx5)
> > }
> > }
> >
> > +/* Set the devicetree target based on the compatible string */
> > +static int sparx5_set_target_dt(struct sparx5 *sparx5)
> > +{
> > + struct device_node *node = sparx5->pdev->dev.of_node;
> > +
> > + if (is_sparx5(sparx5))
> > + /* For Sparx5 the devicetree target is always the chip target */
> > + sparx5->target_dt = sparx5->target_ct;
> > + else if (of_device_is_compatible(node, "microchip,lan9691-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9691VAO;
> > + else if (of_device_is_compatible(node, "microchip,lan9692-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9692VAO;
> > + else if (of_device_is_compatible(node, "microchip,lan9693-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9693VAO;
> > + else if (of_device_is_compatible(node, "microchip,lan9694-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9694;
> > + else if (of_device_is_compatible(node, "microchip,lan9695-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9694TSN;
> > + else if (of_device_is_compatible(node, "microchip,lan9696-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9696;
> > + else if (of_device_is_compatible(node, "microchip,lan9697-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9696TSN;
> > + else if (of_device_is_compatible(node, "microchip,lan9698-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9698;
> > + else if (of_device_is_compatible(node, "microchip,lan9699-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9698TSN;
> > + else if (of_device_is_compatible(node, "microchip,lan969a-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9694RED;
> > + else if (of_device_is_compatible(node, "microchip,lan969b-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9696RED;
> > + else if (of_device_is_compatible(node, "microchip,lan969c-switch"))
> > + sparx5->target_dt = SPX5_TARGET_CT_LAN9698RED;
> > + else
> > + return -EINVAL;
> > +
> > + return 0;
> > +}
> > +
> > +/* Compare the devicetree target with the chip target.
> > + * Make sure the chip target supports the features and bandwidth requested
> > + * from the devicetree target.
> > + */
> > +static int sparx5_verify_target(struct sparx5 *sparx5)
> > +{
> > + switch (sparx5->target_dt) {
> > + case SPX5_TARGET_CT_7546:
> > + case SPX5_TARGET_CT_7549:
> > + case SPX5_TARGET_CT_7552:
> > + case SPX5_TARGET_CT_7556:
> > + case SPX5_TARGET_CT_7558:
> > + case SPX5_TARGET_CT_7546TSN:
> > + case SPX5_TARGET_CT_7549TSN:
> > + case SPX5_TARGET_CT_7552TSN:
> > + case SPX5_TARGET_CT_7556TSN:
> > + case SPX5_TARGET_CT_7558TSN:
> > + return 0;
>
> All this is weird. Why would you verify? You were matched, it cannot be
> mis-matching.
We are verifying that the match (target/compatible string) from the
device tree is supported by the chip. Maybe I wasn't too clear about the
intend in v1.
Each target supports different bandwidths and features. If you have a
lan9698 chip, it must, obviously, be possible to run it as a lan9698
target. However, some targets can be run on chip targets other than
themselves, given that the chip supports the bandwidth and features of
the provided target. In contrary, trying to run as a target with a
feature not supported by the chip, or a bandwidth higher than what the
chip supports, should be rejected.
Without this logic, the chip id is read and a target is determined. That
means on a lan9698 chip you will always match the lan9698 target.
With the new logic, it is possible to run as a different target than
what is read from the chip id, given that the target you are trying to
run as, is supported by the chip.
>
> > + case SPX5_TARGET_CT_LAN9698RED:
> > + if (sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
>
> What is "ct"? sorry, all this code is a big no.
In this case we were matched as a SPX5_TARGET_CT_LAN9698RED target. We
are verifying that the chip target (target_ct, which is read from the
chip) supports the target we were matched as.
> Krzysztof
>
This is a feature that we would like, as it gives the flexibility of
running different targets on the same chip. Now if this is something
that cannot be accepted, I will have to ditch this part.
Let me know.
/Daniel
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-23 11:00 ` Daniel Machon
@ 2024-10-23 12:06 ` Krzysztof Kozlowski
2024-10-23 18:33 ` Daniel Machon
0 siblings, 1 reply; 36+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-23 12:06 UTC (permalink / raw)
To: Daniel Machon
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
On 23/10/2024 13:00, Daniel Machon wrote:
> Hi Krzysztof,
>
>>> Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
>>> that we support, and verify that the devicetree target is supported by
>>> the chip target.
>>>
>>> Each SKU supports different bandwidths and features (see [1] for
>>> details). We want to be able to run a SKU with a lower bandwidth and/or
>>> feature set, than what is supported by the actual chip. In order to
>>> accomplish this we:
>>>
>>> - add new field sparx5->target_dt that reflects the target from the
>>> devicetree (compatible string).
>>>
>>> - compare the devicetree target with the actual chip target. If the
>>> bandwidth and features provided by the devicetree target is
>>> supported by the chip, we approve - otherwise reject.
>>>
>>> - set the core clock and features based on the devicetree target
>>>
>>> [1] https://www.microchip.com/en-us/product/lan9698
>>>
>>> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
>>> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
>>> ---
>>> drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
>>> .../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
>>> .../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
>>> 3 files changed, 193 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
>>> index 3435ca86dd70..8fe302415563 100644
>>> --- a/drivers/net/ethernet/microchip/sparx5/Makefile
>>> +++ b/drivers/net/ethernet/microchip/sparx5/Makefile
>>> @@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
>>> # Provide include files
>>> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
>>> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
>>> +ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
>>> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
>>> index 5c986c373b3e..edbe639d98c5 100644
>>> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
>>> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
>>> @@ -24,6 +24,8 @@
>>> #include <linux/types.h>
>>> #include <linux/reset.h>
>>>
>>> +#include "lan969x.h" /* lan969x_desc */
>>> +
>>> #include "sparx5_main_regs.h"
>>> #include "sparx5_main.h"
>>> #include "sparx5_port.h"
>>> @@ -227,6 +229,168 @@ bool is_sparx5(struct sparx5 *sparx5)
>>> }
>>> }
>>>
>>> +/* Set the devicetree target based on the compatible string */
>>> +static int sparx5_set_target_dt(struct sparx5 *sparx5)
>>> +{
>>> + struct device_node *node = sparx5->pdev->dev.of_node;
>>> +
>>> + if (is_sparx5(sparx5))
>>> + /* For Sparx5 the devicetree target is always the chip target */
>>> + sparx5->target_dt = sparx5->target_ct;
>>> + else if (of_device_is_compatible(node, "microchip,lan9691-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9691VAO;
>>> + else if (of_device_is_compatible(node, "microchip,lan9692-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9692VAO;
>>> + else if (of_device_is_compatible(node, "microchip,lan9693-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9693VAO;
>>> + else if (of_device_is_compatible(node, "microchip,lan9694-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694;
>>> + else if (of_device_is_compatible(node, "microchip,lan9695-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694TSN;
>>> + else if (of_device_is_compatible(node, "microchip,lan9696-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696;
>>> + else if (of_device_is_compatible(node, "microchip,lan9697-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696TSN;
>>> + else if (of_device_is_compatible(node, "microchip,lan9698-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698;
>>> + else if (of_device_is_compatible(node, "microchip,lan9699-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698TSN;
>>> + else if (of_device_is_compatible(node, "microchip,lan969a-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694RED;
>>> + else if (of_device_is_compatible(node, "microchip,lan969b-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696RED;
>>> + else if (of_device_is_compatible(node, "microchip,lan969c-switch"))
>>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698RED;
>>> + else
>>> + return -EINVAL;
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +/* Compare the devicetree target with the chip target.
>>> + * Make sure the chip target supports the features and bandwidth requested
>>> + * from the devicetree target.
>>> + */
>>> +static int sparx5_verify_target(struct sparx5 *sparx5)
>>> +{
>>> + switch (sparx5->target_dt) {
>>> + case SPX5_TARGET_CT_7546:
>>> + case SPX5_TARGET_CT_7549:
>>> + case SPX5_TARGET_CT_7552:
>>> + case SPX5_TARGET_CT_7556:
>>> + case SPX5_TARGET_CT_7558:
>>> + case SPX5_TARGET_CT_7546TSN:
>>> + case SPX5_TARGET_CT_7549TSN:
>>> + case SPX5_TARGET_CT_7552TSN:
>>> + case SPX5_TARGET_CT_7556TSN:
>>> + case SPX5_TARGET_CT_7558TSN:
>>> + return 0;
>>
>> All this is weird. Why would you verify? You were matched, it cannot be
>> mis-matching.
>
> We are verifying that the match (target/compatible string) from the
> device tree is supported by the chip. Maybe I wasn't too clear about the
> intend in v1.
>
> Each target supports different bandwidths and features. If you have a
> lan9698 chip, it must, obviously, be possible to run it as a lan9698
> target. However, some targets can be run on chip targets other than
> themselves, given that the chip supports the bandwidth and features of
> the provided target. In contrary, trying to run as a target with a
> feature not supported by the chip, or a bandwidth higher than what the
> chip supports, should be rejected.
But you are not supposed to compare DT with what you auto-detected.
Detect your hardware, test if it is supported and then bail out.
None of above explains the code.
>
> Without this logic, the chip id is read and a target is determined. That
> means on a lan9698 chip you will always match the lan9698 target.
That's not the job of kernel.
>
> With the new logic, it is possible to run as a different target than
> what is read from the chip id, given that the target you are trying to
> run as, is supported by the chip.
So just run on different target.
>
>>
>>> + case SPX5_TARGET_CT_LAN9698RED:
>>> + if (sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
>>
>> What is "ct"? sorry, all this code is a big no.
>
> In this case we were matched as a SPX5_TARGET_CT_LAN9698RED target. We
> are verifying that the chip target (target_ct, which is read from the
> chip) supports the target we were matched as.
>
>> Krzysztof
>>
>
> This is a feature that we would like, as it gives the flexibility of
> running different targets on the same chip. Now if this is something
> that cannot be accepted, I will have to ditch this part.
I have no clue what the "target" is but so far it looks like you try to
validate DT against detected device. That's not how it should work.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target
2024-10-23 12:06 ` Krzysztof Kozlowski
@ 2024-10-23 18:33 ` Daniel Machon
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-23 18:33 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier, netdev,
linux-arm-kernel, linux-kernel, devicetree
> > Hi Krzysztof,
> >
> >>> Add compatible strings for the twelve lan969x SKU's (Stock Keeping Unit)
> >>> that we support, and verify that the devicetree target is supported by
> >>> the chip target.
> >>>
> >>> Each SKU supports different bandwidths and features (see [1] for
> >>> details). We want to be able to run a SKU with a lower bandwidth and/or
> >>> feature set, than what is supported by the actual chip. In order to
> >>> accomplish this we:
> >>>
> >>> - add new field sparx5->target_dt that reflects the target from the
> >>> devicetree (compatible string).
> >>>
> >>> - compare the devicetree target with the actual chip target. If the
> >>> bandwidth and features provided by the devicetree target is
> >>> supported by the chip, we approve - otherwise reject.
> >>>
> >>> - set the core clock and features based on the devicetree target
> >>>
> >>> [1] https://www.microchip.com/en-us/product/lan9698
> >>>
> >>> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> >>> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> >>> ---
> >>> drivers/net/ethernet/microchip/sparx5/Makefile | 1 +
> >>> .../net/ethernet/microchip/sparx5/sparx5_main.c | 194 ++++++++++++++++++++-
> >>> .../net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
> >>> 3 files changed, 193 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/drivers/net/ethernet/microchip/sparx5/Makefile b/drivers/net/ethernet/microchip/sparx5/Makefile
> >>> index 3435ca86dd70..8fe302415563 100644
> >>> --- a/drivers/net/ethernet/microchip/sparx5/Makefile
> >>> +++ b/drivers/net/ethernet/microchip/sparx5/Makefile
> >>> @@ -19,3 +19,4 @@ sparx5-switch-$(CONFIG_DEBUG_FS) += sparx5_vcap_debugfs.o
> >>> # Provide include files
> >>> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
> >>> ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/fdma
> >>> +ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/lan969x
> >>> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> >>> index 5c986c373b3e..edbe639d98c5 100644
> >>> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> >>> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
> >>> @@ -24,6 +24,8 @@
> >>> #include <linux/types.h>
> >>> #include <linux/reset.h>
> >>>
> >>> +#include "lan969x.h" /* lan969x_desc */
> >>> +
> >>> #include "sparx5_main_regs.h"
> >>> #include "sparx5_main.h"
> >>> #include "sparx5_port.h"
> >>> @@ -227,6 +229,168 @@ bool is_sparx5(struct sparx5 *sparx5)
> >>> }
> >>> }
> >>>
> >>> +/* Set the devicetree target based on the compatible string */
> >>> +static int sparx5_set_target_dt(struct sparx5 *sparx5)
> >>> +{
> >>> + struct device_node *node = sparx5->pdev->dev.of_node;
> >>> +
> >>> + if (is_sparx5(sparx5))
> >>> + /* For Sparx5 the devicetree target is always the chip target */
> >>> + sparx5->target_dt = sparx5->target_ct;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9691-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9691VAO;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9692-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9692VAO;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9693-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9693VAO;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9694-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9695-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694TSN;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9696-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9697-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696TSN;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9698-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698;
> >>> + else if (of_device_is_compatible(node, "microchip,lan9699-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698TSN;
> >>> + else if (of_device_is_compatible(node, "microchip,lan969a-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9694RED;
> >>> + else if (of_device_is_compatible(node, "microchip,lan969b-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9696RED;
> >>> + else if (of_device_is_compatible(node, "microchip,lan969c-switch"))
> >>> + sparx5->target_dt = SPX5_TARGET_CT_LAN9698RED;
> >>> + else
> >>> + return -EINVAL;
> >>> +
> >>> + return 0;
> >>> +}
> >>> +
> >>> +/* Compare the devicetree target with the chip target.
> >>> + * Make sure the chip target supports the features and bandwidth requested
> >>> + * from the devicetree target.
> >>> + */
> >>> +static int sparx5_verify_target(struct sparx5 *sparx5)
> >>> +{
> >>> + switch (sparx5->target_dt) {
> >>> + case SPX5_TARGET_CT_7546:
> >>> + case SPX5_TARGET_CT_7549:
> >>> + case SPX5_TARGET_CT_7552:
> >>> + case SPX5_TARGET_CT_7556:
> >>> + case SPX5_TARGET_CT_7558:
> >>> + case SPX5_TARGET_CT_7546TSN:
> >>> + case SPX5_TARGET_CT_7549TSN:
> >>> + case SPX5_TARGET_CT_7552TSN:
> >>> + case SPX5_TARGET_CT_7556TSN:
> >>> + case SPX5_TARGET_CT_7558TSN:
> >>> + return 0;
> >>
> >> All this is weird. Why would you verify? You were matched, it cannot be
> >> mis-matching.
> >
> > We are verifying that the match (target/compatible string) from the
> > device tree is supported by the chip. Maybe I wasn't too clear about the
> > intend in v1.
> >
> > Each target supports different bandwidths and features. If you have a
> > lan9698 chip, it must, obviously, be possible to run it as a lan9698
> > target. However, some targets can be run on chip targets other than
> > themselves, given that the chip supports the bandwidth and features of
> > the provided target. In contrary, trying to run as a target with a
> > feature not supported by the chip, or a bandwidth higher than what the
> > chip supports, should be rejected.
>
> But you are not supposed to compare DT with what you auto-detected.
> Detect your hardware, test if it is supported and then bail out.
>
> None of above explains the code.
>
> >
> > Without this logic, the chip id is read and a target is determined. That
> > means on a lan9698 chip you will always match the lan9698 target.
>
> That's not the job of kernel.
>
> >
> > With the new logic, it is possible to run as a different target than
> > what is read from the chip id, given that the target you are trying to
> > run as, is supported by the chip.
>
> So just run on different target.
>
> >
> >>
> >>> + case SPX5_TARGET_CT_LAN9698RED:
> >>> + if (sparx5->target_ct == SPX5_TARGET_CT_LAN9698RED)
> >>
> >> What is "ct"? sorry, all this code is a big no.
> >
> > In this case we were matched as a SPX5_TARGET_CT_LAN9698RED target. We
> > are verifying that the chip target (target_ct, which is read from the
> > chip) supports the target we were matched as.
> >
> >> Krzysztof
> >>
> >
> > This is a feature that we would like, as it gives the flexibility of
> > running different targets on the same chip. Now if this is something
> > that cannot be accepted, I will have to ditch this part.
>
> I have no clue what the "target" is but so far it looks like you try to
> validate DT against detected device. That's not how it should work.
I will get rid of the verification in v2.
Thanks.
/Daniel
>
> Best regards,
> Krzysztof
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH net-next 15/15] net: sparx5: add feature support
2024-10-21 13:58 [PATCH net-next 00/15] net: sparx5: add support for lan969x switch device Daniel Machon
` (13 preceding siblings ...)
2024-10-21 13:58 ` [PATCH net-next 14/15] net: sparx5: add compatible strings for lan969x and verify the target Daniel Machon
@ 2024-10-21 13:58 ` Daniel Machon
14 siblings, 0 replies; 36+ messages in thread
From: Daniel Machon @ 2024-10-21 13:58 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
andrew, Lars Povlsen, Steen Hegelund, horatiu.vultur,
jensemil.schulzostergaard, Parthiban.Veerasooran, Raju.Lakkaraju,
UNGLinuxDriver, Richard Cochran, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, jacob.e.keller, ast, maxime.chevallier
Cc: netdev, linux-arm-kernel, linux-kernel, Steen Hegelund,
devicetree
Lan969x supports a number of different features, depending on the SKU
(Stock Keeping Unit, see [1] for details). Add new field
sparx5->features and initialize the features based on the target. Also
add the function sparx5_has_feature() and use it throughout. For now, we
only need to handle features: PSFP and PTP - more will come in the
future.
[1] https://www.microchip.com/en-us/product/lan9698
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
.../net/ethernet/microchip/sparx5/sparx5_main.c | 40 +++++++++++++++++++++-
.../net/ethernet/microchip/sparx5/sparx5_main.h | 7 ++++
.../ethernet/microchip/sparx5/sparx5_tc_flower.c | 5 +++
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index edbe639d98c5..ecec93625d37 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -267,6 +267,40 @@ static int sparx5_set_target_dt(struct sparx5 *sparx5)
return 0;
}
+static void sparx5_init_features(struct sparx5 *sparx5)
+{
+ switch (sparx5->target_dt) {
+ case SPX5_TARGET_CT_7546:
+ case SPX5_TARGET_CT_7549:
+ case SPX5_TARGET_CT_7552:
+ case SPX5_TARGET_CT_7556:
+ case SPX5_TARGET_CT_7558:
+ case SPX5_TARGET_CT_7546TSN:
+ case SPX5_TARGET_CT_7549TSN:
+ case SPX5_TARGET_CT_7552TSN:
+ case SPX5_TARGET_CT_7556TSN:
+ case SPX5_TARGET_CT_7558TSN:
+ case SPX5_TARGET_CT_LAN9691VAO:
+ case SPX5_TARGET_CT_LAN9694TSN:
+ case SPX5_TARGET_CT_LAN9694RED:
+ case SPX5_TARGET_CT_LAN9692VAO:
+ case SPX5_TARGET_CT_LAN9696TSN:
+ case SPX5_TARGET_CT_LAN9696RED:
+ case SPX5_TARGET_CT_LAN9693VAO:
+ case SPX5_TARGET_CT_LAN9698TSN:
+ case SPX5_TARGET_CT_LAN9698RED:
+ sparx5->features = (SPX5_FEATURE_PSFP | SPX5_FEATURE_PTP);
+ break;
+ default:
+ break;
+ }
+}
+
+bool sparx5_has_feature(struct sparx5 *sparx5, enum sparx5_feature feature)
+{
+ return sparx5->features & feature;
+}
+
/* Compare the devicetree target with the chip target.
* Make sure the chip target supports the features and bandwidth requested
* from the devicetree target.
@@ -934,7 +968,8 @@ static int sparx5_start(struct sparx5 *sparx5)
sparx5->xtr_irq = -ENXIO;
}
- if (sparx5->ptp_irq >= 0) {
+ if (sparx5->ptp_irq >= 0 &&
+ sparx5_has_feature(sparx5, SPX5_FEATURE_PTP)) {
err = devm_request_threaded_irq(sparx5->dev, sparx5->ptp_irq,
NULL, ops->ptp_irq_handler,
IRQF_ONESHOT, "sparx5-ptp",
@@ -1088,6 +1123,9 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
if (err)
goto cleanup_config;
+ /* Initialize the features based on the devicetree target */
+ sparx5_init_features(sparx5);
+
/* Initialize Switchcore and internal RAMs */
err = sparx5_init_switchcore(sparx5);
if (err) {
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index 8a2b74d0bd35..5163e26a28b4 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -75,6 +75,11 @@ enum sparx5_cal_bw {
SPX5_CAL_SPEED_12G5 = 7
};
+enum sparx5_feature {
+ SPX5_FEATURE_PSFP = BIT(0),
+ SPX5_FEATURE_PTP = BIT(1),
+};
+
#define SPX5_PORTS 65
#define SPX5_PORTS_ALL 70 /* Total number of ports */
@@ -338,6 +343,7 @@ struct sparx5 {
u32 chip_id;
enum spx5_target_chiptype target_ct;
enum spx5_target_chiptype target_dt; /* target from devicetree */
+ u32 features;
void __iomem *regs[NUM_TARGETS];
int port_count;
struct mutex lock; /* MAC reg lock */
@@ -405,6 +411,7 @@ struct sparx5 {
/* sparx5_main.c */
bool is_sparx5(struct sparx5 *sparx5);
+bool sparx5_has_feature(struct sparx5 *sparx5, enum sparx5_feature feature);
/* sparx5_switchdev.c */
int sparx5_register_notifier_blocks(struct sparx5 *sparx5);
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
index c3bbed140554..4dc1ebd5d510 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
@@ -1284,6 +1284,11 @@ static int sparx5_tc_flower_replace(struct net_device *ndev,
/* Setup PSFP */
if (tc_sg_idx >= 0 || tc_pol_idx >= 0) {
+ if (!sparx5_has_feature(sparx5, SPX5_FEATURE_PSFP)) {
+ err = -EOPNOTSUPP;
+ goto out;
+ }
+
err = sparx5_tc_flower_psfp_setup(sparx5, vrule, tc_sg_idx,
tc_pol_idx, &sg, &fm, &sf);
if (err)
--
2.34.1
^ permalink raw reply related [flat|nested] 36+ messages in thread