linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table
@ 2018-07-04 18:33 Linus Walleij
  2018-07-04 18:33 ` [PATCH net-next 2/5 v2] net: gemini: Improve connection prints Linus Walleij
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Linus Walleij @ 2018-07-04 18:33 UTC (permalink / raw)
  To: linux-arm-kernel

The code to calculate the hardware register enumerator
for the maximum L3 length isn't entirely simple to read.
Use the existing defines and rewrite the function into a
table look-up.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- No changes, just resending with the rest.
---
 drivers/net/ethernet/cortina/gemini.c | 61 ++++++++++++++++++++-------
 1 file changed, 46 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 6d7404f66f84..8fc31723f700 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -401,26 +401,57 @@ static int gmac_setup_phy(struct net_device *netdev)
 	return 0;
 }
 
-static int gmac_pick_rx_max_len(int max_l3_len)
-{
-	/* index = CONFIG_MAXLEN_XXX values */
-	static const int max_len[8] = {
-		1536, 1518, 1522, 1542,
-		9212, 10236, 1518, 1518
-	};
-	int i, n = 5;
+/* The maximum frame length is not logically enumerated in the
+ * hardware, so we do a table lookup to find the applicable max
+ * frame length.
+ */
+struct gmac_max_framelen {
+	unsigned int max_l3_len;
+	u8 val;
+};
 
-	max_l3_len += ETH_HLEN + VLAN_HLEN;
+static const struct gmac_max_framelen gmac_maxlens[] = {
+	{
+		.max_l3_len = 1518,
+		.val = CONFIG0_MAXLEN_1518,
+	},
+	{
+		.max_l3_len = 1522,
+		.val = CONFIG0_MAXLEN_1522,
+	},
+	{
+		.max_l3_len = 1536,
+		.val = CONFIG0_MAXLEN_1536,
+	},
+	{
+		.max_l3_len = 1542,
+		.val = CONFIG0_MAXLEN_1542,
+	},
+	{
+		.max_l3_len = 9212,
+		.val = CONFIG0_MAXLEN_9k,
+	},
+	{
+		.max_l3_len = 10236,
+		.val = CONFIG0_MAXLEN_10k,
+	},
+};
+
+static int gmac_pick_rx_max_len(unsigned int max_l3_len)
+{
+	const struct gmac_max_framelen *maxlen;
+	int maxtot;
+	int i;
 
-	if (max_l3_len > max_len[n])
-		return -1;
+	maxtot = max_l3_len + ETH_HLEN + VLAN_HLEN;
 
-	for (i = 0; i < 5; i++) {
-		if (max_len[i] >= max_l3_len && max_len[i] < max_len[n])
-			n = i;
+	for (i = 0; i < ARRAY_SIZE(gmac_maxlens); i++) {
+		maxlen = &gmac_maxlens[i];
+		if (maxtot <= maxlen->max_l3_len)
+			return maxlen->val;
 	}
 
-	return n;
+	return -1;
 }
 
 static int gmac_init(struct net_device *netdev)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next 2/5 v2] net: gemini: Improve connection prints
  2018-07-04 18:33 [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Linus Walleij
@ 2018-07-04 18:33 ` Linus Walleij
  2018-07-04 20:40   ` Andrew Lunn
  2018-07-04 18:33 ` [PATCH net-next 3/5 v2] net: gemini: Allow multiple ports to instantiate Linus Walleij
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2018-07-04 18:33 UTC (permalink / raw)
  To: linux-arm-kernel

Switch over to using a module parameter and debug prints
that can be controlled by this or ethtool like everyone
else. Depromote all other prints to debug messages.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Use a module parameter and the message levels like all
  other drivers and stop trying to be special.
---
 drivers/net/ethernet/cortina/gemini.c | 44 +++++++++++++++------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 8fc31723f700..f219208d2351 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -46,6 +46,11 @@
 #define DRV_NAME		"gmac-gemini"
 #define DRV_VERSION		"1.0"
 
+#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
+static int debug = -1;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
+
 #define HSIZE_8			0x00
 #define HSIZE_16		0x01
 #define HSIZE_32		0x02
@@ -300,23 +305,26 @@ static void gmac_speed_set(struct net_device *netdev)
 		status.bits.speed = GMAC_SPEED_1000;
 		if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
 			status.bits.mii_rmii = GMAC_PHY_RGMII_1000;
