1  /*
2  * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 and
6  * only version 2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * RMNET Data configuration specification
14  */
15 
16 #ifndef _RMNET_DATA_H_
17 #define _RMNET_DATA_H_
18 
19 /* ***************** Constants ********************************************** */
20 #define RMNET_LOCAL_LOGICAL_ENDPOINT -1
21 
22 #define RMNET_EGRESS_FORMAT__RESERVED__         (1<<0)
23 #define RMNET_EGRESS_FORMAT_MAP                 (1<<1)
24 #define RMNET_EGRESS_FORMAT_AGGREGATION         (1<<2)
25 #define RMNET_EGRESS_FORMAT_MUXING              (1<<3)
26 
27 #define RMNET_INGRESS_FIX_ETHERNET              (1<<0)
28 #define RMNET_INGRESS_FORMAT_MAP                (1<<1)
29 #define RMNET_INGRESS_FORMAT_DEAGGREGATION      (1<<2)
30 #define RMNET_INGRESS_FORMAT_DEMUXING           (1<<3)
31 #define RMNET_INGRESS_FORMAT_MAP_COMMANDS       (1<<4)
32 
33 /* ***************** Netlink API ******************************************** */
34 #define RMNET_NETLINK_PROTO 31
35 #define RMNET_MAX_STR_LEN  16
36 #define RMNET_NL_DATA_MAX_LEN 64
37 
38 #define RMNET_NETLINK_MSG_COMMAND    0
39 #define RMNET_NETLINK_MSG_RETURNCODE 1
40 #define RMNET_NETLINK_MSG_RETURNDATA 2
41 
42 struct rmnet_nl_msg_s {
43 	uint16_t reserved;
44 	uint16_t message_type;
45 	uint16_t reserved2:14;
46 	uint16_t crd:2;
47 	union {
48 		uint16_t arg_length;
49 		uint16_t return_code;
50 	};
51 	union {
52 		uint8_t data[RMNET_NL_DATA_MAX_LEN];
53 		struct {
54 			uint8_t  dev[RMNET_MAX_STR_LEN];
55 			uint32_t flags;
56 			uint16_t agg_size;
57 			uint16_t agg_count;
58 			uint8_t  tail_spacing;
59 		} data_format;
60 		struct {
61 			uint8_t dev[RMNET_MAX_STR_LEN];
62 			int32_t ep_id;
63 			uint8_t operating_mode;
64 			uint8_t next_dev[RMNET_MAX_STR_LEN];
65 		} local_ep_config;
66 		struct {
67 			uint32_t id;
68 			uint8_t  vnd_name[RMNET_MAX_STR_LEN];
69 		} vnd;
70 		struct {
71 			uint32_t id;
72 			uint32_t map_flow_id;
73 			uint32_t tc_flow_id;
74 		} flow_control;
75 	};
76 };
77 
78 enum rmnet_netlink_message_types_e {
79 	/*
80 	 * RMNET_NETLINK_ASSOCIATE_NETWORK_DEVICE - Register RMNET data driver
81 	 *                                          on a particular device.
82 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
83 	 * Returns: status code
84 	 */
85 	RMNET_NETLINK_ASSOCIATE_NETWORK_DEVICE,
86 
87 	/*
88 	 * RMNET_NETLINK_UNASSOCIATE_NETWORK_DEVICE - Unregister RMNET data
89 	 *                                            driver on a particular
90 	 *                                            device.
91 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
92 	 * Returns: status code
93 	 */
94 	RMNET_NETLINK_UNASSOCIATE_NETWORK_DEVICE,
95 
96 	/*
97 	 * RMNET_NETLINK_GET_NETWORK_DEVICE_ASSOCIATED - Get if RMNET data
98 	 *                                            driver is registered on a
99 	 *                                            particular device.
100 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
101 	 * Returns: 1 if registered, 0 if not
102 	 */
103 	RMNET_NETLINK_GET_NETWORK_DEVICE_ASSOCIATED,
104 
105 	/*
106 	 * RMNET_NETLINK_SET_LINK_EGRESS_DATA_FORMAT - Sets the egress data
107 	 *                                             format for a particular
108 	 *                                             link.
109 	 * Args: uint32_t egress_flags
110 	 *       char[] dev_name: Null terminated ASCII string, max length: 15
111 	 * Returns: status code
112 	 */
113 	RMNET_NETLINK_SET_LINK_EGRESS_DATA_FORMAT,
114 
115 	/*
116 	 * RMNET_NETLINK_GET_LINK_EGRESS_DATA_FORMAT - Gets the egress data
117 	 *                                             format for a particular
118 	 *                                             link.
119 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
120 	 * Returns: 4-bytes data: uint32_t egress_flags
121 	 */
122 	RMNET_NETLINK_GET_LINK_EGRESS_DATA_FORMAT,
123 
124 	/*
125 	 * RMNET_NETLINK_SET_LINK_INGRESS_DATA_FORMAT - Sets the ingress data
126 	 *                                              format for a particular
127 	 *                                              link.
128 	 * Args: uint32_t ingress_flags
129 	 *       char[] dev_name: Null terminated ASCII string, max length: 15
130 	 * Returns: status code
131 	 */
132 	RMNET_NETLINK_SET_LINK_INGRESS_DATA_FORMAT,
133 
134 	/*
135 	 * RMNET_NETLINK_GET_LINK_INGRESS_DATA_FORMAT - Gets the ingress data
136 	 *                                              format for a particular
137 	 *                                              link.
138 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
139 	 * Returns: 4-bytes data: uint32_t ingress_flags
140 	 */
141 	RMNET_NETLINK_GET_LINK_INGRESS_DATA_FORMAT,
142 
143 	/*
144 	 * RMNET_NETLINK_SET_LOGICAL_EP_CONFIG - Sets the logical endpoint
145 	 *                                       configuration for a particular
146 	 *                                       link.
147 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
148 	 *     int32_t logical_ep_id, valid values are -1 through 31
149 	 *     uint8_t rmnet_mode: one of none, vnd, bridged
150 	 *     char[] egress_dev_name: Egress device if operating in bridge mode
151 	 * Returns: status code
152 	 */
153 	RMNET_NETLINK_SET_LOGICAL_EP_CONFIG,
154 
155 	/*
156 	 * RMNET_NETLINK_UNSET_LOGICAL_EP_CONFIG - Un-sets the logical endpoint
157 	 *                                       configuration for a particular
158 	 *                                       link.
159 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
160 	 *       int32_t logical_ep_id, valid values are -1 through 31
161 	 * Returns: status code
162 	 */
163 	RMNET_NETLINK_UNSET_LOGICAL_EP_CONFIG,
164 
165 	/*
166 	 * RMNET_NETLINK_GET_LOGICAL_EP_CONFIG - Gets the logical endpoint
167 	 *                                       configuration for a particular
168 	 *                                       link.
169 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
170 	 *        int32_t logical_ep_id, valid values are -1 through 31
171 	 * Returns: uint8_t rmnet_mode: one of none, vnd, bridged
172 	 * char[] egress_dev_name: Egress device
173 	 */
174 	RMNET_NETLINK_GET_LOGICAL_EP_CONFIG,
175 
176 	/*
177 	 * RMNET_NETLINK_NEW_VND - Creates a new virtual network device node
178 	 * Args: int32_t node number
179 	 * Returns: status code
180 	 */
181 	RMNET_NETLINK_NEW_VND,
182 
183 	/*
184 	 * RMNET_NETLINK_NEW_VND_WITH_PREFIX - Creates a new virtual network
185 	 *                                     device node with the specified
186 	 *                                     prefix for the device name
187 	 * Args: int32_t node number
188 	 *       char[] vnd_name - Use as prefix
189 	 * Returns: status code
190 	 */
191 	RMNET_NETLINK_NEW_VND_WITH_PREFIX,
192 
193 	/*
194 	 * RMNET_NETLINK_GET_VND_NAME - Gets the string name of a VND from ID
195 	 * Args: int32_t node number
196 	 * Returns: char[] vnd_name
197 	 */
198 	RMNET_NETLINK_GET_VND_NAME,
199 
200 	/*
201 	 * RMNET_NETLINK_FREE_VND - Removes virtual network device node
202 	 * Args: int32_t node number
203 	 * Returns: status code
204 	 */
205 	RMNET_NETLINK_FREE_VND,
206 
207 	/*
208 	 * RMNET_NETLINK_ADD_VND_TC_FLOW - Add flow control handle on VND
209 	 * Args: int32_t node number
210 	 *       uint32_t MAP Flow Handle
211 	 *       uint32_t TC Flow Handle
212 	 * Returns: status code
213 	 */
214 	RMNET_NETLINK_ADD_VND_TC_FLOW,
215 
216 	/*
217 	 * RMNET_NETLINK_DEL_VND_TC_FLOW - Removes flow control handle on VND
218 	 * Args: int32_t node number
219 	 *       uint32_t MAP Flow Handle
220 	 * Returns: status code
221 	 */
222 	RMNET_NETLINK_DEL_VND_TC_FLOW
223 };
224 
225 enum rmnet_config_endpoint_modes_e {
226 	RMNET_EPMODE_NONE,
227 	RMNET_EPMODE_VND,
228 	RMNET_EPMODE_BRIDGE,
229 	RMNET_EPMODE_LENGTH /* Must be the last item in the list */
230 };
231 
232 enum rmnet_config_return_codes_e {
233 	RMNET_CONFIG_OK,
234 	RMNET_CONFIG_UNKNOWN_MESSAGE,
235 	RMNET_CONFIG_UNKNOWN_ERROR,
236 	RMNET_CONFIG_NOMEM,
237 	RMNET_CONFIG_DEVICE_IN_USE,
238 	RMNET_CONFIG_INVALID_REQUEST,
239 	RMNET_CONFIG_NO_SUCH_DEVICE,
240 	RMNET_CONFIG_BAD_ARGUMENTS,
241 	RMNET_CONFIG_BAD_EGRESS_DEVICE,
242 	RMNET_CONFIG_TC_HANDLE_FULL
243 };
244 
245 #endif /* _RMNET_DATA_H_ */
246