Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1536223

[PATCH v2 net-next v2 1/4] net: dsa: mv88e6xxx: add helper to disable ports

From Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Newsgroups linux.kernel
Subject [PATCH v2 net-next v2 1/4] net: dsa: mv88e6xxx: add helper to disable ports
Date 2016-12-05 17:40 +0100
Message-ID <sL4t3-6UN-1@gated-at.bofh.it> (permalink)
References <sL4jo-6RL-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Before resetting a switch, the ports should be set to the Disabled state
and the transmit queues should be drained.

Add an helper to explicit that.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index ca453f3..1d4d3be 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2356,6 +2356,26 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
 	mutex_unlock(&chip->reg_lock);
 }
 
+static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
+{
+	int i, err;
+
+	/* Set all ports to the Disabled state */
+	for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
+		err = mv88e6xxx_port_set_state(chip, i,
+					       PORT_CONTROL_STATE_DISABLED);
+		if (err)
+			return err;
+	}
+
+	/* Wait for transmit queues to drain,
+	 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
+	 */
+	usleep_range(2000, 4000);
+
+	return 0;
+}
+
 static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
 {
 	bool ppu_active = mv88e6xxx_has(chip, MV88E6XXX_FLAG_PPU_ACTIVE);
@@ -2364,18 +2384,10 @@ static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
 	unsigned long timeout;
 	u16 reg;
 	int err;
-	int i;
 
-	/* Set all ports to the disabled state. */
-	for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
-		err = mv88e6xxx_port_set_state(chip, i,
-					       PORT_CONTROL_STATE_DISABLED);
-		if (err)
-			return err;
-	}
-
-	/* Wait for transmit queues to drain. */
-	usleep_range(2000, 4000);
+	err = mv88e6xxx_disable_ports(chip);
+	if (err)
+		return err;
 
 	/* If there is a gpio connected to the reset pin, toggle it */
 	if (gpiod) {
-- 
2.10.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 net-next v2 0/4] net: dsa: mv88e6xxx: rework reset and PPU code Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-05 17:30 +0100
  [PATCH v2 net-next v2 4/4] net: dsa: mv88e6xxx: add PPU operations Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-05 17:30 +0100
    Re: [PATCH v2 net-next v2 4/4] net: dsa: mv88e6xxx: add PPU  operations Stefan Eichenberger <eichest@gmail.com> - 2016-12-05 22:10 +0100
      Re: [PATCH v2 net-next v2 4/4] net: dsa: mv88e6xxx: add PPU operations Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-05 23:20 +0100
        Re: [PATCH v2 net-next v2 4/4] net: dsa: mv88e6xxx: add PPU operations Stefan Eichenberger <eichest@gmail.com> - 2016-12-06 13:30 +0100
  [PATCH v2 net-next v2 2/4] net: dsa: mv88e6xxx: add helper to hardware reset Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-05 17:30 +0100
  [PATCH v2 net-next v2 1/4] net: dsa: mv88e6xxx: add helper to disable ports Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-05 17:40 +0100
  [PATCH v2 net-next v2 3/4] net: dsa: mv88e6xxx: add a soft reset operation Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-12-05 17:40 +0100
    Re: [PATCH v2 net-next v2 3/4] net: dsa: mv88e6xxx: add a soft reset  operation Stefan Eichenberger <eichest@gmail.com> - 2016-12-05 22:30 +0100

csiph-web