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