diff mbox series

[RFC,net-next,03/28] net: ethernet: ti: introduce the CPSW Proxy Client

Message ID 20240518124234.2671651-4-s-vadapalli@ti.com (mailing list archive)
State New, archived
Headers show
Series Add CPSW Proxy Client driver | expand

Commit Message

Siddharth Vadapalli May 18, 2024, 12:42 p.m. UTC
The CPSW Proxy Client driver in Linux communicates with Ethernet
Switch Firmware (EthFw) running on a remote core via RPMsg.
EthFw announces its RPMsg Endpoint over the RPMsg-Bus notifying
its presence to all Clients.

Register the CPSW Proxy Client driver with the RPMsg framework.

Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
 drivers/net/ethernet/ti/Kconfig             | 14 +++++
 drivers/net/ethernet/ti/Makefile            |  3 +
 drivers/net/ethernet/ti/cpsw-proxy-client.c | 70 +++++++++++++++++++++
 3 files changed, 87 insertions(+)
 create mode 100644 drivers/net/ethernet/ti/cpsw-proxy-client.c
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index 1729eb0e0b41..ffbfd625625d 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -79,6 +79,20 @@  config TI_CPSW_SWITCHDEV
 	  To compile this driver as a module, choose M here: the module
 	  will be called cpsw_new.
 
+config TI_CPSW_PROXY_CLIENT
+	tristate "TI CPSW Proxy Client"
+	depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
+	help
+		This driver supports Ethernet functionality for CPSWnG
+		Ethernet Subsystem which is configured by Ethernet Switch
+		Firmware (EthFw).
+
+		The Ethernet Switch Firmware acts as a proxy to the Linux
+		Client driver by performing all the necessary configuration
+		of the CPSW Peripheral while enabling network data transfer
+		to/from the Linux Client to CPSW over the allocated TX DMA
+		Channels and RX DMA Flows.
+
 config TI_CPTS
 	tristate "TI Common Platform Time Sync (CPTS) Support"
 	depends on ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST
diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
index 6e086b4c0384..229b828f099e 100644
--- a/drivers/net/ethernet/ti/Makefile
+++ b/drivers/net/ethernet/ti/Makefile
@@ -7,6 +7,9 @@  obj-$(CONFIG_TI_CPSW) += cpsw-common.o
 obj-$(CONFIG_TI_DAVINCI_EMAC) += cpsw-common.o
 obj-$(CONFIG_TI_CPSW_SWITCHDEV) += cpsw-common.o
 
+obj-$(CONFIG_TI_CPSW_PROXY_CLIENT) += ti-cpsw-proxy-client.o
+ti-cpsw-proxy-client-y := cpsw-proxy-client.o
+
 obj-$(CONFIG_TLAN) += tlan.o
 obj-$(CONFIG_TI_DAVINCI_EMAC) += ti_davinci_emac.o
 ti_davinci_emac-y := davinci_emac.o davinci_cpdma.o
diff --git a/drivers/net/ethernet/ti/cpsw-proxy-client.c b/drivers/net/ethernet/ti/cpsw-proxy-client.c
new file mode 100644
index 000000000000..91d3338b3788
--- /dev/null
+++ b/drivers/net/ethernet/ti/cpsw-proxy-client.c
@@ -0,0 +1,70 @@ 
+// SPDX-License-Identifier: GPL-2.0-only or MIT
+/* Texas Instruments CPSW Proxy Client Driver
+ *
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+
+#include "ethfw_abi.h"
+
+struct cpsw_proxy_priv {
+	struct rpmsg_device		*rpdev;
+	struct device			*dev;
+};
+
+static int cpsw_proxy_client_cb(struct rpmsg_device *rpdev, void *data,
+				int len, void *priv, u32 src)
+{
+	struct device *dev = &rpdev->dev;
+
+	dev_dbg(dev, "callback invoked\n");
+
+	return 0;
+}
+
+static int cpsw_proxy_client_probe(struct rpmsg_device *rpdev)
+{
+	struct cpsw_proxy_priv *proxy_priv;
+
+	proxy_priv = devm_kzalloc(&rpdev->dev, sizeof(struct cpsw_proxy_priv), GFP_KERNEL);
+	if (!proxy_priv)
+		return -ENOMEM;
+
+	proxy_priv->rpdev = rpdev;
+	proxy_priv->dev = &rpdev->dev;
+	dev_dbg(proxy_priv->dev, "driver probed\n");
+
+	return 0;
+}
+
+static void cpsw_proxy_client_remove(struct rpmsg_device *rpdev)
+{
+	struct device *dev = &rpdev->dev;
+
+	dev_dbg(dev, "driver removed\n");
+}
+
+static struct rpmsg_device_id cpsw_proxy_client_id_table[] = {
+	{
+		.name = ETHFW_SERVICE_EP_NAME,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(rpmsg, cpsw_proxy_client_id_table);
+
+static struct rpmsg_driver cpsw_proxy_client_driver = {
+	.drv.name	= KBUILD_MODNAME,
+	.id_table	= cpsw_proxy_client_id_table,
+	.probe		= cpsw_proxy_client_probe,
+	.callback	= cpsw_proxy_client_cb,
+	.remove		= cpsw_proxy_client_remove,
+};
+module_rpmsg_driver(cpsw_proxy_client_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("CPSW Proxy Client Driver");
+MODULE_AUTHOR("Siddharth Vadapalli <s-vadapalli@ti.com>");