rmnet_config.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* Copyright (c) 2013-2014, 2016-2021 The Linux Foundation. All rights reserved.
  2. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * RMNET Data configuration engine
  14. *
  15. */
  16. #include <linux/skbuff.h>
  17. #include <net/gro_cells.h>
  18. #ifndef _RMNET_CONFIG_H_
  19. #define _RMNET_CONFIG_H_
  20. #define RMNET_MAX_LOGICAL_EP 255
  21. #define RMNET_MAX_VEID 16
  22. #define RMNET_SHS_STMP_ALL BIT(0)
  23. #define RMNET_SHS_NO_PSH BIT(1)
  24. #define RMNET_SHS_NO_DLMKR BIT(2)
  25. #define RMNET_LLM(prio) ((prio) == 0xDA001A) /* qmipriod */
  26. #define RMNET_APS_MAJOR 0x9B6D
  27. #define RMNET_APS_LLC_MASK 0x0100
  28. #define RMNET_APS_LLB_MASK 0x0200
  29. #define RMNET_APS_LLC(prio) \
  30. (((prio) >> 16 == RMNET_APS_MAJOR) && ((prio) & RMNET_APS_LLC_MASK))
  31. #define RMNET_APS_LLB(prio) \
  32. (((prio) >> 16 == RMNET_APS_MAJOR) && ((prio) & RMNET_APS_LLB_MASK))
  33. struct rmnet_shs_clnt_s {
  34. u16 config;
  35. u16 map_mask;
  36. u16 max_pkts;
  37. union {
  38. struct rmnet_port *port;
  39. } info;
  40. };
  41. struct rmnet_endpoint {
  42. u8 mux_id;
  43. struct net_device *egress_dev;
  44. struct hlist_node hlnode;
  45. };
  46. struct rmnet_agg_stats {
  47. u64 ul_agg_reuse;
  48. u64 ul_agg_alloc;
  49. };
  50. struct rmnet_port_priv_stats {
  51. u64 dl_hdr_last_qmap_vers;
  52. u64 dl_hdr_last_ep_id;
  53. u64 dl_hdr_last_trans_id;
  54. u64 dl_hdr_last_seq;
  55. u64 dl_hdr_last_bytes;
  56. u64 dl_hdr_last_pkts;
  57. u64 dl_hdr_last_flows;
  58. u64 dl_hdr_count;
  59. u64 dl_hdr_total_bytes;
  60. u64 dl_hdr_total_pkts;
  61. u64 dl_trl_last_seq;
  62. u64 dl_trl_count;
  63. struct rmnet_agg_stats agg;
  64. u64 dl_chain_stat[7];
  65. u64 dl_frag_stat_1;
  66. u64 dl_frag_stat[5];
  67. };
  68. struct rmnet_egress_agg_params {
  69. u16 agg_size;
  70. u8 agg_count;
  71. u8 agg_features;
  72. u32 agg_time;
  73. };
  74. enum {
  75. RMNET_DEFAULT_AGG_STATE,
  76. RMNET_LL_AGG_STATE,
  77. RMNET_MAX_AGG_STATE,
  78. };
  79. struct rmnet_aggregation_state {
  80. struct rmnet_egress_agg_params params;
  81. struct timespec64 agg_time;
  82. struct timespec64 agg_last;
  83. struct hrtimer hrtimer;
  84. struct work_struct agg_wq;
  85. /* Protect aggregation related elements */
  86. spinlock_t agg_lock;
  87. struct sk_buff *agg_skb;
  88. int (*send_agg_skb)(struct sk_buff *skb);
  89. int agg_state;
  90. u8 agg_count;
  91. u8 agg_size_order;
  92. struct list_head agg_list;
  93. struct rmnet_agg_page *agg_head;
  94. struct rmnet_agg_stats *stats;
  95. };
  96. struct rmnet_agg_page {
  97. struct list_head list;
  98. struct page *page;
  99. };
  100. /* One instance of this structure is instantiated for each real_dev associated
  101. * with rmnet.
  102. */
  103. struct rmnet_port {
  104. struct net_device *dev;
  105. u32 data_format;
  106. u8 nr_rmnet_devs;
  107. u8 rmnet_mode;
  108. struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP];
  109. struct net_device *bridge_ep;
  110. void *rmnet_perf;
  111. struct rmnet_aggregation_state agg_state[RMNET_MAX_AGG_STATE];
  112. void *qmi_info;
  113. /* dl marker elements */
  114. struct list_head dl_list;
  115. struct rmnet_port_priv_stats stats;
  116. int dl_marker_flush;
  117. /* Port Config for shs */
  118. struct rmnet_shs_clnt_s shs_cfg;
  119. struct rmnet_shs_clnt_s phy_shs_cfg;
  120. /* Descriptor pool */
  121. spinlock_t desc_pool_lock;
  122. struct rmnet_frag_descriptor_pool *frag_desc_pool;
  123. };
  124. extern struct rtnl_link_ops rmnet_link_ops;
  125. struct rmnet_vnd_stats {
  126. u64 rx_pkts;
  127. u64 rx_bytes;
  128. u64 tx_pkts;
  129. u64 tx_bytes;
  130. u32 tx_drops;
  131. };
  132. struct rmnet_pcpu_stats {
  133. struct rmnet_vnd_stats stats;
  134. struct u64_stats_sync syncp;
  135. };
  136. struct rmnet_coal_close_stats {
  137. u64 non_coal;
  138. u64 ip_miss;
  139. u64 trans_miss;
  140. u64 hw_nl;
  141. u64 hw_pkt;
  142. u64 hw_byte;
  143. u64 hw_time;
  144. u64 hw_evict;
  145. u64 coal;
  146. };
  147. struct rmnet_coal_stats {
  148. u64 coal_rx;
  149. u64 coal_pkts;
  150. u64 coal_hdr_nlo_err;
  151. u64 coal_hdr_pkt_err;
  152. u64 coal_csum_err;
  153. u64 coal_reconstruct;
  154. u64 coal_ip_invalid;
  155. u64 coal_trans_invalid;
  156. struct rmnet_coal_close_stats close;
  157. u64 coal_veid[RMNET_MAX_VEID];
  158. u64 coal_tcp;
  159. u64 coal_tcp_bytes;
  160. u64 coal_udp;
  161. u64 coal_udp_bytes;
  162. };
  163. struct rmnet_priv_stats {
  164. u64 csum_ok;
  165. u64 csum_valid_unset;
  166. u64 csum_validation_failed;
  167. u64 csum_err_bad_buffer;
  168. u64 csum_err_invalid_ip_version;
  169. u64 csum_err_invalid_transport;
  170. u64 csum_fragmented_pkt;
  171. u64 csum_skipped;
  172. u64 csum_sw;
  173. u64 csum_hw;
  174. struct rmnet_coal_stats coal;
  175. u64 ul_prio;
  176. u64 tso_pkts;
  177. u64 tso_arriv_errs;
  178. u64 tso_segment_success;
  179. u64 tso_segment_fail;
  180. u64 tso_segment_skip;
  181. u64 ll_tso_segs;
  182. u64 ll_tso_errs;
  183. u64 aps_prio;
  184. };
  185. struct rmnet_priv {
  186. u8 mux_id;
  187. struct net_device *real_dev;
  188. struct rmnet_pcpu_stats __percpu *pcpu_stats;
  189. struct gro_cells gro_cells;
  190. struct rmnet_priv_stats stats;
  191. void __rcu *qos_info;
  192. char aps_cb[16];
  193. };
  194. enum rmnet_dl_marker_prio {
  195. RMNET_PERF,
  196. RMNET_SHS,
  197. };
  198. enum rmnet_trace_func {
  199. RMNET_MODULE,
  200. NW_STACK_MODULE,
  201. };
  202. enum rmnet_trace_evt {
  203. RMNET_DLVR_SKB,
  204. RMNET_RCV_FROM_PND,
  205. RMNET_TX_UL_PKT,
  206. NW_STACK_DEV_Q_XMIT,
  207. NW_STACK_NAPI_GRO_FLUSH,
  208. NW_STACK_RX,
  209. NW_STACK_TX,
  210. };
  211. int rmnet_is_real_dev_registered(const struct net_device *real_dev);
  212. struct rmnet_port *rmnet_get_port(struct net_device *real_dev);
  213. struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id);
  214. int rmnet_add_bridge(struct net_device *rmnet_dev,
  215. struct net_device *slave_dev,
  216. struct netlink_ext_ack *extack);
  217. int rmnet_del_bridge(struct net_device *rmnet_dev,
  218. struct net_device *slave_dev);
  219. #endif /* _RMNET_CONFIG_H_ */