rmnet_config.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /* Copyright (c) 2013-2014, 2016-2021 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/skbuff.h>
  16. #include <net/gro_cells.h>
  17. #ifndef _RMNET_CONFIG_H_
  18. #define _RMNET_CONFIG_H_
  19. #define RMNET_MAX_LOGICAL_EP 255
  20. #define RMNET_MAX_VEID 4
  21. #define RMNET_SHS_STMP_ALL BIT(0)
  22. #define RMNET_SHS_NO_PSH BIT(1)
  23. #define RMNET_SHS_NO_DLMKR BIT(2)
  24. struct rmnet_shs_clnt_s {
  25. u16 config;
  26. u16 map_mask;
  27. u16 max_pkts;
  28. union {
  29. struct rmnet_port *port;
  30. } info;
  31. };
  32. struct rmnet_endpoint {
  33. u8 mux_id;
  34. struct net_device *egress_dev;
  35. struct hlist_node hlnode;
  36. };
  37. struct rmnet_agg_stats {
  38. u64 ul_agg_reuse;
  39. u64 ul_agg_alloc;
  40. };
  41. struct rmnet_port_priv_stats {
  42. u64 dl_hdr_last_qmap_vers;
  43. u64 dl_hdr_last_ep_id;
  44. u64 dl_hdr_last_trans_id;
  45. u64 dl_hdr_last_seq;
  46. u64 dl_hdr_last_bytes;
  47. u64 dl_hdr_last_pkts;
  48. u64 dl_hdr_last_flows;
  49. u64 dl_hdr_count;
  50. u64 dl_hdr_total_bytes;
  51. u64 dl_hdr_total_pkts;
  52. u64 dl_trl_last_seq;
  53. u64 dl_trl_count;
  54. struct rmnet_agg_stats agg;
  55. };
  56. struct rmnet_egress_agg_params {
  57. u16 agg_size;
  58. u8 agg_count;
  59. u8 agg_features;
  60. u32 agg_time;
  61. };
  62. enum {
  63. RMNET_DEFAULT_AGG_STATE,
  64. RMNET_LL_AGG_STATE,
  65. RMNET_MAX_AGG_STATE,
  66. };
  67. struct rmnet_aggregation_state {
  68. struct rmnet_egress_agg_params params;
  69. struct timespec64 agg_time;
  70. struct timespec64 agg_last;
  71. struct hrtimer hrtimer;
  72. struct work_struct agg_wq;
  73. /* Protect aggregation related elements */
  74. spinlock_t agg_lock;
  75. struct sk_buff *agg_skb;
  76. int (*send_agg_skb)(struct sk_buff *skb);
  77. int agg_state;
  78. u8 agg_count;
  79. u8 agg_size_order;
  80. struct list_head agg_list;
  81. struct rmnet_agg_page *agg_head;
  82. struct rmnet_agg_stats *stats;
  83. };
  84. struct rmnet_agg_page {
  85. struct list_head list;
  86. struct page *page;
  87. };
  88. /* One instance of this structure is instantiated for each real_dev associated
  89. * with rmnet.
  90. */
  91. struct rmnet_port {
  92. struct net_device *dev;
  93. u32 data_format;
  94. u8 nr_rmnet_devs;
  95. u8 rmnet_mode;
  96. struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP];
  97. struct net_device *bridge_ep;
  98. void *rmnet_perf;
  99. struct rmnet_aggregation_state agg_state[RMNET_MAX_AGG_STATE];
  100. void *qmi_info;
  101. /* dl marker elements */
  102. struct list_head dl_list;
  103. struct rmnet_port_priv_stats stats;
  104. int dl_marker_flush;
  105. /* Port Config for shs */
  106. struct rmnet_shs_clnt_s shs_cfg;
  107. struct rmnet_shs_clnt_s phy_shs_cfg;
  108. /* Descriptor pool */
  109. spinlock_t desc_pool_lock;
  110. struct rmnet_frag_descriptor_pool *frag_desc_pool;
  111. };
  112. extern struct rtnl_link_ops rmnet_link_ops;
  113. struct rmnet_vnd_stats {
  114. u64 rx_pkts;
  115. u64 rx_bytes;
  116. u64 tx_pkts;
  117. u64 tx_bytes;
  118. u32 tx_drops;
  119. };
  120. struct rmnet_pcpu_stats {
  121. struct rmnet_vnd_stats stats;
  122. struct u64_stats_sync syncp;
  123. };
  124. struct rmnet_coal_close_stats {
  125. u64 non_coal;
  126. u64 ip_miss;
  127. u64 trans_miss;
  128. u64 hw_nl;
  129. u64 hw_pkt;
  130. u64 hw_byte;
  131. u64 hw_time;
  132. u64 hw_evict;
  133. u64 coal;
  134. };
  135. struct rmnet_coal_stats {
  136. u64 coal_rx;
  137. u64 coal_pkts;
  138. u64 coal_hdr_nlo_err;
  139. u64 coal_hdr_pkt_err;
  140. u64 coal_csum_err;
  141. u64 coal_reconstruct;
  142. u64 coal_ip_invalid;
  143. u64 coal_trans_invalid;
  144. struct rmnet_coal_close_stats close;
  145. u64 coal_veid[RMNET_MAX_VEID];
  146. u64 coal_tcp;
  147. u64 coal_tcp_bytes;
  148. u64 coal_udp;
  149. u64 coal_udp_bytes;
  150. };
  151. struct rmnet_priv_stats {
  152. u64 csum_ok;
  153. u64 csum_valid_unset;
  154. u64 csum_validation_failed;
  155. u64 csum_err_bad_buffer;
  156. u64 csum_err_invalid_ip_version;
  157. u64 csum_err_invalid_transport;
  158. u64 csum_fragmented_pkt;
  159. u64 csum_skipped;
  160. u64 csum_sw;
  161. u64 csum_hw;
  162. struct rmnet_coal_stats coal;
  163. u64 ul_prio;
  164. u64 tso_pkts;
  165. u64 tso_arriv_errs;
  166. u64 tso_segment_success;
  167. u64 tso_segment_fail;
  168. u64 tso_segment_skip;
  169. u64 ll_tso_segs;
  170. u64 ll_tso_errs;
  171. };
  172. struct rmnet_priv {
  173. u8 mux_id;
  174. struct net_device *real_dev;
  175. struct rmnet_pcpu_stats __percpu *pcpu_stats;
  176. struct gro_cells gro_cells;
  177. struct rmnet_priv_stats stats;
  178. void __rcu *qos_info;
  179. };
  180. enum rmnet_dl_marker_prio {
  181. RMNET_PERF,
  182. RMNET_SHS,
  183. };
  184. enum rmnet_trace_func {
  185. RMNET_MODULE,
  186. NW_STACK_MODULE,
  187. };
  188. enum rmnet_trace_evt {
  189. RMNET_DLVR_SKB,
  190. RMNET_RCV_FROM_PND,
  191. RMNET_TX_UL_PKT,
  192. NW_STACK_DEV_Q_XMIT,
  193. NW_STACK_NAPI_GRO_FLUSH,
  194. NW_STACK_RX,
  195. NW_STACK_TX,
  196. };
  197. int rmnet_is_real_dev_registered(const struct net_device *real_dev);
  198. struct rmnet_port *rmnet_get_port(struct net_device *real_dev);
  199. struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id);
  200. int rmnet_add_bridge(struct net_device *rmnet_dev,
  201. struct net_device *slave_dev,
  202. struct netlink_ext_ack *extack);
  203. int rmnet_del_bridge(struct net_device *rmnet_dev,
  204. struct net_device *slave_dev);
  205. #endif /* _RMNET_CONFIG_H_ */