lkml.org 
[lkml]   [2021]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[net-next RFC PATCH v4 10/15] net: dsa: tag_qca: add support for handling mdio Ethernet and MIB packet
Date
Add connect/disconnect helper to assign private struct to the cpu port
dsa priv.
Add support for Ethernet mdio packet and MIB packet if the dsa driver
provide an handler to correctly parse and elaborate the data.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
net/dsa/tag_qca.c | 52 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c
index b91f9f1b2deb..7edc198fdb60 100644
--- a/net/dsa/tag_qca.c
+++ b/net/dsa/tag_qca.c
@@ -32,11 +32,15 @@ static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev)

static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)
{
+ struct dsa_port *dp = dev->dsa_ptr;
+ struct tag_qca_priv *priv;
u16 hdr, pk_type;
__be16 *phdr;
int port;
u8 ver;

+ priv = dp->ds->tagger_data;
+
if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN)))
return NULL;

@@ -51,9 +55,19 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)
/* Get pk type */
pk_type = FIELD_GET(QCA_HDR_RECV_TYPE, hdr);

- /* MDIO read/write packet */
- if (pk_type == QCA_HDR_RECV_TYPE_RW_REG_ACK)
+ /* Ethernet MDIO read/write packet */
+ if (pk_type == QCA_HDR_RECV_TYPE_RW_REG_ACK) {
+ if (priv->rw_reg_ack_handler)
+ priv->rw_reg_ack_handler(dp, skb);
+ return NULL;
+ }
+
+ /* Ethernet MIB counter packet */
+ if (pk_type == QCA_HDR_RECV_TYPE_MIB) {
+ if (priv->mib_autocast_handler)
+ priv->mib_autocast_handler(dp, skb);
return NULL;
+ }

/* Remove QCA tag and recalculate checksum */
skb_pull_rcsum(skb, QCA_HDR_LEN);
@@ -69,9 +83,43 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)
return skb;
}

+static int qca_tag_connect(struct dsa_switch_tree *dst)
+{
+ struct tag_qca_priv *priv;
+ struct dsa_port *dp;
+
+ list_for_each_entry(dp, &dst->ports, list) {
+ if (dp->ds->tagger_data)
+ continue;
+
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ dp->ds->tagger_data = priv;
+ }
+
+ return 0;
+}
+
+static void qca_tag_disconnect(struct dsa_switch_tree *dst)
+{
+ struct dsa_port *dp;
+
+ list_for_each_entry(dp, &dst->ports, list) {
+ if (dp->ds->tagger_data)
+ continue;
+
+ kfree(dp->ds->tagger_data);
+ dp->ds->tagger_data = NULL;
+ }
+}
+
static const struct dsa_device_ops qca_netdev_ops = {
.name = "qca",
.proto = DSA_TAG_PROTO_QCA,
+ .connect = qca_tag_connect,
+ .disconnect = qca_tag_disconnect,
.xmit = qca_tag_xmit,
.rcv = qca_tag_rcv,
.needed_headroom = QCA_HDR_LEN,
--
2.32.0
\
 
 \ /
  Last update: 2021-12-11 20:59    [W:0.116 / U:1.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site