blob: aa8a0b559c0769fbb5317df5a51e936fd099f429 [file] [log] [blame]
Conner Hufff90a2502016-10-31 11:22:15 -07001/* Copyright (c) 2013-2014, 2016-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 * RMNET Data configuration engine
13 */
14
15#include <linux/types.h>
16#include <linux/time.h>
17#include <linux/spinlock.h>
18#include <net/rmnet_config.h>
19
20#ifndef _RMNET_DATA_CONFIG_H_
21#define _RMNET_DATA_CONFIG_H_
22
23#define RMNET_DATA_MAX_LOGICAL_EP 256
24
25/**
26 * struct rmnet_logical_ep_conf_s - Logical end-point configuration
27 *
28 * @refcount: Reference count for this endpoint. 0 signifies the endpoint is not
29 * configured for use
30 * @rmnet_mode: Specifies how the traffic should be finally delivered. Possible
31 * options are available in enum rmnet_config_endpoint_modes_e
32 * @mux_id: Virtual channel ID used by MAP protocol
33 * @egress_dev: Next device to deliver the packet to. Exact usage of this
34 * parmeter depends on the rmnet_mode
35 */
36struct rmnet_logical_ep_conf_s {
Conner Huffa9112ff2017-10-10 14:19:50 -070037 struct net_device *egress_dev;
38 struct timespec last_flush_time;
39 long curr_time_limit;
40 unsigned int flush_byte_count;
41 unsigned int curr_byte_threshold;
Subash Abhinov Kasiviswanathan2139ce8a2016-10-14 11:01:48 -060042 u8 refcount;
43 u8 rmnet_mode;
44 u8 mux_id;
Subash Abhinov Kasiviswanathan2139ce8a2016-10-14 11:01:48 -060045};
46
47/**
48 * struct rmnet_phys_ep_conf_s - Physical endpoint configuration
49 * One instance of this structure is instantiated for each net_device associated
50 * with rmnet_data.
51 *
52 * @dev: The device which is associated with rmnet_data. Corresponds to this
53 * specific instance of rmnet_phys_ep_conf_s
54 * @local_ep: Default non-muxed endpoint. Used for non-MAP protocols/formats
55 * @muxed_ep: All multiplexed logical endpoints associated with this device
56 * @ingress_data_format: RMNET_INGRESS_FORMAT_* flags from rmnet_data.h
57 * @egress_data_format: RMNET_EGRESS_FORMAT_* flags from rmnet_data.h
58 *
59 * @egress_agg_size: Maximum size (bytes) of data which should be aggregated
60 * @egress_agg_count: Maximum count (packets) of data which should be aggregated
61 * Smaller of the two parameters above are chosen for
62 * aggregation
63 * @tail_spacing: Guaranteed padding (bytes) when de-aggregating ingress frames
64 * @agg_time: Wall clock time when aggregated frame was created
65 * @agg_last: Last time the aggregation routing was invoked
66 */
67struct rmnet_phys_ep_config {
68 struct net_device *dev;
69 struct rmnet_logical_ep_conf_s local_ep;
70 struct rmnet_logical_ep_conf_s muxed_ep[RMNET_DATA_MAX_LOGICAL_EP];
71 u32 ingress_data_format;
72 u32 egress_data_format;
73
74 /* MAP specific */
75 u16 egress_agg_size;
76 u16 egress_agg_count;
77 u8 tail_spacing;
78 /* MAP aggregation state machine
79 * - This is not sctrictly configuration and is updated at runtime
80 * Make sure all of these are protected by the agg_lock
81 */
82 spinlock_t agg_lock;
83 struct sk_buff *agg_skb;
84 u8 agg_state;
85 u8 agg_count;
86 struct timespec agg_time;
87 struct timespec agg_last;
88};
89
90int rmnet_config_init(void);
91void rmnet_config_exit(void);
92
93int rmnet_unassociate_network_device(struct net_device *dev);
94int rmnet_set_ingress_data_format(struct net_device *dev,
95 u32 ingress_data_format,
96 u8 tail_spacing);
97int rmnet_set_egress_data_format(struct net_device *dev,
98 u32 egress_data_format,
99 u16 agg_size,
100 u16 agg_count);
101int rmnet_associate_network_device(struct net_device *dev);
102int _rmnet_set_logical_endpoint_config
103 (struct net_device *dev, int config_id,
104 struct rmnet_logical_ep_conf_s *epconfig);
105int rmnet_set_logical_endpoint_config(struct net_device *dev,
106 int config_id,
107 u8 rmnet_mode,
108 struct net_device *egress_dev);
109int _rmnet_unset_logical_endpoint_config(struct net_device *dev,
110 int config_id);
111int rmnet_unset_logical_endpoint_config(struct net_device *dev,
112 int config_id);
113int _rmnet_get_logical_endpoint_config
114 (struct net_device *dev, int config_id,
115 struct rmnet_logical_ep_conf_s *epconfig);
116int rmnet_get_logical_endpoint_config(struct net_device *dev,
117 int config_id,
118 u8 *rmnet_mode,
119 u8 *egress_dev_name,
120 size_t egress_dev_name_size);
121void rmnet_config_netlink_msg_handler (struct sk_buff *skb);
122int rmnet_config_notify_cb(struct notifier_block *nb,
123 unsigned long event, void *data);
124int rmnet_create_vnd(int id);
125int rmnet_create_vnd_prefix(int id, const char *name);
Subash Abhinov Kasiviswanathan58598632017-02-23 18:24:42 -0700126int rmnet_create_vnd_name(int id, const char *name);
Subash Abhinov Kasiviswanathan2139ce8a2016-10-14 11:01:48 -0600127int rmnet_free_vnd(int id);
128
129struct rmnet_phys_ep_config *_rmnet_get_phys_ep_config
130 (struct net_device *dev);
131
132#endif /* _RMNET_DATA_CONFIG_H_ */