Netdev List
 help / color / mirror / Atom feed
* [PATCH v2 06/11] net: stmmac: dwmac-rk: Add internal phy support for rk3228
From: David Wu @ 2017-07-27 13:02 UTC (permalink / raw)
  To: davem, heiko, andrew, f.fainelli, robh+dt, mark.rutland,
	catalin.marinas, will.deacon, olof, linux, arnd
  Cc: peppe.cavallaro, alexandre.torgue, huangtao, hwg, netdev,
	linux-arm-kernel, linux-rockchip, devicetree, linux-kernel,
	David Wu
In-Reply-To: <1501160540-30662-1-git-send-email-david.wu@rock-chips.com>

There is only one mac controller in rk3228, which could connect to
external phy or internal phy, use the grf_com_mux bit15 to route
external/internal phy.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index ec280d1..3ec9cd8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -86,6 +86,8 @@ struct rk_priv_data {
 #define RK3228_GRF_MAC_CON0	0x0900
 #define RK3228_GRF_MAC_CON1	0x0904
 
+#define RK3228_GRF_CON_MUX	0x50
+
 /* RK3228_GRF_MAC_CON0 */
 #define RK3228_GMAC_CLK_RX_DL_CFG(val)	HIWORD_UPDATE(val, 0x7F, 7)
 #define RK3228_GMAC_CLK_TX_DL_CFG(val)	HIWORD_UPDATE(val, 0x7F, 0)
@@ -111,6 +113,9 @@ struct rk_priv_data {
 #define RK3228_GMAC_RXCLK_DLY_ENABLE	GRF_BIT(1)
 #define RK3228_GMAC_RXCLK_DLY_DISABLE	GRF_CLR_BIT(1)
 
+/* RK3228_GRF_COM_MUX */
+#define RK3228_GRF_CON_MUX_GMAC_INTERNAL_PHY	GRF_BIT(15)
+
 static void rk3228_set_to_rgmii(struct rk_priv_data *bsp_priv,
 				int tx_delay, int rx_delay)
 {
@@ -191,11 +196,18 @@ static void rk3228_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
 		dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
 }
 
+static void rk3228_internal_phy_powerup(struct rk_priv_data *priv)
+{
+	regmap_write(priv->grf, RK3228_GRF_CON_MUX,
+		     RK3228_GRF_CON_MUX_GMAC_INTERNAL_PHY);
+}
+
 static const struct rk_gmac_ops rk3228_ops = {
 	.set_to_rgmii = rk3228_set_to_rgmii,
 	.set_to_rmii = rk3228_set_to_rmii,
 	.set_rgmii_speed = rk3228_set_rgmii_speed,
 	.set_rmii_speed = rk3228_set_rmii_speed,
+	.internal_phy_powerup =  rk3228_internal_phy_powerup,
 };
 
 #define RK3288_GRF_SOC_CON1	0x0248
-- 
1.9.1

^ permalink raw reply related

* [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
From: David Wu @ 2017-07-27 13:02 UTC (permalink / raw)
  To: davem, heiko, andrew, f.fainelli, robh+dt, mark.rutland,
	catalin.marinas, will.deacon, olof, linux, arnd
  Cc: peppe.cavallaro, alexandre.torgue, huangtao, hwg, netdev,
	linux-arm-kernel, linux-rockchip, devicetree, linux-kernel,
	David Wu
In-Reply-To: <1501160156-30328-1-git-send-email-david.wu@rock-chips.com>

To make internal phy work, need to configure the phy_clock,
phy cru_reset and related registers.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
changes in v2:
 - Use the standard "phy-mode" property for internal phy. (Florian)
 - Move the internal macphy clock to the optional properties. (Heiko)

 .../devicetree/bindings/net/rockchip-dwmac.txt     |  4 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 94 +++++++++++++++++++++-
 2 files changed, 93 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
index 8f42755..ecebab8 100644
--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
@@ -25,7 +25,8 @@ Required properties:
  - clock-names: One name for each entry in the clocks property.
  - phy-mode: See ethernet.txt file in the same directory.
  - pinctrl-names: Names corresponding to the numbered pinctrl states.
- - pinctrl-0: pin-control mode. can be <&rgmii_pins> or <&rmii_pins>.
+ - pinctrl-0: pin-control mode. can be <&rgmii_pins>, <&rmii_pins> or led pins
+   for internal phy mode.
  - clock_in_out: For RGMII, it must be "input", means main clock(125MHz)
    is not sourced from SoC's PLL, but input from PHY; For RMII, "input" means
    PHY provides the reference clock(50MHz), "output" means GMAC provides the
@@ -40,6 +41,7 @@ Optional properties:
  - tx_delay: Delay value for TXD timing. Range value is 0~0x7F, 0x30 as default.
  - rx_delay: Delay value for RXD timing. Range value is 0~0x7F, 0x10 as default.
  - phy-supply: phandle to a regulator if the PHY needs one
+ - clocks: <&cru MAC_PHY>: clock for internal macphy
 
 Example:
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index a8e8fd5..ec280d1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -41,6 +41,7 @@ struct rk_gmac_ops {
 	void (*set_to_rmii)(struct rk_priv_data *bsp_priv);
 	void (*set_rgmii_speed)(struct rk_priv_data *bsp_priv, int speed);
 	void (*set_rmii_speed)(struct rk_priv_data *bsp_priv, int speed);
+	void (*internal_phy_powerup)(struct rk_priv_data *bsp_priv);
 };
 
 struct rk_priv_data {
@@ -52,6 +53,7 @@ struct rk_priv_data {
 
 	bool clk_enabled;
 	bool clock_input;
+	bool internal_phy;
 
 	struct clk *clk_mac;
 	struct clk *gmac_clkin;
@@ -61,6 +63,9 @@ struct rk_priv_data {
 	struct clk *clk_mac_refout;
 	struct clk *aclk_mac;
 	struct clk *pclk_mac;
+	struct clk *clk_macphy;
+
+	struct reset_control *macphy_reset;
 
 	int tx_delay;
 	int rx_delay;
@@ -750,6 +755,50 @@ static void rk3399_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
 	.set_rmii_speed = rk3399_set_rmii_speed,
 };
 
+#define RK_GRF_MACPHY_CON0		0xb00
+#define RK_GRF_MACPHY_CON1		0xb04
+#define RK_GRF_MACPHY_CON2		0xb08
+#define RK_GRF_MACPHY_CON3		0xb0c
+
+#define RK_MACPHY_ENABLE		GRF_BIT(0)
+#define RK_MACPHY_DISABLE		GRF_CLR_BIT(0)
+#define RK_MACPHY_CFG_CLK_50M		GRF_BIT(14)
+#define RK_GMAC2PHY_RMII_MODE		(GRF_BIT(6) | GRF_CLR_BIT(7))
+#define RK_GRF_CON2_MACPHY_ID		HIWORD_UPDATE(0x1234, 0xffff, 0)
+#define RK_GRF_CON3_MACPHY_ID		HIWORD_UPDATE(0x35, 0x3f, 0)
+
+static void rk_gmac_internal_phy_powerup(struct rk_priv_data *priv)
+{
+	if (priv->ops->internal_phy_powerup)
+		priv->ops->internal_phy_powerup(priv);
+
+	regmap_write(priv->grf, RK_GRF_MACPHY_CON0, RK_MACPHY_CFG_CLK_50M);
+	regmap_write(priv->grf, RK_GRF_MACPHY_CON0, RK_GMAC2PHY_RMII_MODE);
+
+	regmap_write(priv->grf, RK_GRF_MACPHY_CON2, RK_GRF_CON2_MACPHY_ID);
+	regmap_write(priv->grf, RK_GRF_MACPHY_CON3, RK_GRF_CON3_MACPHY_ID);
+
+	if (priv->macphy_reset) {
+		/* macphy needs to be disabled before trying to reset it */
+		regmap_write(priv->grf, RK_GRF_MACPHY_CON0, RK_MACPHY_DISABLE);
+		if (priv->macphy_reset)
+			reset_control_assert(priv->macphy_reset);
+		usleep_range(10, 20);
+		if (priv->macphy_reset)
+			reset_control_deassert(priv->macphy_reset);
+		usleep_range(10, 20);
+		regmap_write(priv->grf, RK_GRF_MACPHY_CON0, RK_MACPHY_ENABLE);
+		msleep(30);
+	}
+}
+
+static void rk_gmac_internal_phy_powerdown(struct rk_priv_data *priv)
+{
+	regmap_write(priv->grf, RK_GRF_MACPHY_CON0, RK_MACPHY_DISABLE);
+	if (priv->macphy_reset)
+		reset_control_assert(priv->macphy_reset);
+}
+
 static int gmac_clk_init(struct rk_priv_data *bsp_priv)
 {
 	struct device *dev = &bsp_priv->pdev->dev;
@@ -781,7 +830,8 @@ static int gmac_clk_init(struct rk_priv_data *bsp_priv)
 		dev_err(dev, "cannot get clock %s\n",
 			"stmmaceth");
 
-	if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII) {
+	if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII ||
+	    bsp_priv->phy_iface == PHY_INTERFACE_MODE_INTERNAL) {
 		bsp_priv->clk_mac_ref = devm_clk_get(dev, "clk_mac_ref");
 		if (IS_ERR(bsp_priv->clk_mac_ref))
 			dev_err(dev, "cannot get clock %s\n",
@@ -799,10 +849,19 @@ static int gmac_clk_init(struct rk_priv_data *bsp_priv)
 	if (bsp_priv->clock_input) {
 		dev_info(dev, "clock input from PHY\n");
 	} else {
-		if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII)
+		if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII ||
+		    bsp_priv->phy_iface == PHY_INTERFACE_MODE_INTERNAL)
 			clk_set_rate(bsp_priv->clk_mac, 50000000);
 	}
 
+	if (bsp_priv->internal_phy) {
+		bsp_priv->clk_macphy = devm_clk_get(dev, "clk_macphy");
+		if (IS_ERR(bsp_priv->clk_macphy))
+			dev_err(dev, "cannot get %s clock\n", "clk_macphy");
+		else
+			clk_set_rate(bsp_priv->clk_macphy, 50000000);
+	}
+
 	return 0;
 }
 
@@ -812,7 +871,8 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 
 	if (enable) {
 		if (!bsp_priv->clk_enabled) {
-			if (phy_iface == PHY_INTERFACE_MODE_RMII) {
+			if (phy_iface == PHY_INTERFACE_MODE_RMII ||
+			    phy_iface == PHY_INTERFACE_MODE_INTERNAL) {
 				if (!IS_ERR(bsp_priv->mac_clk_rx))
 					clk_prepare_enable(
 						bsp_priv->mac_clk_rx);
@@ -826,6 +886,9 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 						bsp_priv->clk_mac_refout);
 			}
 
+			if (!IS_ERR(bsp_priv->clk_macphy))
+				clk_prepare_enable(bsp_priv->clk_macphy);
+
 			if (!IS_ERR(bsp_priv->aclk_mac))
 				clk_prepare_enable(bsp_priv->aclk_mac);
 
@@ -844,7 +907,8 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 		}
 	} else {
 		if (bsp_priv->clk_enabled) {
-			if (phy_iface == PHY_INTERFACE_MODE_RMII) {
+			if (phy_iface == PHY_INTERFACE_MODE_RMII ||
+			    phy_iface == PHY_INTERFACE_MODE_INTERNAL) {
 				if (!IS_ERR(bsp_priv->mac_clk_rx))
 					clk_disable_unprepare(
 						bsp_priv->mac_clk_rx);
@@ -858,6 +922,9 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
 						bsp_priv->clk_mac_refout);
 			}
 
+			if (!IS_ERR(bsp_priv->clk_macphy))
+				clk_disable_unprepare(bsp_priv->clk_macphy);
+
 			if (!IS_ERR(bsp_priv->aclk_mac))
 				clk_disable_unprepare(bsp_priv->aclk_mac);
 
@@ -940,6 +1007,17 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
 			bsp_priv->clock_input = false;
 	}
 
+	if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_INTERNAL) {
+		bsp_priv->internal_phy = true;
+		bsp_priv->macphy_reset = devm_reset_control_get(dev, "mac-phy");
+		if (IS_ERR(bsp_priv->macphy_reset)) {
+			dev_info(dev, "no macphy_reset control found\n");
+			bsp_priv->macphy_reset = NULL;
+		}
+	}
+	dev_info(dev, "internal PHY? (%s).\n",
+		 bsp_priv->internal_phy ? "yes" : "no");
+
 	ret = of_property_read_u32(dev->of_node, "tx_delay", &value);
 	if (ret) {
 		bsp_priv->tx_delay = 0x30;
@@ -1000,6 +1078,7 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
 		bsp_priv->ops->set_to_rgmii(bsp_priv, 0, bsp_priv->rx_delay);
 		break;
 	case PHY_INTERFACE_MODE_RMII:
+	case PHY_INTERFACE_MODE_INTERNAL:
 		dev_info(dev, "init for RMII\n");
 		bsp_priv->ops->set_to_rmii(bsp_priv);
 		break;
@@ -1014,6 +1093,9 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);
 
+	if (bsp_priv->internal_phy)
+		rk_gmac_internal_phy_powerup(bsp_priv);
+
 	return 0;
 }
 
@@ -1021,6 +1103,9 @@ static void rk_gmac_powerdown(struct rk_priv_data *gmac)
 {
 	struct device *dev = &gmac->pdev->dev;
 
+	if (gmac->internal_phy)
+		rk_gmac_internal_phy_powerdown(gmac);
+
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);
 
@@ -1041,6 +1126,7 @@ static void rk_fix_speed(void *priv, unsigned int speed)
 		bsp_priv->ops->set_rgmii_speed(bsp_priv, speed);
 		break;
 	case PHY_INTERFACE_MODE_RMII:
+	case PHY_INTERFACE_MODE_INTERNAL:
 		bsp_priv->ops->set_rmii_speed(bsp_priv, speed);
 		break;
 	default:
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH net] udp6: fix socket leak on early demux
From: Paolo Abeni @ 2017-07-27 12:56 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Eric Dumazet, Sam Edwards, Marc Haber,
	Subash Abhinov Kasiviswanathan
In-Reply-To: <714e32ad7eb21b0b791ecc314cfcc16765c96cd9.1501159497.git.pabeni@redhat.com>

Hi David,

I'm sorry but I'm really too low on coffee and I missed adding the
proper v2 tag in the subject. Please let me know if you prefer I repost
with a proper subject or if you prefer otherwise.

Thanks!

Paolo

^ permalink raw reply

* [PATCH v2 03/11] arm64: defconfig: Enable CONFIG_ROCKCHIP_PHY
From: David Wu @ 2017-07-27 12:55 UTC (permalink / raw)
  To: davem, heiko, andrew, f.fainelli, robh+dt, mark.rutland,
	catalin.marinas, will.deacon, olof, linux, arnd
  Cc: peppe.cavallaro, alexandre.torgue, huangtao, hwg, netdev,
	linux-arm-kernel, linux-rockchip, devicetree, linux-kernel,
	David Wu
In-Reply-To: <1501160156-30328-1-git-send-email-david.wu@rock-chips.com>

Make the rockchip phy driver built into the kernel.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 6c7d147..925bd478 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -203,6 +203,7 @@ CONFIG_MARVELL_PHY=m
 CONFIG_MESON_GXL_PHY=m
 CONFIG_MICREL_PHY=y
 CONFIG_REALTEK_PHY=m
+CONFIG_ROCKCHIP_PHY=y
 CONFIG_USB_PEGASUS=m
 CONFIG_USB_RTL8150=m
 CONFIG_USB_RTL8152=m
-- 
1.9.1

^ permalink raw reply related

* [PATCH v2 02/11] multi_v7_defconfig: Make rockchip phy built-in
From: David Wu @ 2017-07-27 12:55 UTC (permalink / raw)
  To: davem, heiko, andrew, f.fainelli, robh+dt, mark.rutland,
	catalin.marinas, will.deacon, olof, linux, arnd
  Cc: huangtao, hwg, alexandre.torgue, devicetree, netdev, linux-kernel,
	linux-rockchip, David Wu, peppe.cavallaro, linux-arm-kernel
In-Reply-To: <1501160156-30328-1-git-send-email-david.wu@rock-chips.com>

Enable the rockchip phy for multi_v7_defconfig builds.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 4d19c1b..94d7e71 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -270,6 +270,7 @@ CONFIG_ICPLUS_PHY=y
 CONFIG_REALTEK_PHY=y
 CONFIG_MICREL_PHY=y
 CONFIG_FIXED_PHY=y
+CONFIG_ROCKCHIP_PHY=y
 CONFIG_USB_PEGASUS=y
 CONFIG_USB_RTL8152=m
 CONFIG_USB_USBNET=y
-- 
1.9.1

^ permalink raw reply related

* [PATCH v2 01/11] net: phy: Add rockchip phy driver support
From: David Wu @ 2017-07-27 12:55 UTC (permalink / raw)
  To: davem, heiko, andrew, f.fainelli, robh+dt, mark.rutland,
	catalin.marinas, will.deacon, olof, linux, arnd
  Cc: huangtao, hwg, alexandre.torgue, devicetree, netdev, linux-kernel,
	linux-rockchip, David Wu, peppe.cavallaro, linux-arm-kernel
In-Reply-To: <1501160156-30328-1-git-send-email-david.wu@rock-chips.com>

Support internal ephy currently.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
changes in v2:
 - Alphabetic order for Kconfig and Makefile.
 - Add analog register init.
 - Disable auto-mdix for workround.
 - Rename config

 drivers/net/phy/Kconfig    |   5 ++
 drivers/net/phy/Makefile   |   1 +
 drivers/net/phy/rockchip.c | 128 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+)
 create mode 100644 drivers/net/phy/rockchip.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 2dda720..8dc6cd7 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -334,6 +334,11 @@ config REALTEK_PHY
 	---help---
 	  Supports the Realtek 821x PHY.
 
+config ROCKCHIP_PHY
+        tristate "Drivers for ROCKCHIP PHYs"
+        ---help---
+          Currently supports the internal ephy.
+
 config SMSC_PHY
 	tristate "SMSC PHYs"
 	---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 8e9b9f3..350520e 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_MICROSEMI_PHY)	+= mscc.o
 obj-$(CONFIG_NATIONAL_PHY)	+= national.o
 obj-$(CONFIG_QSEMI_PHY)		+= qsemi.o
 obj-$(CONFIG_REALTEK_PHY)	+= realtek.o