-		netdev_info(netdev, "connect to RGMII @ 1Gbit\n");
+		netdev_dbg(netdev, "connect %s to RGMII @ 1Gbit\n",
+			   phydev_name(phydev));
 		break;
 	case 100:
 		status.bits.speed = GMAC_SPEED_100;
 		if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
 			status.bits.mii_rmii = GMAC_PHY_RGMII_100_10;
-		netdev_info(netdev, "connect to RGMII @ 100 Mbit\n");
+		netdev_dbg(netdev, "connect %s to RGMII @ 100 Mbit\n",
+			   phydev_name(phydev));
 		break;
 	case 10:
 		status.bits.speed = GMAC_SPEED_10;
 		if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
 			status.bits.mii_rmii = GMAC_PHY_RGMII_100_10;
-		netdev_info(netdev, "connect to RGMII @ 10 Mbit\n");
+		netdev_dbg(netdev, "connect %s to RGMII @ 10 Mbit\n",
+			   phydev_name(phydev));
 		break;
 	default:
-		netdev_warn(netdev, "Not supported PHY speed (%d)\n",
-			    phydev->speed);
+		netdev_warn(netdev, "Unsupported PHY speed (%d) on %s\n",
+			    phydev->speed, phydev_name(phydev));
 	}
 
 	if (phydev->duplex == DUPLEX_FULL) {
@@ -363,11 +371,8 @@ static int gmac_setup_phy(struct net_device *netdev)
 		return -ENODEV;
 	netdev->phydev = phy;
 
-	netdev_info(netdev, "connected to PHY \"%s\"\n",
-		    phydev_name(phy));
-	phy_attached_print(phy, "phy_id=0x%.8lx, phy_mode=%s\n",
-			   (unsigned long)phy->phy_id,
-			   phy_modes(phy->interface));
+	netdev_dbg(netdev, "connected to PHY \"%s\"\n",
+		   phydev_name(phy));
 
 	phy->supported &= PHY_GBIT_FEATURES;
 	phy->supported |= SUPPORTED_Asym_Pause | SUPPORTED_Pause;
@@ -376,19 +381,19 @@ static int gmac_setup_phy(struct net_device *netdev)
 	/* set PHY interface type */
 	switch (phy->interface) {
 	case PHY_INTERFACE_MODE_MII:
-		netdev_info(netdev, "set GMAC0 to GMII mode, GMAC1 disabled\n");
+		netdev_dbg(netdev,
+			   "MII: set GMAC0 to GMII mode, GMAC1 disabled\n");
 		status.bits.mii_rmii = GMAC_PHY_MII;
-		netdev_info(netdev, "connect to MII\n");
 		break;
 	case PHY_INTERFACE_MODE_GMII:
-		netdev_info(netdev, "set GMAC0 to GMII mode, GMAC1 disabled\n");
+		netdev_dbg(netdev,
+			   "GMII: set GMAC0 to GMII mode, GMAC1 disabled\n");
 		status.bits.mii_rmii = GMAC_PHY_GMII;
-		netdev_info(netdev, "connect to GMII\n");
 		break;
 	case PHY_INTERFACE_MODE_RGMII:
-		dev_info(dev, "set GMAC0 and GMAC1 to MII/RGMII mode\n");
+		netdev_dbg(netdev,
+			   "RGMII: set GMAC0 and GMAC1 to MII/RGMII mode\n");
 		status.bits.mii_rmii = GMAC_PHY_RGMII_100_10;
-		netdev_info(netdev, "connect to RGMII\n");
 		break;
 	default:
 		netdev_err(netdev, "Unsupported MII interface\n");
@@ -1307,8 +1312,8 @@ static void gmac_enable_irq(struct net_device *netdev, int enable)
 	unsigned long flags;
 	u32 val, mask;
 
-	netdev_info(netdev, "%s device %d %s\n", __func__,
-		    netdev->dev_id, enable ? "enable" : "disable");
+	netdev_dbg(netdev, "%s device %d %s\n", __func__,
+		   netdev->dev_id, enable ? "enable" : "disable");
 	spin_lock_irqsave(&geth->irq_lock, flags);
 
 	mask = GMAC0_IRQ0_2 << (netdev->dev_id * 2);
@@ -1813,7 +1818,7 @@ static int gmac_open(struct net_device *netdev)
 		     HRTIMER_MODE_REL);
 	port->rx_coalesce_timer.function = &gmac_coalesce_delay_expired;
 
-	netdev_info(netdev, "opened\n");
+	netdev_dbg(netdev, "opened\n");
 
 	return 0;
 
@@ -2385,6 +2390,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 	port->id = id;
 	port->geth = geth;
 	port->dev = dev;
+	port->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
 
 	/* DMA memory */
 	dmares = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next 3/5 v2] net: gemini: Allow multiple ports to instantiate
  2018-07-04 18:33 [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Linus Walleij
  2018-07-04 18:33 ` [PATCH net-next 2/5 v2] net: gemini: Improve connection prints Linus Walleij
@ 2018-07-04 18:33 ` Linus Walleij
  2018-07-04 18:33 ` [PATCH net-next 4/5 v2] net: gemini: Move main init to port Linus Walleij
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2018-07-04 18:33 UTC (permalink / raw)
  To: linux-arm-kernel

The code was not tested with two ports actually in use at
the same time. (I blame this on lack of actual hardware using
that feature.) Now after locating a system using both ports,
add necessary fix to make both ports come up.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- No changes, just resending with the rest.
---
 drivers/net/ethernet/cortina/gemini.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index f219208d2351..6b5aa5704c4f 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -1789,7 +1789,10 @@ static int gmac_open(struct net_device *netdev)
 	phy_start(netdev->phydev);
 
 	err = geth_resize_freeq(port);
-	if (err) {
+	/* It's fine if it's just busy, the other port has set up
+	 * the freeq in that case.
+	 */
+	if (err && (err != -EBUSY)) {
 		netdev_err(netdev, "could not resize freeq\n");
 		goto err_stop_phy;
 	}
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next 4/5 v2] net: gemini: Move main init to port
  2018-07-04 18:33 [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Linus Walleij
  2018-07-04 18:33 ` [PATCH net-next 2/5 v2] net: gemini: Improve connection prints Linus Walleij
  2018-07-04 18:33 ` [PATCH net-next 3/5 v2] net: gemini: Allow multiple ports to instantiate Linus Walleij
@ 2018-07-04 18:33 ` Linus Walleij
  2018-07-04 18:33 ` [PATCH net-next 5/5 v2] net: gemini: Indicate that we can handle jumboframes Linus Walleij
  2018-07-07 16:14 ` [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Michał Mirosław
  4 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2018-07-04 18:33 UTC (permalink / raw)
  To: linux-arm-kernel

The initialization sequence for the ethernet, setting up
interrupt routing and such things, need to be done after
both the ports are clocked and reset. Before this the
config will not "take". Move the initialization to the
port probe function and keep track of init status in
the state.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- No changes, just resending with the rest.
---
 drivers/net/ethernet/cortina/gemini.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 6b5aa5704c4f..4e341570047f 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -151,6 +151,7 @@ struct gemini_ethernet {
 	void __iomem *base;
 	struct gemini_ethernet_port *port0;
 	struct gemini_ethernet_port *port1;
+	bool initialized;
 
 	spinlock_t	irq_lock; /* Locks IRQ-related registers */
 	unsigned int	freeq_order;
@@ -2303,6 +2304,14 @@ static void gemini_port_remove(struct gemini_ethernet_port *port)
 
 static void gemini_ethernet_init(struct gemini_ethernet *geth)
 {
+	/* Only do this once both ports are online */
+	if (geth->initialized)
+		return;
+	if (geth->port0 && geth->port1)
+		geth->initialized = true;
+	else
+		return;
+
 	writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_0_REG);
 	writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_1_REG);
 	writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_2_REG);
@@ -2450,6 +2459,10 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 		geth->port0 = port;
 	else
 		geth->port1 = port;
+
+	/* This will just be done once both ports are up and reset */
+	gemini_ethernet_init(geth);
+
 	platform_set_drvdata(pdev, port);
 
 	/* Set up and register the netdev */
@@ -2567,7 +2580,6 @@ static int gemini_ethernet_probe(struct platform_device *pdev)
 
 	spin_lock_init(&geth->irq_lock);
 	spin_lock_init(&geth->freeq_lock);
-	gemini_ethernet_init(geth);
 
 	/* The children will use this */
 	platform_set_drvdata(pdev, geth);
@@ -2580,8 +2592,8 @@ static int gemini_ethernet_remove(struct platform_device *pdev)
 {
 	struct gemini_ethernet *geth = platform_get_drvdata(pdev);
 
-	gemini_ethernet_init(geth);
 	geth_cleanup_freeq(geth);
+	geth->initialized = false;
 
 	return 0;
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next 5/5 v2] net: gemini: Indicate that we can handle jumboframes
  2018-07-04 18:33 [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Linus Walleij
                   ` (2 preceding siblings ...)
  2018-07-04 18:33 ` [PATCH net-next 4/5 v2] net: gemini: Move main init to port Linus Walleij
@ 2018-07-04 18:33 ` Linus Walleij
  2018-07-04 20:35   ` Andrew Lunn
  2018-07-07 16:14 ` [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Michał Mirosław
  4 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2018-07-04 18:33 UTC (permalink / raw)
  To: linux-arm-kernel

The hardware supposedly handles frames up to 10236 bytes and
implements .ndo_change_mtu() so accept 10236 minus the ethernet
header for a VLAN tagged frame on the netdevices. Use
ETH_MIN_MTU as minimum MTU.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Change the min MTU from 256 (vendor code) to ETH_MIN_MTU
  which makes more sense.
---
 drivers/net/ethernet/cortina/gemini.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 4e341570047f..af38f9869734 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -2476,6 +2476,11 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 
 	netdev->hw_features = GMAC_OFFLOAD_FEATURES;
 	netdev->features |= GMAC_OFFLOAD_FEATURES | NETIF_F_GRO;
+	/* We can handle jumbo frames up to 10236 bytes so, let's accept
+	 * payloads of 10236 bytes minus VLAN and ethernet header
+	 */
+	netdev->min_mtu = ETH_MIN_MTU;
+	netdev->max_mtu = 10236 - VLAN_ETH_HLEN;
 
 	port->freeq_refill = 0;
 	netif_napi_add(netdev, &port->napi, gmac_napi_poll,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next 5/5 v2] net: gemini: Indicate that we can handle jumboframes
  2018-07-04 18:33 ` [PATCH net-next 5/5 v2] net: gemini: Indicate that we can handle jumboframes Linus Walleij
@ 2018-07-04 20:35   ` Andrew Lunn
  2018-07-11 19:10     ` Linus Walleij
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2018-07-04 20:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 04, 2018 at 08:33:24PM +0200, Linus Walleij wrote:
> The hardware supposedly handles frames up to 10236 bytes and
> implements .ndo_change_mtu() so accept 10236 minus the ethernet
> header for a VLAN tagged frame on the netdevices. Use
> ETH_MIN_MTU as minimum MTU.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Hi Linus

Did you try with an MTU of 68? Maybe the vendor picked 256 because of
a hardware limit?

Otherwise the change looks good.

	  Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next 2/5 v2] net: gemini: Improve connection prints
  2018-07-04 18:33 ` [PATCH net-next 2/5 v2] net: gemini: Improve connection prints Linus Walleij
@ 2018-07-04 20:40   ` Andrew Lunn
  2018-07-08 20:47     ` Linus Walleij
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2018-07-04 20:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 04, 2018 at 08:33:21PM +0200, Linus Walleij wrote:
> Switch over to using a module parameter and debug prints
> that can be controlled by this or ethtool like everyone
> else. Depromote all other prints to debug messages.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Use a module parameter and the message levels like all
>   other drivers and stop trying to be special.
> ---
>  drivers/net/ethernet/cortina/gemini.c | 44 +++++++++++++++------------
>  1 file changed, 25 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 8fc31723f700..f219208d2351 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -46,6 +46,11 @@
>  #define DRV_NAME		"gmac-gemini"
>  #define DRV_VERSION		"1.0"
>  
> +#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
> +static int debug = -1;
> +module_param(debug, int, 0);
> +MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
> +
>  #define HSIZE_8			0x00
>  #define HSIZE_16		0x01
>  #define HSIZE_32		0x02
> @@ -300,23 +305,26 @@ static void gmac_speed_set(struct net_device *netdev)
>  		status.bits.speed = GMAC_SPEED_1000;
>  		if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
>  			status.bits.mii_rmii = GMAC_PHY_RGMII_1000;
> -		netdev_info(netdev, "connect to RGMII @ 1Gbit\n");
> +		netdev_dbg(netdev, "connect %s to RGMII @ 1Gbit\n",
> +			   phydev_name(phydev));

Hi Linus

Since these are netdev_dbg, they will generally never be seen. So
could you add a call to phy_print_status() at the end of this
function. That is what most MAC drivers do.

> -	netdev_info(netdev, "connected to PHY \"%s\"\n",
> -		    phydev_name(phy));
> -	phy_attached_print(phy, "phy_id=0x%.8lx, phy_mode=%s\n",
> -			   (unsigned long)phy->phy_id,
> -			   phy_modes(phy->interface));
> +	netdev_dbg(netdev, "connected to PHY \"%s\"\n",
> +		   phydev_name(phy));
>  

It would be nice to call phy_attached_info(), as most other MAC
drivers do.

	Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table
  2018-07-04 18:33 [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Linus Walleij
                   ` (3 preceding siblings ...)
  2018-07-04 18:33 ` [PATCH net-next 5/5 v2] net: gemini: Indicate that we can handle jumboframes Linus Walleij
@ 2018-07-07 16:14 ` Michał Mirosław
  4 siblings, 0 replies; 10+ messages in thread
From: Michał Mirosław @ 2018-07-07 16:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 04, 2018 at 08:33:20PM +0200, Linus Walleij wrote:
> The code to calculate the hardware register enumerator
> for the maximum L3 length isn't entirely simple to read.
> Use the existing defines and rewrite the function into a
> table look-up.

A matter of habit. ;-)
I think that if you just renamed 'n' to 'best_index' and avoided
reusing 'max_l3_len' (as you already did) the idea could be made
more obvious without expading the code to twice the lines.

