at v5.13 3.4 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/device.h> 8#include <linux/kernel.h> 9#include <linux/skbuff.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_MAX: Number of supported port types 19 */ 20enum wwan_port_type { 21 WWAN_PORT_AT, 22 WWAN_PORT_MBIM, 23 WWAN_PORT_QMI, 24 WWAN_PORT_QCDM, 25 WWAN_PORT_FIREHOSE, 26 WWAN_PORT_MAX, 27}; 28 29struct wwan_port; 30 31/** struct wwan_port_ops - The WWAN port operations 32 * @start: The routine for starting the WWAN port device. 33 * @stop: The routine for stopping the WWAN port device. 34 * @tx: The routine that sends WWAN port protocol data to the device. 35 * 36 * The wwan_port_ops structure contains a list of low-level operations 37 * that control a WWAN port device. All functions are mandatory. 38 */ 39struct wwan_port_ops { 40 int (*start)(struct wwan_port *port); 41 void (*stop)(struct wwan_port *port); 42 int (*tx)(struct wwan_port *port, struct sk_buff *skb); 43}; 44 45/** 46 * wwan_create_port - Add a new WWAN port 47 * @parent: Device to use as parent and shared by all WWAN ports 48 * @type: WWAN port type 49 * @ops: WWAN port operations 50 * @drvdata: Pointer to caller driver data 51 * 52 * Allocate and register a new WWAN port. The port will be automatically exposed 53 * to user as a character device and attached to the right virtual WWAN device, 54 * based on the parent pointer. The parent pointer is the device shared by all 55 * components of a same WWAN modem (e.g. USB dev, PCI dev, MHI controller...). 56 * 57 * drvdata will be placed in the WWAN port device driver data and can be 58 * retrieved with wwan_port_get_drvdata(). 59 * 60 * This function must be balanced with a call to wwan_remove_port(). 61 * 62 * Returns a valid pointer to wwan_port on success or PTR_ERR on failure 63 */ 64struct wwan_port *wwan_create_port(struct device *parent, 65 enum wwan_port_type type, 66 const struct wwan_port_ops *ops, 67 void *drvdata); 68 69/** 70 * wwan_remove_port - Remove a WWAN port 71 * @port: WWAN port to remove 72 * 73 * Remove a previously created port. 74 */ 75void wwan_remove_port(struct wwan_port *port); 76 77/** 78 * wwan_port_rx - Receive data from the WWAN port 79 * @port: WWAN port for which data is received 80 * @skb: Pointer to the rx buffer 81 * 82 * A port driver calls this function upon data reception (MBIM, AT...). 83 */ 84void wwan_port_rx(struct wwan_port *port, struct sk_buff *skb); 85 86/** 87 * wwan_port_txoff - Stop TX on WWAN port 88 * @port: WWAN port for which TX must be stopped 89 * 90 * Used for TX flow control, a port driver calls this function to indicate TX 91 * is temporary unavailable (e.g. due to ring buffer fullness). 92 */ 93void wwan_port_txoff(struct wwan_port *port); 94 95 96/** 97 * wwan_port_txon - Restart TX on WWAN port 98 * @port: WWAN port for which TX must be restarted 99 * 100 * Used for TX flow control, a port driver calls this function to indicate TX 101 * is available again. 102 */ 103void wwan_port_txon(struct wwan_port *port); 104 105/** 106 * wwan_port_get_drvdata - Retrieve driver data from a WWAN port 107 * @port: Related WWAN port 108 */ 109void *wwan_port_get_drvdata(struct wwan_port *port); 110 111#endif /* __WWAN_H */