+obj-$(CONFIG_ROCKCHIP_PHY)	+= rockchip.o
 obj-$(CONFIG_SMSC_PHY)		+= smsc.o
 obj-$(CONFIG_STE10XP)		+= ste10Xp.o
 obj-$(CONFIG_TERANETICS_PHY)	+= teranetics.o
diff --git a/drivers/net/phy/rockchip.c b/drivers/net/phy/rockchip.c
new file mode 100644
index 0000000..3f74658
--- /dev/null
+++ b/drivers/net/phy/rockchip.c
@@ -0,0 +1,128 @@
+/**
+ * drivers/net/phy/rockchip.c
+ *
+ * Driver for ROCKCHIP PHY
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * David Wu<david.wu@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/phy.h>
+#include <linux/netdevice.h>
+
+#define MII_INTERNAL_CTRL_STATUS	17
+#define SMI_ADDR_TSTCNTL		20
+#define SMI_ADDR_TSTREAD1		21
+#define SMI_ADDR_TSTREAD2		22
+#define SMI_ADDR_TSTWRITE		23
+
+#define AUTOMDIX_EN			BIT(7)
+#define TSTCNTL_RD			(BIT(15) | BIT(10))
+#define TSTCNTL_WR          		(BIT(14) | BIT(10))
+
+#define WR_ADDR_A7CFG			0x18
+
+static void rockchip_init_tstmode(struct phy_device *phydev)
+{
+	/* Enable access to Analog and DSP register banks */
+	phy_write(phydev, SMI_ADDR_TSTCNTL, 0x0400);
+	phy_write(phydev, SMI_ADDR_TSTCNTL, 0x0000);
+	phy_write(phydev, SMI_ADDR_TSTCNTL, 0x0400);
+}
+
+static void  rockchip_close_tstmode(struct phy_device *phydev)
+{
+	/* Back to basic register bank */
+	phy_write(phydev, SMI_ADDR_TSTCNTL, 0x0000);
+}
+
+static void rockchip_internal_phy_analog_init(struct phy_device *phydev)
+{
+	rockchip_init_tstmode(phydev);
+
+	/*
+	 * Adjust tx amplitude to make sginal better,
+	 * the default value is 0x8.
+	 */
+	phy_write(phydev, SMI_ADDR_TSTWRITE, 0xB);
+	phy_write(phydev, SMI_ADDR_TSTCNTL, TSTCNTL_WR | WR_ADDR_A7CFG);
+
+	rockchip_close_tstmode(phydev);
+}
+
+static int rockchip_internal_phy_config_init(struct phy_device *phydev)
+{
+	int val;
+
+	/*
+	 * The auto MIDX has linked problem on some board,
+	 * workround to disable auto MDIX.
+	 */
+	val = phy_read(phydev, MII_INTERNAL_CTRL_STATUS);
+	val &= ~AUTOMDIX_EN;
+	phy_write(phydev, MII_INTERNAL_CTRL_STATUS, val);
+
+	rockchip_internal_phy_analog_init(phydev);
+
+	return 0;
+}
+
+static int rockchip_internal_phy_read_status(struct phy_device *phydev)
+{
+	int ret, old_speed;
+
+	old_speed = phydev->speed;
+	ret = genphy_read_status(phydev);
+	if (ret)
+		return ret;
+
+	/*
+	 * If mode switch happens from 10BT to 100BT, all DSP/AFE
+	 * registers are set to default values. So any AFE/DSP
+	 * registers have to be re-initialized in this case.
+	 */
+	if ((old_speed == SPEED_10) && (phydev->speed == SPEED_100))
+		rockchip_internal_phy_analog_init(phydev);
+
+	return ret;
+}
+
+static struct phy_driver rockchip_phy_driver[] = {
+{
+	.phy_id 	= 0x1234d400,
+	.phy_id_mask	= 0xffff0000,
+	.name		= "rockchip internal ephy",
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+			  | SUPPORTED_Asym_Pause),
+	.soft_reset 	= genphy_soft_reset,
+	.config_init	= rockchip_internal_phy_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= rockchip_internal_phy_read_status,
+	.suspend	= genphy_suspend,
+	.resume 	= genphy_resume,
+},
+};
+
+module_phy_driver(rockchip_phy_driver);
+
+static struct mdio_device_id __maybe_unused rockchip_phy_tbl[] = {
+	{ 0x1234d400, 0xffff0000 },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(mdio, rockchip_phy_tbl);
+
+MODULE_AUTHOR("David Wu<david.wu@rock-chips.com>");
+MODULE_DESCRIPTION("Rockchip phy driver");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

^ permalink raw reply related

* [PATCH v2 00/11] Add the internal phy support
From: David Wu @ 2017-07-27 12:55 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q, heiko-4mtYJXux2i+zQB+pC5nmwQ,
	andrew-g2DYL2Zd6BY, f.fainelli-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	catalin.marinas-5wv7dgnIgG8, will.deacon-5wv7dgnIgG8,
	olof-nZhT3qVonbNeoWH0uzbU5w, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	arnd-r2nGTMty4D4
  Cc: peppe.cavallaro-qxv4g6HH51o, alexandre.torgue-qxv4g6HH51o,
	huangtao-TNX95d0MmH7DzftRWevZcw, hwg-TNX95d0MmH7DzftRWevZcw,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Wu

The rk3228 and rk3328 support internal phy inside, let's enable
it to work. And the internal phy need to do some special setting, so
register the rockchip internal phy driver.

David Wu (11):
  net: phy: Add rockchip phy driver support
  multi_v7_defconfig: Make rockchip phy built-in
  arm64: defconfig: Enable CONFIG_ROCKCHIP_PHY
  net: stmmac: dwmac-rk: Remove unwanted code for rk3328_set_to_rmii()
  net: stmmac: dwmac-rk: Add internal phy support
  net: stmmac: dwmac-rk: Add internal phy support for rk3228
  net: stmmac: dwmac-rk: Add internal phy supprot for rk3328
  ARM: dts: rk322x: Add support internal phy for gmac
  ARM: dts: rk3228-evb: Enable the internal phy for gmac
  ARM64: dts: rockchip: Add gmac2phy node support for rk3328
  ARM64: dts: rockchip: Enable gmac2phy for rk3328-evb

 .../devicetree/bindings/net/rockchip-dwmac.txt     |   4 +-
 arch/arm/boot/dts/rk3228-evb.dts                   |  19 +++
 arch/arm/boot/dts/rk322x.dtsi                      |   8 +-
 arch/arm/configs/multi_v7_defconfig                |   1 +
 arch/arm64/boot/dts/rockchip/rk3328-evb.dts        |  17 +++
 arch/arm64/boot/dts/rockchip/rk3328.dtsi           |  24 ++++
 arch/arm64/configs/defconfig                       |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 135 +++++++++++++++++++--
 drivers/net/phy/Kconfig                            |   5 +
 drivers/net/phy/Makefile                           |   1 +
 drivers/net/phy/rockchip.c                         | 128 +++++++++++++++++++
 11 files changed, 328 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/phy/rockchip.c

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH v2 04/11] net: stmmac: dwmac-rk: Remove unwanted code for rk3328_set_to_rmii()
From: David Wu @ 2017-07-27 12:55 UTC (permalink / raw)
  To: davem, heiko, andrew, f.fainelli, robh+dt, mark.rutland,
	catalin.marinas, will.deacon, olof, linux, arnd
  Cc: peppe.cavallaro, alexandre.torgue, huangtao, hwg, netdev,
	linux-arm-kernel, linux-rockchip, devicetree, linux-kernel,
	David Wu
