OSDN Git Service

devfreq_boost: Introduce devfreq boost driver
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / ipc_router_xprt.h
1 /* Copyright (c) 2011-2015,2017 The Linux Foundation. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  */
12
13 #ifndef _IPC_ROUTER_XPRT_H
14 #define _IPC_ROUTER_XPRT_H
15
16 #include <linux/types.h>
17 #include <linux/errno.h>
18 #include <linux/mm.h>
19 #include <linux/list.h>
20 #include <linux/platform_device.h>
21 #include <linux/msm_ipc.h>
22 #include <linux/ipc_router.h>
23 #include <linux/kref.h>
24
25 #define IPC_ROUTER_XPRT_EVENT_DATA  1
26 #define IPC_ROUTER_XPRT_EVENT_OPEN  2
27 #define IPC_ROUTER_XPRT_EVENT_CLOSE 3
28
29 #define FRAG_PKT_WRITE_ENABLE 0x1
30
31 /**
32  * rr_header_v1 - IPC Router header version 1
33  * @version: Version information.
34  * @type: IPC Router Message Type.
35  * @src_node_id: Source Node ID of the message.
36  * @src_port_id: Source Port ID of the message.
37  * @control_flag: Flag to indicate flow control.
38  * @size: Size of the IPC Router payload.
39  * @dst_node_id: Destination Node ID of the message.
40  * @dst_port_id: Destination Port ID of the message.
41  */
42 struct rr_header_v1 {
43         uint32_t version;
44         uint32_t type;
45         uint32_t src_node_id;
46         uint32_t src_port_id;
47         uint32_t control_flag;
48         uint32_t size;
49         uint32_t dst_node_id;
50         uint32_t dst_port_id;
51 };
52
53 /**
54  * rr_header_v2 - IPC Router header version 2
55  * @version: Version information.
56  * @type: IPC Router Message Type.
57  * @control_flag: Flags to indicate flow control, optional header etc.
58  * @opt_len: Combined size of the all optional headers in units of words.
59  * @size: Size of the IPC Router payload.
60  * @src_node_id: Source Node ID of the message.
61  * @src_port_id: Source Port ID of the message.
62  * @dst_node_id: Destination Node ID of the message.
63  * @dst_port_id: Destination Port ID of the message.
64  */
65 struct rr_header_v2 {
66         uint8_t version;
67         uint8_t type;
68         uint8_t control_flag;
69         uint8_t opt_len;
70         uint32_t size;
71         uint16_t src_node_id;
72         uint16_t src_port_id;
73         uint16_t dst_node_id;
74         uint16_t dst_port_id;
75 } __attribute__((__packed__));
76
77 union rr_header {
78         struct rr_header_v1 hdr_v1;
79         struct rr_header_v2 hdr_v2;
80 };
81
82 /**
83  * rr_opt_hdr - Optional header for IPC Router header version 2
84  * @len: Total length of the optional header.
85  * @data: Pointer to the actual optional header.
86  */
87 struct rr_opt_hdr {
88         size_t len;
89         unsigned char *data;
90 };
91
92 #define IPC_ROUTER_HDR_SIZE sizeof(union rr_header)
93 #define IPCR_WORD_SIZE 4
94
95 /**
96  * rr_packet - Router to Router packet structure
97  * @list: Pointer to prev & next packets in a port's rx list.
98  * @hdr: Header information extracted from or prepended to a packet.
99  * @opt_hdr: Optinal header information.
100  * @pkt_fragment_q: Queue of SKBs containing payload.
101  * @length: Length of data in the chain of SKBs
102  * @ref: Reference count for the packet.
103  * @ws_need: Flag to check wakeup soruce need
104  */
105 struct rr_packet {
106         struct list_head list;
107         struct rr_header_v1 hdr;
108         struct rr_opt_hdr opt_hdr;
109         struct sk_buff_head *pkt_fragment_q;
110         uint32_t length;
111         struct kref ref;
112         bool ws_need;
113 };
114
115 /**
116  * msm_ipc_router_xprt - Structure to hold XPRT specific information
117  * @name: Name of the XPRT.
118  * @link_id: Network cluster ID to which the XPRT belongs to.
119  * @priv: XPRT's private data.
120  * @get_version: Method to get header version supported by the XPRT.
121  * @set_version: Method to set header version in XPRT.
122  * @get_option: Method to get XPRT specific options.
123  * @read_avail: Method to get data size available to be read from the XPRT.
124  * @read: Method to read data from the XPRT.
125  * @write_avail: Method to get write space available in the XPRT.
126  * @write: Method to write data to the XPRT.
127  * @close: Method to close the XPRT.
128  * @sft_close_done: Method to indicate to the XPRT that handling of reset
129  *                  event is complete.
130  * @get_ws_info: Method to get the wakeup soruce inforamtion of the XPRT
131  */
132 struct msm_ipc_router_xprt {
133         char *name;
134         uint32_t link_id;
135         void *priv;
136
137         int (*get_version)(struct msm_ipc_router_xprt *xprt);
138         int (*get_option)(struct msm_ipc_router_xprt *xprt);
139         void (*set_version)(struct msm_ipc_router_xprt *xprt,
140                             unsigned version);
141         int (*read_avail)(struct msm_ipc_router_xprt *xprt);
142         int (*read)(void *data, uint32_t len,
143                     struct msm_ipc_router_xprt *xprt);
144         int (*write_avail)(struct msm_ipc_router_xprt *xprt);
145         int (*write)(void *data, uint32_t len,
146                      struct msm_ipc_router_xprt *xprt);
147         int (*close)(struct msm_ipc_router_xprt *xprt);
148         void (*sft_close_done)(struct msm_ipc_router_xprt *xprt);
149         bool (*get_ws_info)(struct msm_ipc_router_xprt *xprt);
150 };
151
152 void msm_ipc_router_xprt_notify(struct msm_ipc_router_xprt *xprt,
153                                 unsigned event,
154                                 void *data);
155
156 /**
157  * create_pkt() - Create a Router packet
158  * @data: SKB queue to be contained inside the packet.
159  *
160  * @return: pointer to packet on success, NULL on failure.
161  */
162 struct rr_packet *create_pkt(struct sk_buff_head *data);
163 struct rr_packet *clone_pkt(struct rr_packet *pkt);
164 void release_pkt(struct rr_packet *pkt);
165
166 /**
167  * ipc_router_peek_pkt_size() - Peek into the packet header to get potential packet size
168  * @data: Starting address of the packet which points to router header.
169  *
170  * @returns: potential packet size on success, < 0 on error.
171  *
172  * This function is used by the underlying transport abstraction layer to
173  * peek into the potential packet size of an incoming packet. This information
174  * is used to perform link layer fragmentation and re-assembly
175  */
176 int ipc_router_peek_pkt_size(char *data);
177
178 #endif