rmnet_config.h 5.5 KB

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