kernel: 5.15: update Aquantia PHY driver to v6.1 code
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 766-v5.18-03-net-dsa-tag_qca-convert-to-FIELD-macro.patch
1 From 6b0458299297ca4ab6fb295800e29a4e501d50c1 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Wed, 2 Feb 2022 01:03:22 +0100
4 Subject: [PATCH 03/16] net: dsa: tag_qca: convert to FIELD macro
5
6 Convert driver to FIELD macro to drop redundant define.
7
8 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
9 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
10 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13 net/dsa/tag_qca.c | 34 +++++++++++++++-------------------
14 1 file changed, 15 insertions(+), 19 deletions(-)
15
16 --- a/net/dsa/tag_qca.c
17 +++ b/net/dsa/tag_qca.c
18 @@ -4,29 +4,24 @@
19 */
20
21 #include <linux/etherdevice.h>
22 +#include <linux/bitfield.h>
23
24 #include "dsa_priv.h"
25
26 #define QCA_HDR_LEN 2
27 #define QCA_HDR_VERSION 0x2
28
29 -#define QCA_HDR_RECV_VERSION_MASK GENMASK(15, 14)
30 -#define QCA_HDR_RECV_VERSION_S 14
31 -#define QCA_HDR_RECV_PRIORITY_MASK GENMASK(13, 11)
32 -#define QCA_HDR_RECV_PRIORITY_S 11
33 -#define QCA_HDR_RECV_TYPE_MASK GENMASK(10, 6)
34 -#define QCA_HDR_RECV_TYPE_S 6
35 +#define QCA_HDR_RECV_VERSION GENMASK(15, 14)
36 +#define QCA_HDR_RECV_PRIORITY GENMASK(13, 11)
37 +#define QCA_HDR_RECV_TYPE GENMASK(10, 6)
38 #define QCA_HDR_RECV_FRAME_IS_TAGGED BIT(3)
39 -#define QCA_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0)
40 +#define QCA_HDR_RECV_SOURCE_PORT GENMASK(2, 0)
41
42 -#define QCA_HDR_XMIT_VERSION_MASK GENMASK(15, 14)
43 -#define QCA_HDR_XMIT_VERSION_S 14
44 -#define QCA_HDR_XMIT_PRIORITY_MASK GENMASK(13, 11)
45 -#define QCA_HDR_XMIT_PRIORITY_S 11
46 -#define QCA_HDR_XMIT_CONTROL_MASK GENMASK(10, 8)
47 -#define QCA_HDR_XMIT_CONTROL_S 8
48 +#define QCA_HDR_XMIT_VERSION GENMASK(15, 14)
49 +#define QCA_HDR_XMIT_PRIORITY GENMASK(13, 11)
50 +#define QCA_HDR_XMIT_CONTROL GENMASK(10, 8)
51 #define QCA_HDR_XMIT_FROM_CPU BIT(7)
52 -#define QCA_HDR_XMIT_DP_BIT_MASK GENMASK(6, 0)
53 +#define QCA_HDR_XMIT_DP_BIT GENMASK(6, 0)
54
55 static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev)
56 {
57 @@ -40,8 +35,9 @@ static struct sk_buff *qca_tag_xmit(stru
58 phdr = dsa_etype_header_pos_tx(skb);
59
60 /* Set the version field, and set destination port information */
61 - hdr = QCA_HDR_VERSION << QCA_HDR_XMIT_VERSION_S |
62 - QCA_HDR_XMIT_FROM_CPU | BIT(dp->index);
63 + hdr = FIELD_PREP(QCA_HDR_XMIT_VERSION, QCA_HDR_VERSION);
64 + hdr |= QCA_HDR_XMIT_FROM_CPU;
65 + hdr |= FIELD_PREP(QCA_HDR_XMIT_DP_BIT, BIT(dp->index));
66
67 *phdr = htons(hdr);
68
69 @@ -62,7 +58,7 @@ static struct sk_buff *qca_tag_rcv(struc
70 hdr = ntohs(*phdr);
71
72 /* Make sure the version is correct */
73 - ver = (hdr & QCA_HDR_RECV_VERSION_MASK) >> QCA_HDR_RECV_VERSION_S;
74 + ver = FIELD_GET(QCA_HDR_RECV_VERSION, hdr);
75 if (unlikely(ver != QCA_HDR_VERSION))
76 return NULL;
77
78 @@ -71,7 +67,7 @@ static struct sk_buff *qca_tag_rcv(struc
79 dsa_strip_etype_header(skb, QCA_HDR_LEN);
80
81 /* Get source port information */
82 - port = (hdr & QCA_HDR_RECV_SOURCE_PORT_MASK);
83 + port = FIELD_GET(QCA_HDR_RECV_SOURCE_PORT, hdr);
84
85 skb->dev = dsa_master_find_slave(dev, 0, port);
86 if (!skb->dev)