Lines Matching refs:dp
33 static int dsa_port_notify(const struct dsa_port *dp, unsigned long e, void *v)
35 struct raw_notifier_head *nh = &dp->ds->dst->nh;
43 int dsa_port_set_state(struct dsa_port *dp, u8 state,
46 struct dsa_switch *ds = dp->ds;
47 int port = dp->index;
61 if ((dp->stp_state == BR_STATE_LEARNING ||
62 dp->stp_state == BR_STATE_FORWARDING) &&
69 dp->stp_state = state;
74 static void dsa_port_set_state_now(struct dsa_port *dp, u8 state)
78 err = dsa_port_set_state(dp, state, NULL);
83 int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy)
85 struct dsa_switch *ds = dp->ds;
86 int port = dp->index;
95 if (!dp->bridge_dev)
96 dsa_port_set_state_now(dp, BR_STATE_FORWARDING);
98 if (dp->pl)
99 phylink_start(dp->pl);
104 int dsa_port_enable(struct dsa_port *dp, struct phy_device *phy)
109 err = dsa_port_enable_rt(dp, phy);
115 void dsa_port_disable_rt(struct dsa_port *dp)
117 struct dsa_switch *ds = dp->ds;
118 int port = dp->index;
120 if (dp->pl)
121 phylink_stop(dp->pl);
123 if (!dp->bridge_dev)
124 dsa_port_set_state_now(dp, BR_STATE_DISABLED);
130 void dsa_port_disable(struct dsa_port *dp)
133 dsa_port_disable_rt(dp);
137 int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br)
140 .tree_index = dp->ds->dst->index,
141 .sw_index = dp->ds->index,
142 .port = dp->index,
148 err = dsa_port_bridge_flags(dp, BR_FLOOD | BR_MCAST_FLOOD, NULL);
155 dp->bridge_dev = br;
161 dsa_port_bridge_flags(dp, 0, NULL);
162 dp->bridge_dev = NULL;
168 void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
171 .tree_index = dp->ds->dst->index,
172 .sw_index = dp->ds->index,
173 .port = dp->index,
181 dp->bridge_dev = NULL;
188 dsa_port_bridge_flags(dp, 0, NULL);
193 dsa_port_set_state_now(dp, BR_STATE_FORWARDING);
197 static bool dsa_port_can_apply_vlan_filtering(struct dsa_port *dp,
200 struct dsa_switch *ds = dp->ds;
208 if (vlan_filtering && dsa_is_user_port(ds, dp->index)) {
209 struct net_device *upper_dev, *slave = dp->slave;
210 struct net_device *br = dp->bridge_dev;
252 if (other_bridge == dp->bridge_dev)
262 int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
265 struct dsa_switch *ds = dp->ds;
279 apply = dsa_port_can_apply_vlan_filtering(dp, vlan_filtering);
285 if (dsa_port_is_vlan_filtering(dp) == vlan_filtering)
288 err = ds->ops->port_vlan_filtering(ds, dp->index, vlan_filtering,
297 dp->vlan_filtering = vlan_filtering;
306 bool dsa_port_skip_vlan_configuration(struct dsa_port *dp)
308 struct dsa_switch *ds = dp->ds;
310 if (!dp->bridge_dev)
314 !br_vlan_enabled(dp->bridge_dev));
317 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
328 return dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info);
330 dp->ageing_time = ageing_time;
332 return dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info);
335 int dsa_port_pre_bridge_flags(const struct dsa_port *dp, unsigned long flags,
338 struct dsa_switch *ds = dp->ds;
347 int dsa_port_bridge_flags(const struct dsa_port *dp, unsigned long flags,
350 struct dsa_switch *ds = dp->ds;
351 int port = dp->index;
364 int dsa_port_mrouter(struct dsa_port *dp, bool mrouter,
367 struct dsa_switch *ds = dp->ds;
368 int port = dp->index;
376 int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu,
380 .sw_index = dp->ds->index,
382 .port = dp->index,
386 return dsa_port_notify(dp, DSA_NOTIFIER_MTU, &info);
389 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
393 .sw_index = dp->ds->index,
394 .port = dp->index,
399 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_ADD, &info);
402 int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
406 .sw_index = dp->ds->index,
407 .port = dp->index,
413 return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
416 int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data)
418 struct dsa_switch *ds = dp->ds;
419 int port = dp->index;
427 int dsa_port_mdb_add(const struct dsa_port *dp,
432 .sw_index = dp->ds->index,
433 .port = dp->index,
438 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_ADD, &info);
441 int dsa_port_mdb_del(const struct dsa_port *dp,
445 .sw_index = dp->ds->index,
446 .port = dp->index,
450 return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info);
453 int dsa_port_vlan_add(struct dsa_port *dp,
458 .sw_index = dp->ds->index,
459 .port = dp->index,
464 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info);
467 int dsa_port_vlan_del(struct dsa_port *dp,
471 .sw_index = dp->ds->index,
472 .port = dp->index,
476 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
479 static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp)
484 phy_dn = of_parse_phandle(dp->dn, "phy-handle", 0);
502 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
503 struct dsa_switch *ds = dp->ds;
508 ds->ops->phylink_validate(ds, dp->index, supported, state);
514 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
515 struct dsa_switch *ds = dp->ds;
524 err = ds->ops->phylink_mac_link_state(ds, dp->index, state);
527 dp->index, err);
536 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
537 struct dsa_switch *ds = dp->ds;
542 ds->ops->phylink_mac_config(ds, dp->index, mode, state);
547 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
548 struct dsa_switch *ds = dp->ds;
553 ds->ops->phylink_mac_an_restart(ds, dp->index);
560 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
562 struct dsa_switch *ds = dp->ds;
564 if (dsa_is_user_port(ds, dp->index))
565 phydev = dp->slave->phydev;
569 ds->ops->adjust_link(ds, dp->index, phydev);
573 ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface);
583 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
584 struct dsa_switch *ds = dp->ds;
588 ds->ops->adjust_link(ds, dp->index, phydev);
592 ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev,
605 static int dsa_port_setup_phy_of(struct dsa_port *dp, bool enable)
607 struct dsa_switch *ds = dp->ds;
609 int port = dp->index;
612 phydev = dsa_port_get_phy_device(dp);
643 static int dsa_port_fixed_link_register_of(struct dsa_port *dp)
645 struct device_node *dn = dp->dn;
646 struct dsa_switch *ds = dp->ds;
648 int port = dp->index;
677 static int dsa_port_phylink_register(struct dsa_port *dp)
679 struct dsa_switch *ds = dp->ds;
680 struct device_node *port_dn = dp->dn;
688 dp->pl_config.dev = ds->dev;
689 dp->pl_config.type = PHYLINK_DEV;
690 dp->pl_config.pcs_poll = ds->pcs_poll;
692 dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn),
694 if (IS_ERR(dp->pl)) {
695 pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl));
696 return PTR_ERR(dp->pl);
699 err = phylink_of_phy_connect(dp->pl, port_dn, 0);
708 phylink_destroy(dp->pl);
712 int dsa_port_link_register_of(struct dsa_port *dp)
714 struct dsa_switch *ds = dp->ds;
716 int port = dp->index;
719 phy_np = of_parse_phandle(dp->dn, "phy-handle", 0);
720 if (of_phy_is_fixed_link(dp->dn) || phy_np) {
725 return dsa_port_phylink_register(dp);
734 if (of_phy_is_fixed_link(dp->dn))
735 return dsa_port_fixed_link_register_of(dp);
737 return dsa_port_setup_phy_of(dp, true);
740 void dsa_port_link_unregister_of(struct dsa_port *dp)
742 struct dsa_switch *ds = dp->ds;
744 if (!ds->ops->adjust_link && dp->pl) {
746 phylink_disconnect_phy(dp->pl);
748 phylink_destroy(dp->pl);
749 dp->pl = NULL;
753 if (of_phy_is_fixed_link(dp->dn))
754 of_phy_deregister_fixed_link(dp->dn);
756 dsa_port_setup_phy_of(dp, false);
759 int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data)
764 if (of_phy_is_fixed_link(dp->dn))
767 phydev = dsa_port_get_phy_device(dp);
778 int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data)
783 if (of_phy_is_fixed_link(dp->dn))
786 phydev = dsa_port_get_phy_device(dp);
797 int dsa_port_get_phy_sset_count(struct dsa_port *dp)
802 if (of_phy_is_fixed_link(dp->dn))
805 phydev = dsa_port_get_phy_device(dp);