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


Groups > linux.kernel > #1742283 > unrolled thread

[PATCH net-next 0/8] net: dsa: change dsa_ptr for a dsa_port

Started byVivien Didelot <vivien.didelot@savoirfairelinux.com>
First post2017-09-29 20:50 +0200
Last post2017-09-29 21:40 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net-next 0/8] net: dsa: change dsa_ptr for a dsa_port Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-09-29 20:50 +0200
    [PATCH net-next 8/8] net: dsa: remove tag ops from the switch tree Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-09-29 20:50 +0200
    [PATCH net-next 4/8] net: dsa: use temporary dsa_device_ops variable Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-09-29 20:50 +0200
      Re: [PATCH net-next 4/8] net: dsa: use temporary dsa_device_ops  variable Florian Fainelli <f.fainelli@gmail.com> - 2017-09-29 21:20 +0200
    Re: [PATCH net-next 0/8] net: dsa: change dsa_ptr for a dsa_port Florian Fainelli <f.fainelli@gmail.com> - 2017-09-29 21:30 +0200
      Re: [PATCH net-next 0/8] net: dsa: change dsa_ptr for a dsa_port Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-09-29 21:40 +0200

#1742283 — [PATCH net-next 0/8] net: dsa: change dsa_ptr for a dsa_port

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-09-29 20:50 +0200
Subject[PATCH net-next 0/8] net: dsa: change dsa_ptr for a dsa_port
Message-ID<uv8wh-1rx-5@gated-at.bofh.it>
With DSA, a master net_device is physically wired to a dedicated CPU
switch port. For interaction with the DSA layer, the struct net_device
contains a dsa_ptr, which currently points to a dsa_switch_tree object.

This is only valid for a switch fabric with a single CPU port. In order
to support switch fabrics with multiple CPU ports, we first need to
change the type of dsa_ptr to what it really is: a dsa_port object.

This is what this patchset does. The first 4 patches cleans up portions
of DSA core to make the next patches more readable. These next patches
prepare the xmit and receive hot paths and finally change dsa_ptr.

Vivien Didelot (8):
  net: dsa: directly fetch switch in mtk_tag_rcv
  net: dsa: directly fetch switch in lan9303_rcv
  net: dsa: use cpu_dp in master code
  net: dsa: use temporary dsa_device_ops variable
  net: dsa: add tagging ops to port
  net: dsa: prepare master receive hot path
  net: dsa: change dsa_ptr for a dsa_port
  net: dsa: remove tag ops from the switch tree

 include/linux/netdevice.h |  4 ++--
 include/net/dsa.h         | 19 ++++++++-----------
 net/dsa/dsa.c             |  6 +++---
 net/dsa/dsa2.c            | 15 ++++++++++-----
 net/dsa/dsa_priv.h        |  7 +------
 net/dsa/legacy.c          | 15 ++++++++++-----
 net/dsa/master.c          | 47 ++++++++++++++++++++++-------------------------
 net/dsa/slave.c           |  3 +--
 net/dsa/tag_brcm.c        |  3 +--
 net/dsa/tag_dsa.c         |  3 ++-
 net/dsa/tag_edsa.c        |  3 ++-
 net/dsa/tag_ksz.c         |  3 +--
 net/dsa/tag_lan9303.c     |  6 ++----
 net/dsa/tag_mtk.c         | 12 ++----------
 net/dsa/tag_qca.c         |  3 +--
 net/dsa/tag_trailer.c     |  3 +--
 16 files changed, 69 insertions(+), 83 deletions(-)

-- 
2.14.1

[toc] | [next] | [standalone]


