blob: 5ce46007da346bfbb149c95964decadd3d9c47f5 [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 {
37 u8 refcount;
38 u8 rmnet_mode;
39 u8 mux_id;
40 struct timespec flush_time;
Conner Hufff90a2502016-10-31 11:22:15 -070041 unsigned int flush_byte_count;
Subash Abhinov Kasiviswanathan2139ce8a2016-10-14 11:01:48 -060042 struct net_device *egress_dev;
43};
44
45/**
46 * struct rmnet_phys_ep_conf_s - Physical endpoint configuration
47 * One instance of this structure is instantiated for each net_device associated
48 * with rmnet_data.
49 *
50 * @dev: The device which is associated with rmnet_data. Corresponds to this
51 * specific instance of rmnet_phys_ep_conf_s
52 * @local_ep: Default non-muxed endpoint. Used for non-MAP protocols/formats
53 * @muxed_ep: All multiplexed logical endpoints associated with this device
54 * @ingress_data_format: RMNET_INGRESS_FORMAT_* flags from rmnet_data.h
55 * @egress_data_format: RMNET_EGRESS_FORMAT_* flags from rmnet_data.h
56 *
57 * @egress_agg_size: Maximum size (bytes) of data which should be aggregated
58 * @egress_agg_count: Maximum count (packets) of data which should be aggregated
59 * Smaller of the two parameters above are chosen for
60 * aggregation
61 * @tail_spacing: Guaranteed padding (bytes) when de-aggregating ingress frames
62 * @agg_time: Wall clock time when aggregated frame was created
63 * @agg_last: Last time the aggregation routing was invoked
64 */
65struct rmnet_phys_ep_config {
66 struct net_device *dev;
67 struct rmnet_logical_ep_conf_s local_ep;
68 struct rmnet_logical_ep_conf_s muxed_ep[RMNET_DATA_MAX_LOGICAL_EP];
69 u32 ingress_data_format;
70 u32 egress_data_format;
71
72 /* MAP specific */
73 u16 egress_agg_size;
74 u16 egress_agg_count;
75 u8 tail_spacing;
76 /* MAP aggregation state machine
77 * - This is not sctrictly configuration and is updated at runtime
78 * Make sure all of these are protected by the agg_lock
79 */
80 spinlock_t agg_lock;
81 struct sk_buff *agg_skb;
82 u8 agg_state;
83 u8 agg_count;
84 struct timespec agg_time;
85 struct timespec agg_last;
86};
87
88int rmnet_config_init(void);
89void rmnet_config_exit(void);
90
91int rmnet_unassociate_network_device(struct net_device *dev);
92int rmnet_set_ingress_data_format(struct net_device *dev,
93 u32 ingress_data_format,
94 u8 tail_spacing);
95int rmnet_set_egress_data_format(struct net_device *dev,
96 u32 egress_data_format,
97 u16 agg_size,
98 u16 agg_count);
99int rmnet_associate_network_device(struct net_device *dev);
100int _rmnet_set_logical_endpoint_config
101 (struct net_device *dev, int config_id,
102 struct rmnet_logical_ep_conf_s *epconfig);
103int rmnet_set_logical_endpoint_config(struct net_device *dev,
104 int config_id,
105 u8 rmnet_mode,
106 struct net_device *egress_dev);
107int _rmnet_unset_logical_endpoint_config(struct net_device *dev,
108 int config_id);
109int rmnet_unset_logical_endpoint_config(struct net_device *dev,
110 int config_id);
111int _rmnet_get_logical_endpoint_config
112 (struct net_device *dev, int config_id,
113 struct rmnet_logical_ep_conf_s *epconfig);
114int rmnet_get_logical_endpoint_config(struct net_device *dev,
115 int config_id,
116 u8 *rmnet_mode,
117 u8 *egress_dev_name,
118 size_t egress_dev_name_size);
119void rmnet_config_netlink_msg_handler (struct sk_buff *skb);
120int rmnet_config_notify_cb(struct notifier_block *nb,
121 unsigned long event, void *data);
122int rmnet_create_vnd(int id);
123int rmnet_create_vnd_prefix(int id, const char *name);
Subash Abhinov Kasiviswanathan58598632017-02-23 18:24:42 -0700124int rmnet_create_vnd_name(int id, const char *name);
Subash Abhinov Kasiviswanathan2139ce8a2016-10-14 11:01:48 -0600125int rmnet_free_vnd(int id);
126
127struct rmnet_phys_ep_config *_rmnet_get_phys_ep_config
128 (struct net_device *dev);
129
130#endif /* _RMNET_DATA_CONFIG_H_ */