Lines Matching +full:ocelot +full:- +full:1
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
2 /* Microsemi Ocelot Switch driver
5 * Copyright 2020-2021 NXP
12 #include "ocelot.h"
18 static int ocelot_mrp_find_partner_port(struct ocelot *ocelot, in ocelot_mrp_find_partner_port() argument
23 for (i = 0; i < ocelot->num_phys_ports; ++i) { in ocelot_mrp_find_partner_port()
24 struct ocelot_port *ocelot_port = ocelot->ports[i]; in ocelot_mrp_find_partner_port()
29 if (ocelot_port->mrp_ring_id == p->mrp_ring_id) in ocelot_mrp_find_partner_port()
33 return -1; in ocelot_mrp_find_partner_port()
36 static int ocelot_mrp_del_vcap(struct ocelot *ocelot, int id) in ocelot_mrp_del_vcap() argument
41 block_vcap_is2 = &ocelot->block[VCAP_IS2]; in ocelot_mrp_del_vcap()
47 return ocelot_vcap_filter_del(ocelot, filter); in ocelot_mrp_del_vcap()
50 static int ocelot_mrp_redirect_add_vcap(struct ocelot *ocelot, int src_port, in ocelot_mrp_redirect_add_vcap() argument
59 return -ENOMEM; in ocelot_mrp_redirect_add_vcap()
61 filter->key_type = OCELOT_VCAP_KEY_ETYPE; in ocelot_mrp_redirect_add_vcap()
62 filter->prio = 1; in ocelot_mrp_redirect_add_vcap()
63 filter->id.cookie = OCELOT_VCAP_IS2_MRP_REDIRECT(ocelot, src_port); in ocelot_mrp_redirect_add_vcap()
64 filter->id.tc_offload = false; in ocelot_mrp_redirect_add_vcap()
65 filter->block_id = VCAP_IS2; in ocelot_mrp_redirect_add_vcap()
66 filter->type = OCELOT_VCAP_FILTER_OFFLOAD; in ocelot_mrp_redirect_add_vcap()
67 filter->ingress_port_mask = BIT(src_port); in ocelot_mrp_redirect_add_vcap()
68 ether_addr_copy(filter->key.etype.dmac.value, mrp_test_dmac); in ocelot_mrp_redirect_add_vcap()
69 ether_addr_copy(filter->key.etype.dmac.mask, mrp_test_mask); in ocelot_mrp_redirect_add_vcap()
70 filter->action.mask_mode = OCELOT_MASK_MODE_REDIRECT; in ocelot_mrp_redirect_add_vcap()
71 filter->action.port_mask = BIT(dst_port); in ocelot_mrp_redirect_add_vcap()
73 err = ocelot_vcap_filter_add(ocelot, filter, NULL); in ocelot_mrp_redirect_add_vcap()
87 ether_addr_copy(filter->key.etype.dmac.value, mrp_test_dmac); in ocelot_populate_mrp_trap_key()
88 ether_addr_copy(filter->key.etype.dmac.mask, mrp_mask); in ocelot_populate_mrp_trap_key()
91 static int ocelot_mrp_trap_add(struct ocelot *ocelot, int port) in ocelot_mrp_trap_add() argument
93 unsigned long cookie = OCELOT_VCAP_IS2_MRP_TRAP(ocelot); in ocelot_mrp_trap_add()
95 return ocelot_trap_add(ocelot, port, cookie, false, in ocelot_mrp_trap_add()
99 static int ocelot_mrp_trap_del(struct ocelot *ocelot, int port) in ocelot_mrp_trap_del() argument
101 unsigned long cookie = OCELOT_VCAP_IS2_MRP_TRAP(ocelot); in ocelot_mrp_trap_del()
103 return ocelot_trap_del(ocelot, port, cookie); in ocelot_mrp_trap_del()
106 static void ocelot_mrp_save_mac(struct ocelot *ocelot, in ocelot_mrp_save_mac() argument
109 ocelot_mact_learn(ocelot, PGID_BLACKHOLE, mrp_test_dmac, in ocelot_mrp_save_mac()
111 ocelot_mact_learn(ocelot, PGID_BLACKHOLE, mrp_control_dmac, in ocelot_mrp_save_mac()
115 static void ocelot_mrp_del_mac(struct ocelot *ocelot, in ocelot_mrp_del_mac() argument
118 ocelot_mact_forget(ocelot, mrp_test_dmac, OCELOT_STANDALONE_PVID); in ocelot_mrp_del_mac()
119 ocelot_mact_forget(ocelot, mrp_control_dmac, OCELOT_STANDALONE_PVID); in ocelot_mrp_del_mac()
122 int ocelot_mrp_add(struct ocelot *ocelot, int port, in ocelot_mrp_add() argument
125 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_mrp_add()
130 return -EOPNOTSUPP; in ocelot_mrp_add()
133 dev = priv->dev; in ocelot_mrp_add()
135 if (mrp->p_port != dev && mrp->s_port != dev) in ocelot_mrp_add()
138 ocelot_port->mrp_ring_id = mrp->ring_id; in ocelot_mrp_add()
144 int ocelot_mrp_del(struct ocelot *ocelot, int port, in ocelot_mrp_del() argument
147 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_mrp_del()
150 return -EOPNOTSUPP; in ocelot_mrp_del()
152 if (ocelot_port->mrp_ring_id != mrp->ring_id) in ocelot_mrp_del()
155 ocelot_port->mrp_ring_id = 0; in ocelot_mrp_del()
161 int ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port, in ocelot_mrp_add_ring_role() argument
164 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_mrp_add_ring_role()
169 return -EOPNOTSUPP; in ocelot_mrp_add_ring_role()
171 if (mrp->ring_role != BR_MRP_RING_ROLE_MRC && !mrp->sw_backup) in ocelot_mrp_add_ring_role()
172 return -EOPNOTSUPP; in ocelot_mrp_add_ring_role()
174 if (ocelot_port->mrp_ring_id != mrp->ring_id) in ocelot_mrp_add_ring_role()
177 ocelot_mrp_save_mac(ocelot, ocelot_port); in ocelot_mrp_add_ring_role()
179 if (mrp->ring_role != BR_MRP_RING_ROLE_MRC) in ocelot_mrp_add_ring_role()
180 return ocelot_mrp_trap_add(ocelot, port); in ocelot_mrp_add_ring_role()
182 dst_port = ocelot_mrp_find_partner_port(ocelot, ocelot_port); in ocelot_mrp_add_ring_role()
183 if (dst_port == -1) in ocelot_mrp_add_ring_role()
184 return -EINVAL; in ocelot_mrp_add_ring_role()
186 err = ocelot_mrp_redirect_add_vcap(ocelot, port, dst_port); in ocelot_mrp_add_ring_role()
190 err = ocelot_mrp_trap_add(ocelot, port); in ocelot_mrp_add_ring_role()
192 ocelot_mrp_del_vcap(ocelot, in ocelot_mrp_add_ring_role()
193 OCELOT_VCAP_IS2_MRP_REDIRECT(ocelot, port)); in ocelot_mrp_add_ring_role()
201 int ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port, in ocelot_mrp_del_ring_role() argument
204 struct ocelot_port *ocelot_port = ocelot->ports[port]; in ocelot_mrp_del_ring_role()
208 return -EOPNOTSUPP; in ocelot_mrp_del_ring_role()
210 if (mrp->ring_role != BR_MRP_RING_ROLE_MRC && !mrp->sw_backup) in ocelot_mrp_del_ring_role()
211 return -EOPNOTSUPP; in ocelot_mrp_del_ring_role()
213 if (ocelot_port->mrp_ring_id != mrp->ring_id) in ocelot_mrp_del_ring_role()
216 err = ocelot_mrp_trap_del(ocelot, port); in ocelot_mrp_del_ring_role()
220 ocelot_mrp_del_vcap(ocelot, OCELOT_VCAP_IS2_MRP_REDIRECT(ocelot, port)); in ocelot_mrp_del_ring_role()
222 for (i = 0; i < ocelot->num_phys_ports; ++i) { in ocelot_mrp_del_ring_role()
223 ocelot_port = ocelot->ports[i]; in ocelot_mrp_del_ring_role()
228 if (ocelot_port->mrp_ring_id != 0) in ocelot_mrp_del_ring_role()
232 ocelot_mrp_del_mac(ocelot, ocelot->ports[port]); in ocelot_mrp_del_ring_role()