The max_len[] array in the original code documents how the HW reacts
to a specific setting.

Acked-by: Micha? Miros?aw <mirq-linux@rere.qmqm.pl>

Best Regards,
Micha? Miros?aw

> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - No changes, just resending with the rest.
> ---
>  drivers/net/ethernet/cortina/gemini.c | 61 ++++++++++++++++++++-------
>  1 file changed, 46 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 6d7404f66f84..8fc31723f700 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -401,26 +401,57 @@ static int gmac_setup_phy(struct net_device *netdev)
>  	return 0;
>  }
>  
> -static int gmac_pick_rx_max_len(int max_l3_len)
> -{
> -	/* index = CONFIG_MAXLEN_XXX values */
> -	static const int max_len[8] = {
> -		1536, 1518, 1522, 1542,
> -		9212, 10236, 1518, 1518
> -	};
> -	int i, n = 5;
> +/* The maximum frame length is not logically enumerated in the
> + * hardware, so we do a table lookup to find the applicable max
> + * frame length.
> + */
> +struct gmac_max_framelen {
> +	unsigned int max_l3_len;
> +	u8 val;
> +};
>  
> -	max_l3_len += ETH_HLEN + VLAN_HLEN;
> +static const struct gmac_max_framelen gmac_maxlens[] = {
> +	{
> +		.max_l3_len = 1518,
> +		.val = CONFIG0_MAXLEN_1518,
> +	},
> +	{
> +		.max_l3_len = 1522,
> +		.val = CONFIG0_MAXLEN_1522,
> +	},
> +	{
> +		.max_l3_len = 1536,
> +		.val = CONFIG0_MAXLEN_1536,
> +	},
> +	{
> +		.max_l3_len = 1542,
> +		.val = CONFIG0_MAXLEN_1542,
> +	},
> +	{
> +		.max_l3_len = 9212,
> +		.val = CONFIG0_MAXLEN_9k,
> +	},
> +	{
> +		.max_l3_len = 10236,
> +		.val = CONFIG0_MAXLEN_10k,
> +	},
> +};
> +
> +static int gmac_pick_rx_max_len(unsigned int max_l3_len)
> +{
> +	const struct gmac_max_framelen *maxlen;
> +	int maxtot;
> +	int i;
>  
> -	if (max_l3_len > max_len[n])
> -		return -1;
> +	maxtot = max_l3_len + ETH_HLEN + VLAN_HLEN;
>  
> -	for (i = 0; i < 5; i++) {
> -		if (max_len[i] >= max_l3_len && max_len[i] < max_len[n])
> -			n = i;
> +	for (i = 0; i < ARRAY_SIZE(gmac_maxlens); i++) {
> +		maxlen = &gmac_maxlens[i];
> +		if (maxtot <= maxlen->max_l3_len)
> +			return maxlen->val;
>  	}
>  
> -	return n;
> +	return -1;
>  }
>  
>  static int gmac_init(struct net_device *netdev)
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next 2/5 v2] net: gemini: Improve connection prints
  2018-07-04 20:40   ` Andrew Lunn
@ 2018-07-08 20:47     ` Linus Walleij
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2018-07-08 20:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 4, 2018 at 10:40 PM Andrew Lunn <andrew@lunn.ch> wrote:
> On Wed, Jul 04, 2018 at 08:33:21PM +0200, Linus Walleij wrote:
> > @@ -300,23 +305,26 @@ static void gmac_speed_set(struct net_device *netdev)
> >               status.bits.speed = GMAC_SPEED_1000;
> >               if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
> >                       status.bits.mii_rmii = GMAC_PHY_RGMII_1000;
> > -             netdev_info(netdev, "connect to RGMII @ 1Gbit\n");
> > +             netdev_dbg(netdev, "connect %s to RGMII @ 1Gbit\n",
> > +                        phydev_name(phydev));
>
> Hi Linus
>
> Since these are netdev_dbg, they will generally never be seen. So
> could you add a call to phy_print_status() at the end of this
> function. That is what most MAC drivers do.

It does:

       if (netif_msg_link(port)) {
                phy_print_status(phydev);
                netdev_info(netdev, "link flow control: %s\n",
                            phydev->pause
                            ? (phydev->asym_pause ? "tx" : "both")
                            : (phydev->asym_pause ? "rx" : "none")
                );
        }

Just not visible in the patch since it was there all the time :D

My new module parameter however, makes that
phy_print_status() actually show up-

I can mention it in the commit message so it's clear.

> > -     netdev_info(netdev, "connected to PHY \"%s\"\n",
> > -                 phydev_name(phy));
> > -     phy_attached_print(phy, "phy_id=0x%.8lx, phy_mode=%s\n",
> > -                        (unsigned long)phy->phy_id,
> > -                        phy_modes(phy->interface));
> > +     netdev_dbg(netdev, "connected to PHY \"%s\"\n",
> > +                phydev_name(phy));
> >
>
> It would be nice to call phy_attached_info(), as most other MAC
> drivers do.

OK adding it!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next 5/5 v2] net: gemini: Indicate that we can handle jumboframes
  2018-07-04 20:35   ` Andrew Lunn
@ 2018-07-11 19:10     ` Linus Walleij
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2018-07-11 19:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 4, 2018 at 10:35 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Wed, Jul 04, 2018 at 08:33:24PM +0200, Linus Walleij wrote:
> > The hardware supposedly handles frames up to 10236 bytes and
> > implements .ndo_change_mtu() so accept 10236 minus the ethernet
> > header for a VLAN tagged frame on the netdevices. Use
> > ETH_MIN_MTU as minimum MTU.
> >
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> Hi Linus
>
> Did you try with an MTU of 68? Maybe the vendor picked 256 because of
> a hardware limit?

