Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: felix: directly call ocelot_port_{set,unset}_dsa_8021q_cpu

Absorb the final details of calling ocelot_port_{,un}set_dsa_8021q_cpu(),
i.e. the need to lock &ocelot->fwd_domain_lock, into the callee, to
simplify the caller and permit easier code reuse later.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
8c166acb a72e23dd

+17 -27
+9 -27
drivers/net/dsa/ocelot/felix.c
··· 240 240 return 0; 241 241 } 242 242 243 - /* Alternatively to using the NPI functionality, that same hardware MAC 244 - * connected internally to the enetc or fman DSA master can be configured to 245 - * use the software-defined tag_8021q frame format. As far as the hardware is 246 - * concerned, it thinks it is a "dumb switch" - the queues of the CPU port 247 - * module are now disconnected from it, but can still be accessed through 248 - * register-based MMIO. 249 - */ 250 - static void felix_8021q_cpu_port_init(struct ocelot *ocelot, int port) 251 - { 252 - mutex_lock(&ocelot->fwd_domain_lock); 253 - 254 - ocelot_port_set_dsa_8021q_cpu(ocelot, port); 255 - 256 - mutex_unlock(&ocelot->fwd_domain_lock); 257 - } 258 - 259 - static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port) 260 - { 261 - mutex_lock(&ocelot->fwd_domain_lock); 262 - 263 - ocelot_port_unset_dsa_8021q_cpu(ocelot, port); 264 - 265 - mutex_unlock(&ocelot->fwd_domain_lock); 266 - } 267 - 268 243 static int felix_trap_get_cpu_port(struct dsa_switch *ds, 269 244 const struct ocelot_vcap_filter *trap) 270 245 { ··· 398 423 return BIT(ocelot->num_phys_ports); 399 424 } 400 425 426 + /* Alternatively to using the NPI functionality, that same hardware MAC 427 + * connected internally to the enetc or fman DSA master can be configured to 428 + * use the software-defined tag_8021q frame format. As far as the hardware is 429 + * concerned, it thinks it is a "dumb switch" - the queues of the CPU port 430 + * module are now disconnected from it, but can still be accessed through 431 + * register-based MMIO. 432 + */ 401 433 static const struct felix_tag_proto_ops felix_tag_npi_proto_ops = { 402 434 .setup = felix_tag_npi_setup, 403 435 .teardown = felix_tag_npi_teardown, ··· 422 440 return err; 423 441 424 442 dsa_switch_for_each_cpu_port(cpu_dp, ds) { 425 - felix_8021q_cpu_port_init(ocelot, cpu_dp->index); 443 + ocelot_port_set_dsa_8021q_cpu(ocelot, cpu_dp->index); 426 444 427 445 /* TODO we could support multiple CPU ports in tag_8021q mode */ 428 446 break; ··· 472 490 } 473 491 474 492 dsa_switch_for_each_cpu_port(cpu_dp, ds) { 475 - felix_8021q_cpu_port_deinit(ocelot, cpu_dp->index); 493 + ocelot_port_unset_dsa_8021q_cpu(ocelot, cpu_dp->index); 476 494 477 495 /* TODO we could support multiple CPU ports in tag_8021q mode */ 478 496 break;
+8
drivers/net/ethernet/mscc/ocelot.c
··· 2195 2195 { 2196 2196 u16 vid; 2197 2197 2198 + mutex_lock(&ocelot->fwd_domain_lock); 2199 + 2198 2200 ocelot->ports[port]->is_dsa_8021q_cpu = true; 2199 2201 2200 2202 for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) ··· 2205 2203 ocelot_update_pgid_cpu(ocelot); 2206 2204 2207 2205 ocelot_apply_bridge_fwd_mask(ocelot, true); 2206 + 2207 + mutex_unlock(&ocelot->fwd_domain_lock); 2208 2208 } 2209 2209 EXPORT_SYMBOL_GPL(ocelot_port_set_dsa_8021q_cpu); 2210 2210 2211 2211 void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port) 2212 2212 { 2213 2213 u16 vid; 2214 + 2215 + mutex_lock(&ocelot->fwd_domain_lock); 2214 2216 2215 2217 ocelot->ports[port]->is_dsa_8021q_cpu = false; 2216 2218 ··· 2224 2218 ocelot_update_pgid_cpu(ocelot); 2225 2219 2226 2220 ocelot_apply_bridge_fwd_mask(ocelot, true); 2221 + 2222 + mutex_unlock(&ocelot->fwd_domain_lock); 2227 2223 } 2228 2224 EXPORT_SYMBOL_GPL(ocelot_port_unset_dsa_8021q_cpu); 2229 2225