xrs700x.c (41fb0cf1bced59c1fe178cf6cc9f716b5da9e40e) xrs700x.c (d3eed0e57d5d1bcbf1bd60f83a4adfe7d7b8dd9c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2020 NovaTech LLC
4 * George McCollister <george.mccollister@gmail.com>
5 */
6
7#include <net/dsa.h>
8#include <linux/if_bridge.h>

--- 487 unchanged lines hidden (view full) ---

496
497 regmap_fields_write(priv->ps_sel_speed, port, val);
498
499 dev_dbg_ratelimited(priv->dev, "%s: port: %d mode: %u speed: %u\n",
500 __func__, port, mode, speed);
501}
502
503static int xrs700x_bridge_common(struct dsa_switch *ds, int port,
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2020 NovaTech LLC
4 * George McCollister <george.mccollister@gmail.com>
5 */
6
7#include <net/dsa.h>
8#include <linux/if_bridge.h>

--- 487 unchanged lines hidden (view full) ---

496
497 regmap_fields_write(priv->ps_sel_speed, port, val);
498
499 dev_dbg_ratelimited(priv->dev, "%s: port: %d mode: %u speed: %u\n",
500 __func__, port, mode, speed);
501}
502
503static int xrs700x_bridge_common(struct dsa_switch *ds, int port,
504 struct net_device *bridge, bool join)
504 struct dsa_bridge bridge, bool join)
505{
506 unsigned int i, cpu_mask = 0, mask = 0;
507 struct xrs700x *priv = ds->priv;
508 int ret;
509
510 for (i = 0; i < ds->num_ports; i++) {
511 if (dsa_is_cpu_port(ds, i))
512 continue;
513
514 cpu_mask |= BIT(i);
515
505{
506 unsigned int i, cpu_mask = 0, mask = 0;
507 struct xrs700x *priv = ds->priv;
508 int ret;
509
510 for (i = 0; i < ds->num_ports; i++) {
511 if (dsa_is_cpu_port(ds, i))
512 continue;
513
514 cpu_mask |= BIT(i);
515
516 if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) == bridge)
516 if (dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
517 continue;
518
519 mask |= BIT(i);
520 }
521
522 for (i = 0; i < ds->num_ports; i++) {
517 continue;
518
519 mask |= BIT(i);
520 }
521
522 for (i = 0; i < ds->num_ports; i++) {
523 if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != bridge)
523 if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
524 continue;
525
526 /* 1 = Disable forwarding to the port */
527 ret = regmap_write(priv->regmap, XRS_PORT_FWD_MASK(i), mask);
528 if (ret)
529 return ret;
530 }
531
532 if (!join) {
533 ret = regmap_write(priv->regmap, XRS_PORT_FWD_MASK(port),
534 cpu_mask);
535 if (ret)
536 return ret;
537 }
538
539 return 0;
540}
541
542static int xrs700x_bridge_join(struct dsa_switch *ds, int port,
524 continue;
525
526 /* 1 = Disable forwarding to the port */
527 ret = regmap_write(priv->regmap, XRS_PORT_FWD_MASK(i), mask);
528 if (ret)
529 return ret;
530 }
531
532 if (!join) {
533 ret = regmap_write(priv->regmap, XRS_PORT_FWD_MASK(port),
534 cpu_mask);
535 if (ret)
536 return ret;
537 }
538
539 return 0;
540}
541
542static int xrs700x_bridge_join(struct dsa_switch *ds, int port,
543 struct net_device *bridge)
543 struct dsa_bridge bridge)
544{
545 return xrs700x_bridge_common(ds, port, bridge, true);
546}
547
548static void xrs700x_bridge_leave(struct dsa_switch *ds, int port,
544{
545 return xrs700x_bridge_common(ds, port, bridge, true);
546}
547
548static void xrs700x_bridge_leave(struct dsa_switch *ds, int port,
549 struct net_device *bridge)
549 struct dsa_bridge bridge)
550{
551 xrs700x_bridge_common(ds, port, bridge, false);
552}
553
554static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
555 struct net_device *hsr)
556{
557 unsigned int val = XRS_HSR_CFG_HSR_PRP;

--- 274 unchanged lines hidden ---
550{
551 xrs700x_bridge_common(ds, port, bridge, false);
552}
553
554static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
555 struct net_device *hsr)
556{
557 unsigned int val = XRS_HSR_CFG_HSR_PRP;

--- 274 unchanged lines hidden ---