xref: /linux/drivers/net/wwan/t7xx/t7xx_port_proxy.h (revision cffaefd15a8f423cdee5d8eac15d267bc92de314)
1 /* SPDX-License-Identifier: GPL-2.0-only
2  *
3  * Copyright (c) 2021, MediaTek Inc.
4  * Copyright (c) 2021-2022, Intel Corporation.
5  *
6  * Authors:
7  *  Amir Hanania <amir.hanania@intel.com>
8  *  Haijun Liu <haijun.liu@mediatek.com>
9  *  Moises Veleta <moises.veleta@intel.com>
10  *  Ricardo Martinez <ricardo.martinez@linux.intel.com>
11  *
12  * Contributors:
13  *  Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
14  *  Eliot Lee <eliot.lee@intel.com>
15  *  Sreehari Kancharla <sreehari.kancharla@intel.com>
16  */
17 
18 #ifndef __T7XX_PORT_PROXY_H__
19 #define __T7XX_PORT_PROXY_H__
20 
21 #include <linux/bits.h>
22 #include <linux/device.h>
23 #include <linux/skbuff.h>
24 #include <linux/types.h>
25 
26 #include "t7xx_hif_cldma.h"
27 #include "t7xx_modem_ops.h"
28 #include "t7xx_port.h"
29 
30 #define MTK_QUEUES		16
31 #define RX_QUEUE_MAXLEN		32
32 #define CTRL_QUEUE_MAXLEN	16
33 
34 enum port_cfg_id {
35 	PORT_CFG_ID_INVALID,
36 	PORT_CFG_ID_NORMAL,
37 	PORT_CFG_ID_EARLY,
38 };
39 
40 struct port_proxy {
41 	int			port_count;
42 	struct list_head	rx_ch_ports[PORT_CH_ID_MASK + 1];
43 	struct list_head	queue_ports[CLDMA_NUM][MTK_QUEUES];
44 	struct device		*dev;
45 	enum port_cfg_id	cfg_id;
46 	struct t7xx_port	ports[];
47 };
48 
49 struct ccci_header {
50 	__le32 packet_header;
51 	__le32 packet_len;
52 	__le32 status;
53 	__le32 ex_msg;
54 };
55 
56 /* Coupled with HW - indicates if there is data following the CCCI header or not */
57 #define CCCI_HEADER_NO_DATA	0xffffffff
58 
59 #define CCCI_H_AST_BIT		BIT(31)
60 #define CCCI_H_SEQ_FLD		GENMASK(30, 16)
61 #define CCCI_H_CHN_FLD		GENMASK(15, 0)
62 
63 struct ctrl_msg_header {
64 	__le32	ctrl_msg_id;
65 	__le32	ex_msg;
66 	__le32	data_length;
67 };
68 
69 /* Control identification numbers for AP<->MD messages  */
70 #define CTL_ID_HS1_MSG		0x0
71 #define CTL_ID_HS2_MSG		0x1
72 #define CTL_ID_HS3_MSG		0x2
73 #define CTL_ID_MD_EX		0x4
74 #define CTL_ID_DRV_VER_ERROR	0x5
75 #define CTL_ID_MD_EX_ACK	0x6
76 #define CTL_ID_MD_EX_PASS	0x8
77 #define CTL_ID_PORT_ENUM	0x9
78 
79 /* Modem exception check identification code - "EXCP" */
80 #define MD_EX_CHK_ID		0x45584350
81 /* Modem exception check acknowledge identification code - "EREC" */
82 #define MD_EX_CHK_ACK_ID	0x45524543
83 
84 #define PORT_INFO_RSRVD		GENMASK(31, 16)
85 #define PORT_INFO_ENFLG		BIT(15)
86 #define PORT_INFO_CH_ID		GENMASK(14, 0)
87 
88 #define PORT_ENUM_VER		0
89 #define PORT_ENUM_HEAD_PATTERN	0x5a5a5a5a
90 #define PORT_ENUM_TAIL_PATTERN	0xa5a5a5a5
91 #define PORT_ENUM_VER_MISMATCH	0x00657272
92 
93 /* Port operations mapping */
94 extern struct port_ops wwan_sub_port_ops;
95 extern struct port_ops ctl_port_ops;
96 
97 #ifdef CONFIG_WWAN_DEBUGFS
98 extern struct port_ops t7xx_trace_port_ops;
99 #endif
100 
101 void t7xx_port_proxy_reset(struct port_proxy *port_prox);
102 void t7xx_port_proxy_uninit(struct port_proxy *port_prox);
103 int t7xx_port_proxy_init(struct t7xx_modem *md);
104 void t7xx_port_proxy_md_status_notify(struct port_proxy *port_prox, unsigned int state);
105 int t7xx_port_enum_msg_handler(struct t7xx_modem *md, void *msg);
106 int t7xx_port_proxy_chl_enable_disable(struct port_proxy *port_prox, unsigned int ch_id,
107 				       bool en_flag);
108 void t7xx_port_proxy_set_cfg(struct t7xx_modem *md, enum port_cfg_id cfg_id);
109 int t7xx_port_proxy_recv_skb(struct cldma_queue *queue, struct sk_buff *skb);
110 int t7xx_port_proxy_recv_skb_from_dedicated_queue(struct cldma_queue *queue, struct sk_buff *skb);
111 
112 #endif /* __T7XX_PORT_PROXY_H__ */
113