xrs700x.c (1758047057dbe329be712a31b79db7151b5871f8) xrs700x.c (b6459415b384cb829f0b2a4268f211c789f6cf0b)
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>
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/etherdevice.h>
8#include <linux/if_bridge.h>
9#include <linux/of_device.h>
10#include <linux/netdev_features.h>
11#include <linux/if_hsr.h>
12#include "xrs700x.h"
13#include "xrs700x_reg.h"
14
15#define XRS700X_MIB_INTERVAL msecs_to_jiffies(3000)

--- 480 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,
9#include <linux/if_bridge.h>
10#include <linux/of_device.h>
11#include <linux/netdev_features.h>
12#include <linux/if_hsr.h>
13#include "xrs700x.h"
14#include "xrs700x_reg.h"
15
16#define XRS700X_MIB_INTERVAL msecs_to_jiffies(3000)

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

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

--- 274 unchanged lines hidden ---