• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2  * Copyright (c) 2013-2015, 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 #define RMNET_EGRESS_FORMAT_MAP_CKSUMV3         (1<<4)
27 #define RMNET_EGRESS_FORMAT_MAP_CKSUMV4         (1<<5)
28 
29 #define RMNET_INGRESS_FIX_ETHERNET              (1<<0)
30 #define RMNET_INGRESS_FORMAT_MAP                (1<<1)
31 #define RMNET_INGRESS_FORMAT_DEAGGREGATION      (1<<2)
32 #define RMNET_INGRESS_FORMAT_DEMUXING           (1<<3)
33 #define RMNET_INGRESS_FORMAT_MAP_COMMANDS       (1<<4)
34 #define RMNET_INGRESS_FORMAT_MAP_CKSUMV3        (1<<5)
35 #define RMNET_INGRESS_FORMAT_MAP_CKSUMV4        (1<<6)
36 
37 /* ***************** Netlink API ******************************************** */
38 #define RMNET_NETLINK_PROTO 31
39 #define RMNET_MAX_STR_LEN  16
40 #define RMNET_NL_DATA_MAX_LEN 64
41 
42 #define RMNET_NETLINK_MSG_COMMAND    0
43 #define RMNET_NETLINK_MSG_RETURNCODE 1
44 #define RMNET_NETLINK_MSG_RETURNDATA 2
45 
46 struct rmnet_nl_msg_s {
47 	uint16_t reserved;
48 	uint16_t message_type;
49 	uint16_t reserved2:14;
50 	uint16_t crd:2;
51 	union {
52 		uint16_t arg_length;
53 		uint16_t return_code;
54 	};
55 	union {
56 		uint8_t data[RMNET_NL_DATA_MAX_LEN];
57 		struct {
58 			uint8_t  dev[RMNET_MAX_STR_LEN];
59 			uint32_t flags;
60 			uint16_t agg_size;
61 			uint16_t agg_count;
62 			uint8_t  tail_spacing;
63 		} data_format;
64 		struct {
65 			uint8_t dev[RMNET_MAX_STR_LEN];
66 			int32_t ep_id;
67 			uint8_t operating_mode;
68 			uint8_t next_dev[RMNET_MAX_STR_LEN];
69 		} local_ep_config;
70 		struct {
71 			uint32_t id;
72 			uint8_t  vnd_name[RMNET_MAX_STR_LEN];
73 		} vnd;
74 		struct {
75 			uint32_t id;
76 			uint32_t map_flow_id;
77 			uint32_t tc_flow_id;
78 		} flow_control;
79 	};
80 };
81 
82 enum rmnet_netlink_message_types_e {
83 	/*
84 	 * RMNET_NETLINK_ASSOCIATE_NETWORK_DEVICE - Register RMNET data driver
85 	 *                                          on a particular device.
86 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
87 	 * Returns: status code
88 	 */
89 	RMNET_NETLINK_ASSOCIATE_NETWORK_DEVICE,
90 
91 	/*
92 	 * RMNET_NETLINK_UNASSOCIATE_NETWORK_DEVICE - Unregister RMNET data
93 	 *                                            driver on a particular
94 	 *                                            device.
95 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
96 	 * Returns: status code
97 	 */
98 	RMNET_NETLINK_UNASSOCIATE_NETWORK_DEVICE,
99 
100 	/*
101 	 * RMNET_NETLINK_GET_NETWORK_DEVICE_ASSOCIATED - Get if RMNET data
102 	 *                                            driver is registered on a
103 	 *                                            particular device.
104 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
105 	 * Returns: 1 if registered, 0 if not
106 	 */
107 	RMNET_NETLINK_GET_NETWORK_DEVICE_ASSOCIATED,
108 
109 	/*
110 	 * RMNET_NETLINK_SET_LINK_EGRESS_DATA_FORMAT - Sets the egress data
111 	 *                                             format for a particular
112 	 *                                             link.
113 	 * Args: uint32_t egress_flags
114 	 *       char[] dev_name: Null terminated ASCII string, max length: 15
115 	 * Returns: status code
116 	 */
117 	RMNET_NETLINK_SET_LINK_EGRESS_DATA_FORMAT,
118 
119 	/*
120 	 * RMNET_NETLINK_GET_LINK_EGRESS_DATA_FORMAT - Gets the egress data
121 	 *                                             format for a particular
122 	 *                                             link.
123 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
124 	 * Returns: 4-bytes data: uint32_t egress_flags
125 	 */
126 	RMNET_NETLINK_GET_LINK_EGRESS_DATA_FORMAT,
127 
128 	/*
129 	 * RMNET_NETLINK_SET_LINK_INGRESS_DATA_FORMAT - Sets the ingress data
130 	 *                                              format for a particular
131 	 *                                              link.
132 	 * Args: uint32_t ingress_flags
133 	 *       char[] dev_name: Null terminated ASCII string, max length: 15
134 	 * Returns: status code
135 	 */
136 	RMNET_NETLINK_SET_LINK_INGRESS_DATA_FORMAT,
137 
138 	/*
139 	 * RMNET_NETLINK_GET_LINK_INGRESS_DATA_FORMAT - Gets the ingress data
140 	 *                                              format for a particular
141 	 *                                              link.
142 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
143 	 * Returns: 4-bytes data: uint32_t ingress_flags
144 	 */
145 	RMNET_NETLINK_GET_LINK_INGRESS_DATA_FORMAT,
146 
147 	/*
148 	 * RMNET_NETLINK_SET_LOGICAL_EP_CONFIG - Sets the logical endpoint
149 	 *                                       configuration for a particular
150 	 *                                       link.
151 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
152 	 *     int32_t logical_ep_id, valid values are -1 through 31
153 	 *     uint8_t rmnet_mode: one of none, vnd, bridged
154 	 *     char[] egress_dev_name: Egress device if operating in bridge mode
155 	 * Returns: status code
156 	 */
157 	RMNET_NETLINK_SET_LOGICAL_EP_CONFIG,
158 
159 	/*
160 	 * RMNET_NETLINK_UNSET_LOGICAL_EP_CONFIG - Un-sets the logical endpoint
161 	 *                                       configuration for a particular
162 	 *                                       link.
163 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
164 	 *       int32_t logical_ep_id, valid values are -1 through 31
165 	 * Returns: status code
166 	 */
167 	RMNET_NETLINK_UNSET_LOGICAL_EP_CONFIG,
168 
169 	/*
170 	 * RMNET_NETLINK_GET_LOGICAL_EP_CONFIG - Gets the logical endpoint
171 	 *                                       configuration for a particular
172 	 *                                       link.
173 	 * Args: char[] dev_name: Null terminated ASCII string, max length: 15
174 	 *        int32_t logical_ep_id, valid values are -1 through 31
175 	 * Returns: uint8_t rmnet_mode: one of none, vnd, bridged
176 	 * char[] egress_dev_name: Egress device
177 	 */
178 	RMNET_NETLINK_GET_LOGICAL_EP_CONFIG,
179 
180 	/*
181 	 * RMNET_NETLINK_NEW_VND - Creates a new virtual network device node
182 	 * Args: int32_t node number
183 	 * Returns: status code
184 	 */
185 	RMNET_NETLINK_NEW_VND,
186 
187 	/*
188 	 * RMNET_NETLINK_NEW_VND_WITH_PREFIX - Creates a new virtual network
189 	 *                                     device node with the specified
190 	 *                                     prefix for the device name
191 	 * Args: int32_t node number
192 	 *       char[] vnd_name - Use as prefix
193 	 * Returns: status code
194 	 */
195 	RMNET_NETLINK_NEW_VND_WITH_PREFIX,
196 
197 	/*
198 	 * RMNET_NETLINK_GET_VND_NAME - Gets the string name of a VND from ID
199 	 * Args: int32_t node number
200 	 * Returns: char[] vnd_name
201 	 */
202 	RMNET_NETLINK_GET_VND_NAME,
203 
204 	/*
205 	 * RMNET_NETLINK_FREE_VND - Removes virtual network device node
206 	 * Args: int32_t node number
207 	 * Returns: status code
208 	 */
209 	RMNET_NETLINK_FREE_VND,
210 
211 	/*
212 	 * RMNET_NETLINK_ADD_VND_TC_FLOW - Add flow control handle on VND
213 	 * Args: int32_t node number
214 	 *       uint32_t MAP Flow Handle
215 	 *       uint32_t TC Flow Handle
216 	 * Returns: status code
217 	 */
218 	RMNET_NETLINK_ADD_VND_TC_FLOW,
219 
220 	/*
221 	 * RMNET_NETLINK_DEL_VND_TC_FLOW - Removes flow control handle on VND
222 	 * Args: int32_t node number
223 	 *       uint32_t MAP Flow Handle
224 	 * Returns: status code
225 	 */
226 	RMNET_NETLINK_DEL_VND_TC_FLOW
227 };
228 
229 enum rmnet_config_endpoint_modes_e {
230 	/* Pass the frame up the stack with no modifications to skb->dev      */
231 	RMNET_EPMODE_NONE,
232 	/* Replace skb->dev to a virtual rmnet device and pass up the stack   */
233 	RMNET_EPMODE_VND,
234 	/* Pass the frame directly to another device with dev_queue_xmit().   */
235 	RMNET_EPMODE_BRIDGE,
236 	/* Must be the last item in the list                                  */
237 	RMNET_EPMODE_LENGTH
238 };
239 
240 enum rmnet_config_return_codes_e {
241 	RMNET_CONFIG_OK,
242 	RMNET_CONFIG_UNKNOWN_MESSAGE,
243 	RMNET_CONFIG_UNKNOWN_ERROR,
244 	RMNET_CONFIG_NOMEM,
245 	RMNET_CONFIG_DEVICE_IN_USE,
246 	RMNET_CONFIG_INVALID_REQUEST,
247 	RMNET_CONFIG_NO_SUCH_DEVICE,
248 	RMNET_CONFIG_BAD_ARGUMENTS,
249 	RMNET_CONFIG_BAD_EGRESS_DEVICE,
250 	RMNET_CONFIG_TC_HANDLE_FULL
251 };
252 
253 #endif /* _RMNET_DATA_H_ */
254