1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. 3 */ 4 5 #ifndef _RMNET_MAP_H_ 6 #define _RMNET_MAP_H_ 7 8 struct rmnet_map_control_command { 9 u8 command_name; 10 u8 cmd_type:2; 11 u8 reserved:6; 12 u16 reserved2; 13 u32 transaction_id; 14 union { 15 struct { 16 u16 ip_family:2; 17 u16 reserved:14; 18 __be16 flow_control_seq_num; 19 __be32 qos_id; 20 } flow_control; 21 u8 data[0]; 22 }; 23 } __aligned(1); 24 25 enum rmnet_map_commands { 26 RMNET_MAP_COMMAND_NONE, 27 RMNET_MAP_COMMAND_FLOW_DISABLE, 28 RMNET_MAP_COMMAND_FLOW_ENABLE, 29 /* These should always be the last 2 elements */ 30 RMNET_MAP_COMMAND_UNKNOWN, 31 RMNET_MAP_COMMAND_ENUM_LENGTH 32 }; 33 34 struct rmnet_map_header { 35 u8 pad_len:6; 36 u8 reserved_bit:1; 37 u8 cd_bit:1; 38 u8 mux_id; 39 __be16 pkt_len; 40 } __aligned(1); 41 42 struct rmnet_map_dl_csum_trailer { 43 u8 reserved1; 44 u8 valid:1; 45 u8 reserved2:7; 46 u16 csum_start_offset; 47 u16 csum_length; 48 __be16 csum_value; 49 } __aligned(1); 50 51 struct rmnet_map_ul_csum_header { 52 __be16 csum_start_offset; 53 u16 csum_insert_offset:14; 54 u16 udp_ip4_ind:1; 55 u16 csum_enabled:1; 56 } __aligned(1); 57 58 #define RMNET_MAP_GET_MUX_ID(Y) (((struct rmnet_map_header *) \ 59 (Y)->data)->mux_id) 60 #define RMNET_MAP_GET_CD_BIT(Y) (((struct rmnet_map_header *) \ 61 (Y)->data)->cd_bit) 62 #define RMNET_MAP_GET_PAD(Y) (((struct rmnet_map_header *) \ 63 (Y)->data)->pad_len) 64 #define RMNET_MAP_GET_CMD_START(Y) ((struct rmnet_map_control_command *) \ 65 ((Y)->data + \ 66 sizeof(struct rmnet_map_header))) 67 #define RMNET_MAP_GET_LENGTH(Y) (ntohs(((struct rmnet_map_header *) \ 68 (Y)->data)->pkt_len)) 69 70 #define RMNET_MAP_COMMAND_REQUEST 0 71 #define RMNET_MAP_COMMAND_ACK 1 72 #define RMNET_MAP_COMMAND_UNSUPPORTED 2 73 #define RMNET_MAP_COMMAND_INVALID 3 74 75 #define RMNET_MAP_NO_PAD_BYTES 0 76 #define RMNET_MAP_ADD_PAD_BYTES 1 77 78 struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb, 79 struct rmnet_port *port); 80 struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb, 81 int hdrlen, int pad); 82 void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port); 83 int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len); 84 void rmnet_map_checksum_uplink_packet(struct sk_buff *skb, 85 struct net_device *orig_dev); 86 87 #endif /* _RMNET_MAP_H_ */ 88