From: M Chetan Kumar <m.chetan.kumar@intel.com>
To: netdev@vger.kernel.org, linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, krishna.c.sudi@intel.com, linuxwwan@intel.com
Subject: [PATCH V3 07/16] net: iosm: wwan port control device
Date: Thu, 20 May 2021 19:31:49 +0530 [thread overview]
Message-ID: <20210520140158.10132-8-m.chetan.kumar@intel.com> (raw)
In-Reply-To: <20210520140158.10132-1-m.chetan.kumar@intel.com>
Implements wwan port for MBIM & AT protocol communication
Signed-off-by: M Chetan Kumar <m.chetan.kumar@intel.com>
---
v3:
* Renamed file to iosm_ipc_port.c
* WWAN PORT adaptation for AT & MBIM protocol communication.
v2:
* Renamed iosm_sio struct to iosm_cdev.
* Added memory barriers around atomic operations.
---
drivers/net/wwan/iosm/iosm_ipc_port.c | 85 +++++++++++++++++++++++++++
drivers/net/wwan/iosm/iosm_ipc_port.h | 50 ++++++++++++++++
2 files changed, 135 insertions(+)
create mode 100644 drivers/net/wwan/iosm/iosm_ipc_port.c
create mode 100644 drivers/net/wwan/iosm/iosm_ipc_port.h
diff --git a/drivers/net/wwan/iosm/iosm_ipc_port.c b/drivers/net/wwan/iosm/iosm_ipc_port.c
new file mode 100644
index 000000000000..beb944847398
--- /dev/null
+++ b/drivers/net/wwan/iosm/iosm_ipc_port.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2020-21 Intel Corporation.
+ */
+
+#include "iosm_ipc_chnl_cfg.h"
+#include "iosm_ipc_imem_ops.h"
+#include "iosm_ipc_port.h"
+
+/* open logical channel for control communication */
+static int ipc_port_ctrl_start(struct wwan_port *port)
+{
+ struct iosm_cdev *ipc_port = wwan_port_get_drvdata(port);
+ int ret = 0;
+
+ ipc_port->channel = ipc_imem_sys_port_open(ipc_port->ipc_imem,
+ ipc_port->chl_id,
+ IPC_HP_CDEV_OPEN);
+ if (!ipc_port->channel)
+ ret = -EIO;
+
+ return ret;
+}
+
+/* close logical channel */
+static void ipc_port_ctrl_stop(struct wwan_port *port)
+{
+ struct iosm_cdev *ipc_port = wwan_port_get_drvdata(port);
+
+ ipc_imem_sys_cdev_close(ipc_port);
+}
+
+/* transfer control data to modem */
+static int ipc_port_ctrl_tx(struct wwan_port *port, struct sk_buff *skb)
+{
+ struct iosm_cdev *ipc_port = wwan_port_get_drvdata(port);
+
+ return ipc_imem_sys_cdev_write(ipc_port, skb);
+}
+
+static const struct wwan_port_ops ipc_wwan_ctrl_ops = {
+ .start = ipc_port_ctrl_start,
+ .stop = ipc_port_ctrl_stop,
+ .tx = ipc_port_ctrl_tx,
+};
+
+/* Port init func */
+struct iosm_cdev *ipc_port_init(struct iosm_imem *ipc_imem,
+ struct ipc_chnl_cfg ipc_port_cfg)
+{
+ struct iosm_cdev *ipc_port = kzalloc(sizeof(*ipc_port), GFP_KERNEL);
+ enum wwan_port_type port_type = ipc_port_cfg.wwan_port_type;
+ enum ipc_channel_id chl_id = ipc_port_cfg.id;
+
+ if (!ipc_port)
+ return NULL;
+
+ ipc_port->dev = ipc_imem->dev;
+ ipc_port->pcie = ipc_imem->pcie;
+
+ ipc_port->port_type = port_type;
+ ipc_port->chl_id = chl_id;
+ ipc_port->ipc_imem = ipc_imem;
+
+ ipc_port->iosm_port = wwan_create_port(ipc_port->dev, port_type,
+ &ipc_wwan_ctrl_ops, ipc_port);
+
+ return ipc_port;
+}
+
+/* Port deinit func */
+void ipc_port_deinit(struct iosm_cdev *port[])
+{
+ struct iosm_cdev *ipc_port;
+ u8 ctrl_chl_nr;
+
+ for (ctrl_chl_nr = 0; ctrl_chl_nr < IPC_MEM_MAX_CHANNELS;
+ ctrl_chl_nr++) {
+ if (port[ctrl_chl_nr]) {
+ ipc_port = port[ctrl_chl_nr];
+ wwan_remove_port(ipc_port->iosm_port);
+ kfree(ipc_port);
+ }
+ }
+}
diff --git a/drivers/net/wwan/iosm/iosm_ipc_port.h b/drivers/net/wwan/iosm/iosm_ipc_port.h
new file mode 100644
index 000000000000..11bc8ed21616
--- /dev/null
+++ b/drivers/net/wwan/iosm/iosm_ipc_port.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (C) 2020-21 Intel Corporation.
+ */
+
+#ifndef IOSM_IPC_PORT_H
+#define IOSM_IPC_PORT_H
+
+#include <linux/wwan.h>
+
+#include "iosm_ipc_imem_ops.h"
+
+/**
+ * struct iosm_cdev - State of the char driver layer.
+ * @iosm_port: Pointer of type wwan_port
+ * @ipc_imem: imem instance
+ * @dev: Pointer to device struct
+ * @pcie: PCIe component
+ * @port_type: WWAN port type
+ * @channel: Channel instance
+ * @chl_id: Channel Indentifier
+ */
+struct iosm_cdev {
+ struct wwan_port *iosm_port;
+ struct iosm_imem *ipc_imem;
+ struct device *dev;
+ struct iosm_pcie *pcie;
+ enum wwan_port_type port_type;
+ struct ipc_mem_channel *channel;
+ enum ipc_channel_id chl_id;
+};
+
+/**
+ * ipc_port_init - Allocate IPC port & register to wwan subsystem for AT/MBIM
+ * communication.
+ * @ipc_imem: Pointer to iosm_imem structure
+ * @ipc_port_cfg: IPC Port Config
+ *
+ * Returns: 0 on success & NULL on failure
+ */
+struct iosm_cdev *ipc_port_init(struct iosm_imem *ipc_imem,
+ struct ipc_chnl_cfg ipc_port_cfg);
+
+/**
+ * ipc_port_deinit - Free IPC port & unregister port with wwan subsystem.
+ * @ipc_port: Array of pointer to the ipc port data-struct
+ */
+void ipc_port_deinit(struct iosm_cdev *ipc_port[]);
+
+#endif
--
2.25.1
next prev parent reply other threads:[~2021-05-20 14:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 14:01 [PATCH V3 00/16] net: iosm: PCIe Driver for Intel M.2 Modem M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 01/16] net: iosm: entry point M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 02/16] net: iosm: irq handling M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 03/16] net: iosm: mmio scratchpad M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 04/16] net: iosm: shared memory IPC interface M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 05/16] net: iosm: shared memory I/O operations M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 06/16] net: iosm: channel configuration M Chetan Kumar
2021-05-20 14:01 ` M Chetan Kumar [this message]
2021-05-20 14:01 ` [PATCH V3 08/16] net: iosm: bottom half M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 09/16] net: iosm: multiplex IP sessions M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 10/16] net: iosm: encode or decode datagram M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 11/16] net: iosm: power management M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 12/16] net: iosm: shared memory protocol M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 13/16] net: iosm: protocol operations M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 14/16] net: iosm: uevent support M Chetan Kumar
2021-05-20 14:01 ` [PATCH V3 15/16] net: iosm: net driver M Chetan Kumar
2021-05-21 19:55 ` Loic Poulain
2021-05-24 10:36 ` Kumar, M Chetan
2021-05-25 8:24 ` Loic Poulain
2021-05-25 12:55 ` Johannes Berg
2021-05-25 14:59 ` Loic Poulain
2021-05-27 9:40 ` Johannes Berg
2021-05-27 11:39 ` Loic Poulain
2021-06-01 7:31 ` Johannes Berg
2021-05-20 14:01 ` [PATCH V3 16/16] net: iosm: infrastructure M Chetan Kumar
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=20210520140158.10132-8-m.chetan.kumar@intel.com \
--to=m.chetan.kumar@intel.com \
--cc=johannes@sipsolutions.net \
--cc=krishna.c.sudi@intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linuxwwan@intel.com \
--cc=netdev@vger.kernel.org \
/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).