blob: 718140cf075f509260ea4ae657373c9b1d33b82f [file] [log] [blame]
Subash Abhinov Kasiviswanathanbf783ba2017-11-08 15:55:29 -07001/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
Subash Abhinov Kasiviswanathan2139ce8a2016-10-14 11:01:48 -06002 *
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#include <linux/types.h>
14#include <linux/spinlock.h>
15#include <net/rmnet_config.h>
16
17#ifndef _RMNET_MAP_H_
18#define _RMNET_MAP_H_
19
20struct rmnet_map_control_command_s {
21 u8 command_name;
22#ifndef RMNET_USE_BIG_ENDIAN_STRUCTS
23 u8 cmd_type:2;
24 u8 reserved:6;
25#else
26 u8 reserved:6;
27 u8 cmd_type:2;
28#endif /* RMNET_USE_BIG_ENDIAN_STRUCTS */
29 u16 reserved2;
30 u32 transaction_id;
31 union {
32 u8 data[65528];
33 struct {
34#ifndef RMNET_USE_BIG_ENDIAN_STRUCTS
35 u16 ip_family:2;
36 u16 reserved:14;
37#else
38 u16 reserved:14;
39 u16 ip_family:2;
40#endif /* RMNET_USE_BIG_ENDIAN_STRUCTS */
41 u16 flow_control_seq_num;
42 u32 qos_id;
43 } flow_control;
44 };
45} __aligned(1);
46
47struct rmnet_map_dl_checksum_trailer_s {
48 unsigned char reserved_h;
49#if defined(__LITTLE_ENDIAN_BITFIELD)
50 unsigned char valid:1;
51 unsigned char reserved_l:7;
52#elif defined(__BIG_ENDIAN_BITFIELD)
53 unsigned char reserved_l:7;
54 unsigned char valid:1;
55#else
56#error "Please fix <asm/byteorder.h>"
57#endif
58 unsigned short checksum_start_offset;
59 unsigned short checksum_length;
60 unsigned short checksum_value;
61} __aligned(1);
62
63struct rmnet_map_ul_checksum_header_s {
64 unsigned short checksum_start_offset;
65#if defined(__LITTLE_ENDIAN_BITFIELD)
66 unsigned short checksum_insert_offset:14;
67 unsigned short udp_ip4_ind:1;
68 unsigned short cks_en:1;
69#elif defined(__BIG_ENDIAN_BITFIELD)
70 unsigned short cks_en:1;
71 unsigned short udp_ip4_ind:1;
72 unsigned short checksum_insert_offset:14;
73#else
74#error "Please fix <asm/byteorder.h>"
75#endif
76} __aligned(1);
77
78enum rmnet_map_results_e {
79 RMNET_MAP_SUCCESS,
80 RMNET_MAP_CONSUMED,
81 RMNET_MAP_GENERAL_FAILURE,
82 RMNET_MAP_NOT_ENABLED,
83 RMNET_MAP_FAILED_AGGREGATION,
84 RMNET_MAP_FAILED_MUX
85};
86
87enum rmnet_map_mux_errors_e {
88 RMNET_MAP_MUX_SUCCESS,
89 RMNET_MAP_MUX_INVALID_MUX_ID,
90 RMNET_MAP_MUX_INVALID_PAD_LENGTH,
91 RMNET_MAP_MUX_INVALID_PKT_LENGTH,
92 /* This should always be the last element */
93 RMNET_MAP_MUX_ENUM_LENGTH
94};
95
96enum rmnet_map_checksum_errors_e {
97 RMNET_MAP_CHECKSUM_OK,
98 RMNET_MAP_CHECKSUM_VALID_FLAG_NOT_SET,
99 RMNET_MAP_CHECKSUM_VALIDATION_FAILED,
100 RMNET_MAP_CHECKSUM_ERR_UNKNOWN,
101 RMNET_MAP_CHECKSUM_ERR_NOT_DATA_PACKET,
102 RMNET_MAP_CHECKSUM_ERR_BAD_BUFFER,
103 RMNET_MAP_CHECKSUM_ERR_UNKNOWN_IP_VERSION,
104 RMNET_MAP_CHECKSUM_ERR_UNKNOWN_TRANSPORT,
105 RMNET_MAP_CHECKSUM_FRAGMENTED_PACKET,
106 RMNET_MAP_CHECKSUM_SKIPPED,
107 RMNET_MAP_CHECKSUM_SW,
108 /* This should always be the last element */
109 RMNET_MAP_CHECKSUM_ENUM_LENGTH
110};
111
112enum rmnet_map_commands_e {
113 RMNET_MAP_COMMAND_NONE,
114 RMNET_MAP_COMMAND_FLOW_DISABLE,
115 RMNET_MAP_COMMAND_FLOW_ENABLE,
116 /* These should always be the last 2 elements */
117 RMNET_MAP_COMMAND_UNKNOWN,
118 RMNET_MAP_COMMAND_ENUM_LENGTH
119};
120
121enum rmnet_map_agg_state_e {
122 RMNET_MAP_AGG_IDLE,
123 RMNET_MAP_TXFER_SCHEDULED
124};
125
126#define RMNET_MAP_COMMAND_REQUEST 0
127#define RMNET_MAP_COMMAND_ACK 1
128#define RMNET_MAP_COMMAND_UNSUPPORTED 2
129#define RMNET_MAP_COMMAND_INVALID 3
130
131#define RMNET_MAP_NO_PAD_BYTES 0
132#define RMNET_MAP_ADD_PAD_BYTES 1
133
134uint8_t rmnet_map_demultiplex(struct sk_buff *skb);
135struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
136 struct rmnet_phys_ep_config *config);
137
138struct rmnet_map_header_s *rmnet_map_add_map_header(struct sk_buff *skb,
139 int hdrlen, int pad);
140rx_handler_result_t rmnet_map_command(struct sk_buff *skb,
141 struct rmnet_phys_ep_config *config);
142void rmnet_map_aggregate(struct sk_buff *skb,
143 struct rmnet_phys_ep_config *config);
144
145int rmnet_map_checksum_downlink_packet(struct sk_buff *skb);
146int rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
147 struct net_device *orig_dev,
148 u32 egress_data_format);
Subash Abhinov Kasiviswanathanbf783ba2017-11-08 15:55:29 -0700149int rmnet_ul_aggregation_skip(struct sk_buff *skb, int offset);
Subash Abhinov Kasiviswanathan08fed022017-11-17 17:54:49 -0700150enum hrtimer_restart rmnet_map_flush_packet_queue(struct hrtimer *t);
Subash Abhinov Kasiviswanathan2139ce8a2016-10-14 11:01:48 -0600151#endif /* _RMNET_MAP_H_ */