From: MD Danish Anwar <danishanwar@ti.com>
To: Randy Dunlap <rdunlap@infradead.org>,
Roger Quadros <rogerq@kernel.org>,
Simon Horman <simon.horman@corigine.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Andrew Lunn <andrew@lunn.ch>,
Richard Cochran <richardcochran@gmail.com>,
Conor Dooley <conor+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Rob Herring <robh+dt@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
"David S. Miller" <davem@davemloft.net>,
MD Danish Anwar <danishanwar@ti.com>
Cc: <nm@ti.com>, <srk@ti.com>, <linux-kernel@vger.kernel.org>,
<devicetree@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-omap@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH v13 04/10] net: ti: icssg-prueth: Add icssg queues APIs and macros
Date: Tue, 1 Aug 2023 14:44:22 +0530 [thread overview]
Message-ID: <20230801091428.1359979-5-danishanwar@ti.com> (raw)
In-Reply-To: <20230801091428.1359979-1-danishanwar@ti.com>
Add icssg_queue.c file. This file introduces macros and APIs related to
ICSSG queues. These will be used by ICSSG Ethernet driver.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
---
drivers/net/ethernet/ti/icssg/icssg_prueth.h | 5 ++
drivers/net/ethernet/ti/icssg/icssg_queues.c | 50 ++++++++++++++++++++
2 files changed, 55 insertions(+)
create mode 100644 drivers/net/ethernet/ti/icssg/icssg_queues.c
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
index e93488a79dbf..42fdf4005010 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
@@ -209,4 +209,9 @@ int emac_set_port_state(struct prueth_emac *emac,
enum icssg_port_state_cmd state);
void icssg_config_set_speed(struct prueth_emac *emac);
+/* Buffer queue helpers */
+int icssg_queue_pop(struct prueth *prueth, u8 queue);
+void icssg_queue_push(struct prueth *prueth, int queue, u16 addr);
+u32 icssg_queue_level(struct prueth *prueth, int queue);
+
#endif /* __NET_TI_ICSSG_PRUETH_H */
diff --git a/drivers/net/ethernet/ti/icssg/icssg_queues.c b/drivers/net/ethernet/ti/icssg/icssg_queues.c
new file mode 100644
index 000000000000..3c34f61ad40b
--- /dev/null
+++ b/drivers/net/ethernet/ti/icssg/icssg_queues.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0
+/* ICSSG Buffer queue helpers
+ *
+ * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com
+ */
+
+#include <linux/regmap.h>
+#include "icssg_prueth.h"
+
+#define ICSSG_QUEUES_MAX 64
+#define ICSSG_QUEUE_OFFSET 0xd00
+#define ICSSG_QUEUE_PEEK_OFFSET 0xe00
+#define ICSSG_QUEUE_CNT_OFFSET 0xe40
+#define ICSSG_QUEUE_RESET_OFFSET 0xf40
+
+int icssg_queue_pop(struct prueth *prueth, u8 queue)
+{
+ u32 val, cnt;
+
+ if (queue >= ICSSG_QUEUES_MAX)
+ return -EINVAL;
+
+ regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, &cnt);
+ if (!cnt)
+ return -EINVAL;
+
+ regmap_read(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, &val);
+
+ return val;
+}
+
+void icssg_queue_push(struct prueth *prueth, int queue, u16 addr)
+{
+ if (queue >= ICSSG_QUEUES_MAX)
+ return;
+
+ regmap_write(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, addr);
+}
+
+u32 icssg_queue_level(struct prueth *prueth, int queue)
+{
+ u32 reg;
+
+ if (queue >= ICSSG_QUEUES_MAX)
+ return 0;
+
+ regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, ®);
+
+ return reg;
+}
--
2.34.1
next prev parent reply other threads:[~2023-08-01 9:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 9:14 [PATCH v13 00/10] Introduce ICSSG based ethernet Driver MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 01/10] net: ti: icssg-prueth: Add Firmware Interface for ICSSG Ethernet driver MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 02/10] net: ti: icssg-prueth: Add mii helper apis and macros MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 03/10] net: ti: icssg-prueth: Add Firmware config and classification APIs MD Danish Anwar
2023-08-01 9:14 ` MD Danish Anwar [this message]
2023-08-01 9:14 ` [PATCH v13 05/10] dt-bindings: net: Add ICSSG Ethernet MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 06/10] net: ti: icssg-prueth: Add ICSSG ethernet driver MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 07/10] net: ti: icssg-prueth: Add ICSSG Stats MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 08/10] net: ti: icssg-prueth: Add Standard network staticstics MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 09/10] net: ti: icssg-prueth: Add ethtool ops for ICSSG Ethernet driver MD Danish Anwar
2023-08-01 9:14 ` [PATCH v13 10/10] net: ti: icssg-prueth: Add Power management support MD Danish Anwar
2023-08-02 9:50 ` [PATCH v13 00/10] Introduce ICSSG based ethernet Driver patchwork-bot+netdevbpf
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=20230801091428.1359979-5-danishanwar@ti.com \
--to=danishanwar@ti.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nm@ti.com \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=richardcochran@gmail.com \
--cc=robh+dt@kernel.org \
--cc=rogerq@kernel.org \
--cc=simon.horman@corigine.com \
--cc=srk@ti.com \
--cc=vigneshr@ti.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).