In-Reply-To: <1501160156-30328-1-git-send-email-david.wu@rock-chips.com>

This is wrong setting for rk3328_set_to_rmii(), so remove it.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index f0df519..a8e8fd5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -365,9 +365,6 @@ static void rk3328_set_to_rmii(struct rk_priv_data *bsp_priv)
 	regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1,
 		     RK3328_GMAC_PHY_INTF_SEL_RMII |
 		     RK3328_GMAC_RMII_MODE);
-
-	/* set MAC to RMII mode */
-	regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1, GRF_BIT(11));
 }
 
 static void rk3328_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed)
-- 
1.9.1

^ permalink raw reply related

* [PATCH net] udp6: fix socket leak on early demux
From: Paolo Abeni @ 2017-07-27 12:45 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Eric Dumazet, Sam Edwards, Marc Haber,
	Subash Abhinov Kasiviswanathan

When an early demuxed packet reaches __udp6_lib_lookup_skb(), the
sk reference is retrieved and used, but the relevant reference
count is leaked and the socket destructor is never called.
Beyond leaking the sk memory, if there are pending UDP packets
in the receive queue, even the related accounted memory is leaked.

In the long run, this will cause persistent forward allocation errors
and no UDP skbs (both ipv4 and ipv6) will be able to reach the
user-space.

Fix this by explicitly accessing the early demux reference before
the lookup, and properly decreasing the socket reference count
after usage.

Also drop the skb_steal_sock() in __udp6_lib_lookup_skb(), and
the now obsoleted comment about "socket cache".

The newly added code is derived from the current ipv4 code for the
similar path.

v1 -> v2:
  fixed the __udp6_lib_rcv() return code for resubmission,
  as suggested by Eric

Reported-by: Sam Edwards <CFSworks@gmail.com>
Reported-by: Marc Haber <mh+netdev@zugschlus.de>
Fixes: 5425077d73e0 ("net: ipv6: Add early demux handler for UDP unicast")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 include/net/udp.h |  1 +
 net/ipv4/udp.c    |  3 ++-
 net/ipv6/udp.c    | 27 ++++++++++++++++++---------
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/include/net/udp.h b/include/net/udp.h
index 56ce2d2a612d..cc8036987dcb 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -260,6 +260,7 @@ static inline struct sk_buff *skb_recv_udp(struct sock *sk, unsigned int flags,
 }
 
 void udp_v4_early_demux(struct sk_buff *skb);
+void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst);
 int udp_get_port(struct sock *sk, unsigned short snum,
 		 int (*saddr_cmp)(const struct sock *,
 				  const struct sock *));
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index fac7cb9e3b0f..e6276fa3750b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1928,7 +1928,7 @@ static int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 /* For TCP sockets, sk_rx_dst is protected by socket lock
  * For UDP, we use xchg() to guard against concurrent changes.
  */
-static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
+void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
 {
 	struct dst_entry *old;
 
@@ -1937,6 +1937,7 @@ static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
 		dst_release(old);
 	}
 }
