ocelot_rmw_rix(ocelot, 0, cpu_flood, ANA_PGID_PGID, PGID_MC);
ocelot_rmw_rix(ocelot, 0, cpu_flood, ANA_PGID_PGID, PGID_BC);
- felix->dsa_8021q_ctx = kzalloc(sizeof(*felix->dsa_8021q_ctx),
- GFP_KERNEL);
+ felix->dsa_8021q_ctx = dsa_tag_8021q_register(ds, &felix_tag_8021q_ops,
+ htons(ETH_P_8021AD));
if (!felix->dsa_8021q_ctx)
return -ENOMEM;
- felix->dsa_8021q_ctx->ops = &felix_tag_8021q_ops;
- felix->dsa_8021q_ctx->proto = htons(ETH_P_8021AD);
- felix->dsa_8021q_ctx->ds = ds;
-
err = dsa_8021q_setup(felix->dsa_8021q_ctx, true);
if (err)
goto out_free_dsa_8021_ctx;
out_teardown_dsa_8021q:
dsa_8021q_setup(felix->dsa_8021q_ctx, false);
out_free_dsa_8021_ctx:
- kfree(felix->dsa_8021q_ctx);
+ dsa_tag_8021q_unregister(felix->dsa_8021q_ctx);
return err;
}
if (err)
dev_err(ds->dev, "dsa_8021q_setup returned %d", err);
- kfree(felix->dsa_8021q_ctx);
+ dsa_tag_8021q_unregister(felix->dsa_8021q_ctx);
for (port = 0; port < ds->num_ports; port++) {
if (dsa_is_unused_port(ds, port))
mutex_init(&priv->ptp_data.lock);
mutex_init(&priv->mgmt_lock);
- priv->dsa_8021q_ctx = devm_kzalloc(dev, sizeof(*priv->dsa_8021q_ctx),
- GFP_KERNEL);
+ priv->dsa_8021q_ctx = dsa_tag_8021q_register(ds, &sja1105_dsa_8021q_ops,
+ htons(ETH_P_8021Q));
if (!priv->dsa_8021q_ctx)
return -ENOMEM;
- priv->dsa_8021q_ctx->ops = &sja1105_dsa_8021q_ops;
- priv->dsa_8021q_ctx->proto = htons(ETH_P_8021Q);
- priv->dsa_8021q_ctx->ds = ds;
-
- INIT_LIST_HEAD(&priv->dsa_8021q_ctx->crosschip_links);
INIT_LIST_HEAD(&priv->bridge_vlans);
INIT_LIST_HEAD(&priv->dsa_8021q_vlans);
rc = dsa_register_switch(priv->ds);
if (rc)
- return rc;
+ goto out_tag_8021q_unregister;
if (IS_ENABLED(CONFIG_NET_SCH_CBS)) {
priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers,
out_unregister_switch:
dsa_unregister_switch(ds);
+out_tag_8021q_unregister:
+ dsa_tag_8021q_unregister(priv->dsa_8021q_ctx);
return rc;
}
static int sja1105_remove(struct spi_device *spi)
{
struct sja1105_private *priv = spi_get_drvdata(spi);
+ struct dsa_switch *ds = priv->ds;
+
+ dsa_unregister_switch(ds);
+ dsa_tag_8021q_unregister(priv->dsa_8021q_ctx);
- dsa_unregister_switch(priv->ds);
return 0;
}
__be16 proto;
};
+struct dsa_8021q_context *dsa_tag_8021q_register(struct dsa_switch *ds,
+ const struct dsa_8021q_ops *ops,
+ __be16 proto);
+
+void dsa_tag_8021q_unregister(struct dsa_8021q_context *ctx);
+
int dsa_8021q_setup(struct dsa_8021q_context *ctx, bool enabled);
int dsa_8021q_crosschip_bridge_join(struct dsa_8021q_context *ctx, int port,
}
EXPORT_SYMBOL_GPL(dsa_8021q_crosschip_bridge_leave);
+struct dsa_8021q_context *dsa_tag_8021q_register(struct dsa_switch *ds,
+ const struct dsa_8021q_ops *ops,
+ __be16 proto)
+{
+ struct dsa_8021q_context *ctx;
+
+ ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return NULL;
+
+ ctx->ops = ops;
+ ctx->proto = proto;
+ ctx->ds = ds;
+
+ INIT_LIST_HEAD(&ctx->crosschip_links);
+
+ return ctx;
+}
+EXPORT_SYMBOL_GPL(dsa_tag_8021q_register);
+
+void dsa_tag_8021q_unregister(struct dsa_8021q_context *ctx)
+{
+ struct dsa_8021q_crosschip_link *c, *n;
+
+ list_for_each_entry_safe(c, n, &ctx->crosschip_links, list) {
+ list_del(&c->list);
+ kfree(c);
+ }
+
+ kfree(ctx);
+}
+EXPORT_SYMBOL_GPL(dsa_tag_8021q_unregister);
+
struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
u16 tpid, u16 tci)
{