rmnet_data.h 8.6 KB

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