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);
486 struct xrs700x *priv = dp->ds->priv;
510 static int xrs700x_bridge_common(struct dsa_switch *ds, int port,
514 struct xrs700x *priv = ds->priv;
517 for (i = 0; i < ds->num_ports; i++) {
518 if (dsa_is_cpu_port(ds, i))
523 if (dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
529 for (i = 0; i < ds->num_ports; i++) {
530 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
549 static int xrs700x_bridge_join(struct dsa_switch *ds, int port,
553 return xrs700x_bridge_common(ds, port, bridge, true);
556 static void xrs700x_bridge_leave(struct dsa_switch *ds, int port,
559 xrs700x_bridge_common(ds, port, bridge, false);
562 static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
568 struct xrs700x *priv = ds->priv;
594 dsa_hsr_foreach_port(dp, ds, hsr) {
619 val = GENMASK(ds->num_ports - 1, 0);
625 val &= ~BIT(dsa_upstream_port(ds, port));
638 ret = xrs700x_port_add_hsrsup_ipf(ds, partner->index, fwd ? port : -1);
642 ret = xrs700x_port_add_hsrsup_ipf(ds, port, fwd ? partner->index : -1);
653 user = dsa_to_port(ds, hsr_pair[i])->user;
660 static int xrs700x_hsr_leave(struct dsa_switch *ds, int port,
664 struct xrs700x *priv = ds->priv;
669 dsa_hsr_foreach_port(dp, ds, hsr) {
687 val = GENMASK(ds->num_ports - 1, 0);
688 val &= ~BIT(dsa_upstream_port(ds, port));
707 user = dsa_to_port(ds, hsr_pair[i])->user;
754 priv->ds->num_ports = info->num_ports;
767 struct dsa_switch *ds;
770 ds = devm_kzalloc(base, sizeof(*ds), GFP_KERNEL);
771 if (!ds)
774 ds->dev = base;
782 ds->ops = &xrs700x_ops;
783 ds->phylink_mac_ops = &xrs700x_phylink_mac_ops;
784 ds->priv = priv;
787 priv->ds = ds;
822 priv->ports = devm_kcalloc(priv->dev, priv->ds->num_ports,
827 for (i = 0; i < priv->ds->num_ports; i++) {
833 return dsa_register_switch(priv->ds);
839 dsa_unregister_switch(priv->ds);
845 dsa_switch_shutdown(priv->ds);