xref: /linux/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h (revision 4201c9260a8d3c4ef238e51692a7e9b4e1e29efe)
1 /* Copyright (c) 2013-2018, 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 
13 #ifndef _RMNET_MAP_H_
14 #define _RMNET_MAP_H_
15 #include <linux/if_rmnet.h>
16 
17 struct rmnet_map_control_command {
18 	u8  command_name;
19 	u8  cmd_type:2;
20 	u8  reserved:6;
21 	u16 reserved2;
22 	u32 transaction_id;
23 	union {
24 		struct {
25 			u16 ip_family:2;
26 			u16 reserved:14;
27 			__be16 flow_control_seq_num;
28 			__be32 qos_id;
29 		} flow_control;
30 		u8 data[0];
31 	};
32 }  __aligned(1);
33 
34 enum rmnet_map_commands {
35 	RMNET_MAP_COMMAND_NONE,
36 	RMNET_MAP_COMMAND_FLOW_DISABLE,
37 	RMNET_MAP_COMMAND_FLOW_ENABLE,
38 	/* These should always be the last 2 elements */
39 	RMNET_MAP_COMMAND_UNKNOWN,
40 	RMNET_MAP_COMMAND_ENUM_LENGTH
41 };
42 
43 #define RMNET_MAP_GET_MUX_ID(Y) (((struct rmnet_map_header *) \
44 				 (Y)->data)->mux_id)
45 #define RMNET_MAP_GET_CD_BIT(Y) (((struct rmnet_map_header *) \
46 				(Y)->data)->cd_bit)
47 #define RMNET_MAP_GET_PAD(Y) (((struct rmnet_map_header *) \
48 				(Y)->data)->pad_len)
49 #define RMNET_MAP_GET_CMD_START(Y) ((struct rmnet_map_control_command *) \
50 				    ((Y)->data + \
51 				      sizeof(struct rmnet_map_header)))
52 #define RMNET_MAP_GET_LENGTH(Y) (ntohs(((struct rmnet_map_header *) \
53 					(Y)->data)->pkt_len))
54 
55 #define RMNET_MAP_COMMAND_REQUEST     0
56 #define RMNET_MAP_COMMAND_ACK         1
57 #define RMNET_MAP_COMMAND_UNSUPPORTED 2
58 #define RMNET_MAP_COMMAND_INVALID     3
59 
60 #define RMNET_MAP_NO_PAD_BYTES        0
61 #define RMNET_MAP_ADD_PAD_BYTES       1
62 
63 struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
64 				      struct rmnet_port *port);
65 struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb,
66 						  int hdrlen, int pad);
67 void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port);
68 int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len);
69 void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
70 				      struct net_device *orig_dev);
71 
72 #endif /* _RMNET_MAP_H_ */
73