Yeah works fine:

ping -s 68 169.254.1.2
PING 169.254.1.2 (169.254.1.2) 68(96) bytes of data.
76 bytes from 169.254.1.2: icmp_seq=1 ttl=64 time=0.359 ms
76 bytes from 169.254.1.2: icmp_seq=2 ttl=64 time=0.346 ms
76 bytes from 169.254.1.2: icmp_seq=3 ttl=64 time=0.351 ms

This also works fine:

ping -s 9000 169.254.1.2
PING 169.254.1.2 (169.254.1.2) 9000(9028) bytes of data.
9008 bytes from 169.254.1.2: icmp_seq=1 ttl=64 time=1.45 ms
9008 bytes from 169.254.1.2: icmp_seq=2 ttl=64 time=1.68 ms
9008 bytes from 169.254.1.2: icmp_seq=3 ttl=64 time=1.55 ms

I'll send new patches with all suggested changes soon :)

Thanks a lot for your help!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-11 19:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 18:33 [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Linus Walleij
2018-07-04 18:33 ` [PATCH net-next 2/5 v2] net: gemini: Improve connection prints Linus Walleij
2018-07-04 20:40   ` Andrew Lunn
2018-07-08 20:47     ` Linus Walleij
2018-07-04 18:33 ` [PATCH net-next 3/5 v2] net: gemini: Allow multiple ports to instantiate Linus Walleij
2018-07-04 18:33 ` [PATCH net-next 4/5 v2] net: gemini: Move main init to port Linus Walleij
2018-07-04 18:33 ` [PATCH net-next 5/5 v2] net: gemini: Indicate that we can handle jumboframes Linus Walleij
2018-07-04 20:35   ` Andrew Lunn
2018-07-11 19:10     ` Linus Walleij
2018-07-07 16:14 ` [PATCH net-next 1/5 v2] net: gemini: Look up L3 maxlen from table Michał Mirosław

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).