xref: /linux/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
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 };
22 
23 struct rmnet_egress_agg_params {
24 	u32 bytes;
25 	u32 count;
26 	u64 time_nsec;
27 };
28 
29 /* One instance of this structure is instantiated for each real_dev associated
30  * with rmnet.
31  */
32 struct rmnet_port {
33 	struct net_device *dev;
34 	u32 data_format;
35 	u8 nr_rmnet_devs;
36 	u8 rmnet_mode;
37 	struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP];
38 	struct net_device *bridge_ep;
39 	struct net_device *rmnet_dev;
40 
41 	/* Egress aggregation information */
42 	struct rmnet_egress_agg_params egress_agg_params;
43 	/* Protect aggregation related elements */
44 	spinlock_t agg_lock;
45 	struct sk_buff *skbagg_head;
46 	struct sk_buff *skbagg_tail;
47 	int agg_state;
48 	u8 agg_count;
49 	struct timespec64 agg_time;
50 	struct timespec64 agg_last;
51 	struct hrtimer hrtimer;
52 	struct work_struct agg_wq;
53 };
54 
55 extern struct rtnl_link_ops rmnet_link_ops;
56 
57 struct rmnet_vnd_stats {
58 	u64 rx_pkts;
59 	u64 rx_bytes;
60 	u64 tx_pkts;
61 	u64 tx_bytes;
62 	u32 tx_drops;
63 };
64 
65 struct rmnet_pcpu_stats {
66 	struct rmnet_vnd_stats stats;
67 	struct u64_stats_sync syncp;
68 };
69 
70 struct rmnet_priv_stats {
71 	u64 csum_ok;
72 	u64 csum_ip4_header_bad;
73 	u64 csum_valid_unset;
74 	u64 csum_validation_failed;
75 	u64 csum_err_bad_buffer;
76 	u64 csum_err_invalid_ip_version;
77 	u64 csum_err_invalid_transport;
78 	u64 csum_fragmented_pkt;
79 	u64 csum_skipped;
80 	u64 csum_sw;
81 	u64 csum_hw;
82 };
83 
84 struct rmnet_priv {
85 	u8 mux_id;
86 	struct net_device *real_dev;
87 	struct rmnet_pcpu_stats __percpu *pcpu_stats;
88 	struct gro_cells gro_cells;
89 	struct rmnet_priv_stats stats;
90 };
91 
92 struct rmnet_port *rmnet_get_port_rcu(struct net_device *real_dev);
93 struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id);
94 int rmnet_add_bridge(struct net_device *rmnet_dev,
95 		     struct net_device *slave_dev,
96 		     struct netlink_ext_ack *extack);
97 int rmnet_del_bridge(struct net_device *rmnet_dev,
98 		     struct net_device *slave_dev);
99 struct rmnet_port*
100 rmnet_get_port_rtnl(const struct net_device *real_dev);
101 #endif /* _RMNET_CONFIG_H_ */
102