qdf_nbuf.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449
  1. /*
  2. * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * DOC: qdf_nbuf_public network buffer API
  28. * This file defines the network buffer abstraction.
  29. */
  30. #ifndef _QDF_NBUF_H
  31. #define _QDF_NBUF_H
  32. #include <qdf_util.h>
  33. #include <qdf_types.h>
  34. #include <qdf_lock.h>
  35. #include <i_qdf_nbuf.h>
  36. #include <i_qdf_trace.h>
  37. #include <qdf_net_types.h>
  38. #define IPA_NBUF_OWNER_ID 0xaa55aa55
  39. #define QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02
  40. #define QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04
  41. #define QDF_NBUF_PKT_TRAC_TYPE_MGMT_ACTION 0x08
  42. #define QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10
  43. #define QDF_NBUF_PKT_TRAC_MAX_STRING 12
  44. #define QDF_NBUF_PKT_TRAC_PROTO_STRING 4
  45. #define QDF_NBUF_PKT_ERROR 1
  46. #define QDF_NBUF_TRAC_IPV4_OFFSET 14
  47. #define QDF_NBUF_TRAC_IPV4_HEADER_SIZE 20
  48. #define QDF_NBUF_TRAC_DHCP_SRV_PORT 67
  49. #define QDF_NBUF_TRAC_DHCP_CLI_PORT 68
  50. #define QDF_NBUF_TRAC_ETH_TYPE_OFFSET 12
  51. #define QDF_NBUF_TRAC_EAPOL_ETH_TYPE 0x888E
  52. #define QDF_NBUF_TRAC_ARP_ETH_TYPE 0x0806
  53. #define QDF_NBUF_DEST_MAC_OFFSET 0
  54. #define QDF_NBUF_SRC_MAC_OFFSET 6
  55. /* EAPOL Related MASK */
  56. #define EAPOL_PACKET_TYPE_OFFSET 15
  57. #define EAPOL_KEY_INFO_OFFSET 19
  58. #define EAPOL_MASK 0x8013
  59. #define EAPOL_M1_BIT_MASK 0x8000
  60. #define EAPOL_M2_BIT_MASK 0x0001
  61. #define EAPOL_M3_BIT_MASK 0x8013
  62. #define EAPOL_M4_BIT_MASK 0x0003
  63. /* Tracked Packet types */
  64. #define QDF_NBUF_TX_PKT_INVALID 0
  65. #define QDF_NBUF_TX_PKT_DATA_TRACK 1
  66. #define QDF_NBUF_TX_PKT_MGMT_TRACK 2
  67. /* Different Packet states */
  68. #define QDF_NBUF_TX_PKT_HDD 1
  69. #define QDF_NBUF_TX_PKT_TXRX_ENQUEUE 2
  70. #define QDF_NBUF_TX_PKT_TXRX_DEQUEUE 3
  71. #define QDF_NBUF_TX_PKT_TXRX 4
  72. #define QDF_NBUF_TX_PKT_HTT 5
  73. #define QDF_NBUF_TX_PKT_HTC 6
  74. #define QDF_NBUF_TX_PKT_HIF 7
  75. #define QDF_NBUF_TX_PKT_CE 8
  76. #define QDF_NBUF_TX_PKT_FREE 9
  77. #define QDF_NBUF_TX_PKT_STATE_MAX 10
  78. /**
  79. * struct mon_rx_status - This will have monitor mode rx_status extracted from
  80. * htt_rx_desc used later to update radiotap information.
  81. * @tsft: Time Synchronization Function timer
  82. * @chan_freq: Capture channel frequency
  83. * @chan_num: Capture channel number
  84. * @chan_flags: Bitmap of Channel flags, IEEE80211_CHAN_TURBO,
  85. * IEEE80211_CHAN_CCK...
  86. * @vht_flags: VHT flgs, only present for VHT frames.
  87. * @vht_flag_values1-5: Contains corresponding data for flags field
  88. * @rate: Rate in terms 500Kbps
  89. * @rtap_flags: Bit map of available fields in the radiotap
  90. * @ant_signal_db: Rx packet RSSI
  91. * @nr_ant: Number of Antennas used for streaming
  92. * @mcs: MCS index of Rx frame
  93. * @is_stbc: Is STBC enabled
  94. * @sgi: Rx frame short guard interval
  95. * @ldpc: ldpc enabled
  96. * @beamformed: Is frame beamformed.
  97. */
  98. struct mon_rx_status {
  99. uint64_t tsft;
  100. uint16_t chan_freq;
  101. uint16_t chan_num;
  102. uint16_t chan_flags;
  103. uint16_t vht_flags;
  104. uint16_t vht_flag_values6;
  105. uint8_t rate;
  106. uint8_t rtap_flags;
  107. uint8_t ant_signal_db;
  108. uint8_t nr_ant;
  109. uint8_t mcs;
  110. uint8_t vht_flag_values1;
  111. uint8_t vht_flag_values2;
  112. uint8_t vht_flag_values3[4];
  113. uint8_t vht_flag_values4;
  114. uint8_t vht_flag_values5;
  115. uint8_t is_stbc;
  116. uint8_t sgi;
  117. uint8_t ldpc;
  118. uint8_t beamformed;
  119. };
  120. /* DHCP Related Mask */
  121. #define QDF_DHCP_OPTION53 (0x35)
  122. #define QDF_DHCP_OPTION53_LENGTH (1)
  123. #define QDF_DHCP_OPTION53_OFFSET (0x11A)
  124. #define QDF_DHCP_OPTION53_LENGTH_OFFSET (0x11B)
  125. #define QDF_DHCP_OPTION53_STATUS_OFFSET (0x11C)
  126. #define QDF_DHCP_DISCOVER (1)
  127. #define QDF_DHCP_OFFER (2)
  128. #define QDF_DHCP_REQUEST (3)
  129. #define QDF_DHCP_DECLINE (4)
  130. #define QDF_DHCP_ACK (5)
  131. #define QDF_DHCP_NAK (6)
  132. #define QDF_DHCP_RELEASE (7)
  133. #define QDF_DHCP_INFORM (8)
  134. #define ARP_SUB_TYPE_OFFSET 20
  135. #define ARP_REQUEST (1)
  136. #define ARP_RESPONSE (2)
  137. #define QDF_NBUF_IPA_CHECK_MASK 0x80000000
  138. /**
  139. * @qdf_nbuf_t - Platform indepedent packet abstraction
  140. */
  141. typedef __qdf_nbuf_t qdf_nbuf_t;
  142. /**
  143. * @qdf_dma_map_cb_t - Dma map callback prototype
  144. */
  145. typedef void (*qdf_dma_map_cb_t)(void *arg, qdf_nbuf_t buf,
  146. qdf_dma_map_t dmap);
  147. /**
  148. * @qdf_nbuf_queue_t - Platform independent packet queue abstraction
  149. */
  150. typedef __qdf_nbuf_queue_t qdf_nbuf_queue_t;
  151. /* BUS/DMA mapping routines */
  152. static inline QDF_STATUS
  153. qdf_nbuf_dmamap_create(qdf_device_t osdev, qdf_dma_map_t *dmap)
  154. {
  155. return __qdf_nbuf_dmamap_create(osdev, dmap);
  156. }
  157. static inline void
  158. qdf_nbuf_dmamap_destroy(qdf_device_t osdev, qdf_dma_map_t dmap)
  159. {
  160. __qdf_nbuf_dmamap_destroy(osdev, dmap);
  161. }
  162. static inline void
  163. qdf_nbuf_dmamap_set_cb(qdf_dma_map_t dmap, qdf_dma_map_cb_t cb, void *arg)
  164. {
  165. __qdf_nbuf_dmamap_set_cb(dmap, cb, arg);
  166. }
  167. static inline void
  168. qdf_nbuf_set_send_complete_flag(qdf_nbuf_t buf, bool flag)
  169. {
  170. __qdf_nbuf_set_send_complete_flag(buf, flag);
  171. }
  172. static inline QDF_STATUS
  173. qdf_nbuf_map(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  174. {
  175. return __qdf_nbuf_map(osdev, buf, dir);
  176. }
  177. static inline void
  178. qdf_nbuf_unmap(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  179. {
  180. __qdf_nbuf_unmap(osdev, buf, dir);
  181. }
  182. static inline QDF_STATUS
  183. qdf_nbuf_map_nbytes(qdf_device_t osdev, qdf_nbuf_t buf,
  184. qdf_dma_dir_t dir, int nbytes)
  185. {
  186. return __qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes);
  187. }
  188. static inline void
  189. qdf_nbuf_unmap_nbytes(qdf_device_t osdev,
  190. qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  191. {
  192. __qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes);
  193. }
  194. #ifndef REMOVE_INIT_DEBUG_CODE
  195. static inline void
  196. qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  197. {
  198. __qdf_nbuf_sync_for_cpu(osdev, buf, dir);
  199. }
  200. #endif
  201. static inline QDF_STATUS
  202. qdf_nbuf_map_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  203. {
  204. return __qdf_nbuf_map_single(osdev, buf, dir);
  205. }
  206. static inline QDF_STATUS
  207. qdf_nbuf_map_nbytes_single(
  208. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  209. {
  210. return __qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes);
  211. }
  212. static inline void
  213. qdf_nbuf_unmap_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  214. {
  215. __qdf_nbuf_unmap_single(osdev, buf, dir);
  216. }
  217. static inline void
  218. qdf_nbuf_unmap_nbytes_single(
  219. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  220. {
  221. return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
  222. }
  223. static inline int qdf_nbuf_get_num_frags(qdf_nbuf_t buf)
  224. {
  225. return __qdf_nbuf_get_num_frags(buf);
  226. }
  227. /**
  228. * qdf_nbuf_get_frag_len() - get fragment length
  229. * @buf: Network buffer
  230. * @frag_num: Fragment number
  231. *
  232. * Return: Fragment length
  233. */
  234. static inline int qdf_nbuf_get_frag_len(qdf_nbuf_t buf, int frag_num)
  235. {
  236. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  237. return __qdf_nbuf_get_frag_len(buf, frag_num);
  238. }
  239. /**
  240. * qdf_nbuf_get_frag_vaddr() - get fragment virtual address
  241. * @buf: Network buffer
  242. * @frag_num: Fragment number
  243. *
  244. * Return: Fragment virtual address
  245. */
  246. static inline unsigned char *qdf_nbuf_get_frag_vaddr(qdf_nbuf_t buf,
  247. int frag_num)
  248. {
  249. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  250. return __qdf_nbuf_get_frag_vaddr(buf, frag_num);
  251. }
  252. /**
  253. * qdf_nbuf_get_frag_vaddr_always() - get fragment virtual address
  254. * @buf: Network buffer
  255. *
  256. * Return: Fragment virtual address
  257. */
  258. static inline unsigned char *
  259. qdf_nbuf_get_frag_vaddr_always(qdf_nbuf_t buf)
  260. {
  261. return __qdf_nbuf_get_frag_vaddr_always(buf);
  262. }
  263. /**
  264. * qdf_nbuf_get_frag_paddr() - get fragment physical address
  265. * @buf: Network buffer
  266. * @frag_num: Fragment number
  267. *
  268. * Return: Fragment physical address
  269. */
  270. static inline qdf_dma_addr_t qdf_nbuf_get_frag_paddr(qdf_nbuf_t buf,
  271. unsigned int frag_num)
  272. {
  273. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  274. return __qdf_nbuf_get_frag_paddr(buf, frag_num);
  275. }
  276. /**
  277. * qdf_nbuf_get_frag_is_wordstream() - is fragment wordstream
  278. * @buf: Network buffer
  279. * @frag_num: Fragment number
  280. *
  281. * Return: Fragment wordstream or not
  282. */
  283. static inline int qdf_nbuf_get_frag_is_wordstream(qdf_nbuf_t buf, int frag_num)
  284. {
  285. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  286. return __qdf_nbuf_get_frag_is_wordstream(buf, frag_num);
  287. }
  288. static inline int qdf_nbuf_ipa_owned_get(qdf_nbuf_t buf)
  289. {
  290. return __qdf_nbuf_ipa_owned_get(buf);
  291. }
  292. static inline void qdf_nbuf_ipa_owned_set(qdf_nbuf_t buf)
  293. {
  294. __qdf_nbuf_ipa_owned_set(buf);
  295. }
  296. static inline int qdf_nbuf_ipa_priv_get(qdf_nbuf_t buf)
  297. {
  298. return __qdf_nbuf_ipa_priv_get(buf);
  299. }
  300. static inline void qdf_nbuf_ipa_priv_set(qdf_nbuf_t buf, uint32_t priv)
  301. {
  302. QDF_BUG(!(priv & QDF_NBUF_IPA_CHECK_MASK));
  303. __qdf_nbuf_ipa_priv_set(buf, priv);
  304. }
  305. /**
  306. * qdf_nbuf_set_frag_is_wordstream() - set fragment wordstream
  307. * @buf: Network buffer
  308. * @frag_num: Fragment number
  309. * @is_wordstream: Wordstream
  310. *
  311. * Return: none
  312. */
  313. static inline void
  314. qdf_nbuf_set_frag_is_wordstream(qdf_nbuf_t buf,
  315. int frag_num, int is_wordstream)
  316. {
  317. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  318. __qdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream);
  319. }
  320. static inline void
  321. qdf_nbuf_set_vdev_ctx(qdf_nbuf_t buf, void *vdev_ctx)
  322. {
  323. __qdf_nbuf_set_vdev_ctx(buf, vdev_ctx);
  324. }
  325. static inline void
  326. qdf_nbuf_set_fctx_type(qdf_nbuf_t buf, void *ctx, uint8_t type)
  327. {
  328. __qdf_nbuf_set_fctx_type(buf, ctx, type);
  329. }
  330. static inline void *
  331. qdf_nbuf_get_vdev_ctx(qdf_nbuf_t buf)
  332. {
  333. return __qdf_nbuf_get_vdev_ctx(buf);
  334. }
  335. static inline void *qdf_nbuf_get_fctx(qdf_nbuf_t buf)
  336. {
  337. return __qdf_nbuf_get_fctx(buf);
  338. }
  339. static inline uint8_t qdf_nbuf_get_ftype(qdf_nbuf_t buf)
  340. {
  341. return __qdf_nbuf_get_ftype(buf);
  342. }
  343. static inline qdf_dma_addr_t
  344. qdf_nbuf_mapped_paddr_get(qdf_nbuf_t buf)
  345. {
  346. return __qdf_nbuf_mapped_paddr_get(buf);
  347. }
  348. static inline void
  349. qdf_nbuf_mapped_paddr_set(qdf_nbuf_t buf, qdf_dma_addr_t paddr)
  350. {
  351. __qdf_nbuf_mapped_paddr_set(buf, paddr);
  352. }
  353. static inline void
  354. qdf_nbuf_frag_push_head(qdf_nbuf_t buf,
  355. int frag_len, char *frag_vaddr,
  356. qdf_dma_addr_t frag_paddr)
  357. {
  358. __qdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr);
  359. }
  360. #define qdf_nbuf_num_frags_init(_nbuf) __qdf_nbuf_num_frags_init((_nbuf))
  361. /* For efficiency, it is the responsibility of the caller to ensure that val
  362. * is either 0 or 1.
  363. */
  364. static inline void
  365. qdf_nbuf_set_chfrag_start(qdf_nbuf_t buf, uint8_t val)
  366. {
  367. __qdf_nbuf_set_chfrag_start(buf, val);
  368. }
  369. static inline int qdf_nbuf_is_chfrag_start(qdf_nbuf_t buf)
  370. {
  371. return __qdf_nbuf_is_chfrag_start(buf);
  372. }
  373. /* For efficiency, it is the responsibility of the caller to ensure that val
  374. * is either 0 or 1.
  375. */
  376. static inline void qdf_nbuf_set_chfrag_end(qdf_nbuf_t buf, uint8_t val)
  377. {
  378. __qdf_nbuf_set_chfrag_end(buf, val);
  379. }
  380. static inline int qdf_nbuf_is_chfrag_end(qdf_nbuf_t buf)
  381. {
  382. return __qdf_nbuf_is_chfrag_end(buf);
  383. }
  384. static inline void
  385. qdf_nbuf_dma_map_info(qdf_dma_map_t bmap, qdf_dmamap_info_t *sg)
  386. {
  387. __qdf_nbuf_dma_map_info(bmap, sg);
  388. }
  389. #ifdef MEMORY_DEBUG
  390. void qdf_net_buf_debug_init(void);
  391. void qdf_net_buf_debug_exit(void);
  392. void qdf_net_buf_debug_clean(void);
  393. void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
  394. uint8_t *file_name, uint32_t line_num);
  395. void qdf_net_buf_debug_delete_node(qdf_nbuf_t net_buf);
  396. void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf);
  397. /* nbuf allocation rouines */
  398. #define qdf_nbuf_alloc(d, s, r, a, p) \
  399. qdf_nbuf_alloc_debug(d, s, r, a, p, __FILE__, __LINE__)
  400. static inline qdf_nbuf_t
  401. qdf_nbuf_alloc_debug(qdf_device_t osdev, qdf_size_t size, int reserve,
  402. int align, int prio, uint8_t *file_name,
  403. uint32_t line_num)
  404. {
  405. qdf_nbuf_t net_buf;
  406. net_buf = __qdf_nbuf_alloc(osdev, size, reserve, align, prio);
  407. /* Store SKB in internal QDF tracking table */
  408. if (qdf_likely(net_buf))
  409. qdf_net_buf_debug_add_node(net_buf, size, file_name, line_num);
  410. return net_buf;
  411. }
  412. static inline void qdf_nbuf_free(qdf_nbuf_t net_buf)
  413. {
  414. /* Remove SKB from internal QDF tracking table */
  415. if (qdf_likely(net_buf))
  416. qdf_net_buf_debug_delete_node(net_buf);
  417. __qdf_nbuf_free(net_buf);
  418. }
  419. #else
  420. static inline void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf)
  421. {
  422. return;
  423. }
  424. /* Nbuf allocation rouines */
  425. static inline qdf_nbuf_t
  426. qdf_nbuf_alloc(qdf_device_t osdev,
  427. qdf_size_t size, int reserve, int align, int prio)
  428. {
  429. return __qdf_nbuf_alloc(osdev, size, reserve, align, prio);
  430. }
  431. static inline void qdf_nbuf_free(qdf_nbuf_t buf)
  432. {
  433. __qdf_nbuf_free(buf);
  434. }
  435. #endif
  436. #ifdef WLAN_FEATURE_FASTPATH
  437. /**
  438. * qdf_nbuf_init_fast() - before put buf into pool,turn it to init state
  439. *
  440. * @buf: buf instance
  441. * Return: data pointer of this buf where new data has to be
  442. * put, or NULL if there is not enough room in this buf.
  443. */
  444. static inline void qdf_nbuf_init_fast(qdf_nbuf_t nbuf)
  445. {
  446. atomic_set(&nbuf->users, 1);
  447. nbuf->data = nbuf->head + NET_SKB_PAD;
  448. skb_reset_tail_pointer(nbuf);
  449. }
  450. #endif /* WLAN_FEATURE_FASTPATH */
  451. static inline void qdf_nbuf_tx_free(qdf_nbuf_t buf_list, int tx_err)
  452. {
  453. __qdf_nbuf_tx_free(buf_list, tx_err);
  454. }
  455. static inline void qdf_nbuf_ref(qdf_nbuf_t buf)
  456. {
  457. __qdf_nbuf_ref(buf);
  458. }
  459. static inline int qdf_nbuf_shared(qdf_nbuf_t buf)
  460. {
  461. return __qdf_nbuf_shared(buf);
  462. }
  463. static inline qdf_nbuf_t qdf_nbuf_copy(qdf_nbuf_t buf)
  464. {
  465. return __qdf_nbuf_copy(buf);
  466. }
  467. static inline QDF_STATUS qdf_nbuf_cat(qdf_nbuf_t dst, qdf_nbuf_t src)
  468. {
  469. return __qdf_nbuf_cat(dst, src);
  470. }
  471. /**
  472. * @qdf_nbuf_copy_bits() - return the length of the copy bits for skb
  473. * @skb: SKB pointer
  474. * @offset: offset
  475. * @len: Length
  476. * @to: To
  477. *
  478. * Return: int32_t
  479. */
  480. static inline int32_t
  481. qdf_nbuf_copy_bits(qdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to)
  482. {
  483. return __qdf_nbuf_copy_bits(nbuf, offset, len, to);
  484. }
  485. /**
  486. * qdf_nbuf_clone() - clone the nbuf (copy is readonly)
  487. * @buf: nbuf to clone from
  488. *
  489. * Return: cloned buffer
  490. */
  491. static inline qdf_nbuf_t qdf_nbuf_clone(qdf_nbuf_t buf)
  492. {
  493. return __qdf_nbuf_clone(buf);
  494. }
  495. /* nbuf manipulation routines */
  496. /**
  497. * @qdf_nbuf_head() - return the address of an nbuf's buffer
  498. * @buf: netbuf
  499. *
  500. * Return: head address
  501. */
  502. static inline uint8_t *qdf_nbuf_head(qdf_nbuf_t buf)
  503. {
  504. return __qdf_nbuf_head(buf);
  505. }
  506. /**
  507. * qdf_nbuf_data() - Return the address of the start of data within an nbuf
  508. * @buf: Network buffer
  509. *
  510. * Return: Data address
  511. */
  512. static inline uint8_t *qdf_nbuf_data(qdf_nbuf_t buf)
  513. {
  514. return __qdf_nbuf_data(buf);
  515. }
  516. /**
  517. * qdf_nbuf_data_addr() - Return the address of skb->data
  518. * @buf: Network buffer
  519. *
  520. * Return: Data address
  521. */
  522. static inline uint8_t *qdf_nbuf_data_addr(qdf_nbuf_t buf)
  523. {
  524. return __qdf_nbuf_data_addr(buf);
  525. }
  526. /**
  527. * qdf_nbuf_headroom() - amount of headroom int the current nbuf
  528. * @buf: Network buffer
  529. *
  530. * Return: Amount of head room
  531. */
  532. static inline uint32_t qdf_nbuf_headroom(qdf_nbuf_t buf)
  533. {
  534. return __qdf_nbuf_headroom(buf);
  535. }
  536. /**
  537. * qdf_nbuf_tailroom() - amount of tail space available
  538. * @buf: Network buffer
  539. *
  540. * Return: amount of tail room
  541. */
  542. static inline uint32_t qdf_nbuf_tailroom(qdf_nbuf_t buf)
  543. {
  544. return __qdf_nbuf_tailroom(buf);
  545. }
  546. /**
  547. * qdf_nbuf_push_head() - push data in the front
  548. * @buf: Network buf instance
  549. * @size: Size to be pushed
  550. *
  551. * Return: New data pointer of this buf after data has been pushed,
  552. * or NULL if there is not enough room in this buf.
  553. */
  554. static inline uint8_t *qdf_nbuf_push_head(qdf_nbuf_t buf, qdf_size_t size)
  555. {
  556. return __qdf_nbuf_push_head(buf, size);
  557. }
  558. /**
  559. * qdf_nbuf_put_tail() - puts data in the end
  560. * @buf: Network buf instance
  561. * @size: Size to be pushed
  562. *
  563. * Return: Data pointer of this buf where new data has to be
  564. * put, or NULL if there is not enough room in this buf.
  565. */
  566. static inline uint8_t *qdf_nbuf_put_tail(qdf_nbuf_t buf, qdf_size_t size)
  567. {
  568. return __qdf_nbuf_put_tail(buf, size);
  569. }
  570. /**
  571. * qdf_nbuf_pull_head() - pull data out from the front
  572. * @buf: Network buf instance
  573. * @size: Size to be popped
  574. *
  575. * Return: New data pointer of this buf after data has been popped,
  576. * or NULL if there is not sufficient data to pull.
  577. */
  578. static inline uint8_t *qdf_nbuf_pull_head(qdf_nbuf_t buf, qdf_size_t size)
  579. {
  580. return __qdf_nbuf_pull_head(buf, size);
  581. }
  582. /**
  583. * qdf_nbuf_trim_tail() - trim data out from the end
  584. * @buf: Network buf instance
  585. * @size: Size to be popped
  586. *
  587. * Return: none
  588. */
  589. static inline void qdf_nbuf_trim_tail(qdf_nbuf_t buf, qdf_size_t size)
  590. {
  591. __qdf_nbuf_trim_tail(buf, size);
  592. }
  593. /**
  594. * qdf_nbuf_len() - get the length of the buf
  595. * @buf: Network buf instance
  596. *
  597. * Return: total length of this buf.
  598. */
  599. static inline qdf_size_t qdf_nbuf_len(qdf_nbuf_t buf)
  600. {
  601. return __qdf_nbuf_len(buf);
  602. }
  603. /**
  604. * qdf_nbuf_set_pktlen() - set the length of the buf
  605. * @buf: Network buf instance
  606. * @size: Size to be set
  607. *
  608. * Return: none
  609. */
  610. static inline void qdf_nbuf_set_pktlen(qdf_nbuf_t buf, uint32_t len)
  611. {
  612. __qdf_nbuf_set_pktlen(buf, len);
  613. }
  614. /**
  615. * qdf_nbuf_reserve() - trim data out from the end
  616. * @buf: Network buf instance
  617. * @size: Size to be popped
  618. *
  619. * Return: none
  620. */
  621. static inline void qdf_nbuf_reserve(qdf_nbuf_t buf, qdf_size_t size)
  622. {
  623. __qdf_nbuf_reserve(buf, size);
  624. }
  625. /**
  626. * qdf_nbuf_peek_header() - return the data pointer & length of the header
  627. * @buf: Network nbuf
  628. * @addr: Data pointer
  629. * @len: Length of the data
  630. *
  631. * Return: none
  632. */
  633. static inline void
  634. qdf_nbuf_peek_header(qdf_nbuf_t buf, uint8_t **addr, uint32_t *len)
  635. {
  636. __qdf_nbuf_peek_header(buf, addr, len);
  637. }
  638. /* nbuf queue routines */
  639. /**
  640. * qdf_nbuf_queue_init() - initialize buf queue
  641. * @head: Network buf queue head
  642. *
  643. * Return: none
  644. */
  645. static inline void qdf_nbuf_queue_init(qdf_nbuf_queue_t *head)
  646. {
  647. __qdf_nbuf_queue_init(head);
  648. }
  649. /**
  650. * qdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue
  651. * @head: Network buf queue head
  652. * @buf: Network buf
  653. *
  654. * Return: none
  655. */
  656. static inline void qdf_nbuf_queue_add(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  657. {
  658. __qdf_nbuf_queue_add(head, buf);
  659. }
  660. /**
  661. * qdf_nbuf_queue_insert_head() - insert nbuf at the head of queue
  662. * @head: Network buf queue head
  663. * @buf: Network buf
  664. *
  665. * Return: none
  666. */
  667. static inline void
  668. qdf_nbuf_queue_insert_head(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  669. {
  670. __qdf_nbuf_queue_insert_head(head, buf);
  671. }
  672. /**
  673. * qdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue
  674. * @head: Network buf queue head
  675. *
  676. * Return: The head buf in the buf queue.
  677. */
  678. static inline qdf_nbuf_t qdf_nbuf_queue_remove(qdf_nbuf_queue_t *head)
  679. {
  680. return __qdf_nbuf_queue_remove(head);
  681. }
  682. /**
  683. * qdf_nbuf_queue_len() - get the length of the queue
  684. * @head: Network buf queue head
  685. *
  686. * Return: length of the queue
  687. */
  688. static inline uint32_t qdf_nbuf_queue_len(qdf_nbuf_queue_t *head)
  689. {
  690. return __qdf_nbuf_queue_len(head);
  691. }
  692. /**
  693. * qdf_nbuf_queue_next() - get the next guy/packet of the given buffer
  694. * @buf: Network buffer
  695. *
  696. * Return: next buffer/packet
  697. */
  698. static inline qdf_nbuf_t qdf_nbuf_queue_next(qdf_nbuf_t buf)
  699. {
  700. return __qdf_nbuf_queue_next(buf);
  701. }
  702. /**
  703. * @qdf_nbuf_is_queue_empty() - check if the buf queue is empty
  704. * @nbq: Network buf queue handle
  705. *
  706. * Return: true if queue is empty
  707. * false if queue is not emty
  708. */
  709. static inline bool qdf_nbuf_is_queue_empty(qdf_nbuf_queue_t *nbq)
  710. {
  711. return __qdf_nbuf_is_queue_empty(nbq);
  712. }
  713. static inline qdf_nbuf_queue_t *
  714. qdf_nbuf_queue_append(qdf_nbuf_queue_t *dest, qdf_nbuf_queue_t *src)
  715. {
  716. return __qdf_nbuf_queue_append(dest, src);
  717. }
  718. static inline void
  719. qdf_nbuf_queue_free(qdf_nbuf_queue_t *head)
  720. {
  721. __qdf_nbuf_queue_free(head);
  722. }
  723. static inline qdf_nbuf_t
  724. qdf_nbuf_queue_first(qdf_nbuf_queue_t *head)
  725. {
  726. return __qdf_nbuf_queue_first(head);
  727. }
  728. /**
  729. * qdf_nbuf_next() - get the next packet in the linked list
  730. * @buf: Network buffer
  731. *
  732. * This function can be used when nbufs are directly linked into a list,
  733. * rather than using a separate network buffer queue object.
  734. *
  735. * Return: next network buffer in the linked list
  736. */
  737. static inline qdf_nbuf_t qdf_nbuf_next(qdf_nbuf_t buf)
  738. {
  739. return __qdf_nbuf_next(buf);
  740. }
  741. /**
  742. * qdf_nbuf_get_protocol() - return the protocol value of the skb
  743. * @skb: Pointer to network buffer
  744. *
  745. * Return: skb protocol
  746. */
  747. static inline uint16_t qdf_nbuf_get_protocol(struct sk_buff *skb)
  748. {
  749. return __qdf_nbuf_get_protocol(skb);
  750. }
  751. /**
  752. * qdf_nbuf_get_ip_summed() - return the ip checksum value of the skb
  753. * @skb: Pointer to network buffer
  754. *
  755. * Return: skb ip_summed
  756. */
  757. static inline uint8_t qdf_nbuf_get_ip_summed(struct sk_buff *skb)
  758. {
  759. return __qdf_nbuf_get_ip_summed(skb);
  760. }
  761. /**
  762. * qdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb
  763. * @skb: Pointer to network buffer
  764. * @ip_summed: ip checksum
  765. *
  766. * Return: none
  767. */
  768. static inline void qdf_nbuf_set_ip_summed(struct sk_buff *skb,
  769. uint8_t ip_summed)
  770. {
  771. __qdf_nbuf_set_ip_summed(skb, ip_summed);
  772. }
  773. /**
  774. * qdf_nbuf_set_next() - add a packet to a linked list
  775. * @this_buf: Predecessor buffer
  776. * @next_buf: Successor buffer
  777. *
  778. * This function can be used to directly link nbufs, rather than using
  779. * a separate network buffer queue object.
  780. *
  781. * Return: none
  782. */
  783. static inline void qdf_nbuf_set_next(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  784. {
  785. __qdf_nbuf_set_next(this_buf, next_buf);
  786. }
  787. /* nbuf extension routines */
  788. /**
  789. * qdf_nbuf_set_next_ext() - link extension of this packet contained in a new
  790. * nbuf
  791. * @this_buf: predecessor buffer
  792. * @next_buf: successor buffer
  793. *
  794. * This function is used to link up many nbufs containing a single logical
  795. * packet - not a collection of packets. Do not use for linking the first
  796. * extension to the head
  797. *
  798. * Return: none
  799. */
  800. static inline void
  801. qdf_nbuf_set_next_ext(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  802. {
  803. __qdf_nbuf_set_next_ext(this_buf, next_buf);
  804. }
  805. /**
  806. * qdf_nbuf_next_ext() - get the next packet extension in the linked list
  807. * @buf: Network buffer
  808. *
  809. * Return: Next network buffer in the linked list
  810. */
  811. static inline qdf_nbuf_t qdf_nbuf_next_ext(qdf_nbuf_t buf)
  812. {
  813. return __qdf_nbuf_next_ext(buf);
  814. }
  815. /**
  816. * qdf_nbuf_append_ext_list() - link list of packet extensions to the head
  817. * segment
  818. * @head_buf: Network buf holding head segment (single)
  819. * @ext_list: Network buf list holding linked extensions to the head
  820. * @ext_len: Total length of all buffers in the extension list
  821. *
  822. * This function is used to link up a list of packet extensions (seg1, 2,
  823. * ...) to the nbuf holding the head segment (seg0)
  824. *
  825. * Return: none
  826. */
  827. static inline void
  828. qdf_nbuf_append_ext_list(qdf_nbuf_t head_buf, qdf_nbuf_t ext_list,
  829. qdf_size_t ext_len)
  830. {
  831. __qdf_nbuf_append_ext_list(head_buf, ext_list, ext_len);
  832. }
  833. /**
  834. * qdf_nbuf_get_ext_list() - Get the link to extended nbuf list.
  835. * @head_buf: Network buf holding head segment (single)
  836. *
  837. * This ext_list is populated when we have Jumbo packet, for example in case of
  838. * monitor mode amsdu packet reception, and are stiched using frags_list.
  839. *
  840. * Return: Network buf list holding linked extensions from head buf.
  841. */
  842. static inline qdf_nbuf_t qdf_nbuf_get_ext_list(qdf_nbuf_t head_buf)
  843. {
  844. return (qdf_nbuf_t)__qdf_nbuf_get_ext_list(head_buf);
  845. }
  846. /**
  847. * qdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand
  848. * @buf: Network buffer
  849. *
  850. * Return: qdf_nbuf_tx_cksum_t checksum offload demand for the frame
  851. */
  852. static inline qdf_nbuf_tx_cksum_t qdf_nbuf_get_tx_cksum(qdf_nbuf_t buf)
  853. {
  854. return __qdf_nbuf_get_tx_cksum(buf);
  855. }
  856. /**
  857. * qdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to
  858. * indicate checksum info to the stack.
  859. * @buf: Network buffer
  860. * @cksum: Checksum
  861. *
  862. * Return: none
  863. */
  864. static inline void
  865. qdf_nbuf_set_rx_cksum(qdf_nbuf_t buf, qdf_nbuf_rx_cksum_t *cksum)
  866. {
  867. __qdf_nbuf_set_rx_cksum(buf, cksum);
  868. }
  869. /**
  870. * qdf_nbuf_get_tid() - this function extracts the TID value from nbuf
  871. * @buf: Network buffer
  872. *
  873. * Return: TID value
  874. */
  875. static inline uint8_t qdf_nbuf_get_tid(qdf_nbuf_t buf)
  876. {
  877. return __qdf_nbuf_get_tid(buf);
  878. }
  879. /**
  880. * qdf_nbuf_set_tid() - this function sets the TID value in nbuf
  881. * @buf: Network buffer
  882. * @tid: TID value
  883. *
  884. * Return: none
  885. */
  886. static inline void qdf_nbuf_set_tid(qdf_nbuf_t buf, uint8_t tid)
  887. {
  888. __qdf_nbuf_set_tid(buf, tid);
  889. }
  890. /**
  891. * qdf_nbuf_get_exemption_type() - this function extracts the exemption type
  892. * from nbuf
  893. * @buf: Network buffer
  894. *
  895. * Return: Exemption type
  896. */
  897. static inline uint8_t qdf_nbuf_get_exemption_type(qdf_nbuf_t buf)
  898. {
  899. return __qdf_nbuf_get_exemption_type(buf);
  900. }
  901. /**
  902. * qdf_nbuf_set_protocol() - this function peeks data into the buffer at given
  903. * offset
  904. * @buf: Network buffer
  905. * @proto: Protocol
  906. *
  907. * Return: none
  908. */
  909. static inline void qdf_nbuf_set_protocol(qdf_nbuf_t buf, uint16_t proto)
  910. {
  911. __qdf_nbuf_set_protocol(buf, proto);
  912. }
  913. /**
  914. * qdf_nbuf_trace_get_proto_type() - this function return packet proto type
  915. * @buf: Network buffer
  916. *
  917. * Return: Packet protocol type
  918. */
  919. static inline uint8_t qdf_nbuf_trace_get_proto_type(qdf_nbuf_t buf)
  920. {
  921. return __qdf_nbuf_trace_get_proto_type(buf);
  922. }
  923. /**
  924. * qdf_nbuf_reg_trace_cb() - this function registers protocol trace callback
  925. * @cb_func_ptr: Callback pointer
  926. *
  927. * Return: none
  928. */
  929. static inline void qdf_nbuf_reg_trace_cb(qdf_nbuf_trace_update_t cb_func_ptr)
  930. {
  931. __qdf_nbuf_reg_trace_cb(cb_func_ptr);
  932. }
  933. /**
  934. * qdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download
  935. * @buf: Network buffer
  936. * @candi: Candidate of parallel download frame
  937. *
  938. * This function stores a flag specifying this TX frame is suitable for
  939. * downloading though a 2nd TX data pipe that is used for short frames for
  940. * protocols that can accept out-of-order delivery.
  941. *
  942. * Return: none
  943. */
  944. static inline void
  945. qdf_nbuf_set_tx_parallel_dnload_frm(qdf_nbuf_t buf, uint8_t candi)
  946. {
  947. __qdf_nbuf_set_tx_htt2_frm(buf, candi);
  948. }
  949. /**
  950. * qdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download
  951. * @buf: Network buffer
  952. *
  953. * This function return whether this TX frame is allow to download though a 2nd
  954. * TX data pipe or not.
  955. *
  956. * Return: none
  957. */
  958. static inline uint8_t qdf_nbuf_get_tx_parallel_dnload_frm(qdf_nbuf_t buf)
  959. {
  960. return __qdf_nbuf_get_tx_htt2_frm(buf);
  961. }
  962. /**
  963. * qdf_nbuf_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  964. * @buf: buffer
  965. *
  966. * This api is for Tx packets.
  967. *
  968. * Return: true if packet is ipv4 packet
  969. */
  970. static inline
  971. bool qdf_nbuf_is_ipv4_pkt(qdf_nbuf_t buf)
  972. {
  973. return __qdf_nbuf_is_ipv4_pkt(buf);
  974. }
  975. /**
  976. * qdf_nbuf_is_ipv4_dhcp_pkt() - check if packet is a dhcp packet or not
  977. * @buf: buffer
  978. *
  979. * This api is for ipv4 packet.
  980. *
  981. * Return: true if packet is DHCP packet
  982. */
  983. static inline
  984. bool qdf_nbuf_is_ipv4_dhcp_pkt(qdf_nbuf_t buf)
  985. {
  986. return __qdf_nbuf_is_ipv4_dhcp_pkt(buf);
  987. }
  988. /**
  989. * qdf_nbuf_is_ipv4_eapol_pkt() - check if packet is a eapol packet or not
  990. * @buf: buffer
  991. *
  992. * This api is for ipv4 packet.
  993. *
  994. * Return: true if packet is EAPOL packet
  995. */
  996. static inline
  997. bool qdf_nbuf_is_ipv4_eapol_pkt(qdf_nbuf_t buf)
  998. {
  999. return __qdf_nbuf_is_ipv4_eapol_pkt(buf);
  1000. }
  1001. /**
  1002. * qdf_nbuf_is_ipv4_arp_pkt() - check if packet is a arp packet or not
  1003. * @buf: buffer
  1004. *
  1005. * This api is for ipv4 packet.
  1006. *
  1007. * Return: true if packet is ARP packet
  1008. */
  1009. static inline
  1010. bool qdf_nbuf_is_ipv4_arp_pkt(qdf_nbuf_t buf)
  1011. {
  1012. return __qdf_nbuf_is_ipv4_arp_pkt(buf);
  1013. }
  1014. /**
  1015. * qdf_invalidate_range() - invalidate virtual address range
  1016. * @start: start address of the address range
  1017. * @end: end address of the address range
  1018. *
  1019. * Note that this function does not write back the cache entries.
  1020. *
  1021. * Return: none
  1022. */
  1023. static inline void qdf_invalidate_range(void *start, void *end)
  1024. {
  1025. __qdf_invalidate_range(start, end);
  1026. }
  1027. /**
  1028. * qdf_nbuf_reset_num_frags() - decrement the number of fragments
  1029. * @buf: Network buffer
  1030. *
  1031. * Return: Number of fragments
  1032. */
  1033. static inline void qdf_nbuf_reset_num_frags(qdf_nbuf_t buf)
  1034. {
  1035. __qdf_nbuf_reset_num_frags(buf);
  1036. }
  1037. /**
  1038. * qdf_dmaaddr_to_32s - return high and low parts of dma_addr
  1039. *
  1040. * Returns the high and low 32-bits of the DMA addr in the provided ptrs
  1041. *
  1042. * Return: N/A
  1043. */
  1044. static inline void qdf_dmaaddr_to_32s(qdf_dma_addr_t dmaaddr,
  1045. uint32_t *lo, uint32_t *hi)
  1046. {
  1047. return __qdf_dmaaddr_to_32s(dmaaddr, lo, hi);
  1048. }
  1049. /**
  1050. * qdf_nbuf_is_tso() - is the network buffer a jumbo packet?
  1051. * @buf: Network buffer
  1052. *
  1053. * Return: 1 - this is a jumbo packet 0 - not a jumbo packet
  1054. */
  1055. static inline uint8_t qdf_nbuf_is_tso(qdf_nbuf_t nbuf)
  1056. {
  1057. return __qdf_nbuf_is_tso(nbuf);
  1058. }
  1059. /**
  1060. * qdf_nbuf_get_tso_info() - function to divide a jumbo TSO
  1061. * network buffer into segments
  1062. * @nbuf: network buffer to be segmented
  1063. * @tso_info: This is the output. The information about the
  1064. * TSO segments will be populated within this.
  1065. *
  1066. * This function fragments a TCP jumbo packet into smaller
  1067. * segments to be transmitted by the driver. It chains the TSO
  1068. * segments created into a list.
  1069. *
  1070. * Return: number of TSO segments
  1071. */
  1072. static inline uint32_t qdf_nbuf_get_tso_info(qdf_device_t osdev,
  1073. qdf_nbuf_t nbuf, struct qdf_tso_info_t *tso_info)
  1074. {
  1075. return __qdf_nbuf_get_tso_info(osdev, nbuf, tso_info);
  1076. }
  1077. /**
  1078. * qdf_nbuf_get_tso_num_seg() - function to calculate the number
  1079. * of TCP segments within the TSO jumbo packet
  1080. * @nbuf: TSO jumbo network buffer to be segmented
  1081. *
  1082. * This function calculates the number of TCP segments that the
  1083. network buffer can be divided into.
  1084. *
  1085. * Return: number of TCP segments
  1086. */
  1087. static inline uint32_t qdf_nbuf_get_tso_num_seg(qdf_nbuf_t nbuf)
  1088. {
  1089. return __qdf_nbuf_get_tso_num_seg(nbuf);
  1090. }
  1091. /**
  1092. * qdf_nbuf_inc_users() - function to increment the number of
  1093. * users referencing this network buffer
  1094. *
  1095. * @nbuf: network buffer
  1096. *
  1097. * This function increments the number of users referencing this
  1098. * network buffer
  1099. *
  1100. * Return: the network buffer
  1101. */
  1102. static inline qdf_nbuf_t qdf_nbuf_inc_users(qdf_nbuf_t nbuf)
  1103. {
  1104. return __qdf_nbuf_inc_users(nbuf);
  1105. }
  1106. /**
  1107. * qdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb
  1108. *
  1109. * @nbuf: Network buffer (skb on linux)
  1110. *
  1111. * This function returns the values of data_attr field
  1112. * in struct cvg_nbuf_cb{}, to which skb->cb is typecast.
  1113. * This value is actually the value programmed in CE descriptor.
  1114. *
  1115. * Return: Value of data_attr
  1116. */
  1117. static inline uint32_t qdf_nbuf_data_attr_get(qdf_nbuf_t buf)
  1118. {
  1119. return __qdf_nbuf_data_attr_get(buf);
  1120. }
  1121. /**
  1122. * qdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb
  1123. *
  1124. * @nbuf: Network buffer (skb on linux)
  1125. * @data_attr: Value to be stored cvg_nbuf_cb->data_attr
  1126. *
  1127. * This function stores the value to be programmed in CE
  1128. * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{}
  1129. *
  1130. * Return: void
  1131. */
  1132. static inline
  1133. void qdf_nbuf_data_attr_set(qdf_nbuf_t buf, uint32_t data_attr)
  1134. {
  1135. __qdf_nbuf_data_attr_set(buf, data_attr);
  1136. }
  1137. /**
  1138. * qdf_nbuf_tx_info_get() - Parse skb and get Tx metadata
  1139. *
  1140. * @nbuf: Network buffer (skb on linux)
  1141. *
  1142. * This function parses the payload to figure out relevant
  1143. * Tx meta-data e.g. whether to enable tx_classify bit
  1144. * in CE.
  1145. *
  1146. * Return: void
  1147. */
  1148. #define qdf_nbuf_tx_info_get __qdf_nbuf_tx_info_get
  1149. void qdf_nbuf_set_state(qdf_nbuf_t nbuf, uint8_t current_state);
  1150. void qdf_nbuf_tx_desc_count_display(void);
  1151. void qdf_nbuf_tx_desc_count_clear(void);
  1152. static inline qdf_nbuf_t
  1153. qdf_nbuf_realloc_headroom(qdf_nbuf_t buf, uint32_t headroom)
  1154. {
  1155. return __qdf_nbuf_realloc_headroom(buf, headroom);
  1156. }
  1157. static inline qdf_nbuf_t
  1158. qdf_nbuf_realloc_tailroom(qdf_nbuf_t buf, uint32_t tailroom)
  1159. {
  1160. return __qdf_nbuf_realloc_tailroom(buf, tailroom);
  1161. }
  1162. static inline qdf_nbuf_t
  1163. qdf_nbuf_expand(qdf_nbuf_t buf, uint32_t headroom, uint32_t tailroom)
  1164. {
  1165. return __qdf_nbuf_expand(buf, headroom, tailroom);
  1166. }
  1167. static inline qdf_nbuf_t
  1168. qdf_nbuf_unshare(qdf_nbuf_t buf)
  1169. {
  1170. return __qdf_nbuf_unshare(buf);
  1171. }
  1172. static inline bool
  1173. qdf_nbuf_is_cloned(qdf_nbuf_t buf)
  1174. {
  1175. return __qdf_nbuf_is_cloned(buf);
  1176. }
  1177. static inline void
  1178. qdf_nbuf_frag_info(qdf_nbuf_t buf, qdf_sglist_t *sg)
  1179. {
  1180. __qdf_nbuf_frag_info(buf, sg);
  1181. }
  1182. static inline qdf_nbuf_tx_cksum_t
  1183. qdf_nbuf_tx_cksum_info(qdf_nbuf_t buf, uint8_t **hdr_off, uint8_t **where)
  1184. {
  1185. return __qdf_nbuf_tx_cksum_info(buf, hdr_off, where);
  1186. }
  1187. static inline void qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf)
  1188. {
  1189. __qdf_nbuf_reset_ctxt(nbuf);
  1190. }
  1191. static inline void
  1192. qdf_nbuf_set_rx_info(__qdf_nbuf_t nbuf, void *info, uint32_t len)
  1193. {
  1194. __qdf_nbuf_set_rx_info(nbuf, info, len);
  1195. }
  1196. static inline void *qdf_nbuf_get_rx_info(__qdf_nbuf_t nbuf)
  1197. {
  1198. return __qdf_nbuf_get_rx_info(nbuf);
  1199. }
  1200. static inline void qdf_nbuf_init(qdf_nbuf_t buf)
  1201. {
  1202. __qdf_nbuf_init(buf);
  1203. }
  1204. static inline void *qdf_nbuf_network_header(qdf_nbuf_t buf)
  1205. {
  1206. return __qdf_nbuf_network_header(buf);
  1207. }
  1208. static inline void *qdf_nbuf_transport_header(qdf_nbuf_t buf)
  1209. {
  1210. return __qdf_nbuf_transport_header(buf);
  1211. }
  1212. static inline qdf_size_t qdf_nbuf_tcp_tso_size(qdf_nbuf_t buf)
  1213. {
  1214. return __qdf_nbuf_tcp_tso_size(buf);
  1215. }
  1216. static inline void *qdf_nbuf_get_cb(qdf_nbuf_t nbuf)
  1217. {
  1218. return __qdf_nbuf_get_cb(nbuf);
  1219. }
  1220. static inline uint32_t qdf_nbuf_get_nr_frags(qdf_nbuf_t nbuf)
  1221. {
  1222. return __qdf_nbuf_get_nr_frags(nbuf);
  1223. }
  1224. static inline qdf_size_t qdf_nbuf_headlen(qdf_nbuf_t buf)
  1225. {
  1226. return __qdf_nbuf_headlen(buf);
  1227. }
  1228. static inline QDF_STATUS qdf_nbuf_frag_map(qdf_device_t osdev,
  1229. qdf_nbuf_t buf, int offset,
  1230. qdf_dma_dir_t dir, int cur_frag)
  1231. {
  1232. return __qdf_nbuf_frag_map(osdev, buf, offset, dir, cur_frag);
  1233. }
  1234. static inline bool qdf_nbuf_tso_tcp_v4(qdf_nbuf_t buf)
  1235. {
  1236. return __qdf_nbuf_tso_tcp_v4(buf);
  1237. }
  1238. static inline bool qdf_nbuf_tso_tcp_v6(qdf_nbuf_t buf)
  1239. {
  1240. return __qdf_nbuf_tso_tcp_v6(buf);
  1241. }
  1242. static inline uint32_t qdf_nbuf_tcp_seq(qdf_nbuf_t buf)
  1243. {
  1244. return __qdf_nbuf_tcp_seq(buf);
  1245. }
  1246. static inline qdf_size_t qdf_nbuf_l2l3l4_hdr_len(qdf_nbuf_t buf)
  1247. {
  1248. return __qdf_nbuf_l2l3l4_hdr_len(buf);
  1249. }
  1250. static inline bool qdf_nbuf_is_nonlinear(qdf_nbuf_t buf)
  1251. {
  1252. return __qdf_nbuf_is_nonlinear(buf);
  1253. }
  1254. static inline uint32_t
  1255. qdf_nbuf_get_frag_size(qdf_nbuf_t buf, uint32_t frag_num)
  1256. {
  1257. return __qdf_nbuf_get_frag_size(buf, frag_num);
  1258. }
  1259. static inline uint32_t qdf_nbuf_get_priority(qdf_nbuf_t buf)
  1260. {
  1261. return __qdf_nbuf_get_priority(buf);
  1262. }
  1263. static inline void qdf_nbuf_set_priority(qdf_nbuf_t buf, uint32_t p)
  1264. {
  1265. __qdf_nbuf_set_priority(buf, p);
  1266. }
  1267. static inline uint8_t *
  1268. qdf_nbuf_get_priv_ptr(qdf_nbuf_t buf)
  1269. {
  1270. return __qdf_nbuf_get_priv_ptr(buf);
  1271. }
  1272. /**
  1273. * qdf_nbuf_update_radiotap() - update radiotap at head of nbuf.
  1274. * @rx_status: rx_status containing required info to update radiotap
  1275. * @nbuf: Pointer to nbuf
  1276. * @headroom_sz: Available headroom size
  1277. *
  1278. * Return: radiotap length.
  1279. */
  1280. unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status,
  1281. qdf_nbuf_t nbuf, uint32_t headroom_sz);
  1282. #endif /* _QDF_NBUF_H */