From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vivien Didelot <vivien.didelot@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>,
Oleksij Rempel <o.rempel@pengutronix.de>,
kernel@pengutronix.de, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Russell King <linux@armlinux.org.uk>
Subject: [PATCH net-next v6 10/10] net: tag: ksz: Add KSZ8863 tag code
Date: Fri, 23 Apr 2021 10:02:18 +0200 [thread overview]
Message-ID: <20210423080218.26526-11-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20210423080218.26526-1-o.rempel@pengutronix.de>
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
Add DSA tag code for Microchip KSZ8863 switch.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
v1 -> v2: - fixed __be16 handling
v2 -> v3: - no changes
v3 -> v4: - changed handling to only one padding byte
v4 -> v5: - incremented DSA_TAG_PROTO_KSZ8863_VALUE
- using tail_tag = true instead of ksz_common_xmit preallocation
---
include/net/dsa.h | 2 ++
net/dsa/tag_ksz.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 507082959aa4..9c8c2b6f0571 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -50,6 +50,7 @@ struct phylink_link_state;
#define DSA_TAG_PROTO_OCELOT_8021Q_VALUE 20
#define DSA_TAG_PROTO_SEVILLE_VALUE 21
#define DSA_TAG_PROTO_BRCM_LEGACY_VALUE 22
+#define DSA_TAG_PROTO_KSZ8863_VALUE 23
enum dsa_tag_protocol {
DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE,
@@ -75,6 +76,7 @@ enum dsa_tag_protocol {
DSA_TAG_PROTO_XRS700X = DSA_TAG_PROTO_XRS700X_VALUE,
DSA_TAG_PROTO_OCELOT_8021Q = DSA_TAG_PROTO_OCELOT_8021Q_VALUE,
DSA_TAG_PROTO_SEVILLE = DSA_TAG_PROTO_SEVILLE_VALUE,
+ DSA_TAG_PROTO_KSZ8863 = DSA_TAG_PROTO_KSZ8863_VALUE,
};
struct packet_type;
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index 4820dbcedfa2..2a06d4087738 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -190,8 +190,60 @@ static const struct dsa_device_ops ksz9893_netdev_ops = {
DSA_TAG_DRIVER(ksz9893_netdev_ops);
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ9893);
+/* For ingress (Host -> KSZ8863), 1 byte is added before FCS.
+ * ---------------------------------------------------------------------------
+ * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|FCS(4bytes)
+ * ---------------------------------------------------------------------------
+ * tag0[1,0] : represents port
+ * (e.g. 0b00=addr-lookup 0b01=port1, 0b10=port2, 0b11=port1+port2)
+ * tag0[3,2] : bits two and three represent prioritization
+ * (e.g. 0b00xx=prio0, 0b01xx=prio1, 0b10xx=prio2, 0b11xx=prio3)
+ *
+ * For egress (KSZ8873 -> Host), 1 byte is added before FCS.
+ * ---------------------------------------------------------------------------
+ * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|FCS(4bytes)
+ * ---------------------------------------------------------------------------
+ * tag0[0] : zero-based value represents port
+ * (eg, 0b0=port1, 0b1=port2)
+ */
+
+static struct sk_buff *ksz8863_xmit(struct sk_buff *skb,
+ struct net_device *dev)
+{
+ struct dsa_port *dp = dsa_slave_to_port(dev);
+
+ /* Tag encoding */
+ u8 *tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
+
+ *tag = BIT(dp->index); /* destination port */
+
+ return skb;
+}
+
+static struct sk_buff *ksz8863_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;
+
+ return ksz_common_rcv(skb, dev, tag[0] & 1, KSZ_EGRESS_TAG_LEN);
+}
+
+static const struct dsa_device_ops ksz8863_netdev_ops = {
+ .name = "ksz8863",
+ .proto = DSA_TAG_PROTO_KSZ8863,
+ .xmit = ksz8863_xmit,
+ .rcv = ksz8863_rcv,
+ .overhead = KSZ_INGRESS_TAG_LEN,
+ .tail_tag = true,
+};
+
+DSA_TAG_DRIVER(ksz8863_netdev_ops);
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ8863);
+
static struct dsa_tag_driver *dsa_tag_driver_array[] = {
&DSA_TAG_DRIVER_NAME(ksz8795_netdev_ops),
+ &DSA_TAG_DRIVER_NAME(ksz8863_netdev_ops),
&DSA_TAG_DRIVER_NAME(ksz9477_netdev_ops),
&DSA_TAG_DRIVER_NAME(ksz9893_netdev_ops),
};
--
2.29.2
prev parent reply other threads:[~2021-04-23 8:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-23 8:02 [PATCH net-next v6 00/10] microchip: add support for ksz88x3 driver family Oleksij Rempel
2021-04-23 8:02 ` [PATCH net-next v6 01/10] net: dsa: microchip: ksz8795: change drivers prefix to be generic Oleksij Rempel
2021-04-24 15:37 ` Andrew Lunn
2021-04-23 8:02 ` [PATCH net-next v6 02/10] net: dsa: microchip: ksz8795: move cpu_select_interface to extra function Oleksij Rempel
2021-04-24 15:38 ` Andrew Lunn
2021-04-23 8:02 ` [PATCH net-next v6 03/10] net: dsa: microchip: ksz8795: move register offsets and shifts to separate struct Oleksij Rempel
2021-04-24 15:43 ` Andrew Lunn
2021-04-23 8:02 ` [PATCH net-next v6 04/10] net: dsa: microchip: ksz8795: add support for ksz88xx chips Oleksij Rempel
2021-04-24 15:51 ` Andrew Lunn
2021-04-23 8:02 ` [PATCH net-next v6 05/10] net: dsa: microchip: Add Microchip KSZ8863 SPI based driver support Oleksij Rempel
2021-04-24 15:54 ` Andrew Lunn
2021-04-23 8:02 ` [PATCH net-next v6 06/10] dt-bindings: net: dsa: document additional Microchip KSZ8863/8873 switch Oleksij Rempel
2021-04-23 8:02 ` [PATCH net-next v6 07/10] net: phy: Add support for microchip SMI0 MDIO bus Oleksij Rempel
2021-04-23 8:02 ` [PATCH net-next v6 08/10] net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support Oleksij Rempel
2021-04-24 16:01 ` Andrew Lunn
2021-04-26 12:25 ` Oleksij Rempel
2021-04-26 12:38 ` Andrew Lunn
2021-04-23 8:02 ` [PATCH net-next v6 09/10] dt-bindings: net: mdio-gpio: add compatible for microchip,mdio-smi0 Oleksij Rempel
2021-04-23 8:02 ` Oleksij Rempel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210423080218.26526-11-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=m.grzeschik@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).