summaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa/sja1105/sja1105_vl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/dsa/sja1105/sja1105_vl.c')
-rw-r--r--drivers/net/dsa/sja1105/sja1105_vl.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/drivers/net/dsa/sja1105/sja1105_vl.c b/drivers/net/dsa/sja1105/sja1105_vl.c
index aa9b0b92f437..f37611885376 100644
--- a/drivers/net/dsa/sja1105/sja1105_vl.c
+++ b/drivers/net/dsa/sja1105/sja1105_vl.c
@@ -5,7 +5,6 @@
#include <linux/dsa/8021q.h>
#include "sja1105.h"
-#define SJA1105_VL_FRAME_MEMORY 100
#define SJA1105_SIZE_VL_STATUS 8
/* The switch flow classification core implements TTEthernet, which 'thinks' in
@@ -141,8 +140,6 @@ static bool sja1105_vl_key_lower(struct sja1105_vl_lookup_entry *a,
static int sja1105_init_virtual_links(struct sja1105_private *priv,
struct netlink_ext_ack *extack)
{
- struct sja1105_l2_forwarding_params_entry *l2_fwd_params;
- struct sja1105_vl_forwarding_params_entry *vl_fwd_params;
struct sja1105_vl_policing_entry *vl_policing;
struct sja1105_vl_forwarding_entry *vl_fwd;
struct sja1105_vl_lookup_entry *vl_lookup;
@@ -153,10 +150,6 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv,
int max_sharindx = 0;
int i, j, k;
- table = &priv->static_config.tables[BLK_IDX_L2_FORWARDING_PARAMS];
- l2_fwd_params = table->entries;
- l2_fwd_params->part_spc[0] = SJA1105_MAX_FRAME_MEMORY;
-
/* Figure out the dimensioning of the problem */
list_for_each_entry(rule, &priv->flow_block.rules, list) {
if (rule->type != SJA1105_RULE_VL)
@@ -308,17 +301,6 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv,
if (!table->entries)
return -ENOMEM;
table->entry_count = 1;
- vl_fwd_params = table->entries;
-
- /* Reserve some frame buffer memory for the critical-traffic virtual
- * links (this needs to be done). At the moment, hardcode the value
- * at 100 blocks of 128 bytes of memory each. This leaves 829 blocks
- * remaining for best-effort traffic. TODO: figure out a more flexible
- * way to perform the frame buffer partitioning.
- */
- l2_fwd_params->part_spc[0] = SJA1105_MAX_FRAME_MEMORY -
- SJA1105_VL_FRAME_MEMORY;
- vl_fwd_params->partspc[0] = SJA1105_VL_FRAME_MEMORY;
for (i = 0; i < num_virtual_links; i++) {
unsigned long cookie = vl_lookup[i].flow_cookie;
@@ -342,6 +324,8 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv,
}
}
+ sja1105_frame_memory_partitioning(priv);
+
return 0;
}
@@ -353,14 +337,14 @@ int sja1105_vl_redirect(struct sja1105_private *priv, int port,
struct sja1105_rule *rule = sja1105_rule_find(priv, cookie);
int rc;
- if (dsa_port_is_vlan_filtering(dsa_to_port(priv->ds, port)) &&
- key->type != SJA1105_KEY_VLAN_AWARE_VL) {
+ if (priv->vlan_state == SJA1105_VLAN_UNAWARE &&
+ key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
NL_SET_ERR_MSG_MOD(extack,
- "Can only redirect based on {DMAC, VID, PCP}");
+ "Can only redirect based on DMAC");
return -EOPNOTSUPP;
- } else if (key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
+ } else if (key->type != SJA1105_KEY_VLAN_AWARE_VL) {
NL_SET_ERR_MSG_MOD(extack,
- "Can only redirect based on DMAC");
+ "Can only redirect based on {DMAC, VID, PCP}");
return -EOPNOTSUPP;
}
@@ -602,14 +586,18 @@ int sja1105_vl_gate(struct sja1105_private *priv, int port,
return -ERANGE;
}
- if (dsa_port_is_vlan_filtering(dsa_to_port(priv->ds, port)) &&
- key->type != SJA1105_KEY_VLAN_AWARE_VL) {
+ if (priv->vlan_state == SJA1105_VLAN_UNAWARE &&
+ key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
+ dev_err(priv->ds->dev, "1: vlan state %d key type %d\n",
+ priv->vlan_state, key->type);
NL_SET_ERR_MSG_MOD(extack,
- "Can only gate based on {DMAC, VID, PCP}");
+ "Can only gate based on DMAC");
return -EOPNOTSUPP;
- } else if (key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
+ } else if (key->type != SJA1105_KEY_VLAN_AWARE_VL) {
+ dev_err(priv->ds->dev, "2: vlan state %d key type %d\n",
+ priv->vlan_state, key->type);
NL_SET_ERR_MSG_MOD(extack,
- "Can only gate based on DMAC");
+ "Can only gate based on {DMAC, VID, PCP}");
return -EOPNOTSUPP;
}