Lines Matching refs:ds
86 static void xrs700x_get_strings(struct dsa_switch *ds, int port,
98 static int xrs700x_get_sset_count(struct dsa_switch *ds, int port, int sset)
153 for (i = 0; i < priv->ds->num_ports; i++)
159 static void xrs700x_get_ethtool_stats(struct dsa_switch *ds, int port,
162 struct xrs700x *priv = ds->priv;
172 static void xrs700x_get_stats64(struct dsa_switch *ds, int port,
175 struct xrs700x *priv = ds->priv;
190 priv->ds->num_ports,
196 priv->ds->num_ports,
202 priv->ds->num_ports,
208 priv->ds->num_ports,
226 static enum dsa_tag_protocol xrs700x_get_tag_protocol(struct dsa_switch *ds,
233 static int xrs700x_reset(struct dsa_switch *ds)
235 struct xrs700x *priv = ds->priv;
255 static void xrs700x_port_stp_state_set(struct dsa_switch *ds, int port,
258 struct xrs700x *priv = ds->priv;
277 dev_err(ds->dev, "invalid STP state: %d\n", state);
297 static int xrs700x_port_add_bpdu_ipf(struct dsa_switch *ds, int port)
299 struct xrs700x *priv = ds->priv;
319 for (i = 0; i < ds->num_ports; i++) {
320 if (dsa_is_cpu_port(ds, i))
340 static int xrs700x_port_add_hsrsup_ipf(struct dsa_switch *ds, int port,
343 struct xrs700x *priv = ds->priv;
363 for (i = 0; i < ds->num_ports; i++) {
364 if (dsa_is_cpu_port(ds, i))
383 static int xrs700x_port_setup(struct dsa_switch *ds, int port)
385 bool cpu_port = dsa_is_cpu_port(ds, port);
386 struct xrs700x *priv = ds->priv;
390 xrs700x_port_stp_state_set(ds, port, BR_STATE_DISABLED);
393 for (i = 0; i < ds->num_ports; i++) {
394 if (!dsa_is_cpu_port(ds, i))
409 ret = xrs700x_port_add_bpdu_ipf(ds, port);
417 static int xrs700x_setup(struct dsa_switch *ds)
419 struct xrs700x *priv = ds->priv;
422 ret = xrs700x_reset(ds);
426 for (i = 0; i < ds->num_ports; i++) {
427 ret = xrs700x_port_setup(ds, i);
437 static void xrs700x_teardown(struct dsa_switch *ds)
439 struct xrs700x *priv = ds->priv;
444 static void xrs700x_phylink_get_caps(struct dsa_switch *ds, int port,
462 dev_err(ds->dev, "Unsupported port: %i\n", port);
484 struct xrs700x *priv = dp->ds->priv;
508 static int xrs700x_bridge_common(struct dsa_switch *ds, int port,
512 struct xrs700x *priv = ds->priv;
515 for (i = 0; i < ds->num_ports; i++) {
516 if (dsa_is_cpu_port(ds, i))
521 if (dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
527 for (i = 0; i < ds->num_ports; i++) {
528 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
547 static int xrs700x_bridge_join(struct dsa_switch *ds, int port,
551 return xrs700x_bridge_common(ds, port, bridge, true);
554 static void xrs700x_bridge_leave(struct dsa_switch *ds, int port,
557 xrs700x_bridge_common(ds, port, bridge, false);
560 static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
566 struct xrs700x *priv = ds->priv;
592 dsa_hsr_foreach_port(dp, ds, hsr) {
617 val = GENMASK(ds->num_ports - 1, 0);
623 val &= ~BIT(dsa_upstream_port(ds, port));
636 ret = xrs700x_port_add_hsrsup_ipf(ds, partner->index, fwd ? port : -1);
640 ret = xrs700x_port_add_hsrsup_ipf(ds, port, fwd ? partner->index : -1);
651 user = dsa_to_port(ds, hsr_pair[i])->user;
658 static int xrs700x_hsr_leave(struct dsa_switch *ds, int port,
662 struct xrs700x *priv = ds->priv;
667 dsa_hsr_foreach_port(dp, ds, hsr) {
685 val = GENMASK(ds->num_ports - 1, 0);
686 val &= ~BIT(dsa_upstream_port(ds, port));
705 user = dsa_to_port(ds, hsr_pair[i])->user;
752 priv->ds->num_ports = info->num_ports;
765 struct dsa_switch *ds;
768 ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL);
769 if (!ds)
772 ds->dev = base;
780 ds->ops = &xrs700x_ops;
781 ds->phylink_mac_ops = &xrs700x_phylink_mac_ops;
782 ds->priv = priv;
785 priv->ds = ds;
820 priv->ports = devm_kcalloc(priv->dev, priv->ds->num_ports,
825 for (i = 0; i < priv->ds->num_ports; i++) {
831 return dsa_register_switch(priv->ds);
837 dsa_unregister_switch(priv->ds);
843 dsa_switch_shutdown(priv->ds);