#1742284 — [PATCH net-next 8/8] net: dsa: remove tag ops from the switch tree

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-09-29 20:50 +0200
Subject[PATCH net-next 8/8] net: dsa: remove tag ops from the switch tree
Message-ID<uv8wi-1rx-23@gated-at.bofh.it>
In reply to#1742283
Now that the dsa_ptr is a dsa_port instance, there is no need to keep
the tag operations in the dsa_switch_tree structure. Remove it.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 include/net/dsa.h | 11 -----------
 net/dsa/dsa2.c    |  2 --
 net/dsa/legacy.c  |  2 --
 3 files changed, 15 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 75dc4024f5a8..bf1006f7c0aa 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -130,11 +130,6 @@ struct dsa_switch_tree {
 	 */
 	struct dsa_platform_data	*pd;
 
-	/* Copy of tag_ops->rcv for faster access in hot path */
-	struct sk_buff *	(*rcv)(struct sk_buff *skb,
-				       struct net_device *dev,
-				       struct packet_type *pt);
-
 	/*
 	 * The switch port to which the CPU is attached.
 	 */
@@ -144,12 +139,6 @@ struct dsa_switch_tree {
 	 * Data for the individual switch chips.
 	 */
 	struct dsa_switch	*ds[DSA_MAX_SWITCHES];
-
-	/*
-	 * Tagging protocol operations for adding and removing an
-	 * encapsulation tag.
-	 */
-	const struct dsa_device_ops *tag_ops;
 };
 
 /* TC matchall action types, only mirroring for now */
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 62302558f38c..54ed054777bd 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -523,11 +523,9 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 	}
 
 	dst->cpu_dp->tag_ops = tag_ops;
-	dst->tag_ops = tag_ops;
 
 	/* Make a few copies for faster access in master receive hot path */
 	dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
-	dst->rcv = dst->tag_ops->rcv;
 	dst->cpu_dp->dst = dst;
 
 	return 0;
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index 71917505a5cc..19ff6e0a21dc 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -153,11 +153,9 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
 			return PTR_ERR(tag_ops);
 
 		dst->cpu_dp->tag_ops = tag_ops;
-		dst->tag_ops = tag_ops;
 
 		/* Few copies for faster access in master receive hot path */
 		dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
-		dst->rcv = dst->tag_ops->rcv;
 		dst->cpu_dp->dst = dst;
 	}
 
-- 
2.14.1

[toc] | [prev] | [next] | [standalone]


#1742286 — [PATCH net-next 4/8] net: dsa: use temporary dsa_device_ops variable

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-09-29 20:50 +0200
Subject[PATCH net-next 4/8] net: dsa: use temporary dsa_device_ops variable
Message-ID<uv8wi-1rx-27@gated-at.bofh.it>
In reply to#1742283
When resolving the DSA tagging protocol used by a CPU switch, use a
temporary "tag_ops" variable to store the dsa_device_ops instead of
using directly dst->tag_ops. This will make the future patches moving
this pointer around easier to read.

