net: wwan: Add Qualcomm BAM-DMUX WWAN network driver
Subsystems (6)
Stephan Gerhold
maintainerv3 cover net: wwan: Add Qualcomm BAM-DMUX WWAN network driver
The BAM Data Multiplexer provides access to the network data channels of modems integrated into many older Qualcomm SoCs, e.g. Qualcomm MSM8916 or MSM8974. This series adds a driver that allows using it.
All the changes in this patch series are based on a quite complicated driver from Qualcomm [1]. The driver has been used in postmarketOS [2] on various smartphones/tablets based on Qualcomm MSM8916 and MSM8974 for more than a year now with no reported problems. It works out of the box with open-source WWAN userspace such as ModemManager.
[1]: https://source.codeaurora.org/quic/la/kernel/msm-3.10/tree/drivers/soc/qcom/bam_dmux.c?h=LA.BR.1.2.9.1-02310-8x16.0
[2]: https://postmarketos.org/
---
Changes in v3:
- Clarify DT schema based on discussion
- Drop bam_dma/dmaengine patches since they already landed in 5.16
- Rebase on net-next
- Simplify cover letter and commit messages
Changes in v2:
- Rename "qcom,remote-power-collapse" -> "qcom,powered-remotely"
- Rebase on net-next and fix conflicts
- Rename network interfaces from "rmnet%d" -> "wwan%d"
- Fix wrong file name in MAINTAINERS entry
Stephan Gerhold (2):
dt-bindings: net: Add schema for Qualcomm BAM-DMUX
net: wwan: Add Qualcomm BAM-DMUX WWAN network driver
.../bindings/net/qcom,bam-dmux.yaml | 92 ++ MAINTAINERS | 8 + drivers/net/wwan/Kconfig | 13 + drivers/net/wwan/Makefile | 1 + drivers/net/wwan/qcom_bam_dmux.c | 907 ++++++++++++++++++ 5 files changed, 1021 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/qcom,bam-dmux.yaml create mode 100644 drivers/net/wwan/qcom_bam_dmux.c
Signature · 1 line
2.34.1
Stephan Gerhold
maintainerPATCH v3 1/2 dt-bindings: net: Add schema for Qualcomm BAM-DMUX
The BAM Data Multiplexer provides access to the network data channels of modems integrated into many older Qualcomm SoCs, e.g. Qualcomm MSM8916 or MSM8974. It is built using a simple protocol layer on top of a DMA engine (Qualcomm BAM) and bidirectional interrupts to coordinate power control.
The device tree node combines the incoming interrupt with the outgoing interrupts (smem-states) as well as the two DMA channels, which allows the BAM-DMUX driver to request all necessary resources.
---
Changes in v2: Clarify that bam-dmux does not directly describe a hardware
block but actually a "firmware convention" that combines different hardware blocks that are described separately.
Changes since RFC: None.
--- .../bindings/net/qcom,bam-dmux.yaml | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/qcom,bam-dmux.yaml
Documentation/devicetree/bindings/net/qcom,bam-dmux.yaml new file +92 -0
@@ -0,0 +1,92 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/qcom,bam-dmux.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm BAM Data Multiplexer + +maintainers: + - Stephan Gerhold <[email protected]> + +description: | + The BAM Data Multiplexer provides access to the network data channels + of modems integrated into many older Qualcomm SoCs, e.g. Qualcomm MSM8916 + or MSM8974. It is built using a simple protocol layer on top of a DMA engine + (Qualcomm BAM DMA) and bidirectional interrupts to coordinate power control. + + Note that this schema does not directly describe a hardware block but rather + a firmware convention that combines several other hardware blocks (such as the + DMA engine). As such it is specific to a firmware version, not a particular + SoC or hardware version. + +properties: + compatible: + const: qcom,bam-dmux + + interrupts: + description: + Interrupts used by the modem to signal the AP. + Both interrupts must be declared as IRQ_TYPE_EDGE_BOTH. + items: + - description: Power control + - description: Power control acknowledgment + + interrupt-names: + items: + - const: pc + - const: pc-ack + + qcom,smem-states: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: State bits used by the AP to signal the modem. + items: + - description: Power control + - description: Power control acknowledgment + + qcom,smem-state-names: + description: Names for the state bits used by the AP to signal the modem. + items: + - const: pc + - const: pc-ack + + dmas: + items: + - description: TX DMA channel phandle + - description: RX DMA channel phandle + + dma-names: + items: + - const: tx + - const: rx + +required: + - compatible + - interrupts + - interrupt-names + - qcom,smem-states + - qcom,smem-state-names + - dmas + - dma-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + mpss: remoteproc { + bam-dmux { + compatible = "qcom,bam-dmux"; + + interrupt-parent = <&modem_smsm>; + interrupts = <1 IRQ_TYPE_EDGE_BOTH>, <11 IRQ_TYPE_EDGE_BOTH>; + interrupt-names = "pc", "pc-ack"; + + qcom,smem-states = <&apps_smsm 1>, <&apps_smsm 11>; + qcom,smem-state-names = "pc", "pc-ack"; + + dmas = <&bam_dmux_dma 4>, <&bam_dmux_dma 5>; + dma-names = "tx", "rx"; + }; + };
Signature · 1 line
2.34.1
Stephan Gerhold
maintainerPATCH v3 2/2 net: wwan: Add Qualcomm BAM-DMUX WWAN network driver
In reply to Stephan GerholdThe BAM Data Multiplexer provides access to the network data channels of modems integrated into many older Qualcomm SoCs, e.g. Qualcomm MSM8916 or MSM8974. It is built using a simple protocol layer on top of a DMA engine (Qualcomm BAM) and bidirectional interrupts to coordinate power control.
The modem announces a fixed set of channels by sending an OPEN command. The driver exports each channel as separate network interface so that a connection can be established via QMI from userspace. The network interface can work either in Ethernet or Raw-IP mode (configurable via QMI). However, Ethernet mode seems to be broken with most firmwares (network packets are actually received as Raw-IP), therefore the driver only supports Raw-IP mode.
Note that the control channel (QMI/AT) is entirely separate from BAM-DMUX and is already supported by the RPMSG_WWAN_CTRL driver.
The driver uses runtime PM to coordinate power control with the modem. TX/RX buffers are put in a kind of "ring queue" and submitted via the bam_dma driver of the DMAEngine subsystem.
The basic architecture looks roughly like this:
+------------+ +-------+
[IPv4/6] | BAM-DMUX | | |
[Data...] | | | |
---------->|wwan0 | [DMUX chan: x] | |
[IPv4/6] | (chan: 0) | [IPv4/6] | |
[Data...] | | [Data...] | |
---------->|wwan1 |--------------->| Modem |
| (chan: 1) | BAM | |
[IPv4/6] | ... | (DMA Engine) | |
[Data...] | | | |
---------->|wwan7 | | |
| (chan: 7) | | |
+------------+ +-------+Note that some newer firmware versions support QMAP ("rmnet" driver) as additional multiplexing layer on top of BAM-DMUX, but this is not currently supported by this driver.
---
Note that this is my first network driver, so I apologize in advance if I made some obvious mistakes. :)
Changes in v2:
- Rebase on net-next
- Simplify commit message by dropping unsupported QMAP architecture
Changes since RFC:
- Rebase on net-next and fix conflicts
- Rename network interfaces from "rmnet%d" -> "wwan%d"
- Fix wrong file name in MAINTAINERS entry
- Clarify control channel in commit message. (It is entirely independent of BAM-DMUX and is already supported by the RPMSG WWAN CTRL driver.)
In combination with the RPMSG_WWAN_CTRL driver the WWAN control ports (QMI/AT) are exposed via the WWAN subsystem. However, the driver does not yet use the link management of the WWAN subsystem. Instead, it simply exposes one network interface for each of the up to 8 channels.
This setup works out of the box with all available open-source userspace WWAN implementations, especially ModemManager (no changes needed). It was easy to support because the setup is very similar to ones already supported for USB modems. Some of them provide multiple network interfaces and ModemManager can bundle them together to a single modem.
As far as I know, using the WWAN link management is an unsolved problem for all the QMI-based setups in the kernel (qmi_wwan, mhi_net, ipa, ...) There are several open problems that I explained in [1] and [2].
What I want to avoid is to create just yet another special setup for BAM-DMUX that needs extra code in WWAN userspace. If we cannot make all the QMI-based setups use the WWAN subsystem then userspace will just get more complicated, not simpler. The current setup in this driver is already supported by ModemManager and therefore does not make userspace any more complicated at least. :)
I'm hoping we can either accept the current setup as-is for now (and try converting all the QMI setups together later) or somehow find a good solution for this since this has been the main blocker for this driver for several months now and I'm still not sure how to solve it. :/
[1]: https://lore.kernel.org/netdev/[email protected]/
[2]: https://lore.kernel.org/netdev/[email protected]/
--- MAINTAINERS | 8 + drivers/net/wwan/Kconfig | 13 + drivers/net/wwan/Makefile | 1 + drivers/net/wwan/qcom_bam_dmux.c | 907 +++++++++++++++++++++++++++++++ 4 files changed, 929 insertions(+) create mode 100644 drivers/net/wwan/qcom_bam_dmux.c
MAINTAINERS +8 -0
@@ -15727,6 +15727,14 @@ W: https://wireless.wiki.kernel.org/en/users/Drivers/ath9k F: Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml F: drivers/net/wireless/ath/ath9k/ +QUALCOMM BAM-DMUX WWAN NETWORK DRIVER +M: Stephan Gerhold <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/net/qcom,bam-dmux.yaml +F: drivers/net/wwan/qcom_bam_dmux.c + QUALCOMM CAMERA SUBSYSTEM DRIVER M: Robert Foss <[email protected]> M: Todor Tomov <[email protected]>
drivers/net/wwan/Kconfig +13 -0
@@ -50,6 +50,19 @@ config MHI_WWAN_MBIM To compile this driver as a module, choose M here: the module will be called mhi_wwan_mbim. +config QCOM_BAM_DMUX + tristate "Qualcomm BAM-DMUX WWAN network driver" + depends on (DMA_ENGINE && PM && QCOM_SMEM_STATE) || COMPILE_TEST + help + The BAM Data Multiplexer provides access to the network data channels + of modems integrated into many older Qualcomm SoCs, e.g. Qualcomm + MSM8916 or MSM8974. The connection can be established via QMI/AT from + userspace with control ports available through the WWAN subsystem + (CONFIG_RPMSG_WWAN_CTRL) or QRTR network sockets (CONFIG_QRTR). + + To compile this driver as a module, choose M here: the module will be + called qcom_bam_dmux. + config RPMSG_WWAN_CTRL tristate "RPMSG WWAN control driver" depends on RPMSG
drivers/net/wwan/Makefile +1 -0
@@ -10,5 +10,6 @@ obj-$(CONFIG_WWAN_HWSIM) += wwan_hwsim.o obj-$(CONFIG_MHI_WWAN_CTRL) += mhi_wwan_ctrl.o obj-$(CONFIG_MHI_WWAN_MBIM) += mhi_wwan_mbim.o +obj-$(CONFIG_QCOM_BAM_DMUX) += qcom_bam_dmux.o obj-$(CONFIG_RPMSG_WWAN_CTRL) += rpmsg_wwan_ctrl.o obj-$(CONFIG_IOSM) += iosm/
drivers/net/wwan/qcom_bam_dmux.c new file +907 -0
907 lines not on this page · raw message
Signature · 1 line
2.34.1
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 11 lines · On Sat, 27 Nov 2021 18:31:06 +0100 you wrote:
The BAM Data Multiplexer provides access to the network data channels of modems integrated into many older Qualcomm SoCs, e.g. Qualcomm MSM8916 or MSM8974. This series adds a driver that allows using it.
All the changes in this patch series are based on a quite complicated driver from Qualcomm [1]. The driver has been used in postmarketOS [2] on various smartphones/tablets based on Qualcomm MSM8916 and MSM8974 for more than a year now with no reported problems. It works out of the box with open-source WWAN userspace such as ModemManager.
[...]
Here is the summary with links:
- [net-next,v3,1/2] dt-bindings: net: Add schema for Qualcomm BAM-DMUX
https://git.kernel.org/netdev/net-next/c/f3aee7c900ed - [net-next,v3,2/2] net: wwan: Add Qualcomm BAM-DMUX WWAN network driver https://git.kernel.org/netdev/net-next/c/21a0ffd9b38c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html