From: Ansuel Smith <ansuelsmth@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: Ansuel Smith <ansuelsmth@gmail.com>
Subject: [net-next RFC PATCH 5/6] net: dsa: tag_qca: Add support for handling mdio read/write packet
Date: Tue, 7 Dec 2021 15:59:41 +0100 [thread overview]
Message-ID: <20211207145942.7444-6-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20211207145942.7444-1-ansuelsmth@gmail.com>
Handle mdio read/write Ethernet packet.
When a packet is received, these operation are done:
1. Qca HDR is checked.
2. Packet type is checked.
3. If the type is an mdio read/write packet is parsed.
4. The header data is parsed and put in the generic mdio struct.
5. The rest of the data is copied to the data mdio struct.
6. The seq number is checked and copared with the one in the mdio struct
7. The ack is set to true to set a correct read/write operation
8. The completion is complete
9. The packet is dropped.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
net/dsa/tag_qca.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c
index b8b05d54a74c..1d2c4f519c99 100644
--- a/net/dsa/tag_qca.c
+++ b/net/dsa/tag_qca.c
@@ -9,6 +9,30 @@
#include "dsa_priv.h"
+static void qca_tag_handle_mdio_packet(struct sk_buff *skb,
+ struct net_device *dev)
+{
+ struct mdio_ethhdr *mdio_ethhdr;
+ struct qca8k_port_tag *header;
+ struct dsa_port *cpu_dp;
+
+ cpu_dp = dev->dsa_ptr;
+ header = cpu_dp->priv;
+
+ mdio_ethhdr = (struct mdio_ethhdr *)skb_mac_header(skb);
+
+ header->data[0] = mdio_ethhdr->mdio_data;
+
+ /* Get the rest of the 12 byte of data */
+ memcpy(header->data + 1, skb->data, QCA_HDR_MDIO_DATA2_LEN);
+
+ /* Make sure the seq match the requested packet */
+ if (mdio_ethhdr->seq == header->seq)
+ header->ack = true;
+
+ complete(&header->rw_done);
+}
+
static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct dsa_port *dp = dsa_slave_to_port(dev);
@@ -52,8 +76,10 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)
pk_type = FIELD_GET(QCA_HDR_RECV_TYPE, hdr);
/* MDIO read/write packet */
- if (pk_type == QCA_HDR_RECV_TYPE_RW_REG_ACK)
+ if (pk_type == QCA_HDR_RECV_TYPE_RW_REG_ACK) {
+ qca_tag_handle_mdio_packet(skb, dev);
return NULL;
+ }
/* Remove QCA tag and recalculate checksum */
skb_pull_rcsum(skb, QCA_HDR_LEN);
--
2.32.0
next prev parent reply other threads:[~2021-12-07 15:00 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 14:59 [net-next RFC PATCH 0/6] Add support for qca8k mdio rw in Ethernet packet Ansuel Smith
2021-12-07 14:59 ` [net-next RFC PATCH 1/6] net: dsa: tag_qca: convert to FIELD macro Ansuel Smith
2021-12-07 14:59 ` [net-next RFC PATCH 2/6] net: dsa: tag_qca: move define to include linux/dsa Ansuel Smith
2021-12-07 14:59 ` [net-next RFC PATCH 3/6] net: dsa: tag_qca: add define for mdio read/write in ethernet packet Ansuel Smith
2021-12-07 14:59 ` [net-next RFC PATCH 4/6] net: dsa: qca8k: Add support for mdio read/write in Ethernet packet Ansuel Smith
2021-12-07 14:59 ` Ansuel Smith [this message]
2021-12-07 14:59 ` [net-next RFC PATCH 6/6] net: dsa: qca8k: cache lo and hi for mdio write Ansuel Smith
2021-12-07 15:15 ` [net-next RFC PATCH 0/6] Add support for qca8k mdio rw in Ethernet packet Andrew Lunn
2021-12-07 15:33 ` Ansuel Smith
2021-12-07 18:49 ` Florian Fainelli
2021-12-07 19:44 ` Ansuel Smith
2021-12-07 21:10 ` Vladimir Oltean
2021-12-07 22:01 ` Ansuel Smith
2021-12-07 22:37 ` Andrew Lunn
2021-12-07 18:41 ` Andrew Lunn
2021-12-07 18:53 ` Ansuel Smith
2021-12-07 19:15 ` Andrew Lunn
2021-12-07 19:21 ` Ansuel Smith
2021-12-07 20:52 ` Vladimir Oltean
2021-12-07 21:47 ` Ansuel Smith
2021-12-07 22:22 ` Andrew Lunn
2021-12-07 22:30 ` Ansuel Smith
2021-12-07 22:46 ` Andrew Lunn
2021-12-07 23:47 ` Vladimir Oltean
2021-12-08 0:04 ` Vladimir Oltean
2021-12-08 0:40 ` Vladimir Oltean
2021-12-08 0:42 ` Ansuel Smith
2021-12-08 1:09 ` Vladimir Oltean
2021-12-08 3:32 ` Ansuel Smith
2021-12-08 11:54 ` Vladimir Oltean
2021-12-08 1:15 ` Andrew Lunn
2021-12-07 22:45 ` Vladimir Oltean
2021-12-07 22:54 ` Andrew Lunn
2021-12-07 23:14 ` Vladimir Oltean
2021-12-08 1:35 ` Andrew Lunn
2021-12-08 3:39 ` Ansuel Smith
2021-12-08 11:51 ` Vladimir Oltean
2021-12-07 23:05 ` Ansuel Smith
2021-12-07 23:20 ` Vladimir Oltean
2021-12-07 23:24 ` Ansuel Smith
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=20211207145942.7444-6-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=vivien.didelot@gmail.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).