xref: /linux/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h (revision 68993ced0f618e36cf33388f1e50223e5e6e78cc)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2013-2014, 2016-2018, 2021 The Linux Foundation.
3  * All rights reserved.
4  *
5  * RMNET Data configuration engine
6  */
7 
8 #include <linux/skbuff.h>
9 #include <linux/time.h>
10 #include <net/gro_cells.h>
11 
12 #ifndef _RMNET_CONFIG_H_
13 #define _RMNET_CONFIG_H_
14 
15 #define RMNET_MAX_LOGICAL_EP 255
16 
17 struct rmnet_endpoint {
18 	u8 mux_id;
19 	struct net_device *egress_dev;
20 	struct hlist_node hlnode;
21 	struct rcu_head rcu;
22 };
23 
24 struct rmnet_egress_agg_params {
25 	u32 bytes;
26 	u32 count;
27 	u64 time_nsec;
28 };
29 
30 /* One instance of this structure is instantiated for each real_dev associated
31  * with rmnet.
32  */
33 struct rmnet_port {
34 	struct net_device *dev;
35 	u32 data_format;
36 	u8 nr_rmnet_devs;
37 	u8 rmnet_mode;
38 	struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP];
39 	struct net_device *bridge_ep;
40 	struct net_device *rmnet_dev;
41 
42 	/* Egress aggregation information */
43 	struct rmnet_egress_agg_params egress_agg_params;
44 	/* Protect aggregation related elements */
45 	spinlock_t agg_lock;
46 	struct sk_buff *skbagg_head;
47 	struct sk_buff *skbagg_tail;
48 	int agg_state;
49 	u8 agg_count;
50 	struct timespec64 agg_time;
51 	struct timespec64 agg_last;
52 	struct hrtimer hrtimer;
53 	struct work_struct agg_wq;
54 };
55 
56 extern struct rtnl_link_ops rmnet_link_ops;
57 
58 struct rmnet_vnd_stats {
59 	u64 rx_pkts;
60 	u64 rx_bytes;
61 	u64 tx_pkts;
62 	u64 tx_bytes;
63 	u32 tx_drops;
64 };
65 
66 struct rmnet_pcpu_stats {
67 	struct rmnet_vnd_stats stats;
68 	struct u64_stats_sync syncp;
69 };
70 
71 struct rmnet_priv_stats {
72 	u64 csum_ok;
73 	u64 csum_ip4_header_bad;
74 	u64 csum_valid_unset;
75 	u64 csum_validation_failed;
76 	u64 csum_err_bad_buffer;
77 	u64 csum_err_invalid_ip_version;
78 	u64 csum_err_invalid_transport;
79 	u64 csum_fragmented_pkt;
80 	u64 csum_skipped;
81 	u64 csum_sw;
82 	u64 csum_hw;
83 };
84 
85 struct rmnet_priv {
86 	u8 mux_id;
87 	struct net_device *real_dev;
88 	struct rmnet_pcpu_stats __percpu *pcpu_stats;
89 	struct gro_cells gro_cells;
90 	struct rmnet_priv_stats stats;
91 };
92 
93 struct rmnet_port *rmnet_get_port_rcu(struct net_device *real_dev);
94 struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id);
95 int rmnet_add_bridge(struct net_device *rmnet_dev,
96 		     struct net_device *slave_dev,
97 		     struct netlink_ext_ack *extack);
98 int rmnet_del_bridge(struct net_device *rmnet_dev,
99 		     struct net_device *slave_dev);
100 struct rmnet_port*
101 rmnet_get_port_rtnl(const struct net_device *real_dev);
102 #endif /* _RMNET_CONFIG_H_ */
103