[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221122111152.160377-4-yanchao.yang@mediatek.com>
Date: Tue, 22 Nov 2022 19:11:42 +0800
From: Yanchao Yang <yanchao.yang@...iatek.com>
To: Loic Poulain <loic.poulain@...aro.org>,
Sergey Ryazanov <ryazanov.s.a@...il.com>,
Johannes Berg <johannes@...solutions.net>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
netdev ML <netdev@...r.kernel.org>,
kernel ML <linux-kernel@...r.kernel.org>
CC: MTK ML <linux-mediatek@...ts.infradead.org>,
Liang Lu <liang.lu@...iatek.com>,
Haijun Liu <haijun.liu@...iatek.com>,
Hua Yang <hua.yang@...iatek.com>,
Ting Wang <ting.wang@...iatek.com>,
Felix Chen <felix.chen@...iatek.com>,
Mingliang Xu <mingliang.xu@...iatek.com>,
Min Dong <min.dong@...iatek.com>,
Aiden Wang <aiden.wang@...iatek.com>,
Guohao Zhang <guohao.zhang@...iatek.com>,
Chris Feng <chris.feng@...iatek.com>,
Yanchao Yang <yanchao.yang@...iatek.com>,
Lambert Wang <lambert.wang@...iatek.com>,
Mingchuang Qiao <mingchuang.qiao@...iatek.com>,
Xiayu Zhang <xiayu.zhang@...iatek.com>,
Haozhe Chang <haozhe.chang@...iatek.com>,
MediaTek Corporation <linuxwwan@...iatek.com>
Subject: [PATCH net-next v1 03/13] net: wwan: tmi: Add control plane transaction layer
From: MediaTek Corporation <linuxwwan@...iatek.com>
The control plane implements TX services that reside in the transaction layer.
The services receive the packets from the port layer and call the corresponding
DMA components to transmit data to the device. Meanwhile, TX services receive
and manage the port control commands from the port layer.
The control plane implements RX services that reside in the transaction layer.
The services receive the downlink packets from the modem and transfer the
packets to the corresponding port layer interfaces.
Signed-off-by: Mingliang Xu <mingliang.xu@...iatek.com>
Signed-off-by: MediaTek Corporation <linuxwwan@...iatek.com>
---
drivers/net/wwan/mediatek/Makefile | 3 +-
drivers/net/wwan/mediatek/mtk_ctrl_plane.c | 62 ++++++++++++++++++++++
drivers/net/wwan/mediatek/mtk_ctrl_plane.h | 35 ++++++++++++
drivers/net/wwan/mediatek/mtk_dev.c | 8 +++
drivers/net/wwan/mediatek/mtk_dev.h | 1 +
5 files changed, 108 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/wwan/mediatek/mtk_ctrl_plane.c
create mode 100644 drivers/net/wwan/mediatek/mtk_ctrl_plane.h
diff --git a/drivers/net/wwan/mediatek/Makefile b/drivers/net/wwan/mediatek/Makefile
index 122a791e1683..69a9fb7d5b96 100644
--- a/drivers/net/wwan/mediatek/Makefile
+++ b/drivers/net/wwan/mediatek/Makefile
@@ -5,7 +5,8 @@ MODULE_NAME := mtk_tmi
mtk_tmi-y = \
pcie/mtk_pci.o \
mtk_dev.o \
- mtk_bm.o
+ mtk_bm.o \
+ mtk_ctrl_plane.o
ccflags-y += -I$(srctree)/$(src)/
ccflags-y += -I$(srctree)/$(src)/pcie/
diff --git a/drivers/net/wwan/mediatek/mtk_ctrl_plane.c b/drivers/net/wwan/mediatek/mtk_ctrl_plane.c
new file mode 100644
index 000000000000..4c8f71223a11
--- /dev/null
+++ b/drivers/net/wwan/mediatek/mtk_ctrl_plane.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: BSD-3-Clause-Clear
+/*
+ * Copyright (c) 2022, MediaTek Inc.
+ */
+
+#include <linux/device.h>
+#include <linux/freezer.h>
+#include <linux/kthread.h>
+#include <linux/list.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+
+#include "mtk_bm.h"
+#include "mtk_ctrl_plane.h"
+
+int mtk_ctrl_init(struct mtk_md_dev *mdev)
+{
+ struct mtk_ctrl_blk *ctrl_blk;
+ int err;
+
+ ctrl_blk = devm_kzalloc(mdev->dev, sizeof(*ctrl_blk), GFP_KERNEL);
+ if (!ctrl_blk)
+ return -ENOMEM;
+
+ ctrl_blk->mdev = mdev;
+ mdev->ctrl_blk = ctrl_blk;
+
+ ctrl_blk->bm_pool = mtk_bm_pool_create(mdev, MTK_BUFF_SKB,
+ VQ_MTU_3_5K, BUFF_3_5K_MAX_CNT, MTK_BM_LOW_PRIO);
+ if (!ctrl_blk->bm_pool) {
+ err = -ENOMEM;
+ goto err_free_mem;
+ }
+
+ ctrl_blk->bm_pool_63K = mtk_bm_pool_create(mdev, MTK_BUFF_SKB,
+ VQ_MTU_63K, BUFF_63K_MAX_CNT, MTK_BM_LOW_PRIO);
+
+ if (!ctrl_blk->bm_pool_63K) {
+ err = -ENOMEM;
+ goto err_destroy_pool;
+ }
+
+ return 0;
+
+err_destroy_pool:
+ mtk_bm_pool_destroy(mdev, ctrl_blk->bm_pool);
+err_free_mem:
+ devm_kfree(mdev->dev, ctrl_blk);
+
+ return err;
+}
+
+int mtk_ctrl_exit(struct mtk_md_dev *mdev)
+{
+ struct mtk_ctrl_blk *ctrl_blk = mdev->ctrl_blk;
+
+ mtk_bm_pool_destroy(mdev, ctrl_blk->bm_pool);
+ mtk_bm_pool_destroy(mdev, ctrl_blk->bm_pool_63K);
+ devm_kfree(mdev->dev, ctrl_blk);
+
+ return 0;
+}
diff --git a/drivers/net/wwan/mediatek/mtk_ctrl_plane.h b/drivers/net/wwan/mediatek/mtk_ctrl_plane.h
new file mode 100644
index 000000000000..343766a2b39e
--- /dev/null
+++ b/drivers/net/wwan/mediatek/mtk_ctrl_plane.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause-Clear
+ *
+ * Copyright (c) 2022, MediaTek Inc.
+ */
+
+#ifndef __MTK_CTRL_PLANE_H__
+#define __MTK_CTRL_PLANE_H__
+
+#include <linux/kref.h>
+#include <linux/skbuff.h>
+
+#include "mtk_dev.h"
+
+#define VQ_MTU_3_5K (0xE00)
+#define VQ_MTU_63K (0xFC00)
+
+#define BUFF_3_5K_MAX_CNT (100)
+#define BUFF_63K_MAX_CNT (64)
+
+struct mtk_ctrl_trans {
+ struct mtk_ctrl_blk *ctrl_blk;
+ struct mtk_md_dev *mdev;
+};
+
+struct mtk_ctrl_blk {
+ struct mtk_md_dev *mdev;
+ struct mtk_ctrl_trans *trans;
+ struct mtk_bm_pool *bm_pool;
+ struct mtk_bm_pool *bm_pool_63K;
+};
+
+int mtk_ctrl_init(struct mtk_md_dev *mdev);
+int mtk_ctrl_exit(struct mtk_md_dev *mdev);
+
+#endif /* __MTK_CTRL_PLANE_H__ */
diff --git a/drivers/net/wwan/mediatek/mtk_dev.c b/drivers/net/wwan/mediatek/mtk_dev.c
index 513aac37cb9c..96b111be206a 100644
--- a/drivers/net/wwan/mediatek/mtk_dev.c
+++ b/drivers/net/wwan/mediatek/mtk_dev.c
@@ -4,6 +4,7 @@
*/
#include "mtk_bm.h"
+#include "mtk_ctrl_plane.h"
#include "mtk_dev.h"
int mtk_dev_init(struct mtk_md_dev *mdev)
@@ -14,12 +15,19 @@ int mtk_dev_init(struct mtk_md_dev *mdev)
if (ret)
goto err_bm_init;
+ ret = mtk_ctrl_init(mdev);
+ if (ret)
+ goto err_ctrl_init;
+
+err_ctrl_init:
+ mtk_bm_exit(mdev);
err_bm_init:
return ret;
}
void mtk_dev_exit(struct mtk_md_dev *mdev)
{
+ mtk_ctrl_exit(mdev);
mtk_bm_exit(mdev);
}
diff --git a/drivers/net/wwan/mediatek/mtk_dev.h b/drivers/net/wwan/mediatek/mtk_dev.h
index 0c4b727b9c53..d6e8e9b2e52a 100644
--- a/drivers/net/wwan/mediatek/mtk_dev.h
+++ b/drivers/net/wwan/mediatek/mtk_dev.h
@@ -130,6 +130,7 @@ struct mtk_md_dev {
u32 hw_ver;
int msi_nvecs;
char dev_str[MTK_DEV_STR_LEN];
+ void *ctrl_blk;
struct mtk_bm_ctrl *bm_ctrl;
};
--
2.32.0
Powered by blists - more mailing lists