blob: 6e0c4bebc05cf10b5f21f4104b91b10a5ad2c1f5 [file] [log] [blame]
Arun Kumar Neelakantam3a655402018-06-11 18:18:51 +05301/* Copyright (c) 2011-2016, 2018, The Linux Foundation. All rights reserved.
Karthikeyan Ramasubramanian6a116d62016-09-16 16:05:32 -06002 *
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_PRIVATE_H
14#define _IPC_ROUTER_PRIVATE_H
15
16#include <linux/types.h>
17#include <linux/socket.h>
18#include <linux/errno.h>
19#include <linux/mm.h>
20#include <linux/list.h>
21#include <linux/platform_device.h>
22#include <linux/msm_ipc.h>
23#include <linux/ipc_router.h>
24#include <linux/ipc_router_xprt.h>
25
26#include <net/sock.h>
27
28/* definitions for the R2R wire protocol */
29#define IPC_ROUTER_V1 1
30/* Ambiguous definition but will enable multiplexing IPC_ROUTER_V2 packets
31 * with an existing alternate transport in user-space, if needed.
32 */
33#define IPC_ROUTER_V2 3
34#define IPC_ROUTER_VER_BITMASK ((BIT(IPC_ROUTER_V1)) | (BIT(IPC_ROUTER_V2)))
35#define IPC_ROUTER_HELLO_MAGIC 0xE110
36#define IPC_ROUTER_CHECKSUM_MASK 0xFFFF
37
38#define IPC_ROUTER_ADDRESS 0x0000FFFF
39
Arun Kumar Neelakantam3a655402018-06-11 18:18:51 +053040#define IPC_ROUTER_NID_LOCAL CONFIG_IPC_ROUTER_NODE_ID
Karthikeyan Ramasubramanian6a116d62016-09-16 16:05:32 -060041#define MAX_IPC_PKT_SIZE 66000
42
43#define IPC_ROUTER_LOW_RX_QUOTA 5
44#define IPC_ROUTER_HIGH_RX_QUOTA 10
45
46#define IPC_ROUTER_INFINITY -1
47#define DEFAULT_RCV_TIMEO IPC_ROUTER_INFINITY
48#define DEFAULT_SND_TIMEO IPC_ROUTER_INFINITY
49
50#define ALIGN_SIZE(x) ((4 - ((x) & 3)) & 3)
51
52#define ALL_SERVICE 0xFFFFFFFF
53#define ALL_INSTANCE 0xFFFFFFFF
54
55#define CONTROL_FLAG_CONFIRM_RX 0x1
56#define CONTROL_FLAG_OPT_HDR 0x2
57
58enum {
59 CLIENT_PORT,
60 SERVER_PORT,
61 CONTROL_PORT,
62 IRSC_PORT,
63};
64
65enum {
66 NULL_MODE,
67 SINGLE_LINK_MODE,
68 MULTI_LINK_MODE,
69};
70
71enum {
72 CONNECTION_RESET = -1,
73 NOT_CONNECTED,
74 CONNECTED,
75};
76
77struct msm_ipc_sock {
78 struct sock sk;
79 struct msm_ipc_port *port;
80 void *default_node_vote_info;
81};
82
83/**
84 * msm_ipc_router_create_raw_port() - Create an IPC Router port
85 * @endpoint: User-space space socket information to be cached.
86 * @notify: Function to notify incoming events on the port.
87 * @event: Event ID to be handled.
88 * @oob_data: Any out-of-band data associated with the event.
89 * @oob_data_len: Size of the out-of-band data, if valid.
90 * @priv: Private data registered during the port creation.
91 * @priv: Private Data to be passed during the event notification.
92 *
93 * @return: Valid pointer to port on success, NULL on failure.
94 *
95 * This function is used to create an IPC Router port. The port is used for
96 * communication locally or outside the subsystem.
97 */
98struct msm_ipc_port *
99msm_ipc_router_create_raw_port(void *endpoint,
100 void (*notify)(unsigned int event,
101 void *oob_data,
102 size_t oob_data_len, void *priv),
103 void *priv);
104int msm_ipc_router_send_to(struct msm_ipc_port *src,
105 struct sk_buff_head *data,
106 struct msm_ipc_addr *dest,
107 long timeout);
108int msm_ipc_router_read(struct msm_ipc_port *port_ptr,
109 struct rr_packet **pkt,
110 size_t buf_len);
111
112int msm_ipc_router_recv_from(struct msm_ipc_port *port_ptr,
113 struct rr_packet **pkt,
114 struct msm_ipc_addr *src_addr, long timeout);
115int msm_ipc_router_register_server(struct msm_ipc_port *server_port,
116 struct msm_ipc_addr *name);
117int msm_ipc_router_unregister_server(struct msm_ipc_port *server_port);
118
119int msm_ipc_router_init_sockets(void);
120void msm_ipc_router_exit_sockets(void);
121
122void msm_ipc_sync_sec_rule(u32 service, u32 instance, void *rule);
123
124void msm_ipc_sync_default_sec_rule(void *rule);
125
126int msm_ipc_router_rx_data_wait(struct msm_ipc_port *port_ptr, long timeout);
127
128void msm_ipc_router_free_skb(struct sk_buff_head *skb_head);
129
130/**
131 * ipc_router_set_conn() - Set the connection by initializing dest address
132 * @port_ptr: Local port in which the connection has to be set.
133 * @addr: Destination address of the connection.
134 *
135 * @return: 0 on success, standard Linux error codes on failure.
136 */
137int ipc_router_set_conn(struct msm_ipc_port *port_ptr,
138 struct msm_ipc_addr *addr);
139
140void *msm_ipc_load_default_node(void);
141
142void msm_ipc_unload_default_node(void *pil);
143
144/**
145 * ipc_router_dummy_write_space() - Dummy write space available callback
146 * @sk: Socket pointer for which the callback is called.
147 */
148void ipc_router_dummy_write_space(struct sock *sk);
149
150#endif