mbox series

[RFC,net-next,0/4] DSA tagger helpers

Message ID 20210809115722.351383-1-vladimir.oltean@nxp.com
Headers show
Series DSA tagger helpers | expand

Message

Vladimir Oltean Aug. 9, 2021, 11:57 a.m. UTC
The goal of this series is to minimize the use of memmove and skb->data
in the DSA tagging protocol drivers. Unfiltered access to this level of
information is not very friendly to drive-by contributors, and sometimes
is also not the easiest to review.

For starters, I have converted the most common form of DSA tagging
protocols: the DSA headers which are placed where the EtherType is.

The helper functions introduced by this series are:
- dsa_alloc_etype_header
- dsa_strip_etype_header
- dsa_etype_header_pos_rx
- dsa_etype_header_pos_tx

Vladimir Oltean (4):
  net: dsa: create a helper that strips EtherType DSA headers on RX
  net: dsa: create a helper which allocates space for EtherType DSA
    headers
  net: dsa: create a helper for locating EtherType DSA headers on RX
  net: dsa: create a helper for locating EtherType DSA headers on TX

 net/dsa/dsa_priv.h    | 78 +++++++++++++++++++++++++++++++++++++++++++
 net/dsa/tag_brcm.c    | 16 +++------
 net/dsa/tag_dsa.c     | 20 +++++------
 net/dsa/tag_lan9303.c | 18 ++++------
 net/dsa/tag_mtk.c     | 14 +++-----
 net/dsa/tag_qca.c     | 13 +++-----
 net/dsa/tag_rtl4_a.c  | 16 +++------
 net/dsa/tag_sja1105.c | 25 +++++---------
 8 files changed, 119 insertions(+), 81 deletions(-)

Comments

Andrew Lunn Aug. 10, 2021, 1:01 a.m. UTC | #1
On Mon, Aug 09, 2021 at 02:57:19PM +0300, Vladimir Oltean wrote:
> All header taggers open-code a memmove that is fairly not all that

> obvious, and we can hide the details behind a helper function, since the

> only thing specific to the driver is the length of the header tag.

> 

> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>


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


    Andrew
Andrew Lunn Aug. 10, 2021, 1:05 a.m. UTC | #2
On Mon, Aug 09, 2021 at 02:57:21PM +0300, Vladimir Oltean wrote:
> It seems that protocol tagging driver writers are always surprised about

> the formula they use to reach their EtherType header on RX, which

> becomes apparent from the fact that there are comments in multiple

> drivers that mention the same information.

> 

> Create a helper that returns a void pointer to skb->data - 2, as well as

> centralize the explanation why that is the case.

> 

> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>


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


    Andrew
Florian Fainelli Aug. 10, 2021, 9:18 a.m. UTC | #3
On 8/9/2021 4:57 AM, Vladimir Oltean wrote:
> All header taggers open-code a memmove that is fairly not all that

> obvious, and we can hide the details behind a helper function, since the

> only thing specific to the driver is the length of the header tag.

> 

> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>


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

-- 
Florian
Florian Fainelli Aug. 10, 2021, 9:21 a.m. UTC | #4
On 8/9/2021 4:57 AM, Vladimir Oltean wrote:
> It seems that protocol tagging driver writers are always surprised about

> the formula they use to reach their EtherType header on RX, which

> becomes apparent from the fact that there are comments in multiple

> drivers that mention the same information.

> 

> Create a helper that returns a void pointer to skb->data - 2, as well as

> centralize the explanation why that is the case.

> 

> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>


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

-- 
Florian