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