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