There is no functional changes.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/dsa2.c   | 8 +++++---
 net/dsa/legacy.c | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index dcccaebde708..6a10c5c1639f 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -485,6 +485,7 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 			 struct dsa_switch_tree *dst,
 			 struct dsa_switch *ds)
 {
+	const struct dsa_device_ops *tag_ops;
 	enum dsa_tag_protocol tag_protocol;
 	struct net_device *ethernet_dev;
 	struct device_node *ethernet;
@@ -514,13 +515,14 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 	ds->cpu_port_mask |= BIT(index);
 
 	tag_protocol = ds->ops->get_tag_protocol(ds);
-	dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
-	if (IS_ERR(dst->tag_ops)) {
+	tag_ops = dsa_resolve_tag_protocol(tag_protocol);
+	if (IS_ERR(tag_ops)) {
 		dev_warn(ds->dev, "No tagger for this switch\n");
 		ds->cpu_port_mask &= ~BIT(index);
-		return PTR_ERR(dst->tag_ops);
+		return PTR_ERR(tag_ops);
 	}
 
+	dst->tag_ops = tag_ops;
 	dst->rcv = dst->tag_ops->rcv;
 
 	return 0;
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index ae505d8e4417..8e849013f69d 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -144,13 +144,15 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
 	 * switch.
 	 */
 	if (dst->cpu_dp->ds == ds) {
+		const struct dsa_device_ops *tag_ops;
 		enum dsa_tag_protocol tag_protocol;
 
 		tag_protocol = ops->get_tag_protocol(ds);
-		dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
-		if (IS_ERR(dst->tag_ops))
-			return PTR_ERR(dst->tag_ops);
+		tag_ops = dsa_resolve_tag_protocol(tag_protocol);
+		if (IS_ERR(tag_ops))
+			return PTR_ERR(tag_ops);
 
+		dst->tag_ops = tag_ops;
 		dst->rcv = dst->tag_ops->rcv;
 	}
 
-- 
2.14.1

[toc] | [prev] | [next] | [standalone]


#1742296 — Re: [PATCH net-next 4/8] net: dsa: use temporary dsa_device_ops variable

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-09-29 21:20 +0200
SubjectRe: [PATCH net-next 4/8] net: dsa: use temporary dsa_device_ops variable
Message-ID<uv8Zk-1R9-9@gated-at.bofh.it>
In reply to#1742286
On 09/29/2017 11:36 AM, Vivien Didelot wrote:
> When resolving the DSA tagging protocol used by a CPU switch, use a
> temporary "tag_ops" variable to store the dsa_device_ops instead of
> using directly dst->tag_ops. This will make the future patches moving
> this pointer around easier to read.
> 
> There is no functional changes.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1742304

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-09-29 21:30 +0200
Message-ID<uv990-1UI-23@gated-at.bofh.it>
In reply to#1742283
On 09/29/2017 11:36 AM, Vivien Didelot wrote:
> With DSA, a master net_device is physically wired to a dedicated CPU
> switch port. For interaction with the DSA layer, the struct net_device
> contains a dsa_ptr, which currently points to a dsa_switch_tree object.
> 
> This is only valid for a switch fabric with a single CPU port. In order
> to support switch fabrics with multiple CPU ports, we first need to
> change the type of dsa_ptr to what it really is: a dsa_port object.
> 
> This is what this patchset does. The first 4 patches cleans up portions
> of DSA core to make the next patches more readable. These next patches
> prepare the xmit and receive hot paths and finally change dsa_ptr.

This looks nice and clean, as mentioned in patch 5, there may be room
for organizing the structure a bit more efficiently such that everything
still fits within the first cacheline .

> 
> Vivien Didelot (8):
>   net: dsa: directly fetch switch in mtk_tag_rcv
>   net: dsa: directly fetch switch in lan9303_rcv
>   net: dsa: use cpu_dp in master code
>   net: dsa: use temporary dsa_device_ops variable
>   net: dsa: add tagging ops to port
>   net: dsa: prepare master receive hot path
>   net: dsa: change dsa_ptr for a dsa_port
>   net: dsa: remove tag ops from the switch tree
> 
>  include/linux/netdevice.h |  4 ++--
>  include/net/dsa.h         | 19 ++++++++-----------
>  net/dsa/dsa.c             |  6 +++---
>  net/dsa/dsa2.c            | 15 ++++++++++-----
>  net/dsa/dsa_priv.h        |  7 +------
>  net/dsa/legacy.c          | 15 ++++++++++-----
>  net/dsa/master.c          | 47 ++++++++++++++++++++++-------------------------
>  net/dsa/slave.c           |  3 +--
>  net/dsa/tag_brcm.c        |  3 +--
>  net/dsa/tag_dsa.c         |  3 ++-
>  net/dsa/tag_edsa.c        |  3 ++-
>  net/dsa/tag_ksz.c         |  3 +--
>  net/dsa/tag_lan9303.c     |  6 ++----
>  net/dsa/tag_mtk.c         | 12 ++----------
>  net/dsa/tag_qca.c         |  3 +--
>  net/dsa/tag_trailer.c     |  3 +--
>  16 files changed, 69 insertions(+), 83 deletions(-)
> 


-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1742307

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-09-29 21:40 +0200
Message-ID<uv9iF-20d-11@gated-at.bofh.it>
In reply to#1742304
Hi Florian,

Florian Fainelli <f.fainelli@gmail.com> writes:

> On 09/29/2017 11:36 AM, Vivien Didelot wrote:
>> With DSA, a master net_device is physically wired to a dedicated CPU
>> switch port. For interaction with the DSA layer, the struct net_device
>> contains a dsa_ptr, which currently points to a dsa_switch_tree object.
>> 
>> This is only valid for a switch fabric with a single CPU port. In order
>> to support switch fabrics with multiple CPU ports, we first need to
>> change the type of dsa_ptr to what it really is: a dsa_port object.
>> 
>> This is what this patchset does. The first 4 patches cleans up portions
>> of DSA core to make the next patches more readable. These next patches
>> prepare the xmit and receive hot paths and finally change dsa_ptr.
>
> This looks nice and clean, as mentioned in patch 5, there may be room
> for organizing the structure a bit more efficiently such that everything
> still fits within the first cacheline .

Thanks for this very constructive comment! I'll look into this.


Respinning in a few.

           Vivien

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web