@@ -376,6 +376,8 @@ static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
return dp->vlan_filtering;
}
+bool dsa_port_is_enabled(struct dsa_switch *ds, int port);
+
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
bool is_static, void *data);
struct dsa_switch_ops {
@@ -727,6 +727,35 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
return err;
}
+bool dsa_port_is_enabled(struct dsa_switch *ds, int port)
+{
+ struct device_node *dn = ds->dev->of_node;
+ struct device_node *ports, *port_node;
+ bool found = false;
+ int reg, err;
+
+ ports = of_get_child_by_name(dn, "ports");
+ if (!ports) {
+ dev_err(ds->dev, "no ports child node found\n");
+ return false;
+ }
+
+ for_each_available_child_of_node(ports, port_node) {
+ err = of_property_read_u32(port_node, "reg", ®);
+ if (err)
+ goto out_put_node;
+
+ if (reg == port) {
+ found = true;
+ break;
+ }
+ }
+
+out_put_node:
+ of_node_put(ports);
+ return found;
+}
+
static int dsa_switch_parse_member_of(struct dsa_switch *ds,
struct device_node *dn)
{