+EXPORT_SYMBOL(udp_sk_rx_dst_set);
 
 /*
  *	Multicasts and broadcasts go to each listener.
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4a3e65626e8b..98fe4560e24c 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -291,11 +291,7 @@ static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
 					  struct udp_table *udptable)
 {
 	const struct ipv6hdr *iph = ipv6_hdr(skb);
-	struct sock *sk;
 
-	sk = skb_steal_sock(skb);
-	if (unlikely(sk))
-		return sk;
 	return __udp6_lib_lookup(dev_net(skb->dev), &iph->saddr, sport,
 				 &iph->daddr, dport, inet6_iif(skb),
 				 udptable, skb);
@@ -804,6 +800,24 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	if (udp6_csum_init(skb, uh, proto))
 		goto csum_error;
 
+	/* Check if the socket is already available, e.g. due to early demux */
+	sk = skb_steal_sock(skb);
+	if (sk) {
+		struct dst_entry *dst = skb_dst(skb);
+		int ret;
+
+		if (unlikely(sk->sk_rx_dst != dst))
+			udp_sk_rx_dst_set(sk, dst);
+
+		ret = udpv6_queue_rcv_skb(sk, skb);
+		sock_put(sk);
+
+		/* a return value > 0 means to resubmit the input */
+		if (ret > 0)
+			return ret;
+		return 0;
+	}
+
 	/*
 	 *	Multicast receive code
 	 */
@@ -812,11 +826,6 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 				saddr, daddr, udptable, proto);
 
 	/* Unicast */
