rmnet_config.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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 timespec64 agg_time;
  69. struct timespec64 agg_last;
  70. struct hrtimer hrtimer;
  71. struct work_struct agg_wq;
  72. /* Pointer back to the main lock for use in the workqueue */
  73. spinlock_t *agg_lock;
  74. struct sk_buff *agg_skb;
  75. int (*send_agg_skb)(struct sk_buff *skb);
  76. int agg_state;
  77. u8 agg_count;
  78. };
  79. struct rmnet_agg_page {
  80. struct list_head list;
  81. struct page *page;
  82. };
  83. /* One instance of this structure is instantiated for each real_dev associated
  84. * with rmnet.
  85. */
  86. struct rmnet_port {
  87. struct net_device *dev;
  88. u32 data_format;
  89. u8 nr_rmnet_devs;
  90. u8 rmnet_mode;
  91. struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP];
  92. struct net_device *bridge_ep;
  93. void *rmnet_perf;
  94. struct rmnet_egress_agg_params egress_agg_params;
  95. /* Protect aggregation related elements */
  96. spinlock_t agg_lock;
  97. struct rmnet_aggregation_state agg_state[RMNET_MAX_AGG_STATE];
  98. u8 agg_size_order;
  99. struct list_head agg_list;
  100. struct rmnet_agg_page *agg_head;
  101. void *qmi_info;
  102. /* dl marker elements */
  103. struct list_head dl_list;
  104. struct rmnet_port_priv_stats stats;
  105. int dl_marker_flush;
  106. /* Port Config for shs */
  107. struct rmnet_shs_clnt_s shs_cfg;
  108. struct rmnet_shs_clnt_s phy_shs_cfg;
  109. /* Descriptor pool */
  110. spinlock_t desc_pool_lock;
  111. struct rmnet_frag_descriptor_pool *frag_desc_pool;
  112. };
  113. extern struct rtnl_link_ops rmnet_link_ops;
  114. struct rmnet_vnd_stats {
  115. u64 rx_pkts;
  116. u64 rx_bytes;
  117. u64 tx_pkts;
  118. u64 tx_bytes;
  119. u32 tx_drops;
  120. };
  121. struct rmnet_pcpu_stats {
  122. struct rmnet_vnd_stats stats;
  123. struct u64_stats_sync syncp;
  124. };
  125. struct rmnet_coal_close_stats {
  126. u64 non_coal;
  127. u64 ip_miss;
  128. u64 trans_miss;
  129. u64 hw_nl;
  130. u64 hw_pkt;
  131. u64 hw_byte;
  132. u64 hw_time;
  133. u64 hw_evict;
  134. u64 coal;
  135. };
  136. struct rmnet_coal_stats {
  137. u64 coal_rx;
  138. u64 coal_pkts;
  139. u64 coal_hdr_nlo_err;
  140. u64 coal_hdr_pkt_err;
  141. u64 coal_csum_err;
  142. u64 coal_reconstruct;
  143. u64 coal_ip_invalid;
  144. u64 coal_trans_invalid;
  145. struct rmnet_coal_close_stats close;
  146. u64 coal_veid[RMNET_MAX_VEID];
  147. u64 coal_tcp;
  148. u64 coal_tcp_bytes;
  149. u64 coal_udp;
  150. u64 coal_udp_bytes;
  151. };
  152. struct rmnet_priv_stats {
  153. u64 csum_ok;
  154. u64 csum_valid_unset;
  155. u64 csum_validation_failed;
  156. u64 csum_err_bad_buffer;
  157. u64 csum_err_invalid_ip_version;
  158. u64 csum_err_invalid_transport;
  159. u64 csum_fragmented_pkt;
  160. u64 csum_skipped;
  161. u64 csum_sw;
  162. u64 csum_hw;
  163. struct rmnet_coal_stats coal;
  164. u64 ul_prio;
  165. u64 tso_pkts;
  166. u64 tso_arriv_errs;
  167. };
  168. struct rmnet_priv {
  169. u8 mux_id;
  170. struct net_device *real_dev;
  171. struct rmnet_pcpu_stats __percpu *pcpu_stats;
  172. struct gro_cells gro_cells;
  173. struct rmnet_priv_stats stats;
  174. void __rcu *qos_info;
  175. };
  176. enum rmnet_dl_marker_prio {
  177. RMNET_PERF,
  178. RMNET_SHS,
  179. };
  180. enum rmnet_trace_func {
  181. RMNET_MODULE,
  182. NW_STACK_MODULE,
  183. };
  184. enum rmnet_trace_evt {
  185. RMNET_DLVR_SKB,
  186. RMNET_RCV_FROM_PND,
  187. RMNET_TX_UL_PKT,
  188. NW_STACK_DEV_Q_XMIT,
  189. NW_STACK_NAPI_GRO_FLUSH,
  190. NW_STACK_RX,
  191. NW_STACK_TX,
  192. };
  193. int rmnet_is_real_dev_registered(const struct net_device *real_dev);
  194. struct rmnet_port *rmnet_get_port(struct net_device *real_dev);
  195. struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id);
  196. int rmnet_add_bridge(struct net_device *rmnet_dev,
  197. struct net_device *slave_dev,
  198. struct netlink_ext_ack *extack);
  199. int rmnet_del_bridge(struct net_device *rmnet_dev,
  200. struct net_device *slave_dev);
  201. #endif /* _RMNET_CONFIG_H_ */