Lines Matching refs:ds
86 static void xrs700x_get_strings(struct dsa_switch *ds, int port,
100 static int xrs700x_get_sset_count(struct dsa_switch *ds, int port, int sset)
155 for (i = 0; i < priv->ds->num_ports; i++)
161 static void xrs700x_get_ethtool_stats(struct dsa_switch *ds, int port,
164 struct xrs700x *priv = ds->priv;
174 static void xrs700x_get_stats64(struct dsa_switch *ds, int port,
177 struct xrs700x *priv = ds->priv;
192 priv->ds->num_ports,
198 priv->ds->num_ports,
204 priv->ds->num_ports,
210 priv->ds->num_ports,
228 static enum dsa_tag_protocol xrs700x_get_tag_protocol(struct dsa_switch *ds,
235 static int xrs700x_reset(struct dsa_switch *ds)
237 struct xrs700x *priv = ds->priv;
257 static void xrs700x_port_stp_state_set(struct dsa_switch *ds, int port,
260 struct xrs700x *priv = ds->priv;
279 dev_err(ds->dev, "invalid STP state: %d\n", state);
299 static int xrs700x_port_add_bpdu_ipf(struct dsa_switch *ds, int port)
301 struct xrs700x *priv = ds->priv;
321 for (i = 0; i < ds->num_ports; i++) {
322 if (dsa_is_cpu_port(ds, i))
342 static int xrs700x_port_add_hsrsup_ipf(struct dsa_switch *ds, int port,
345 struct xrs700x *priv = ds->priv;
365 for (i = 0; i < ds->num_ports; i++) {
366 if (dsa_is_cpu_port(ds, i))
385 static int xrs700x_port_setup(struct dsa_switch *ds, int port)
387 bool cpu_port = dsa_is_cpu_port(ds, port);
388 struct xrs700x *priv = ds->priv;
392 xrs700x_port_stp_state_set(ds, port, BR_STATE_DISABLED);
395 for (i = 0; i < ds->num_ports; i++) {
396 if (!dsa_is_cpu_port(ds, i))
411 ret = xrs700x_port_add_bpdu_ipf(ds, port);
419 static int xrs700x_setup(struct dsa_switch *ds)
421 struct xrs700x *priv = ds->priv;
424 ret = xrs700x_reset(ds);
428 for (i = 0; i < ds->num_ports; i++) {
429 ret = xrs700x_port_setup(ds, i);
439 static void xrs700x_teardown(struct dsa_switch *ds)
441 struct xrs700x *priv = ds->priv;
446 static void xrs700x_phylink_get_caps(struct dsa_switch *ds, int port,
464 dev_err(ds->dev, "Unsupported port: %i\n", port);
469 static void xrs700x_mac_link_up(struct dsa_switch *ds, int port,
475 struct xrs700x *priv = ds->priv;
498 static int xrs700x_bridge_common(struct dsa_switch *ds, int port,
502 struct xrs700x *priv = ds->priv;
505 for (i = 0; i < ds->num_ports; i++) {
506 if (dsa_is_cpu_port(ds, i))
511 if (dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
517 for (i = 0; i < ds->num_ports; i++) {
518 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
537 static int xrs700x_bridge_join(struct dsa_switch *ds, int port,
541 return xrs700x_bridge_common(ds, port, bridge, true);
544 static void xrs700x_bridge_leave(struct dsa_switch *ds, int port,
547 xrs700x_bridge_common(ds, port, bridge, false);
550 static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
555 struct xrs700x *priv = ds->priv;
576 dsa_hsr_foreach_port(dp, ds, hsr) {
601 val = GENMASK(ds->num_ports - 1, 0);
607 val &= ~BIT(dsa_upstream_port(ds, port));
620 ret = xrs700x_port_add_hsrsup_ipf(ds, partner->index, fwd ? port : -1);
624 ret = xrs700x_port_add_hsrsup_ipf(ds, port, fwd ? partner->index : -1);
635 slave = dsa_to_port(ds, hsr_pair[i])->slave;
642 static int xrs700x_hsr_leave(struct dsa_switch *ds, int port,
646 struct xrs700x *priv = ds->priv;
651 dsa_hsr_foreach_port(dp, ds, hsr) {
669 val = GENMASK(ds->num_ports - 1, 0);
670 val &= ~BIT(dsa_upstream_port(ds, port));
689 slave = dsa_to_port(ds, hsr_pair[i])->slave;
731 priv->ds->num_ports = info->num_ports;
744 struct dsa_switch *ds;
747 ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL);
748 if (!ds)
751 ds->dev = base;
759 ds->ops = &xrs700x_ops;
760 ds->priv = priv;
763 priv->ds = ds;
798 priv->ports = devm_kcalloc(priv->dev, priv->ds->num_ports,
803 for (i = 0; i < priv->ds->num_ports; i++) {
809 return dsa_register_switch(priv->ds);
815 dsa_unregister_switch(priv->ds);
821 dsa_switch_shutdown(priv->ds);