Commit 82760d7f authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: sja1105: dimension the data structures for a larger port count

Introduce a SJA1105_MAX_NUM_PORTS macro which at the moment is equal to
SJA1105_NUM_PORTS (5). With the introduction of SJA1110, these
structures will need to hold information for up to 11 ports.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f238fef1
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "sja1105_static_config.h" #include "sja1105_static_config.h"
#define SJA1105_NUM_PORTS 5 #define SJA1105_NUM_PORTS 5
#define SJA1105_MAX_NUM_PORTS SJA1105_NUM_PORTS
#define SJA1105_NUM_TC 8 #define SJA1105_NUM_TC 8
#define SJA1105ET_FDB_BIN_SIZE 4 #define SJA1105ET_FDB_BIN_SIZE 4
/* The hardware value is in multiples of 10 ms. /* The hardware value is in multiples of 10 ms.
...@@ -57,19 +58,19 @@ struct sja1105_regs { ...@@ -57,19 +58,19 @@ struct sja1105_regs {
u64 ptpclkcorp; u64 ptpclkcorp;
u64 ptpsyncts; u64 ptpsyncts;
u64 ptpschtm; u64 ptpschtm;
u64 ptpegr_ts[SJA1105_NUM_PORTS]; u64 ptpegr_ts[SJA1105_MAX_NUM_PORTS];
u64 pad_mii_tx[SJA1105_NUM_PORTS]; u64 pad_mii_tx[SJA1105_MAX_NUM_PORTS];
u64 pad_mii_rx[SJA1105_NUM_PORTS]; u64 pad_mii_rx[SJA1105_MAX_NUM_PORTS];
u64 pad_mii_id[SJA1105_NUM_PORTS]; u64 pad_mii_id[SJA1105_MAX_NUM_PORTS];
u64 cgu_idiv[SJA1105_NUM_PORTS]; u64 cgu_idiv[SJA1105_MAX_NUM_PORTS];
u64 mii_tx_clk[SJA1105_NUM_PORTS]; u64 mii_tx_clk[SJA1105_MAX_NUM_PORTS];
u64 mii_rx_clk[SJA1105_NUM_PORTS]; u64 mii_rx_clk[SJA1105_MAX_NUM_PORTS];
u64 mii_ext_tx_clk[SJA1105_NUM_PORTS]; u64 mii_ext_tx_clk[SJA1105_MAX_NUM_PORTS];
u64 mii_ext_rx_clk[SJA1105_NUM_PORTS]; u64 mii_ext_rx_clk[SJA1105_MAX_NUM_PORTS];
u64 rgmii_tx_clk[SJA1105_NUM_PORTS]; u64 rgmii_tx_clk[SJA1105_MAX_NUM_PORTS];
u64 rmii_ref_clk[SJA1105_NUM_PORTS]; u64 rmii_ref_clk[SJA1105_MAX_NUM_PORTS];
u64 rmii_ext_tx_clk[SJA1105_NUM_PORTS]; u64 rmii_ext_tx_clk[SJA1105_MAX_NUM_PORTS];
u64 stats[__MAX_SJA1105_STATS_AREA][SJA1105_NUM_PORTS]; u64 stats[__MAX_SJA1105_STATS_AREA][SJA1105_MAX_NUM_PORTS];
}; };
struct sja1105_info { struct sja1105_info {
...@@ -206,8 +207,8 @@ enum sja1105_vlan_state { ...@@ -206,8 +207,8 @@ enum sja1105_vlan_state {
struct sja1105_private { struct sja1105_private {
struct sja1105_static_config static_config; struct sja1105_static_config static_config;
bool rgmii_rx_delay[SJA1105_NUM_PORTS]; bool rgmii_rx_delay[SJA1105_MAX_NUM_PORTS];
bool rgmii_tx_delay[SJA1105_NUM_PORTS]; bool rgmii_tx_delay[SJA1105_MAX_NUM_PORTS];
bool best_effort_vlan_filtering; bool best_effort_vlan_filtering;
unsigned long learn_ena; unsigned long learn_ena;
unsigned long ucast_egress_floods; unsigned long ucast_egress_floods;
...@@ -220,7 +221,7 @@ struct sja1105_private { ...@@ -220,7 +221,7 @@ struct sja1105_private {
struct list_head dsa_8021q_vlans; struct list_head dsa_8021q_vlans;
struct list_head bridge_vlans; struct list_head bridge_vlans;
struct sja1105_flow_block flow_block; struct sja1105_flow_block flow_block;
struct sja1105_port ports[SJA1105_NUM_PORTS]; struct sja1105_port ports[SJA1105_MAX_NUM_PORTS];
/* Serializes transmission of management frames so that /* Serializes transmission of management frames so that
* the switch doesn't confuse them with one another. * the switch doesn't confuse them with one another.
*/ */
......
...@@ -72,7 +72,7 @@ static int sja1105_setup_bcast_policer(struct sja1105_private *priv, ...@@ -72,7 +72,7 @@ static int sja1105_setup_bcast_policer(struct sja1105_private *priv,
/* Make the broadcast policers of all ports attached to this block /* Make the broadcast policers of all ports attached to this block
* point to the newly allocated policer * point to the newly allocated policer
*/ */
for_each_set_bit(p, &rule->port_mask, SJA1105_NUM_PORTS) { for_each_set_bit(p, &rule->port_mask, SJA1105_MAX_NUM_PORTS) {
int bcast = (ds->num_ports * SJA1105_NUM_TC) + p; int bcast = (ds->num_ports * SJA1105_NUM_TC) + p;
policing[bcast].sharindx = rule->bcast_pol.sharindx; policing[bcast].sharindx = rule->bcast_pol.sharindx;
...@@ -144,7 +144,7 @@ static int sja1105_setup_tc_policer(struct sja1105_private *priv, ...@@ -144,7 +144,7 @@ static int sja1105_setup_tc_policer(struct sja1105_private *priv,
/* Make the policers for traffic class @tc of all ports attached to /* Make the policers for traffic class @tc of all ports attached to
* this block point to the newly allocated policer * this block point to the newly allocated policer
*/ */
for_each_set_bit(p, &rule->port_mask, SJA1105_NUM_PORTS) { for_each_set_bit(p, &rule->port_mask, SJA1105_MAX_NUM_PORTS) {
int index = (p * SJA1105_NUM_TC) + tc; int index = (p * SJA1105_NUM_TC) + tc;
policing[index].sharindx = rule->tc_pol.sharindx; policing[index].sharindx = rule->tc_pol.sharindx;
......
...@@ -1861,8 +1861,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv, ...@@ -1861,8 +1861,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
{ {
struct ptp_system_timestamp ptp_sts_before; struct ptp_system_timestamp ptp_sts_before;
struct ptp_system_timestamp ptp_sts_after; struct ptp_system_timestamp ptp_sts_after;
int speed_mbps[SJA1105_MAX_NUM_PORTS];
struct sja1105_mac_config_entry *mac; struct sja1105_mac_config_entry *mac;
int speed_mbps[SJA1105_NUM_PORTS];
struct dsa_switch *ds = priv->ds; struct dsa_switch *ds = priv->ds;
s64 t1, t2, t3, t4; s64 t1, t2, t3, t4;
s64 t12, t34; s64 t12, t34;
...@@ -2639,7 +2639,7 @@ static int sja1105_notify_crosschip_switches(struct sja1105_private *priv) ...@@ -2639,7 +2639,7 @@ static int sja1105_notify_crosschip_switches(struct sja1105_private *priv)
static int sja1105_build_vlan_table(struct sja1105_private *priv, bool notify) static int sja1105_build_vlan_table(struct sja1105_private *priv, bool notify)
{ {
u16 subvlan_map[SJA1105_NUM_PORTS][DSA_8021Q_N_SUBVLAN]; u16 subvlan_map[SJA1105_MAX_NUM_PORTS][DSA_8021Q_N_SUBVLAN];
struct sja1105_retagging_entry *new_retagging; struct sja1105_retagging_entry *new_retagging;
struct sja1105_vlan_lookup_entry *new_vlan; struct sja1105_vlan_lookup_entry *new_vlan;
struct sja1105_table *table; struct sja1105_table *table;
...@@ -2975,7 +2975,7 @@ static const struct dsa_8021q_ops sja1105_dsa_8021q_ops = { ...@@ -2975,7 +2975,7 @@ static const struct dsa_8021q_ops sja1105_dsa_8021q_ops = {
*/ */
static int sja1105_setup(struct dsa_switch *ds) static int sja1105_setup(struct dsa_switch *ds)
{ {
struct sja1105_dt_port ports[SJA1105_NUM_PORTS]; struct sja1105_dt_port ports[SJA1105_MAX_NUM_PORTS];
struct sja1105_private *priv = ds->priv; struct sja1105_private *priv = ds->priv;
int rc; int rc;
...@@ -3668,7 +3668,7 @@ static int sja1105_probe(struct spi_device *spi) ...@@ -3668,7 +3668,7 @@ static int sja1105_probe(struct spi_device *spi)
return -ENOMEM; return -ENOMEM;
ds->dev = dev; ds->dev = dev;
ds->num_ports = SJA1105_NUM_PORTS; ds->num_ports = SJA1105_MAX_NUM_PORTS;
ds->ops = &sja1105_switch_ops; ds->ops = &sja1105_switch_ops;
ds->priv = priv; ds->priv = priv;
priv->ds = ds; priv->ds = ds;
......
...@@ -39,7 +39,7 @@ struct sja1105_gating_config { ...@@ -39,7 +39,7 @@ struct sja1105_gating_config {
}; };
struct sja1105_tas_data { struct sja1105_tas_data {
struct tc_taprio_qopt_offload *offload[SJA1105_NUM_PORTS]; struct tc_taprio_qopt_offload *offload[SJA1105_MAX_NUM_PORTS];
struct sja1105_gating_config gating_cfg; struct sja1105_gating_config gating_cfg;
enum sja1105_tas_state state; enum sja1105_tas_state state;
enum sja1105_ptp_op last_op; enum sja1105_ptp_op last_op;
......
...@@ -386,7 +386,7 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv, ...@@ -386,7 +386,7 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv,
if (rule->type != SJA1105_RULE_VL) if (rule->type != SJA1105_RULE_VL)
continue; continue;
for_each_set_bit(port, &rule->port_mask, SJA1105_NUM_PORTS) { for_each_set_bit(port, &rule->port_mask, SJA1105_MAX_NUM_PORTS) {
vl_lookup[k].format = SJA1105_VL_FORMAT_PSFP; vl_lookup[k].format = SJA1105_VL_FORMAT_PSFP;
vl_lookup[k].port = port; vl_lookup[k].port = port;
vl_lookup[k].macaddr = rule->key.vl.dmac; vl_lookup[k].macaddr = rule->key.vl.dmac;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment