Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at d986ba0329dcca102e227995371135c9bbcefb6b 207 lines 6.2 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* Copyright (c) 2021, Linaro Ltd <loic.poulain@linaro.org> */ 3 4#ifndef __WWAN_H 5#define __WWAN_H 6 7#include <linux/poll.h> 8#include <linux/netdevice.h> 9#include <linux/types.h> 10 11/** 12 * enum wwan_port_type - WWAN port types 13 * @WWAN_PORT_AT: AT commands 14 * @WWAN_PORT_MBIM: Mobile Broadband Interface Model control 15 * @WWAN_PORT_QMI: Qcom modem/MSM interface for modem control 16 * @WWAN_PORT_QCDM: Qcom Modem diagnostic interface 17 * @WWAN_PORT_FIREHOSE: XML based command protocol 18 * @WWAN_PORT_XMMRPC: Control protocol for Intel XMM modems 19 * @WWAN_PORT_FASTBOOT: Fastboot protocol control 20 * @WWAN_PORT_ADB: ADB protocol control 21 * @WWAN_PORT_MIPC: MTK MIPC diagnostic interface 22 * @WWAN_PORT_NMEA: embedded GNSS receiver with NMEA output 23 * 24 * @WWAN_PORT_MAX: Highest supported port types 25 * @WWAN_PORT_UNKNOWN: Special value to indicate an unknown port type 26 * @__WWAN_PORT_MAX: Internal use 27 */ 28enum wwan_port_type { 29 WWAN_PORT_AT, 30 WWAN_PORT_MBIM, 31 WWAN_PORT_QMI, 32 WWAN_PORT_QCDM, 33 WWAN_PORT_FIREHOSE, 34 WWAN_PORT_XMMRPC, 35 WWAN_PORT_FASTBOOT, 36 WWAN_PORT_ADB, 37 WWAN_PORT_MIPC, 38 WWAN_PORT_NMEA, 39 40 /* Add new port types above this line */ 41 42 __WWAN_PORT_MAX, 43 WWAN_PORT_MAX = __WWAN_PORT_MAX - 1, 44 WWAN_PORT_UNKNOWN, 45}; 46 47struct device; 48struct file; 49struct netlink_ext_ack; 50struct sk_buff; 51struct wwan_port; 52 53/** struct wwan_port_ops - The WWAN port operations 54 * @start: The routine for starting the WWAN port device. 55 * @stop: The routine for stopping the WWAN port device. 56 * @tx: Non-blocking routine that sends WWAN port protocol data to the device. 57 * @tx_blocking: Optional blocking routine that sends WWAN port protocol data 58 * to the device. 59 * @tx_poll: Optional routine that sets additional TX poll flags. 60 * 61 * The wwan_port_ops structure contains a list of low-level operations 62 * that control a WWAN port device. All functions are mandatory unless specified. 63 */ 64struct wwan_port_ops { 65 int (*start)(struct wwan_port *port); 66 void (*stop)(struct wwan_port *port); 67 int (*tx)(struct wwan_port *port, struct sk_buff *skb); 68 69 /* Optional operations */ 70 int (*tx_blocking)(struct wwan_port *port, struct sk_buff *skb); 71 __poll_t (*tx_poll)(struct wwan_port *port, struct file *filp, 72 poll_table *wait); 73}; 74 75/** struct wwan_port_caps - The WWAN port capbilities 76 * @frag_len: WWAN port TX fragments length 77 * @headroom_len: WWAN port TX fragments reserved headroom length 78 */ 79struct wwan_port_caps { 80 size_t frag_len; 81 unsigned int headroom_len; 82}; 83 84/** 85 * wwan_create_port - Add a new WWAN port 86 * @parent: Device to use as parent and shared by all WWAN ports 87 * @type: WWAN port type 88 * @ops: WWAN port operations 89 * @caps: WWAN port capabilities 90 * @drvdata: Pointer to caller driver data 91 * 92 * Allocate and register a new WWAN port. The port will be automatically exposed 93 * to user as a character device and attached to the right virtual WWAN device, 94 * based on the parent pointer. The parent pointer is the device shared by all 95 * components of a same WWAN modem (e.g. USB dev, PCI dev, MHI controller...). 96 * 97 * drvdata will be placed in the WWAN port device driver data and can be 98 * retrieved with wwan_port_get_drvdata(). 99 * 100 * This function must be balanced with a call to wwan_remove_port(). 101 * 102 * Returns: a valid pointer to wwan_port on success or PTR_ERR on failure 103 */ 104struct wwan_port *wwan_create_port(struct device *parent, 105 enum wwan_port_type type, 106 const struct wwan_port_ops *ops, 107 struct wwan_port_caps *caps, 108 void *drvdata); 109 110/** 111 * wwan_remove_port - Remove a WWAN port 112 * @port: WWAN port to remove 113 * 114 * Remove a previously created port. 115 */ 116void wwan_remove_port(struct wwan_port *port); 117 118/** 119 * wwan_port_rx - Receive data from the WWAN port 120 * @port: WWAN port for which data is received 121 * @skb: Pointer to the rx buffer 122 * 123 * A port driver calls this function upon data reception (MBIM, AT...). 124 */ 125void wwan_port_rx(struct wwan_port *port, struct sk_buff *skb); 126 127/** 128 * wwan_port_txoff - Stop TX on WWAN port 129 * @port: WWAN port for which TX must be stopped 130 * 131 * Used for TX flow control, a port driver calls this function to indicate TX 132 * is temporary unavailable (e.g. due to ring buffer fullness). 133 */ 134void wwan_port_txoff(struct wwan_port *port); 135 136 137/** 138 * wwan_port_txon - Restart TX on WWAN port 139 * @port: WWAN port for which TX must be restarted 140 * 141 * Used for TX flow control, a port driver calls this function to indicate TX 142 * is available again. 143 */ 144void wwan_port_txon(struct wwan_port *port); 145 146/** 147 * wwan_port_get_drvdata - Retrieve driver data from a WWAN port 148 * @port: Related WWAN port 149 */ 150void *wwan_port_get_drvdata(struct wwan_port *port); 151 152/** 153 * struct wwan_netdev_priv - WWAN core network device private data 154 * @link_id: WWAN device data link id 155 * @drv_priv: driver private data area, size is determined in &wwan_ops 156 */ 157struct wwan_netdev_priv { 158 u32 link_id; 159 160 /* must be last */ 161 u8 drv_priv[] __aligned(sizeof(void *)); 162}; 163 164static inline void *wwan_netdev_drvpriv(struct net_device *dev) 165{ 166 return ((struct wwan_netdev_priv *)netdev_priv(dev))->drv_priv; 167} 168 169/* 170 * Used to indicate that the WWAN core should not create a default network 171 * link. 172 */ 173#define WWAN_NO_DEFAULT_LINK U32_MAX 174 175/** 176 * struct wwan_ops - WWAN device ops 177 * @priv_size: size of private netdev data area 178 * @setup: set up a new netdev 179 * @newlink: register the new netdev 180 * @dellink: remove the given netdev 181 */ 182struct wwan_ops { 183 unsigned int priv_size; 184 void (*setup)(struct net_device *dev); 185 int (*newlink)(void *ctxt, struct net_device *dev, 186 u32 if_id, struct netlink_ext_ack *extack); 187 void (*dellink)(void *ctxt, struct net_device *dev, 188 struct list_head *head); 189}; 190 191int wwan_register_ops(struct device *parent, const struct wwan_ops *ops, 192 void *ctxt, u32 def_link_id); 193 194void wwan_unregister_ops(struct device *parent); 195 196#ifdef CONFIG_WWAN_DEBUGFS 197struct dentry *wwan_get_debugfs_dir(struct device *parent); 198void wwan_put_debugfs_dir(struct dentry *dir); 199#else 200static inline struct dentry *wwan_get_debugfs_dir(struct device *parent) 201{ 202 return ERR_PTR(-ENODEV); 203} 204static inline void wwan_put_debugfs_dir(struct dentry *dir) {} 205#endif 206 207#endif /* __WWAN_H */