All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/3] net: dsa: ksz: Clean up the tag code in prep for more switches
@ 2018-12-13 16:01 Marek Vasut
  2018-12-13 16:01 ` [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 Marek Vasut
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Marek Vasut @ 2018-12-13 16:01 UTC (permalink / raw)
  To: netdev
  Cc: f.fainelli, andrew, Marek Vasut, Tristram Ha, Vivien Didelot,
	Woojung Huh, David S . Miller

Clean up the KSZ DSA tag code in preparation for adding more switches.

Marek Vasut (1):
  net: dsa: ksz: Add STP multicast handling

Tristram Ha (2):
  net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477
  net: dsa: ksz: Factor out common tag code

 drivers/net/dsa/microchip/Kconfig   |   2 +-
 drivers/net/dsa/microchip/ksz9477.c |   2 +-
 include/net/dsa.h                   |   2 +-
 net/dsa/Kconfig                     |   4 +
 net/dsa/dsa.c                       |   8 +-
 net/dsa/dsa_priv.h                  |   2 +-
 net/dsa/tag_ksz.c                   | 118 ++++++++++++++++++----------
 7 files changed, 89 insertions(+), 49 deletions(-)

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Woojung Huh <woojung.huh@microchip.com>
Cc: David S. Miller <davem@davemloft.net>
---
V2: - New cover letter
    - Drop the KSZ8795 code for now as it needs more work

-- 
2.18.0

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

* [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477
  2018-12-13 16:01 [PATCH V2 0/3] net: dsa: ksz: Clean up the tag code in prep for more switches Marek Vasut
@ 2018-12-13 16:01 ` Marek Vasut
  2018-12-14  8:42   ` Andrew Lunn
  2018-12-13 16:01 ` [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code Marek Vasut
  2018-12-13 16:01 ` [PATCH V2 3/3] net: dsa: ksz: Add STP multicast handling Marek Vasut
  2 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2018-12-13 16:01 UTC (permalink / raw)
  To: netdev
  Cc: f.fainelli, andrew, Tristram Ha, Marek Vasut, Vivien Didelot,
	Woojung Huh, David S . Miller

From: Tristram Ha <Tristram.Ha@microchip.com>

Rename the tag Kconfig option and related macros in preparation for
addition of new KSZ family switches with different tag formats.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Woojung Huh <woojung.huh@microchip.com>
Cc: David S. Miller <davem@davemloft.net>
---
V2: - Rebase on next/master
    - No functional change
---
 drivers/net/dsa/microchip/Kconfig   | 2 +-
 drivers/net/dsa/microchip/ksz9477.c | 2 +-
 include/net/dsa.h                   | 2 +-
 net/dsa/Kconfig                     | 4 ++++
 net/dsa/dsa.c                       | 8 ++++----
 net/dsa/dsa_priv.h                  | 2 +-
 net/dsa/tag_ksz.c                   | 2 +-
 7 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/dsa/microchip/Kconfig b/drivers/net/dsa/microchip/Kconfig
index a8caf9249d50f..bea29fde9f3d1 100644
--- a/drivers/net/dsa/microchip/Kconfig
+++ b/drivers/net/dsa/microchip/Kconfig
@@ -4,7 +4,7 @@ config NET_DSA_MICROCHIP_KSZ_COMMON
 menuconfig NET_DSA_MICROCHIP_KSZ9477
 	tristate "Microchip KSZ9477 series switch support"
 	depends on NET_DSA
-	select NET_DSA_TAG_KSZ
+	select NET_DSA_TAG_KSZ9477
 	select NET_DSA_MICROCHIP_KSZ_COMMON
 	help
 	  This driver adds support for Microchip KSZ9477 switch chips.
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 0684657fbf9a9..57a146a0dd4a2 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -262,7 +262,7 @@ static int ksz9477_reset_switch(struct ksz_device *dev)
 static enum dsa_tag_protocol ksz9477_get_tag_protocol(struct dsa_switch *ds,
 						      int port)
 {
-	return DSA_TAG_PROTO_KSZ;
+	return DSA_TAG_PROTO_KSZ9477;
 }
 
 static int ksz9477_phy_read16(struct dsa_switch *ds, int addr, int reg)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 6ee2e24e0a6e2..b3eefe8e18fd8 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -36,7 +36,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_DSA,
 	DSA_TAG_PROTO_EDSA,
 	DSA_TAG_PROTO_GSWIP,
-	DSA_TAG_PROTO_KSZ,
+	DSA_TAG_PROTO_KSZ9477,
 	DSA_TAG_PROTO_LAN9303,
 	DSA_TAG_PROTO_MTK,
 	DSA_TAG_PROTO_QCA,
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 48c41918fb356..91e52973ee135 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -44,6 +44,10 @@ config NET_DSA_TAG_GSWIP
 config NET_DSA_TAG_KSZ
 	bool
 
+config NET_DSA_TAG_KSZ9477
+	bool
+	select NET_DSA_TAG_KSZ
+
 config NET_DSA_TAG_LAN9303
 	bool
 
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index a69c1790bbfc5..aee909bcddc4f 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -55,8 +55,8 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
 #ifdef CONFIG_NET_DSA_TAG_GSWIP
 	[DSA_TAG_PROTO_GSWIP] = &gswip_netdev_ops,
 #endif
-#ifdef CONFIG_NET_DSA_TAG_KSZ
-	[DSA_TAG_PROTO_KSZ] = &ksz_netdev_ops,
+#ifdef CONFIG_NET_DSA_TAG_KSZ9477
+	[DSA_TAG_PROTO_KSZ9477] = &ksz9477_netdev_ops,
 #endif
 #ifdef CONFIG_NET_DSA_TAG_LAN9303
 	[DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops,
@@ -91,8 +91,8 @@ const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops)
 #ifdef CONFIG_NET_DSA_TAG_GSWIP
 		[DSA_TAG_PROTO_GSWIP] = "gswip",
 #endif
-#ifdef CONFIG_NET_DSA_TAG_KSZ
-		[DSA_TAG_PROTO_KSZ] = "ksz",
+#ifdef CONFIG_NET_DSA_TAG_KSZ9477
+		[DSA_TAG_PROTO_KSZ9477] = "ksz9477",
 #endif
 #ifdef CONFIG_NET_DSA_TAG_LAN9303
 		[DSA_TAG_PROTO_LAN9303] = "lan9303",
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 9e4fd04ab53c8..026a05774bf79 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -210,7 +210,7 @@ extern const struct dsa_device_ops edsa_netdev_ops;
 extern const struct dsa_device_ops gswip_netdev_ops;
 
 /* tag_ksz.c */
-extern const struct dsa_device_ops ksz_netdev_ops;
+extern const struct dsa_device_ops ksz9477_netdev_ops;
 
 /* tag_lan9303.c */
 extern const struct dsa_device_ops lan9303_netdev_ops;
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index 96411f70ab9f4..c24a333e55bde 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -96,7 +96,7 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,
 	return skb;
 }
 
-const struct dsa_device_ops ksz_netdev_ops = {
+const struct dsa_device_ops ksz9477_netdev_ops = {
 	.xmit	= ksz_xmit,
 	.rcv	= ksz_rcv,
 	.overhead = KSZ_INGRESS_TAG_LEN,
-- 
2.18.0

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

* [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code
  2018-12-13 16:01 [PATCH V2 0/3] net: dsa: ksz: Clean up the tag code in prep for more switches Marek Vasut
  2018-12-13 16:01 ` [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 Marek Vasut
@ 2018-12-13 16:01 ` Marek Vasut
  2018-12-14  9:05   ` Andrew Lunn
  2018-12-13 16:01 ` [PATCH V2 3/3] net: dsa: ksz: Add STP multicast handling Marek Vasut
  2 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2018-12-13 16:01 UTC (permalink / raw)
  To: netdev
  Cc: f.fainelli, andrew, Tristram Ha, Marek Vasut, Vivien Didelot,
	Woojung Huh, David S . Miller

From: Tristram Ha <Tristram.Ha@microchip.com>

Factor out common code from the tag_ksz , so that the code can be used
with other KSZ family switches which use differenly sized tags.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Woojung Huh <woojung.huh@microchip.com>
Cc: David S. Miller <davem@davemloft.net>
--
V2: - Rebase on next/master
    - Redo the code refactoring again, this by pulling out common pieces
      of the xmit, receive functions, to avoid function calls through
      pointers.
---
 net/dsa/tag_ksz.c | 112 +++++++++++++++++++++++++++++-----------------
 1 file changed, 72 insertions(+), 40 deletions(-)

diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index c24a333e55bde..6305c4d4068dc 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -14,34 +14,18 @@
 #include <net/dsa.h>
 #include "dsa_priv.h"
 
-/* For Ingress (Host -> KSZ), 2 bytes are added before FCS.
- * ---------------------------------------------------------------------------
- * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|tag1(1byte)|FCS(4bytes)
- * ---------------------------------------------------------------------------
- * tag0 : Prioritization (not used now)
- * tag1 : each bit represents port (eg, 0x01=port1, 0x02=port2, 0x10=port5)
- *
- * For Egress (KSZ -> Host), 1 byte is added before FCS.
- * ---------------------------------------------------------------------------
- * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|FCS(4bytes)
- * ---------------------------------------------------------------------------
- * tag0 : zero-based value represents port
- *	  (eg, 0x00=port1, 0x02=port3, 0x06=port7)
- */
-
-#define	KSZ_INGRESS_TAG_LEN	2
-#define	KSZ_EGRESS_TAG_LEN	1
+/* Typically only one byte is used for tail tag. */
+#define KSZ_EGRESS_TAG_LEN		1
 
-static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
+static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
+				       struct net_device *dev, int len)
 {
-	struct dsa_port *dp = dsa_slave_to_port(dev);
 	struct sk_buff *nskb;
 	int padlen;
-	u8 *tag;
 
 	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
 
-	if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
+	if (skb_tailroom(skb) >= padlen + len) {
 		/* Let dsa_slave_xmit() free skb */
 		if (__skb_put_padto(skb, skb->len + padlen, false))
 			return NULL;
@@ -49,7 +33,7 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
 		nskb = skb;
 	} else {
 		nskb = alloc_skb(NET_IP_ALIGN + skb->len +
-				 padlen + KSZ_INGRESS_TAG_LEN, GFP_ATOMIC);
+				 padlen + len, GFP_ATOMIC);
 		if (!nskb)
 			return NULL;
 		skb_reserve(nskb, NET_IP_ALIGN);
@@ -70,34 +54,82 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
 		consume_skb(skb);
 	}
 
-	tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN);
-	tag[0] = 0;
-	tag[1] = 1 << dp->index; /* destination port */
-
 	return nskb;
 }
 
-static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,
-			       struct packet_type *pt)
+static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
+				      struct net_device *dev,
+				      unsigned int port, unsigned int len)
 {
-	u8 *tag;
-	int source_port;
-
-	tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN;
-
-	source_port = tag[0] & 7;
-
-	skb->dev = dsa_master_find_slave(dev, 0, source_port);
+	skb->dev = dsa_master_find_slave(dev, 0, port);
 	if (!skb->dev)
 		return NULL;
 
-	pskb_trim_rcsum(skb, skb->len - KSZ_EGRESS_TAG_LEN);
+	pskb_trim_rcsum(skb, skb->len - len);
 
 	return skb;
 }
 
+/*
+ * For Ingress (Host -> KSZ9477), 2 bytes are added before FCS.
+ * ---------------------------------------------------------------------------
+ * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|tag1(1byte)|FCS(4bytes)
+ * ---------------------------------------------------------------------------
+ * tag0 : Prioritization (not used now)
+ * tag1 : each bit represents port (eg, 0x01=port1, 0x02=port2, 0x10=port5)
+ *
+ * For Egress (KSZ9477 -> Host), 1 byte is added before FCS.
+ * ---------------------------------------------------------------------------
+ * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|FCS(4bytes)
+ * ---------------------------------------------------------------------------
+ * tag0 : zero-based value represents port
+ *	  (eg, 0x00=port1, 0x02=port3, 0x06=port7)
+ */
+
+#define KSZ9477_INGRESS_TAG_LEN		2
+#define KSZ9477_PTP_TAG_LEN		4
+#define KSZ9477_PTP_TAG_INDICATION	0x80
+
+#define KSZ9477_TAIL_TAG_OVERRIDE	BIT(9)
+#define KSZ9477_TAIL_TAG_LOOKUP		BIT(10)
+
+static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
+				    struct net_device *dev)
+{
+	struct dsa_port *dp = dsa_slave_to_port(dev);
+	struct sk_buff *nskb;
+	u16 *tag;
+	u8 *addr;
+
+	nskb = ksz_common_xmit(skb, dev, KSZ9477_INGRESS_TAG_LEN);
+
+	/* Tag encoding */
+	tag = skb_put(nskb, KSZ9477_INGRESS_TAG_LEN);
+	addr = skb_mac_header(nskb);
+
+	*tag = BIT(dp->index);
+	*tag = cpu_to_be16(*tag);
+
+	return nskb;
+}
+
+static struct sk_buff *ksz9477_rcv(struct sk_buff *skb, struct net_device *dev,
+				   struct packet_type *pt)
+{
+	/* Tag decoding */
+	u8 *tag = skb_tail_pointer(skb) - KSZ_EGRESS_TAG_LEN;
+	unsigned int port = tag[0] & 7;
+	unsigned int len = KSZ_EGRESS_TAG_LEN;
+
+	/* Extra 4-bytes PTP timestamp */
+	if (tag[0] & KSZ9477_PTP_TAG_INDICATION)
+		len += KSZ9477_PTP_TAG_LEN;
+
+	return ksz_common_rcv(skb, dev, port, len);
+}
+
 const struct dsa_device_ops ksz9477_netdev_ops = {
-	.xmit	= ksz_xmit,
-	.rcv	= ksz_rcv,
-	.overhead = KSZ_INGRESS_TAG_LEN,
+	.xmit	= ksz9477_xmit,
+	.rcv	= ksz9477_rcv,
+	.overhead = KSZ9477_INGRESS_TAG_LEN,
 };
-- 
2.18.0

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

* [PATCH V2 3/3] net: dsa: ksz: Add STP multicast handling
  2018-12-13 16:01 [PATCH V2 0/3] net: dsa: ksz: Clean up the tag code in prep for more switches Marek Vasut
  2018-12-13 16:01 ` [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 Marek Vasut
  2018-12-13 16:01 ` [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code Marek Vasut
@ 2018-12-13 16:01 ` Marek Vasut
  2018-12-14  9:07   ` Andrew Lunn
  2 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2018-12-13 16:01 UTC (permalink / raw)
  To: netdev
  Cc: f.fainelli, andrew, Marek Vasut, Tristram Ha, Vivien Didelot,
	Woojung Huh, David S . Miller

In case the destination address is link local, add override bit into the
switch tag to let such a packet through the switch even if the port is down.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Woojung Huh <woojung.huh@microchip.com>
Cc: David S. Miller <davem@davemloft.net>
---
V2: New patch
---
 net/dsa/tag_ksz.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index 6305c4d4068dc..b2d407ee63e8e 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -108,6 +108,10 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
 	addr = skb_mac_header(nskb);
 
 	*tag = BIT(dp->index);
+
+	if (is_link_local_ether_addr(addr))
+		*tag |= KSZ9477_TAIL_TAG_OVERRIDE;
+
 	*tag = cpu_to_be16(*tag);
 
 	return nskb;
-- 
2.18.0

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

* Re: [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477
  2018-12-13 16:01 ` [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 Marek Vasut
@ 2018-12-14  8:42   ` Andrew Lunn
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2018-12-14  8:42 UTC (permalink / raw)
  To: Marek Vasut
  Cc: netdev, f.fainelli, Tristram Ha, Vivien Didelot, Woojung Huh,
	David S . Miller

On Thu, Dec 13, 2018 at 05:01:57PM +0100, Marek Vasut wrote:
> From: Tristram Ha <Tristram.Ha@microchip.com>
> 
> Rename the tag Kconfig option and related macros in preparation for
> addition of new KSZ family switches with different tag formats.
> 
> Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
> Cc: Woojung Huh <woojung.huh@microchip.com>
> Cc: David S. Miller <davem@davemloft.net>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code
  2018-12-13 16:01 ` [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code Marek Vasut
@ 2018-12-14  9:05   ` Andrew Lunn
  2018-12-14 13:30     ` Marek Vasut
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2018-12-14  9:05 UTC (permalink / raw)
  To: Marek Vasut
  Cc: netdev, f.fainelli, Tristram Ha, Vivien Didelot, Woojung Huh,
	David S . Miller

> +static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
> +				       struct net_device *dev, int len)
>  {
> -	struct dsa_port *dp = dsa_slave_to_port(dev);
>  	struct sk_buff *nskb;
>  	int padlen;
> -	u8 *tag;
>  
>  	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
>  
> -	if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
> +	if (skb_tailroom(skb) >= padlen + len) {
>  		/* Let dsa_slave_xmit() free skb */
>  		if (__skb_put_padto(skb, skb->len + padlen, false))
>  			return NULL;

Hi Marek

This can return NULL.

> +static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
> +				    struct net_device *dev)
> +{
> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> +	struct sk_buff *nskb;
> +	u16 *tag;
> +	u8 *addr;
> +
> +	nskb = ksz_common_xmit(skb, dev, KSZ9477_INGRESS_TAG_LEN);

So here you need to check for NULL

Otherwise, i like it. Thanks for removing the function pointer.

	   Andrew

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

* Re: [PATCH V2 3/3] net: dsa: ksz: Add STP multicast handling
  2018-12-13 16:01 ` [PATCH V2 3/3] net: dsa: ksz: Add STP multicast handling Marek Vasut
@ 2018-12-14  9:07   ` Andrew Lunn
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2018-12-14  9:07 UTC (permalink / raw)
  To: Marek Vasut
  Cc: netdev, f.fainelli, Tristram Ha, Vivien Didelot, Woojung Huh,
	David S . Miller

On Thu, Dec 13, 2018 at 05:01:59PM +0100, Marek Vasut wrote:
> In case the destination address is link local, add override bit into the
> switch tag to let such a packet through the switch even if the port is down.

Hi Marek

I think you mean blocked, not down?

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code
  2018-12-14  9:05   ` Andrew Lunn
@ 2018-12-14 13:30     ` Marek Vasut
  2018-12-14 20:11       ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2018-12-14 13:30 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, f.fainelli, Tristram Ha, Vivien Didelot, Woojung Huh,
	David S . Miller

On 12/14/2018 10:05 AM, Andrew Lunn wrote:
>> +static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
>> +				       struct net_device *dev, int len)
>>  {
>> -	struct dsa_port *dp = dsa_slave_to_port(dev);
>>  	struct sk_buff *nskb;
>>  	int padlen;
>> -	u8 *tag;
>>  
>>  	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
>>  
>> -	if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
>> +	if (skb_tailroom(skb) >= padlen + len) {
>>  		/* Let dsa_slave_xmit() free skb */
>>  		if (__skb_put_padto(skb, skb->len + padlen, false))
>>  			return NULL;
> 
> Hi Marek

Hi,

> This can return NULL.
> 
>> +static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
>> +				    struct net_device *dev)
>> +{
>> +	struct dsa_port *dp = dsa_slave_to_port(dev);
>> +	struct sk_buff *nskb;
>> +	u16 *tag;
>> +	u8 *addr;
>> +
>> +	nskb = ksz_common_xmit(skb, dev, KSZ9477_INGRESS_TAG_LEN);
> 
> So here you need to check for NULL

What do we do if the xmit returns NULL ?

-- 
Best regards,
Marek Vasut

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

* Re: [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code
  2018-12-14 13:30     ` Marek Vasut
@ 2018-12-14 20:11       ` Andrew Lunn
  2018-12-15  0:39         ` Marek Vasut
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2018-12-14 20:11 UTC (permalink / raw)
  To: Marek Vasut
  Cc: netdev, f.fainelli, Tristram Ha, Vivien Didelot, Woojung Huh,
	David S . Miller

On Fri, Dec 14, 2018 at 02:30:35PM +0100, Marek Vasut wrote:
> On 12/14/2018 10:05 AM, Andrew Lunn wrote:
> >> +static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
> >> +				       struct net_device *dev, int len)
> >>  {
> >> -	struct dsa_port *dp = dsa_slave_to_port(dev);
> >>  	struct sk_buff *nskb;
> >>  	int padlen;
> >> -	u8 *tag;
> >>  
> >>  	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
> >>  
> >> -	if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
> >> +	if (skb_tailroom(skb) >= padlen + len) {
> >>  		/* Let dsa_slave_xmit() free skb */
> >>  		if (__skb_put_padto(skb, skb->len + padlen, false))
> >>  			return NULL;
> > 
> > Hi Marek
> 
> Hi,
> 
> > This can return NULL.
> > 
> >> +static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
> >> +				    struct net_device *dev)
> >> +{
> >> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> >> +	struct sk_buff *nskb;
> >> +	u16 *tag;
> >> +	u8 *addr;
> >> +
> >> +	nskb = ksz_common_xmit(skb, dev, KSZ9477_INGRESS_TAG_LEN);
> > 
> > So here you need to check for NULL
> 
> What do we do if the xmit returns NULL ?

Return NULL to the caller. There are comments which explain this:

static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
{
[snip]
        /* Transmit function may have to reallocate the original SKB,
         * in which case it must have freed it. Only free it here on error.
         */
        nskb = p->xmit(skb, dev);
        if (!nskb) {
                kfree_skb(skb);
                return NETDEV_TX_OK;
        }

	Andrew

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

* Re: [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code
  2018-12-14 20:11       ` Andrew Lunn
@ 2018-12-15  0:39         ` Marek Vasut
  0 siblings, 0 replies; 10+ messages in thread
From: Marek Vasut @ 2018-12-15  0:39 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, f.fainelli, Tristram Ha, Vivien Didelot, Woojung Huh,
	David S . Miller

On 12/14/2018 09:11 PM, Andrew Lunn wrote:
> On Fri, Dec 14, 2018 at 02:30:35PM +0100, Marek Vasut wrote:
>> On 12/14/2018 10:05 AM, Andrew Lunn wrote:
>>>> +static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
>>>> +				       struct net_device *dev, int len)
>>>>  {
>>>> -	struct dsa_port *dp = dsa_slave_to_port(dev);
>>>>  	struct sk_buff *nskb;
>>>>  	int padlen;
>>>> -	u8 *tag;
>>>>  
>>>>  	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
>>>>  
>>>> -	if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
>>>> +	if (skb_tailroom(skb) >= padlen + len) {
>>>>  		/* Let dsa_slave_xmit() free skb */
>>>>  		if (__skb_put_padto(skb, skb->len + padlen, false))
>>>>  			return NULL;
>>>
>>> Hi Marek
>>
>> Hi,
>>
>>> This can return NULL.
>>>
>>>> +static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
>>>> +				    struct net_device *dev)
>>>> +{
>>>> +	struct dsa_port *dp = dsa_slave_to_port(dev);
>>>> +	struct sk_buff *nskb;
>>>> +	u16 *tag;
>>>> +	u8 *addr;
>>>> +
>>>> +	nskb = ksz_common_xmit(skb, dev, KSZ9477_INGRESS_TAG_LEN);
>>>
>>> So here you need to check for NULL
>>
>> What do we do if the xmit returns NULL ?
> 
> Return NULL to the caller. There are comments which explain this:

Ahh ... right, of course.

> static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
> {
> [snip]
>         /* Transmit function may have to reallocate the original SKB,
>          * in which case it must have freed it. Only free it here on error.
>          */
>         nskb = p->xmit(skb, dev);
>         if (!nskb) {
>                 kfree_skb(skb);
>                 return NETDEV_TX_OK;
>         }
> 
> 	Andrew
> 


-- 
Best regards,
Marek Vasut

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

end of thread, other threads:[~2018-12-15  0:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 16:01 [PATCH V2 0/3] net: dsa: ksz: Clean up the tag code in prep for more switches Marek Vasut
2018-12-13 16:01 ` [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 Marek Vasut
2018-12-14  8:42   ` Andrew Lunn
2018-12-13 16:01 ` [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code Marek Vasut
2018-12-14  9:05   ` Andrew Lunn
2018-12-14 13:30     ` Marek Vasut
2018-12-14 20:11       ` Andrew Lunn
2018-12-15  0:39         ` Marek Vasut
2018-12-13 16:01 ` [PATCH V2 3/3] net: dsa: ksz: Add STP multicast handling Marek Vasut
2018-12-14  9:07   ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.