Loic Poulain 163c5e6262 net: mhi: Add mbim proto
MBIM has initially been specified by USB-IF for transporting data (IP)
between a modem and a host over USB. However some modern modems also
support MBIM over PCIe (via MHI). In the same way as QMAP(rmnet), it
allows to aggregate IP packets and to perform context multiplexing.

This change adds minimal MBIM data transport support to MHI, allowing
to support MBIM only modems. MBIM being based on USB NCM, it reuses
and copy some helpers/functions from the USB stack (cdc-ncm, cdc-mbim).

Note that is a subset of the CDC-MBIM specification, supporting only
transport of network data (IP), there is no support for DSS. Moreover
the multi-session (for multi-pdn) is not supported in this initial
version, but will be added latter, and aligned with the cdc-mbim
solution (VLAN tags).

This code has been inspired from the mhi_mbim downstream implementation
(Carl Yin <carl.yin@quectel.com>).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-02-10 15:11:51 -08:00

41 lines
1.0 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
/* MHI Network driver - Network over MHI bus
*
* Copyright (C) 2021 Linaro Ltd <loic.poulain@linaro.org>
*/
struct mhi_net_stats {
u64_stats_t rx_packets;
u64_stats_t rx_bytes;
u64_stats_t rx_errors;
u64_stats_t rx_dropped;
u64_stats_t rx_length_errors;
u64_stats_t tx_packets;
u64_stats_t tx_bytes;
u64_stats_t tx_errors;
u64_stats_t tx_dropped;
struct u64_stats_sync tx_syncp;
struct u64_stats_sync rx_syncp;
};
struct mhi_net_dev {
struct mhi_device *mdev;
struct net_device *ndev;
struct sk_buff *skbagg_head;
struct sk_buff *skbagg_tail;
const struct mhi_net_proto *proto;
void *proto_data;
struct delayed_work rx_refill;
struct mhi_net_stats stats;
u32 rx_queue_sz;
int msg_enable;
};
struct mhi_net_proto {
int (*init)(struct mhi_net_dev *mhi_netdev);
struct sk_buff * (*tx_fixup)(struct mhi_net_dev *mhi_netdev, struct sk_buff *skb);
void (*rx)(struct mhi_net_dev *mhi_netdev, struct sk_buff *skb);
};
extern const struct mhi_net_proto proto_mbim;