-
-	/*
-	 * check socket cache ... must talk to Alan about his plans
-	 * for sock caches... i'll skip this for now.
-	 */
 	sk = __udp6_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
 	if (sk) {
 		int ret;
-- 
2.13.3

^ permalink raw reply related

* Re: [PATCH 05/11] net: stmmac: dwmac-rk: Add internal phy support
From: David.Wu @ 2017-07-27 12:44 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: davem, heiko, robh+dt, mark.rutland, catalin.marinas, will.deacon,
	olof, linux, arnd, f.fainelli, peppe.cavallaro, alexandre.torgue,
	huangtao, hwg, netdev, linux-arm-kernel, linux-rockchip,
	devicetree, linux-kernel
In-Reply-To: <20170624022954.GD4875@lunn.ch>

Hi Andrew,

在 2017/6/24 10:29, Andrew Lunn 写道:
> If this is the PHY clock, should it actually be specified in the PHY
> binding? Can you read the PHY ID registers with this clock off?
If the phy clock is closed, we can not read the PHYID.

^ permalink raw reply

* [PATCH V3 net-next] TLP: Don't reschedule PTO when there's one outstanding TLP retransmission
From: Mao Wenan @ 2017-07-27 12:08 UTC (permalink / raw)
  To: netdev, davem, ncardwell, ycheng, nanditad, weiyongjun1,
	chenweilong, wangkefeng.wang

If there is one TLP probe went out(TLP use the write_queue_tail
packet as TLP probe, we assume this first TLP probe named A), and
this TLP probe was not acked by receive side.

Then the transmit side sent the next two packetes out(named B,C),
but unfortunately these two packets are also not acked by receive side.

And then there is one data packet with ack_seq A arrive at transmit
side, in tcp_ack() will call tcp_schedule_loss_probe() to rearm PTO,
the handler tcp_send_loss_probe() is to check
if(tp->tlp_high_seq) then go to rearm_timer(because there is one
outstanding TLP named A), so the new TLP probe can't be sent out and
it needs to rearm the RTO timer(timeout is relative to the transmit
time of the write queue head).

After that, there is another data packet with ack_seq A is received,
if the tlp_time_stamp is greater than rto_time_stamp, it will reset
the TLP timeout, which is before previous RTO timeout, so PTO is
rearm and previous RTO is cleared. Because there is no
retransmission packet was sent or no TLP sack receive,
tp->tlp_high_seq can't be reset to zero and the next TLP probe also
can't be sent out, so there is no way(or very long time)
to retransmit the lost packet.

This fix is to check(tp->tlp_high_seq) in tcp_schedule_loss_probe()
when TLP PTO is after RTO, It is not needed to reschedule PTO when
there is one outstanding TLP retransmission, so if the TLP A is lost
RTO can retransmit lost packet, then tp->tlp_high_seq will be set to
0, and TLP will go to the normal work process.

v1->v2
	refine some words of code and patch comments.
v2->v3
	delete senseless "{" and "}" in if clause.

Signed-off-by: Mao Wenan <maowenan@huawei.com>
---
 net/ipv4/tcp_output.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 886d874..b59975f 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2377,6 +2377,7 @@ bool tcp_schedule_loss_probe(struct sock *sk)
 	struct inet_connection_sock *icsk = inet_csk(sk);
 	struct tcp_sock *tp = tcp_sk(sk);
 	u32 timeout, tlp_time_stamp, rto_time_stamp;
+	s32 delta;
 
 	/* No consecutive loss probes. */
 	if (WARN_ON(icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)) {
@@ -2423,7 +2424,12 @@ bool tcp_schedule_loss_probe(struct sock *sk)
 	tlp_time_stamp = tcp_jiffies32 + timeout;
 	rto_time_stamp = (u32)inet_csk(sk)->icsk_timeout;
 	if ((s32)(tlp_time_stamp - rto_time_stamp) > 0) {
-		s32 delta = rto_time_stamp - tcp_jiffies32;
+		/* It is not needed to reschedule PTO when there 
+		 * is one outstanding TLP retransmission. 
+		 */
+		if (tp->tlp_high_seq)
+			return false;
+		delta = rto_time_stamp - tcp_jiffies32;
 		if (delta > 0)
 			timeout = delta;
 	}
-- 
2.5.0

^ permalink raw reply related

* Re: [net 02/14] net/mlx5: Consider tx_enabled in all modes on remap
From: Sergei Shtylyov @ 2017-07-27 11:55 UTC (permalink / raw)
  To: Saeed Mahameed, David S. Miller; +Cc: netdev, Aviv Heller
In-Reply-To: <20170727102532.2317-3-saeedm@mellanox.com>

Hello!

On 07/27/2017 01:25 PM, Saeed Mahameed wrote:

> From: Aviv Heller <avivh@mellanox.com>
>
> The tx_enabled lag event field is used to determine whether a slave is
> active.
> Current logic uses this value only if the mode is active-backup.
>
> However, LACP mode, although considered a load balancing mode, can mark
> a slave as inactive in certain situations (e.g., LACP timeout).
>
> This fix takes the tx_enabled value into account when remapping, with
> no respect to the LAG mode (this should not affect the behavior in XOR
> mode, since in this mode both slaves are marked as active).
>
> Fixes: 7907f23adc18 (net/mlx5: Implement RoCE LAG feature)
> Signed-off-by: Aviv Heller <avivh@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/lag.c | 26 +++++++++++---------------
>  1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
> index a3a836bdcfd2..654b02e7d1aa 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c
> @@ -162,21 +162,17 @@ static bool mlx5_lag_is_bonded(struct mlx5_lag *ldev)
>  static void mlx5_infer_tx_affinity_mapping(struct lag_tracker *tracker,
>  					   u8 *port1, u8 *port2)
>  {
> -	if (tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP) {
> -		if (tracker->netdev_state[0].tx_enabled) {
> -			*port1 = 1;
> -			*port2 = 1;
> -		} else {
> -			*port1 = 2;
> -			*port2 = 2;
> -		}
> -	} else {
> -		*port1 = 1;
> -		*port2 = 2;
> -		if (!tracker->netdev_state[0].link_up)
> -			*port1 = 2;
> -		else if (!tracker->netdev_state[1].link_up)
> -			*port2 = 1;
> +	*port1 = 1;
> +	*port2 = 2;
> +	if (!tracker->netdev_state[0].tx_enabled ||
> +	    !tracker->netdev_state[0].link_up) {
> +		*port1 = 2;
> +		return;
> +	}
> +
> +	if (!tracker->netdev_state[1].tx_enabled ||
> +	    !tracker->netdev_state[1].link_up) {
> +		*port2 = 1;
>  	}

    {} not needed here.

[...]

MBR, Sergei

^ permalink raw reply

* Re: [PATCH net-next v2 07/10] net: dsa: lan9303: Added basic offloading of unicast traffic
From: Egil Hjelmeland @ 2017-07-27 11:21 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: corbet, vivien.didelot, f.fainelli, davem, kernel, linux-doc,
	linux-kernel, netdev
In-Reply-To: <20170726172443.GR12049@lunn.ch>

On 26. juli 2017 19:24, Andrew Lunn wrote:
> Hi Egil
> 
>> +/* forward special tagged packets from port 0 to port 1 *or* port 2 */
>> +static int lan9303_setup_tagging(struct lan9303 *chip)
>> +{
>> +	int ret;
> 
> Blank line please.
> 
> 
>> +	/* enable defining the destination port via special VLAN tagging
>> +	 * for port 0
>> +	 */
>> +	ret = lan9303_write_switch_reg(chip, LAN9303_SWE_INGRESS_PORT_TYPE,
>> +				       0x03);
> 
> #define for 0x03.
> 
>> +	if (ret)
>> +		return ret;
>> +
>> +	/* tag incoming packets at port 1 and 2 on their way to port 0 to be
>> +	 * able to discover their source port
>> +	 */
>> +	return lan9303_write_switch_reg(
>> +		chip, LAN9303_BM_EGRSS_PORT_TYPE,
>> +		LAN9303_BM_EGRSS_PORT_TYPE_SPECIAL_TAG_PORT0);
>> +}
>> +
>>   /* We want a special working switch:
>>    * - do not forward packets between port 1 and 2
>>    * - forward everything from port 1 to port 0
>>    * - forward everything from port 2 to port 0
>> - * - forward special tagged packets from port 0 to port 1 *or* port 2
>>    */
>>   static int lan9303_separate_ports(struct lan9303 *chip)
>>   {
>> @@ -534,22 +555,6 @@ static int lan9303_separate_ports(struct lan9303 *chip)
>>   	if (ret)
>>   		return ret;
>>   
>> -	/* enable defining the destination port via special VLAN tagging
>> -	 * for port 0
>> -	 */
>> -	ret = lan9303_write_switch_reg(chip, LAN9303_SWE_INGRESS_PORT_TYPE,
>> -				       0x03);
>> -	if (ret)
>> -		return ret;
>> -
>> -	/* tag incoming packets at port 1 and 2 on their way to port 0 to be
>> -	 * able to discover their source port
>> -	 */
>> -	ret = lan9303_write_switch_reg(chip, LAN9303_BM_EGRSS_PORT_TYPE,
>> -			LAN9303_BM_EGRSS_PORT_TYPE_SPECIAL_TAG_PORT0);
>> -	if (ret)
>> -		return ret;
>> -
>>   	/* prevent port 1 and 2 from forwarding packets by their own */
>>   	return lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_STATE,
>>   				LAN9303_SWE_PORT_STATE_FORWARDING_PORT0 |
>> @@ -557,6 +562,12 @@ static int lan9303_separate_ports(struct lan9303 *chip)
>>   				LAN9303_SWE_PORT_STATE_BLOCKING_PORT2);
>>   }
>>   
>> +static void lan9303_bridge_ports(struct lan9303 *chip)
>> +{
>> +	/* ports bridged: remove mirroring */
>> +	lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_MIRROR, 0);
>> +}
>> +
>>   static int lan9303_handle_reset(struct lan9303 *chip)
>>   {
>>   	if (!chip->reset_gpio)
>> @@ -707,6 +718,10 @@ static int lan9303_setup(struct dsa_switch *ds)
>>   		return -EINVAL;
>>   	}
>>   
>> +	ret = lan9303_setup_tagging(chip);
>> +	if (ret)
>> +		dev_err(chip->dev, "failed to setup port tagging %d\n", ret);
>> +
>>   	ret = lan9303_separate_ports(chip);
>>   	if (ret)
>>   		dev_err(chip->dev, "failed to separate ports %d\n", ret);
>> @@ -898,17 +913,81 @@ static void lan9303_port_disable(struct dsa_switch *ds, int port,
>>   	}
>>   }
>>   
>> +static int lan9303_port_bridge_join(struct dsa_switch *ds, int port,
>> +				    struct net_device *br)
>> +{
>> +	struct lan9303 *chip = ds->priv;
>> +
>> +	dev_dbg(chip->dev, "%s(port %d)\n", __func__, port);
>> +	if (ds->ports[1].bridge_dev ==  ds->ports[2].bridge_dev) {
>> +		lan9303_bridge_ports(chip);
>> +		chip->is_bridged = true;  /* unleash stp_state_set() */
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static void lan9303_port_bridge_leave(struct dsa_switch *ds, int port,
>> +				      struct net_device *br)
>> +{
>> +	struct lan9303 *chip = ds->priv;
>> +
>> +	dev_dbg(chip->dev, "%s(port %d)\n", __func__, port);
>> +	if (chip->is_bridged) {
>> +		lan9303_separate_ports(chip);
>> +		chip->is_bridged = false;
>> +	}
>> +}
>> +
>> +static void lan9303_port_stp_state_set(struct dsa_switch *ds, int port,
>> +				       u8 state)
>> +{
>> +	int portmask, portstate;
>> +	struct lan9303 *chip = ds->priv;
>> +
>> +	dev_dbg(chip->dev, "%s(port %d, state %d)\n",
>> +		__func__, port, state);
>> +	if (!chip->is_bridged)
>> +		return;
> 
> I think you are over-simplifying here. Say i have a layer 2 VPN and i
> bridge port 1 and the VPN? The software bridge still wants to do STP
> on port 1, in order to solve loops.
> 

Problem is that the mainline lan9303_separate_ports() does its
work by setting port 1 & 2 in STP BLOCKING state (and port 0 in
FORWARDING state). So my understanding is that it would break port
separation if LAN9303_SWE_PORT_STATE is written while the driver
is in the non-bridged state.

I thought the SW bridge would carry doing its STP work even if
there is a port_stp_state_set method on a DSA port?

>> +
>> +	switch (state) {
>> +	case BR_STATE_DISABLED:
>> +		portstate = LAN9303_SWE_PORT_STATE_DISABLED_PORT0;
>> +		break;
>> +	case BR_STATE_BLOCKING:
>> +	case BR_STATE_LISTENING:
>> +		portstate = LAN9303_SWE_PORT_STATE_BLOCKING_PORT0;
>> +		break;
>> +	case BR_STATE_LEARNING:
>> +		portstate = LAN9303_SWE_PORT_STATE_LEARNING_PORT0;
>> +		break;
>> +	case BR_STATE_FORWARDING:
>> +		portstate = LAN9303_SWE_PORT_STATE_FORWARDING_PORT0;
>> +		break;
>> +	default:
>> +		dev_err(chip->dev, "%s(port %d, state %d)\n",
>> +			__func__, port, state);
>> +	}
>> +	portmask = 0x3 << (port * 2);
>> +	portstate     <<= (port * 2);
>> +	lan9303_write_switch_reg_mask(chip, LAN9303_SWE_PORT_STATE,
>> +				      portstate, portmask);
>> +}
> 
> 
> 
> 
>> +
>>   static struct dsa_switch_ops lan9303_switch_ops = {
>>   	.get_tag_protocol = lan9303_get_tag_protocol,
>>   	.setup = lan9303_setup,
>> -	.get_strings = lan9303_get_strings,
> 
> ????
> 
>>   	.phy_read = lan9303_phy_read,
>>   	.phy_write = lan9303_phy_write,
>>   	.adjust_link = lan9303_adjust_link,
>> +	.get_strings = lan9303_get_strings,
> 
> Please don't include other unrelated changes.
> 
>         Andrew
> 


^ permalink raw reply

* [PATCH net] intersil/hostap: Fix outdated comment about dev->destructor
From: Stefano Brivio @ 2017-07-27 11:20 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: David S . Miller, Kalle Valo, Jouni Malinen,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA

After commit cf124db566e6 ("net: Fix inconsistent teardown and
release of private netdev state."), setting
'dev->needs_free_netdev' ensures device data is released, and
'dev->destructor' is not used anymore.

Fixes: cf124db566e6 ("net: Fix inconsistent teardown and release of private netdev state.")
Signed-off-by: Stefano Brivio <sbrivio-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
Despite checkpatch.pl warning against unnecessary changes, this
outdated comment might lead to confusion -- making this change
actually necessary, perhaps.

 drivers/net/wireless/intersil/hostap/hostap_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_main.c b/drivers/net/wireless/intersil/hostap/hostap_main.c
index a3c066f90afc..012930d35434 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_main.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_main.c
@@ -125,8 +125,8 @@ void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
 	else
 		unregister_netdev(dev);
 
-	/* dev->destructor = free_netdev() will free the device data, including
-	 * private data, when removing the device */
+	/* 'dev->needs_free_netdev = true' implies device data, including
+	 * private data, will be freed when the device is removed */
 }
 
 
-- 
2.9.4

^ permalink raw reply related

* Re: [PATCH net-next v2 08/10] net: dsa: lan9303: Added ALR/fdb/mdb handling
From: Egil Hjelmeland @ 2017-07-27 11:04 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: corbet, vivien.didelot, f.fainelli, davem, kernel, linux-doc,
	linux-kernel, netdev
In-Reply-To: <20170726174154.GS12049@lunn.ch>

On 26. juli 2017 19:41, Andrew Lunn wrote:
> Hi Egil
> 
>> +/* This function will wait a while until mask & reg == value */
>> +/* Otherwise, return timeout */
>> +static int lan9303_csr_reg_wait(struct lan9303 *chip, int regno,
>> +				int mask, char value)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < 0x1000; i++) {
>> +		u32 reg;
>> +
>> +		lan9303_read_switch_reg(chip, regno, &reg);
>> +		if ((reg & mask) == value)
>> +			return 0;
>> +	}
>> +	return -ETIMEDOUT;
> 
> Busy looping is probably not a good idea. Can you add a usleep()?
> 

Yes

>> +}
>> +
>> +static int _lan9303_alr_make_entry_raw(struct lan9303 *chip, u32 dat0, u32 dat1)
> 
> What does the _ indicate. I could understand having it when you have
> lan9303_alr_make_entry_raw() call _lan9303_alr_make_entry_raw() after
> taking a lock, but i don't see anything like that here.
> 
Just my sloppy convention for something private, deep down. I can remove
the _.

>> +{
>> +	struct lan9303_alr_cache_entry *entr = lan9303_alr_cache_find_mac(
>> +		chip, mac);
> 
> A long line like this should be split into a declaration and an
> assignment.
> 

OK


> 
> I would probably make this a separate patch.
> 
>    Andrew
> 

Got it.

^ permalink raw reply

* Re: [PATCH v3 net-next] net: systemport: Support 64bit statistics
From: kiki good @ 2017-07-27 11:03 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: David Miller, netdev
In-Reply-To: <504e7936-c0a3-068d-8151-e4347ab7b559@gmail.com>

How about the changes below then ? of course, we need to remove
bcm_sysport_free_cb(cb) from bcm_sysport_tx_reclaim_one() as well.

       u64_stats_update_begin(&stats64->syncp);
       ring->bytes += len;
       if (cb->skb)
       {
               ring->packets++;
     +        bcm_sysport_free_cb(cb);
       }
       u64_stats_update_end(&stats64->syncp);

Thanks
Jmqiao

On Thu, Jul 27, 2017 at 1:44 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> On 07/26/2017 05:40 PM, Jianming.qiao wrote:
>> When using Broadcom Systemport device in 32bit Platform, ifconfig can
>> only report up to 4G tx,rx status, which will be wrapped to 0 when the
>> number of incoming or outgoing packets exceeds 4G, only taking
>> around 2 hours in busy network environment (such as streaming).
>> Therefore, it makes hard for network diagnostic tool to get reliable
>> statistical result, so the patch is used to add 64bit support for
>> Broadcom Systemport device in 32bit Platform.
>>
>> Signed-off-by: Jianming.qiao <kiki-good@hotmail.com>
>> ---
>>  drivers/net/ethernet/broadcom/bcmsysport.c | 71 ++++++++++++++++++++----------
>>  drivers/net/ethernet/broadcom/bcmsysport.h |  9 +++-
>>  2 files changed, 55 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
>> index 5274501..967221f 100644
>> --- a/drivers/net/ethernet/broadcom/bcmsysport.c
>> +++ b/drivers/net/ethernet/broadcom/bcmsysport.c
>> @@ -662,6 +662,7 @@ static int bcm_sysport_alloc_rx_bufs(struct bcm_sysport_priv *priv)
>>  static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
>>                                       unsigned int budget)
>>  {
>> +     struct bcm_sysport_stats *stats64 = &priv->stats64;
>>       struct net_device *ndev = priv->netdev;
>>       unsigned int processed = 0, to_process;
>>       struct bcm_sysport_cb *cb;
>> @@ -765,6 +766,10 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
>>               skb->protocol = eth_type_trans(skb, ndev);
>>               ndev->stats.rx_packets++;
>>               ndev->stats.rx_bytes += len;
>> +             u64_stats_update_begin(&stats64->syncp);
>> +             stats64->rx_packets++;
>> +             stats64->rx_bytes += len;
>> +             u64_stats_update_end(&stats64->syncp);
>>
>>               napi_gro_receive(&priv->napi, skb);
>>  next:
>> @@ -784,24 +789,31 @@ static void bcm_sysport_tx_reclaim_one(struct bcm_sysport_tx_ring *ring,
>>                                      unsigned int *pkts_compl)
>>  {
>>       struct bcm_sysport_priv *priv = ring->priv;
>> +     struct bcm_sysport_stats *stats64 = &priv->stats64;
>>       struct device *kdev = &priv->pdev->dev;
>> +     unsigned int len = 0;
>>
>>       if (cb->skb) {
>> -             ring->bytes += cb->skb->len;
>> -             *bytes_compl += cb->skb->len;
>> +             len = cb->skb->len;
>> +             *bytes_compl += len;
>>               dma_unmap_single(kdev, dma_unmap_addr(cb, dma_addr),
>>                                dma_unmap_len(cb, dma_len),
>>                                DMA_TO_DEVICE);
>> -             ring->packets++;
>>               (*pkts_compl)++;
>>               bcm_sysport_free_cb(cb);
>>       /* SKB fragment */
>>       } else if (dma_unmap_addr(cb, dma_addr)) {
>> -             ring->bytes += dma_unmap_len(cb, dma_len);
>> +             len = dma_unmap_len(cb, dma_len);
>>               dma_unmap_page(kdev, dma_unmap_addr(cb, dma_addr),
>>                              dma_unmap_len(cb, dma_len), DMA_TO_DEVICE);
>>               dma_unmap_addr_set(cb, dma_addr, 0);
>>       }
>> +
>> +     u64_stats_update_begin(&stats64->syncp);
>> +     ring->bytes += len;
>> +     if (cb->skb)
>> +             ring->packets++;
>
> How can this be safe now with bcm_sysport_free_cb() doing cb->skb =
> NULL? I know I recommended moving the 64-bit statistics update out of
> the if () else () clause before but still, it sounds like we are no
> longer able to count the ring packets here.
>
>> +     u64_stats_update_end(&stats64->syncp);
>>  }
>>
>>  /* Reclaim queued SKBs for transmission completion, lockless version */
>> @@ -1671,24 +1683,6 @@ static int bcm_sysport_change_mac(struct net_device *dev, void *p)
>>       return 0;
>>  }
>>
>> -static struct net_device_stats *bcm_sysport_get_nstats(struct net_device *dev)
>> -{
>> -     struct bcm_sysport_priv *priv = netdev_priv(dev);
>> -     unsigned long tx_bytes = 0, tx_packets = 0;
>> -     struct bcm_sysport_tx_ring *ring;
>> -     unsigned int q;
>> -
>> -     for (q = 0; q < dev->num_tx_queues; q++) {
>> -             ring = &priv->tx_rings[q];
>> -             tx_bytes += ring->bytes;
>> -             tx_packets += ring->packets;
>> -     }
>> -
>> -     dev->stats.tx_bytes = tx_bytes;
>> -     dev->stats.tx_packets = tx_packets;
>> -     return &dev->stats;
>> -}
>> -
>>  static void bcm_sysport_netif_start(struct net_device *dev)
>>  {
>>       struct bcm_sysport_priv *priv = netdev_priv(dev);
>> @@ -1923,6 +1917,37 @@ static int bcm_sysport_stop(struct net_device *dev)
>>       return 0;
>>  }
>>
>> +static void bcm_sysport_get_stats64(struct net_device *dev,
>> +                                 struct rtnl_link_stats64 *stats)
>> +{
>> +     struct bcm_sysport_priv *priv = netdev_priv(dev);
>> +     struct bcm_sysport_stats *stats64 = &priv->stats64;
>> +     struct bcm_sysport_tx_ring *ring;
>> +     u64 tx_packets = 0, tx_bytes = 0;
>> +     unsigned int start;
>> +     unsigned int q;
>> +
>> +     netdev_stats_to_stats64(stats, &dev->stats);
>> +
>> +     for (q = 0; q < dev->num_tx_queues; q++) {
>> +             ring = &priv->tx_rings[q];
>> +             do {
>> +                     start = u64_stats_fetch_begin_irq(&stats64->syncp);
>> +                     tx_bytes += ring->bytes;
>> +                     tx_packets += ring->packets;
>> +             } while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
>> +     }
>> +
>> +     stats->tx_packets = tx_packets;
>> +     stats->tx_bytes = tx_bytes;
>> +
>> +     do {
>> +             start = u64_stats_fetch_begin_irq(&stats64->syncp);
>> +             stats->rx_packets = stats64->rx_packets;
>> +             stats->rx_bytes = stats64->rx_bytes;
>> +     } while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
>> +}
>> +
>>  static const struct ethtool_ops bcm_sysport_ethtool_ops = {
>>       .get_drvinfo            = bcm_sysport_get_drvinfo,
>>       .get_msglevel           = bcm_sysport_get_msglvl,
>> @@ -1950,7 +1975,7 @@ static int bcm_sysport_stop(struct net_device *dev)
>>  #ifdef CONFIG_NET_POLL_CONTROLLER
>>       .ndo_poll_controller    = bcm_sysport_poll_controller,
>>  #endif
>> -     .ndo_get_stats          = bcm_sysport_get_nstats,
>> +     .ndo_get_stats64        = bcm_sysport_get_stats64,
>>  };
>>
>>  #define REV_FMT      "v%2x.%02x"
>> diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
>> index 77a51c1..c03a176 100644
>> --- a/drivers/net/ethernet/broadcom/bcmsysport.h
>> +++ b/drivers/net/ethernet/broadcom/bcmsysport.h
>> @@ -657,6 +657,9 @@ struct bcm_sysport_stats {
>>       enum bcm_sysport_stat_type type;
>>       /* reg offset from UMAC base for misc counters */
>>       u16 reg_offset;
>> +     u64     rx_packets;
>> +     u64     rx_bytes;
>> +     struct u64_stats_sync   syncp;
>>  };
>>
>>  /* Software house keeping helper structure */
>> @@ -693,8 +696,8 @@ struct bcm_sysport_tx_ring {
>>       struct bcm_sysport_cb *cbs;     /* Transmit control blocks */
>>       struct dma_desc *desc_cpu;      /* CPU view of the descriptor */
>>       struct bcm_sysport_priv *priv;  /* private context backpointer */
>> -     unsigned long   packets;        /* packets statistics */
>> -     unsigned long   bytes;          /* bytes statistics */
>> +     u64     packets;                /* packets statistics */
>> +     u64     bytes;                  /* bytes statistics */
>>  };
>>
>>  /* Driver private structure */
>> @@ -743,5 +746,7 @@ struct bcm_sysport_priv {
>>
>>       /* Ethtool */
>>       u32                     msg_enable;
>> +     /* 64bit stats on 32bit/64bit Machine */
>> +     struct bcm_sysport_stats stats64;
>>  };
>>  #endif /* __BCM_SYSPORT_H */
>>
>
>
> --
> Florian

^ permalink raw reply

* Re: [net] wl1251: add a missing spin_lock_init()
From: Kalle Valo @ 2017-07-27 10:59 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, pavel, linux-wireless, Cong Wang
In-Reply-To: <1499378437-4971-1-git-send-email-xiyou.wangcong@gmail.com>

Cong Wang <xiyou.wangcong@gmail.com> wrote:

> This fixes the following kernel warning:
> 
>   [ 5668.771453] BUG: spinlock bad magic on CPU#0, kworker/u2:3/9745
>   [ 5668.771850]  lock: 0xce63ef20, .magic: 00000000, .owner: <none>/-1,
>   .owner_cpu: 0
>   [ 5668.772277] CPU: 0 PID: 9745 Comm: kworker/u2:3 Tainted: G        W
>   4.12.0-03002-gec979a4-dirty #40
>   [ 5668.772796] Hardware name: Nokia RX-51 board
>   [ 5668.773071] Workqueue: phy1 wl1251_irq_work
>   [ 5668.773345] [<c010c9e4>] (unwind_backtrace) from [<c010a274>]
>   (show_stack+0x10/0x14)
>   [ 5668.773803] [<c010a274>] (show_stack) from [<c01545a4>]
>   (do_raw_spin_lock+0x6c/0xa0)
>   [ 5668.774230] [<c01545a4>] (do_raw_spin_lock) from [<c06ca578>]
>   (_raw_spin_lock_irqsave+0x10/0x18)
>   [ 5668.774658] [<c06ca578>] (_raw_spin_lock_irqsave) from [<c048c010>]
>   (wl1251_op_tx+0x38/0x5c)
>   [ 5668.775115] [<c048c010>] (wl1251_op_tx) from [<c06a12e8>]
>   (ieee80211_tx_frags+0x188/0x1c0)
>   [ 5668.775543] [<c06a12e8>] (ieee80211_tx_frags) from [<c06a138c>]
>   (__ieee80211_tx+0x6c/0x130)
>   [ 5668.775970] [<c06a138c>] (__ieee80211_tx) from [<c06a3dbc>]
>   (ieee80211_tx+0xdc/0x104)
>   [ 5668.776367] [<c06a3dbc>] (ieee80211_tx) from [<c06a4af0>]
>   (__ieee80211_subif_start_xmit+0x454/0x8c8)
>   [ 5668.776824] [<c06a4af0>] (__ieee80211_subif_start_xmit) from
>   [<c06a4f94>] (ieee80211_subif_start_xmit+0x30/0x2fc)
>   [ 5668.777343] [<c06a4f94>] (ieee80211_subif_start_xmit) from
>   [<c0578848>] (dev_hard_start_xmit+0x80/0x118)
>   ...
> 
> by adding the missing spin_lock_init().
> 
> Reported-by: Pavel Machek <pavel@ucw.cz>
> Cc: Kalle Valo <kvalo@codeaurora.org>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> Acked-by: Pavel Machek <pavel@ucw.cz>

Patch applied to wireless-drivers-next.git, thanks.

6e9aae179f29 wl1251: add a missing spin_lock_init()

-- 
https://patchwork.kernel.org/patch/9829083/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply

* Re: [PATCH net-next v2 06/10] net: dsa: lan9303: added sysfs node swe_bcst_throt
From: Egil Hjelmeland @ 2017-07-27 10:59 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: corbet, vivien.didelot, f.fainelli, davem, kernel, linux-doc,
	linux-kernel, netdev
In-Reply-To: <20170726171423.GQ12049@lunn.ch>

On 26. juli 2017 19:14, Andrew Lunn wrote:
> On Tue, Jul 25, 2017 at 06:15:49PM +0200, Egil Hjelmeland wrote:
>> Allowing per-port access to Switch Engine Broadcast Throttling Register
> 
> Hi Egil
> 
> In general, we are against using sysfs. If there is a generic
> mechanism, that applies for all sorts of network interfaces, it should
> be used instead of sysfs.
> 
> Is this intended to reduce the effect of broadcast storms?
> 
>     Andrew
> 

Yes, this setting can be used to reduce effect of broadcast storms.

I knew you all dislike using sysfs. Still I had a hope you could accept
the dsa_net_device_to_dsa_port() function it the previous patch.
I feel it would be convenient to be able to add driver sysfs nodes in
private branches for own debug and fine tuning, without having to patch
the networking core.



Egil

^ permalink raw reply

* Re: [-next] rtlwifi: kfree entry until after entry->bssid has been accessed
From: Kalle Valo @ 2017-07-27 10:58 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Larry Finger, Chaoming Li, linux-wireless, netdev,
	kernel-janitors, linux-kernel
In-Reply-To: <20170630100843.9188-1-colin.king@canonical.com>

Colin Ian King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> The current code kfree's entry and then dereferences it by accessing
> entry->bssid.  Avoid the dereference-after-free by moving the kfree
> after the access to entry->bssid.
> 
> Detected by CoverityScan, CID#1448600 ("Read from pointer after free")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Patch applied to wireless-drivers-next.git, thanks.

d0116f6f7b30 rtlwifi: kfree entry until after entry->bssid has been accessed

-- 
https://patchwork.kernel.org/patch/9819083/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply

* Re: mlx5 still has lots of warnings
From: Saeed Mahameed @ 2017-07-27 10:55 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Linux Netdev List
In-Reply-To: <20170724095144.57f994ad@xeon-e3>

On Mon, Jul 24, 2017 at 7:51 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> I sent patches for this, and you said you were going to solve this (back in April).
> Still see lots of warnings from MLX5.
>

Hi Stephen,

What gcc version are you using ? what special Cflags to use?
I am failing to see the below warning with "-Wall" and gcc 5.4 at least.

>   CC [M]  drivers/net/ethernet/mellanox/mlx5/core/en_rep.o
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:767:35: warning: ‘mlx5e_rep_switchdev_ops’ defined but not used [-Wunused-const-variable=]
>  static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
>                                    ^~~~~~~~~~~~~~~~~~~~~~~
> In file included from drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:41:0:
> drivers/net/ethernet/mellanox/mlx5/core/en.h:188:19: warning: ‘mlx5e_priv_flags’ defined but not used [-Wunused-const-variable=]
>  static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
>                    ^~~~~~~~~~~~~~~~
> In file included from drivers/net/ethernet/mellanox/mlx5/core/en.h:51:0,
>                  from drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:41:
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:427:34: warning: ‘mlx5e_pme_error_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc mlx5e_pme_error_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:423:34: warning: ‘mlx5e_pme_status_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc mlx5e_pme_status_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:372:34: warning: ‘sq_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc sq_stats_desc[] = {
>                                   ^~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:331:34: warning: ‘rq_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc rq_stats_desc[] = {
>                                   ^~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:303:34: warning: ‘pcie_perf_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc pcie_perf_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:284:34: warning: ‘pport_per_prio_pfc_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc pport_per_prio_pfc_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:277:34: warning: ‘pport_per_prio_traffic_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc pport_per_prio_traffic_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:272:34: warning: ‘pport_phy_statistical_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc pport_phy_statistical_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:256:34: warning: ‘pport_2819_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc pport_2819_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:250:34: warning: ‘pport_2863_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc pport_2863_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:229:34: warning: ‘pport_802_3_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc pport_802_3_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:145:34: warning: ‘vport_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc vport_stats_desc[] = {
>                                   ^~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:133:34: warning: ‘q_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc q_stats_desc[] = {
>                                   ^~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.h:92:34: warning: ‘sw_stats_desc’ defined but not used [-Wunused-const-variable=]
>  static const struct counter_desc sw_stats_desc[] = {
>                                   ^~~~~~~~~~~~~
>   LD [M]  drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.o

^ permalink raw reply

* Re: [PATCH net-next v2 04/10] net: dsa: lan9303: Added adjust_link() method
From: Egil Hjelmeland @ 2017-07-27 10:45 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: corbet, vivien.didelot, f.fainelli, davem, kernel, linux-doc,
	linux-kernel, netdev
In-Reply-To: <20170726170928.GP12049@lunn.ch>

On 26. juli 2017 19:09, Andrew Lunn wrote:
> On Tue, Jul 25, 2017 at 06:15:47PM +0200, Egil Hjelmeland wrote:
>> This makes the driver react to device tree "fixed-link" declaration
>> on CPU port.
>>
>> - turn off autonegotiation
>> - force speed 10 or 100 mb/s
>> - force duplex mode
>>
>> Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
>> ---
>>   drivers/net/dsa/lan9303-core.c | 33 +++++++++++++++++++++++++++++++++
>>   1 file changed, 33 insertions(+)
>>
>> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
>> index 0806a0684d55..be6d78f45a5f 100644
>> --- a/drivers/net/dsa/lan9303-core.c
>> +++ b/drivers/net/dsa/lan9303-core.c
>> @@ -17,6 +17,7 @@
>>   #include <linux/regmap.h>
>>   #include <linux/mutex.h>
>>   #include <linux/mii.h>
>> +#include <linux/phy.h>
>>   
>>   #include "lan9303.h"
>>   
>> @@ -746,6 +747,37 @@ static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum,
>>   	return chip->ops->phy_write(chip, phy, regnum, val);
>>   }
>>   
>> +static void lan9303_adjust_link(struct dsa_switch *ds, int port,
>> +				struct phy_device *phydev)
>> +{
>> +	struct lan9303 *chip = ds->priv;
>> +
>> +	int ctl, res;
>> +
>> +	ctl = lan9303_phy_read(ds, port, MII_BMCR);
>> +
>> +	if (!phy_is_pseudo_fixed_link(phydev))
>> +		return;
>> +
> 
> Hi Egil
> 
> Maybe do this check before reading MII_BMCR?
> 

OK

>> +	ctl &= ~BMCR_ANENABLE;
> 
> Should this also mask out BMCR_SPEED100 and DUPLEX_FULL? Otherwise how
> do you select 10/Half if it is already configured for 100/Full?
> 

Yes you are right. I started out with setting ctl to the fixed default
value, and later changed code to start by reading it from HW.


>> +	if (phydev->speed == SPEED_100)
>> +		ctl |= BMCR_SPEED100;
>> +
>> +	if (phydev->duplex == DUPLEX_FULL)
>> +		ctl |= BMCR_FULLDPLX;
>> +
>> +	res =  lan9303_phy_write(ds, port, MII_BMCR, ctl);
>> +
>> +	if (port == chip->phy_addr_sel_strap) {
>> +		/* Virtual Phy: Remove Turbo 200Mbit mode */
>> +		lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl);
>> +
>> +		ctl &= ~(1 << 10); // TURBO BIT
> 
> BIT(10), or better still something like BIT(LAN9303_VIRT_SPECIAL_TURBO)
> 

Agree

>> +		res =  regmap_write(chip->regmap,
>> +				    LAN9303_VIRT_SPECIAL_CTRL, ctl);
>> +	}
>> +}
> 
>    Andrew
> 


^ permalink raw reply

* Re: [PATCH net-next v2 02/10] net: dsa: lan9303: Do not disable/enable switch fabric port 0 at startup
From: Egil Hjelmeland @ 2017-07-27 10:39 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: corbet, vivien.didelot, f.fainelli, davem, kernel, linux-doc,
	linux-kernel, netdev
In-Reply-To: <20170726165853.GO12049@lunn.ch>

On 26. juli 2017 18:58, Andrew Lunn wrote:
> On Tue, Jul 25, 2017 at 06:15:45PM +0200, Egil Hjelmeland wrote:
>> For some mysterious reason enable switch fabric port 0 TX fails to
>> work, when the TX has previous been disabled. Resolved by not
>> disable/enable switch fabric port 0 at startup. Port 1 and 2 are
>> still disabled in early init.
>>
>> Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
>> ---
>>   drivers/net/dsa/lan9303-core.c | 7 -------
>>   1 file changed, 7 deletions(-)
>>
>> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
>> index e622db586c3d..c2b53659f58f 100644
>> --- a/drivers/net/dsa/lan9303-core.c
>> +++ b/drivers/net/dsa/lan9303-core.c
>> @@ -557,9 +557,6 @@ static int lan9303_disable_processing(struct lan9303 *chip)
>>   {
>>   	int ret;
>>   
>> -	ret = lan9303_disable_packet_processing(chip, LAN9303_PORT_0_OFFSET);
>> -	if (ret)
>> -		return ret;
>>   	ret = lan9303_disable_packet_processing(chip, LAN9303_PORT_1_OFFSET);
>>   	if (ret)
>>   		return ret;
>> @@ -633,10 +630,6 @@ static int lan9303_setup(struct dsa_switch *ds)
>>   	if (ret)
>>   		dev_err(chip->dev, "failed to separate ports %d\n", ret);
>>   
>> -	ret = lan9303_enable_packet_processing(chip, LAN9303_PORT_0_OFFSET);
>> -	if (ret)
>> -		dev_err(chip->dev, "failed to re-enable switching %d\n", ret);
>> -
> 
> Does this mean you are relying on something else enabling port 0? The
> bootloader?
> 
> I'm wondering if it is better to keep the enable, but remove the
> disable?
> 
> 	Andrew
> 

The (switch engine) ports are enabled by default. The only thing our
bootloader does is to set gpo so the lan9303 is kept in reset until
the linux driver starts. When I test with the next-next kernel I just
specify the reset-gpo in DTS and the driver pulls it out of reset.

Keeping the enable does no harm, as far as I recall, but I can
double check that when I get time. I have no idea why the original
mainline code does not work for me. Maybe it is a timing issue?

^ permalink raw reply

* Re: [RFC] switchdev: clarify ndo_get_phys_port_name() formats
From: Or Gerlitz @ 2017-07-27 10:30 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jiri Pirko, Linux Netdev List, Or Gerlitz, Michael Chan,
	Sathya Perla, Simon Horman, David Miller
In-Reply-To: <20170726131146.45fe5b3e@cakuba.netronome.com>

On Wed, Jul 26, 2017 at 11:11 PM, Jakub Kicinski <kubakici@wp.pl> wrote:
> On Wed, 26 Jul 2017 12:23:17 +0300, Or Gerlitz wrote:
>> On Wed, Jul 26, 2017 at 11:13 AM, Jakub Kicinski <kubakici@wp.pl> wrote:
>> > On Wed, 26 Jul 2017 07:48:40 +0200, Jiri Pirko wrote:
>>
>> >> I think it would make sense if the driver would just fill-up a struct in
>> >> the ndo call and core would generate the string.
>>
>> > I do like the idea of core generating the string.  I have a temptation
>> > to try to involve devlink in this somehow, since port id and split info
>> > is already available there.  Perhaps that would only overcomplicate
>> > things.
>>
>> > The other question is: can we remove the option to generate an arbitrary
>> > string completely?  I think Or and mlx5 folks may object since it would
>> > mean mlx5 VF repr names would change.
>>
>> What we have today is the representor driver instance setting the VF index as
>> the of phys port name and we're telling users to have this sort of udev rule:
>>
>> SUBSYSTEM=="net", ACTION=="add",
>> ATTR{phys_switch_id}=="<phys_switch_id>", \ ATTR{phys_port_name}!="",
>> NAME="$PF_NIC$attr{phys_port_name}"
>
> Example names generated by this rule would be pfnic_0, pfnic_1 for vf
> representors 0 and 1?

YES

>> that has affiliation to  the PF where this VF belongs. AFAIK this
>> model/assumption is now under push to
>> higher level (open stack), so lets see if/what we want to change here
>> w.r.t to sriov offloading drivers.
>>
>> I would opt for an approach where the value returned by the kernel is
>> the minimal possible and
>> user-space has flexibility to further orchestrate that with udev
>> rules. I wasn't fully clear on Jakub's suggestion
>> which parts must come from the kernel. Do we have any length
>> limitation for the phys port name?
>
> Looks like the limit today is IFNAMSIZ.  I'm in favor of leaving the
> flexibility to the userspace, why I suggested adding the pf%d or
> pf%dvf%d to the name is that I don't think we have any other way today
> of telling whether representor is for a physical port, VF or PF.

> If I understand mlx5 code, you're not reporting port ids for physical
> ports so presence of the name already implies it's a VF but in case you

yes, currently in our model the PF serves as the uplink representor
when running in offloads mode.

> want to add port splitting support, for example, reporting the name on
> physical ports will become more of a necessity.

> If we adopt Jiri's suggestion of returning structured data it will be
> very easy to give user space type and indexes separately, but we should
> probably still return the string for backwards compatibility.

I am not still clear how the structured data would look like

^ permalink raw reply

* [PATCH net-next] bnxt_re: add MAY_USE_DEVLINK dependency
From: Sathya Perla @ 2017-07-27 10:29 UTC (permalink / raw)
  To: netdev; +Cc: selvin.xavier, devesh.sharma, arnd, michael.chan

bnxt_en depends on MAY_USE_DEVLINK; this is used to force bnxt_en
to be =m when DEVLINK is =m.

Now, bnxt_re selects bnxt_en. Unless bnxt_re also explicitly calls
out dependency on MAY_USE_DEVLINK, Kconfig does not force bnxt_re
to be =m when DEVLINK is =m, causing the following error:

drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.o: In function
`bnxt_dl_register':
bnxt_vfr.c:(.text+0x1440): undefined reference to `devlink_alloc'
bnxt_vfr.c:(.text+0x14c0): undefined reference to `devlink_register'
bnxt_vfr.c:(.text+0x14e0): undefined reference to `devlink_free'
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.o: In function
`bnxt_dl_unregister':
bnxt_vfr.c:(.text+0x1534): undefined reference to `devlink_unregister'
bnxt_vfr.c:(.text+0x153c): undefined reference to `devlink_free'

Fix this by adding MAY_USE_DEVLINK dependency in bnxt_re.

Fixes: 4ab0c6a8ffd7 ("bnxt_en: add support to enable VF-representors")
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sathya Perla <sathya.perla@broadcom.com>
---
 drivers/infiniband/hw/bnxt_re/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/bnxt_re/Kconfig b/drivers/infiniband/hw/bnxt_re/Kconfig
index 19982a4..18f5ed0 100644
--- a/drivers/infiniband/hw/bnxt_re/Kconfig
+++ b/drivers/infiniband/hw/bnxt_re/Kconfig
@@ -1,6 +1,7 @@
 config INFINIBAND_BNXT_RE
     tristate "Broadcom Netxtreme HCA support"
     depends on ETHERNET && NETDEVICES && PCI && INET && DCB
+    depends on MAY_USE_DEVLINK
     select NET_VENDOR_BROADCOM
     select BNXT
     ---help---
-- 
1.8.3.1

^ permalink raw reply related

* [net 13/14] net/mlx5e: Schedule overflow check work to mlx5e workqueue
From: Saeed Mahameed @ 2017-07-27 10:25 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eugenia Emantayev, Saeed Mahameed
In-Reply-To: <20170727102532.2317-1-saeedm@mellanox.com>

From: Eugenia Emantayev <eugenia@mellanox.com>

This is done in order to ensure that work will not run after the cleanup.

Fixes: ef9814deafd0 ('net/mlx5e: Add HW timestamping (TS) support')
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_clock.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
index cde8e8e772ec..84dd63e74041 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
@@ -114,13 +114,14 @@ static void mlx5e_timestamp_overflow(struct work_struct *work)
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp,
 						   overflow_work);
+	struct mlx5e_priv *priv = container_of(tstamp, struct mlx5e_priv, tstamp);
 	unsigned long flags;
 
 	write_lock_irqsave(&tstamp->lock, flags);
 	timecounter_read(&tstamp->clock);
 	write_unlock_irqrestore(&tstamp->lock, flags);
-	schedule_delayed_work(&tstamp->overflow_work,
-			      msecs_to_jiffies(tstamp->overflow_period * 1000));
+	queue_delayed_work(priv->wq, &tstamp->overflow_work,
+			   msecs_to_jiffies(tstamp->overflow_period * 1000));
 }
 
 int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr)
@@ -577,7 +578,7 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
 	INIT_WORK(&tstamp->pps_info.out_work, mlx5e_pps_out);
 	INIT_DELAYED_WORK(&tstamp->overflow_work, mlx5e_timestamp_overflow);
 	if (tstamp->overflow_period)
-		schedule_delayed_work(&tstamp->overflow_work, 0);
+		queue_delayed_work(priv->wq, &tstamp->overflow_work, 0);
 	else
 		mlx5_core_warn(priv->mdev, "invalid overflow period, overflow_work is not scheduled\n");
 
@@ -613,8 +614,6 @@ void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv)
 	}
 
 	cancel_work_sync(&tstamp->pps_info.out_work);
-
-	kfree(tstamp->ptp_info.pin_config);
-
 	cancel_delayed_work_sync(&tstamp->overflow_work);
+	kfree(tstamp->ptp_info.pin_config);
 }
-- 
2.13.0

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox