1 /* Copyright (c) 2011-2015,2017 The Linux Foundation. All rights reserved.
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.
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.
13 #ifndef _IPC_ROUTER_XPRT_H
14 #define _IPC_ROUTER_XPRT_H
16 #include <linux/types.h>
17 #include <linux/errno.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>
25 #define IPC_ROUTER_XPRT_EVENT_DATA 1
26 #define IPC_ROUTER_XPRT_EVENT_OPEN 2
27 #define IPC_ROUTER_XPRT_EVENT_CLOSE 3
29 #define FRAG_PKT_WRITE_ENABLE 0x1
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.
47 uint32_t control_flag;
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.
75 } __attribute__((__packed__));
78 struct rr_header_v1 hdr_v1;
79 struct rr_header_v2 hdr_v2;
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.
92 #define IPC_ROUTER_HDR_SIZE sizeof(union rr_header)
93 #define IPCR_WORD_SIZE 4
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
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;
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
130 * @get_ws_info: Method to get the wakeup soruce inforamtion of the XPRT
132 struct msm_ipc_router_xprt {
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,
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);
152 void msm_ipc_router_xprt_notify(struct msm_ipc_router_xprt *xprt,
157 * create_pkt() - Create a Router packet
158 * @data: SKB queue to be contained inside the packet.
160 * @return: pointer to packet on success, NULL on failure.
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);
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.
170 * @returns: potential packet size on success, < 0 on error.
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
176 int ipc_router_peek_pkt_size(char *data);