1 /* 2 * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: qdf_nbuf_public network buffer API 21 * This file defines the network buffer abstraction. 22 */ 23 24 #ifndef _QDF_NBUF_H 25 #define _QDF_NBUF_H 26 27 #include <qdf_util.h> 28 #include <qdf_types.h> 29 #include <qdf_lock.h> 30 #include <i_qdf_trace.h> 31 #include <i_qdf_nbuf.h> 32 #include <qdf_net_types.h> 33 34 #define IPA_NBUF_OWNER_ID 0xaa55aa55 35 #define QDF_NBUF_PKT_TRAC_TYPE_DNS 0x01 36 #define QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02 37 #define QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04 38 #define QDF_NBUF_PKT_TRAC_TYPE_MGMT_ACTION 0x08 39 #define QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10 40 #define QDF_NBUF_PKT_TRAC_TYPE_ICMP 0x20 41 #define QDF_NBUF_PKT_TRAC_TYPE_ICMPv6 0x40 42 #define QDF_HL_CREDIT_TRACKING 0x80 43 44 #define QDF_NBUF_PKT_TRAC_MAX_STRING 12 45 #define QDF_NBUF_PKT_TRAC_PROTO_STRING 4 46 #define QDF_NBUF_PKT_ERROR 1 47 48 #define QDF_NBUF_TRAC_IPV4_OFFSET 14 49 #define QDF_NBUF_TRAC_IPV4_HEADER_MASK 0xF 50 #define QDF_NBUF_TRAC_IPV4_HEADER_SIZE 20 51 #define QDF_NBUF_TRAC_DHCP_SRV_PORT 67 52 #define QDF_NBUF_TRAC_DHCP_CLI_PORT 68 53 #define QDF_NBUF_TRAC_ETH_TYPE_OFFSET 12 54 #define QDF_NBUF_TRAC_VLAN_ETH_TYPE_OFFSET 16 55 #define QDF_NBUF_TRAC_DOUBLE_VLAN_ETH_TYPE_OFFSET 20 56 #define QDF_NBUF_TRAC_EAPOL_ETH_TYPE 0x888E 57 #define QDF_NBUF_TRAC_WAPI_ETH_TYPE 0x88b4 58 #define QDF_NBUF_TRAC_ARP_ETH_TYPE 0x0806 59 #define QDF_NBUF_PKT_IPV4_DSCP_MASK 0xFC 60 #define QDF_NBUF_PKT_IPV4_DSCP_SHIFT 0x02 61 #define QDF_NBUF_TRAC_TDLS_ETH_TYPE 0x890D 62 #define QDF_NBUF_TRAC_IPV4_ETH_TYPE 0x0800 63 #define QDF_NBUF_TRAC_IPV6_ETH_TYPE 0x86dd 64 #define QDF_NBUF_DEST_MAC_OFFSET 0 65 #define QDF_NBUF_SRC_MAC_OFFSET 6 66 #define QDF_NBUF_TRAC_IPV4_PROTO_TYPE_OFFSET 23 67 #define QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET 30 68 #define QDF_NBUF_TRAC_IPV4_SRC_ADDR_OFFSET 26 69 #define QDF_NBUF_TRAC_IPV6_PROTO_TYPE_OFFSET 20 70 #define QDF_NBUF_TRAC_IPV4_ADDR_MCAST_MASK 0xE0000000 71 #define QDF_NBUF_TRAC_IPV4_ADDR_BCAST_MASK 0xF0000000 72 #define QDF_NBUF_TRAC_IPV6_DEST_ADDR_OFFSET 38 73 #define QDF_NBUF_TRAC_IPV6_DEST_ADDR 0xFF00 74 #define QDF_NBUF_TRAC_IPV6_OFFSET 14 75 #define QDF_NBUF_TRAC_IPV6_HEADER_SIZE 40 76 #define QDF_NBUF_TRAC_ICMP_TYPE 1 77 #define QDF_NBUF_TRAC_TCP_TYPE 6 78 #define QDF_NBUF_TRAC_TCP_FLAGS_OFFSET (47 - 34) 79 #define QDF_NBUF_TRAC_TCP_ACK_OFFSET (42 - 34) 80 #define QDF_NBUF_TRAC_TCP_HEADER_LEN_OFFSET (46 - 34) 81 #define QDF_NBUF_TRAC_TCP_ACK_MASK 0x10 82 #define QDF_NBUF_TRAC_TCP_SPORT_OFFSET (34 - 34) 83 #define QDF_NBUF_TRAC_TCP_DPORT_OFFSET (36 - 34) 84 #define QDF_NBUF_TRAC_UDP_TYPE 17 85 #define QDF_NBUF_TRAC_ICMPV6_TYPE 0x3a 86 #define QDF_NBUF_TRAC_DHCP6_SRV_PORT 547 87 #define QDF_NBUF_TRAC_DHCP6_CLI_PORT 546 88 #define QDF_NBUF_TRAC_MDNS_SRC_N_DST_PORT 5353 89 #define QDF_NBUF_TRAC_IP_OFFSET 14 90 #define QDF_NBUF_TRAC_VLAN_IP_OFFSET 18 91 #define QDF_NBUF_TRAC_DOUBLE_VLAN_IP_OFFSET 22 92 /* One dword for IPv4 header size unit */ 93 #define QDF_NBUF_IPV4_HDR_SIZE_UNIT 4 94 95 /* EAPOL Related MASK */ 96 #define EAPOL_PACKET_TYPE_OFFSET 15 97 #define EAPOL_KEY_INFO_OFFSET 19 98 #define EAPOL_PKT_LEN_OFFSET 16 99 #define EAPOL_KEY_LEN_OFFSET 21 100 #define EAPOL_MASK 0x8013 101 #define EAPOL_M1_BIT_MASK 0x8000 102 #define EAPOL_M2_BIT_MASK 0x0001 103 #define EAPOL_M3_BIT_MASK 0x8013 104 #define EAPOL_M4_BIT_MASK 0x0003 105 106 /* ARP Related MASK */ 107 #define QDF_NBUF_PKT_ARP_OPCODE_OFFSET 20 108 #define QDF_NBUF_PKT_ARPOP_REQ 1 109 #define QDF_NBUF_PKT_ARPOP_REPLY 2 110 #define QDF_NBUF_PKT_ARP_SRC_IP_OFFSET 28 111 #define QDF_NBUF_PKT_ARP_TGT_IP_OFFSET 38 112 113 /* ICMPv4 Related MASK */ 114 #define QDF_NBUF_PKT_ICMPv4_OPCODE_OFFSET 34 115 #define QDF_NBUF_PKT_ICMPv4OP_REQ 0x08 116 #define QDF_NBUF_PKT_ICMPv4OP_REPLY 0x00 117 #define QDF_NBUF_PKT_ICMPv4_SRC_IP_OFFSET 26 118 #define QDF_NBUF_PKT_ICMPv4_TGT_IP_OFFSET 30 119 120 /* TCP Related MASK */ 121 #define QDF_NBUF_PKT_TCP_OPCODE_OFFSET 47 122 #define QDF_NBUF_PKT_TCPOP_SYN 0x02 123 #define QDF_NBUF_PKT_TCPOP_SYN_ACK 0x12 124 #define QDF_NBUF_PKT_TCPOP_ACK 0x10 125 #define QDF_NBUF_PKT_TCP_SRC_PORT_OFFSET 34 126 #define QDF_NBUF_PKT_TCP_DST_PORT_OFFSET 36 127 128 /* DNS Related MASK */ 129 #define QDF_NBUF_PKT_DNS_OVER_UDP_OPCODE_OFFSET 44 130 #define QDF_NBUF_PKT_DNSOP_BITMAP 0xF800 131 #define QDF_NBUF_PKT_DNSOP_STANDARD_QUERY 0x0000 132 #define QDF_NBUF_PKT_DNSOP_STANDARD_RESPONSE 0x8000 133 #define QDF_NBUF_PKT_DNS_SRC_PORT_OFFSET 34 134 #define QDF_NBUF_PKT_DNS_DST_PORT_OFFSET 36 135 #define QDF_NBUF_PKT_DNS_NAME_OVER_UDP_OFFSET 54 136 #define QDF_NBUF_PKT_DNS_STANDARD_PORT 53 137 138 /* Tracked Packet types */ 139 #define QDF_NBUF_TX_PKT_INVALID 0 140 #define QDF_NBUF_TX_PKT_DATA_TRACK 1 141 #define QDF_NBUF_TX_PKT_MGMT_TRACK 2 142 #define QDF_NBUF_RX_PKT_DATA_TRACK 3 143 144 /* Different Packet states */ 145 #define QDF_NBUF_TX_PKT_HDD 1 146 #define QDF_NBUF_TX_PKT_TXRX_ENQUEUE 2 147 #define QDF_NBUF_TX_PKT_TXRX_DEQUEUE 3 148 #define QDF_NBUF_TX_PKT_TXRX 4 149 #define QDF_NBUF_TX_PKT_HTT 5 150 #define QDF_NBUF_TX_PKT_HTC 6 151 #define QDF_NBUF_TX_PKT_HIF 7 152 #define QDF_NBUF_TX_PKT_CE 8 153 #define QDF_NBUF_TX_PKT_FREE 9 154 #define QDF_NBUF_TX_PKT_STATE_MAX 10 155 #define QDF_NBUF_TX_PKT_LI_DP 11 156 157 /* nbuf allocations only come from one domain */ 158 #define QDF_DEBUG_NBUF_DOMAIN 0 159 160 /* qdf_nbuf allocate and map max retry threshold when failed */ 161 #define QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD 20 162 163 /* Enable flag to print TSO specific prints in datapath */ 164 #ifdef TSO_DEBUG_LOG_ENABLE 165 #define TSO_DEBUG(fmt, args ...) \ 166 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_NONE, \ 167 fmt, ## args) 168 #else 169 #define TSO_DEBUG(fmt, args ...) 170 #endif 171 172 #define IEEE80211_AMPDU_FLAG 0x01 173 174 #ifdef GET_MSDU_AGGREGATION 175 #define IEEE80211_AMSDU_FLAG 0x02 176 #endif 177 178 #define MAX_CHAIN 8 179 #define QDF_MON_STATUS_MPDU_FCS_BMAP_NWORDS 8 180 181 /** 182 * struct mon_rx_status - This will have monitor mode rx_status extracted from 183 * htt_rx_desc used later to update radiotap information. 184 * @tsft: Time Synchronization Function timer 185 * @ppdu_timestamp: Timestamp in the PPDU_START TLV 186 * @preamble_type: Preamble type in radio header 187 * @chan_freq: Capture channel frequency 188 * @chan_num: Capture channel number 189 * @chan_flags: Bitmap of Channel flags, IEEE80211_CHAN_TURBO, 190 * IEEE80211_CHAN_CCK... 191 * @ht_flags: HT flags, only present for HT frames. 192 * @vht_flags: VHT flags, only present for VHT frames. 193 * @vht_flag_values1-5: Contains corresponding data for flags field 194 * @he_flags: HE (11ax) flags, only present in HE frames 195 * @he_mu_flags: HE-MU (11ax) flags, only present in HE frames 196 * @he_mu_other_flags: HE-MU-OTHER (11ax) flags, only present in HE frames 197 * @he_sig_A1_known: HE (11ax) sig A1 known field 198 * @he_sig_A2_known: HE (11ax) sig A2 known field 199 * @he_sig_b_common: HE (11ax) sig B common field 200 * @he_sig_b_common_known: HE (11ax) sig B common known field 201 * @l_sig_a_info: L_SIG_A value coming in Rx descriptor 202 * @l_sig_b_info: L_SIG_B value coming in Rx descriptor 203 * @rate: Rate in terms 500Kbps 204 * @rtap_flags: Bit map of available fields in the radiotap 205 * @ant_signal_db: Rx packet RSSI 206 * @nr_ant: Number of Antennas used for streaming 207 * @mcs: MCS index of Rx frame 208 * @ht_mcs: MCS index for HT RX frames 209 * @nss: Number of spatial streams 210 * @bw: bandwidth of rx frame 211 * @is_stbc: Is STBC enabled 212 * @sgi: Rx frame short guard interval 213 * @he_re: HE range extension 214 * @ldpc: ldpc enabled 215 * @beamformed: Is frame beamformed. 216 * @he_sig_b_common_RU[4]: HE (11ax) common RU assignment index 217 * @rssi_comb: Combined RSSI 218 * @rssi[MAX_CHAIN]: 8 bits RSSI per 20Mhz per chain 219 * @duration: 802.11 Duration 220 * @frame_control_info_valid: field indicates if fc value is valid 221 * @frame_control: frame control field 222 * @ast_index: AST table hash index 223 * @tid: QoS traffic tid number 224 * @rs_fcs_err: FCS error flag 225 * @rs_flags: Flags to indicate AMPDU or AMSDU aggregation 226 * @cck_flag: Flag to indicate CCK modulation 227 * @ofdm_flag: Flag to indicate OFDM modulation 228 * @ulofdma_flag: Flag to indicate UL OFDMA PPDU 229 * @he_per_user_1: HE per user info1 230 * @he_per_user_2: HE per user info2 231 * @he_per_user_position: HE per user position info 232 * @he_per_user_known: HE per user known info 233 * @he_flags1: HE flags 234 * @he_flags2: HE flags 235 * @he_RU[4]: HE RU assignment index 236 * @he_data1: HE property of received frame 237 * @he_data2: HE property of received frame 238 * @he_data3: HE property of received frame 239 * @he_data4: HE property of received frame 240 * @he_data5: HE property of received frame 241 * @prev_ppdu_id: ppdu_id in previously received message 242 * @ppdu_id: Id of the PLCP protocol data unit 243 * 244 * The following variables are not coming from the TLVs. 245 * These variables are placeholders for passing information to update_radiotap 246 * function. 247 * @device_id: Device ID coming from sub-system (PCI, AHB etc..) 248 * @chan_noise_floor: Channel Noise Floor for the pdev 249 * @data_sequence_control_info_valid: field to indicate validity of seq control 250 * @first_data_seq_ctrl: Sequence ctrl field of first data frame 251 * @rxpcu_filter_pass: Flag which indicates whether RX packets are received in 252 * BSS mode(not in promisc mode) 253 * @rssi_chain: Rssi chain per nss per bw 254 * @tx_status: packet tx status 255 * @tx_retry_cnt: tx retry count 256 * @add_rtap_ext: add radio tap extension 257 */ 258 struct mon_rx_status { 259 uint64_t tsft; 260 uint32_t ppdu_timestamp; 261 uint32_t preamble_type; 262 qdf_freq_t chan_freq; 263 uint16_t chan_num; 264 uint16_t chan_flags; 265 uint16_t ht_flags; 266 uint16_t vht_flags; 267 uint16_t vht_flag_values6; 268 uint16_t he_flags; 269 uint16_t he_mu_flags; 270 uint16_t he_mu_other_flags; 271 uint16_t he_sig_A1_known; 272 uint16_t he_sig_A2_known; 273 uint16_t he_sig_b_common; 274 uint16_t he_sig_b_common_known; 275 uint32_t l_sig_a_info; 276 uint32_t l_sig_b_info; 277 uint8_t rate; 278 uint8_t rtap_flags; 279 uint8_t ant_signal_db; 280 uint8_t nr_ant; 281 uint8_t mcs; 282 uint8_t ht_mcs; 283 uint8_t nss; 284 uint16_t tcp_msdu_count; 285 uint16_t udp_msdu_count; 286 uint16_t other_msdu_count; 287 uint8_t bw; 288 uint8_t vht_flag_values1; 289 uint8_t vht_flag_values2; 290 uint8_t vht_flag_values3[4]; 291 uint8_t vht_flag_values4; 292 uint8_t vht_flag_values5; 293 uint8_t is_stbc; 294 uint8_t sgi; 295 uint8_t he_re; 296 uint8_t ldpc; 297 uint8_t beamformed; 298 uint8_t he_sig_b_common_RU[4]; 299 int8_t rssi_comb; 300 uint64_t rssi[MAX_CHAIN]; 301 uint8_t reception_type; 302 uint16_t duration; 303 uint8_t frame_control_info_valid; 304 uint16_t frame_control; 305 uint32_t ast_index; 306 uint32_t tid; 307 uint8_t rs_fcs_err; 308 uint8_t rs_flags; 309 uint8_t cck_flag; 310 uint8_t ofdm_flag; 311 uint8_t ulofdma_flag; 312 /* New HE radiotap fields */ 313 uint16_t he_per_user_1; 314 uint16_t he_per_user_2; 315 uint8_t he_per_user_position; 316 uint8_t he_per_user_known; 317 uint16_t he_flags1; 318 uint16_t he_flags2; 319 uint8_t he_RU[4]; 320 uint16_t he_data1; 321 uint16_t he_data2; 322 uint16_t he_data3; 323 uint16_t he_data4; 324 uint16_t he_data5; 325 uint16_t he_data6; 326 uint32_t ppdu_len; 327 uint32_t prev_ppdu_id; 328 uint32_t ppdu_id; 329 uint32_t device_id; 330 int16_t chan_noise_floor; 331 uint8_t monitor_direct_used; 332 uint8_t data_sequence_control_info_valid; 333 uint16_t first_data_seq_ctrl; 334 uint8_t ltf_size; 335 uint8_t rxpcu_filter_pass; 336 int8_t rssi_chain[8][8]; 337 uint32_t rx_antenna; 338 uint8_t tx_status; 339 uint8_t tx_retry_cnt; 340 bool add_rtap_ext; 341 }; 342 343 /** 344 * struct mon_rx_user_status - This will have monitor mode per user rx_status 345 * extracted from hardware TLV. 346 * @mcs: MCS index of Rx frame 347 * @nss: Number of spatial streams 348 * @mu_ul_info_valid: MU UL info below is valid 349 * @ofdma_ru_start_index: OFDMA RU start index 350 * @ofdma_ru_width: OFDMA total RU width 351 * @ofdma_ru_size: OFDMA RU size index 352 * @mu_ul_user_v0_word0: MU UL user info word 0 353 * @mu_ul_user_v0_word1: MU UL user info word 1 354 * @ast_index: AST table hash index 355 * @tid: QoS traffic tid number 356 * @tcp_msdu_count: tcp protocol msdu count 357 * @udp_msdu_count: udp protocol msdu count 358 * @other_msdu_count: other protocol msdu count 359 * @frame_control: frame control field 360 * @frame_control_info_valid: field indicates if fc value is valid 361 * @data_sequence_control_info_valid: field to indicate validity of seq control 362 * @first_data_seq_ctrl: Sequence ctrl field of first data frame 363 * @preamble_type: Preamble type in radio header 364 * @ht_flags: HT flags, only present for HT frames. 365 * @vht_flags: VHT flags, only present for VHT frames. 366 * @he_flags: HE (11ax) flags, only present in HE frames 367 * @rtap_flags: Bit map of available fields in the radiotap 368 * @rs_flags: Flags to indicate AMPDU or AMSDU aggregation 369 * @mpdu_cnt_fcs_ok: mpdu count received with fcs ok 370 * @mpdu_cnt_fcs_err: mpdu count received with fcs ok bitmap 371 * @mpdu_fcs_ok_bitmap: mpdu with fcs ok bitmap 372 * @mpdu_ok_byte_count: mpdu byte count with fcs ok 373 * @mpdu_err_byte_count: mpdu byte count with fcs err 374 */ 375 struct mon_rx_user_status { 376 uint32_t mcs:4, 377 nss:3, 378 mu_ul_info_valid:1, 379 ofdma_ru_start_index:7, 380 ofdma_ru_width:7, 381 ofdma_ru_size:8; 382 uint32_t mu_ul_user_v0_word0; 383 uint32_t mu_ul_user_v0_word1; 384 uint32_t ast_index; 385 uint32_t tid; 386 uint16_t tcp_msdu_count; 387 uint16_t udp_msdu_count; 388 uint16_t other_msdu_count; 389 uint16_t frame_control; 390 uint8_t frame_control_info_valid; 391 uint8_t data_sequence_control_info_valid; 392 uint16_t first_data_seq_ctrl; 393 uint32_t preamble_type; 394 uint16_t ht_flags; 395 uint16_t vht_flags; 396 uint16_t he_flags; 397 uint8_t rtap_flags; 398 uint8_t rs_flags; 399 uint32_t mpdu_cnt_fcs_ok; 400 uint32_t mpdu_cnt_fcs_err; 401 uint32_t mpdu_fcs_ok_bitmap[QDF_MON_STATUS_MPDU_FCS_BMAP_NWORDS]; 402 uint32_t mpdu_ok_byte_count; 403 uint32_t mpdu_err_byte_count; 404 }; 405 406 /** 407 * struct qdf_radiotap_vendor_ns - Vendor Namespace header as per 408 * Radiotap spec: https://www.radiotap.org/fields/Vendor%20Namespace.html 409 * @oui: Vendor OUI 410 * @selector: sub_namespace selector 411 * @skip_length: How many bytes of Vendor Namespace data that follows 412 */ 413 struct qdf_radiotap_vendor_ns { 414 uint8_t oui[3]; 415 uint8_t selector; 416 uint16_t skip_length; 417 } __attribute__((__packed__)); 418 419 /** 420 * struct qdf_radiotap_vendor_ns_ath - Combined QTI Vendor NS 421 * including the Radiotap specified Vendor Namespace header and 422 * QTI specific Vendor Namespace data 423 * @lsig: L_SIG_A (or L_SIG) 424 * @device_id: Device Identification 425 * @lsig_b: L_SIG_B 426 * @ppdu_start_timestamp: Timestamp from RX_PPDU_START TLV 427 */ 428 struct qdf_radiotap_vendor_ns_ath { 429 struct qdf_radiotap_vendor_ns hdr; 430 /* QTI specific data follows */ 431 uint32_t lsig; 432 uint32_t device_id; 433 uint32_t lsig_b; 434 uint32_t ppdu_start_timestamp; 435 } __attribute__((__packed__)); 436 437 #define QDF_MEM_FUNC_NAME_SIZE 48 438 439 /* Masks for HE SIG known fields in mon_rx_status structure */ 440 #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU0 0x00000001 441 #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU1 0x00000002 442 #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU2 0x00000004 443 #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU3 0x00000008 444 #define QDF_MON_STATUS_HE_SIG_B_USER_KNOWN_SIG_B_ALL 0x00fe0000 445 #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_SU 0x00000000 446 #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_EXT_SU 0x40000000 447 #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_TRIG 0xc0000000 448 449 /* DHCP Related Mask */ 450 #define QDF_DHCP_OPTION53 (0x35) 451 #define QDF_DHCP_OPTION53_LENGTH (1) 452 #define QDF_DHCP_OPTION53_OFFSET (0x11A) 453 #define QDF_DHCP_OPTION53_LENGTH_OFFSET (0x11B) 454 #define QDF_DHCP_OPTION53_STATUS_OFFSET (0x11C) 455 #define DHCP_PKT_LEN_OFFSET 16 456 #define DHCP_TRANSACTION_ID_OFFSET 46 457 #define QDF_DHCP_DISCOVER (1) 458 #define QDF_DHCP_OFFER (2) 459 #define QDF_DHCP_REQUEST (3) 460 #define QDF_DHCP_DECLINE (4) 461 #define QDF_DHCP_ACK (5) 462 #define QDF_DHCP_NAK (6) 463 #define QDF_DHCP_RELEASE (7) 464 #define QDF_DHCP_INFORM (8) 465 466 /* ARP Related Mask */ 467 #define ARP_SUB_TYPE_OFFSET 20 468 #define ARP_REQUEST (1) 469 #define ARP_RESPONSE (2) 470 471 /* IPV4 header fields offset values */ 472 #define IPV4_PKT_LEN_OFFSET 16 473 #define IPV4_TCP_SEQ_NUM_OFFSET 38 474 #define IPV4_SRC_ADDR_OFFSET 26 475 #define IPV4_DST_ADDR_OFFSET 30 476 #define IPV4_SRC_PORT_OFFSET 34 477 #define IPV4_DST_PORT_OFFSET 36 478 479 /* IPV4 ICMP Related Mask */ 480 #define ICMP_SEQ_NUM_OFFSET 40 481 #define ICMP_SUBTYPE_OFFSET 34 482 #define ICMP_REQUEST 0x08 483 #define ICMP_RESPONSE 0x00 484 485 #define IPV6_ADDR_STR "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:"\ 486 "%02x%02x:%02x%02x" 487 488 /* IPV6 header fields offset values */ 489 #define IPV6_PKT_LEN_OFFSET 18 490 #define IPV6_TCP_SEQ_NUM_OFFSET 58 491 #define IPV6_SRC_ADDR_OFFSET 22 492 #define IPV6_DST_ADDR_OFFSET 38 493 #define IPV6_SRC_PORT_OFFSET 54 494 #define IPV6_DST_PORT_OFFSET 56 495 496 /* IPV6 ICMPV6 Related Mask */ 497 #define ICMPV6_SEQ_NUM_OFFSET 60 498 #define ICMPV6_SUBTYPE_OFFSET 54 499 #define ICMPV6_REQUEST 0x80 500 #define ICMPV6_RESPONSE 0x81 501 #define ICMPV6_RS 0x85 502 #define ICMPV6_RA 0x86 503 #define ICMPV6_NS 0x87 504 #define ICMPV6_NA 0x88 505 506 #define QDF_NBUF_IPA_CHECK_MASK 0x80000000 507 508 /* HE Radiotap data1 Mask */ 509 #define QDF_MON_STATUS_HE_SU_FORMAT_TYPE 0x0000 510 #define QDF_MON_STATUS_HE_EXT_SU_FORMAT_TYPE 0x0001 511 #define QDF_MON_STATUS_HE_MU_FORMAT_TYPE 0x0002 512 #define QDF_MON_STATUS_HE_TRIG_FORMAT_TYPE 0x0003 513 514 515 #define QDF_MON_STATUS_HE_BEAM_CHANGE_KNOWN 0x0008 516 #define QDF_MON_STATUS_HE_DL_UL_KNOWN 0x0010 517 #define QDF_MON_STATUS_HE_MCS_KNOWN 0x0020 518 #define QDF_MON_STATUS_HE_DCM_KNOWN 0x0040 519 #define QDF_MON_STATUS_HE_CODING_KNOWN 0x0080 520 #define QDF_MON_STATUS_HE_LDPC_EXTRA_SYMBOL_KNOWN 0x0100 521 #define QDF_MON_STATUS_HE_STBC_KNOWN 0x0200 522 #define QDF_MON_STATUS_HE_DATA_BW_RU_KNOWN 0x4000 523 #define QDF_MON_STATUS_HE_DOPPLER_KNOWN 0x8000 524 #define QDF_MON_STATUS_HE_BSS_COLOR_KNOWN 0x0004 525 526 /* HE Radiotap data2 Mask */ 527 #define QDF_MON_STATUS_HE_GI_KNOWN 0x0002 528 #define QDF_MON_STATUS_TXBF_KNOWN 0x0010 529 #define QDF_MON_STATUS_PE_DISAMBIGUITY_KNOWN 0x0020 530 #define QDF_MON_STATUS_TXOP_KNOWN 0x0040 531 #define QDF_MON_STATUS_LTF_SYMBOLS_KNOWN 0x0004 532 #define QDF_MON_STATUS_PRE_FEC_PADDING_KNOWN 0x0008 533 #define QDF_MON_STATUS_MIDABLE_PERIODICITY_KNOWN 0x0080 534 535 /* HE radiotap data3 shift values */ 536 #define QDF_MON_STATUS_BEAM_CHANGE_SHIFT 6 537 #define QDF_MON_STATUS_DL_UL_SHIFT 7 538 #define QDF_MON_STATUS_TRANSMIT_MCS_SHIFT 8 539 #define QDF_MON_STATUS_DCM_SHIFT 12 540 #define QDF_MON_STATUS_CODING_SHIFT 13 541 #define QDF_MON_STATUS_LDPC_EXTRA_SYMBOL_SHIFT 14 542 #define QDF_MON_STATUS_STBC_SHIFT 15 543 544 /* HE radiotap data4 shift values */ 545 #define QDF_MON_STATUS_STA_ID_SHIFT 4 546 547 /* HE radiotap data5 */ 548 #define QDF_MON_STATUS_GI_SHIFT 4 549 #define QDF_MON_STATUS_HE_LTF_SIZE_SHIFT 6 550 #define QDF_MON_STATUS_HE_LTF_SYM_SHIFT 8 551 #define QDF_MON_STATUS_TXBF_SHIFT 14 552 #define QDF_MON_STATUS_PE_DISAMBIGUITY_SHIFT 15 553 #define QDF_MON_STATUS_PRE_FEC_PAD_SHIFT 12 554 555 /* HE radiotap data6 */ 556 #define QDF_MON_STATUS_DOPPLER_SHIFT 4 557 #define QDF_MON_STATUS_TXOP_SHIFT 8 558 559 /* HE radiotap HE-MU flags1 */ 560 #define QDF_MON_STATUS_SIG_B_MCS_KNOWN 0x0010 561 #define QDF_MON_STATUS_SIG_B_DCM_KNOWN 0x0040 562 #define QDF_MON_STATUS_SIG_B_SYM_NUM_KNOWN 0x8000 563 #define QDF_MON_STATUS_RU_0_KNOWN 0x0100 564 #define QDF_MON_STATUS_RU_1_KNOWN 0x0200 565 #define QDF_MON_STATUS_RU_2_KNOWN 0x0400 566 #define QDF_MON_STATUS_RU_3_KNOWN 0x0800 567 #define QDF_MON_STATUS_DCM_FLAG_1_SHIFT 5 568 #define QDF_MON_STATUS_SPATIAL_REUSE_MU_KNOWN 0x0100 569 #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_1_KNOWN 0x4000 570 571 /* HE radiotap HE-MU flags2 */ 572 #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_SHIFT 3 573 #define QDF_MON_STATUS_BW_KNOWN 0x0004 574 #define QDF_MON_STATUS_NUM_SIG_B_SYMBOLS_SHIFT 4 575 #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_KNOWN 0x0100 576 #define QDF_MON_STATUS_NUM_SIG_B_FLAG_2_SHIFT 9 577 #define QDF_MON_STATUS_LTF_FLAG_2_SYMBOLS_SHIFT 12 578 #define QDF_MON_STATUS_LTF_KNOWN 0x8000 579 580 /* HE radiotap per_user_1 */ 581 #define QDF_MON_STATUS_STA_SPATIAL_SHIFT 11 582 #define QDF_MON_STATUS_TXBF_SHIFT 14 583 #define QDF_MON_STATUS_RESERVED_SET_TO_1_SHIFT 19 584 #define QDF_MON_STATUS_STA_CODING_SHIFT 20 585 586 /* HE radiotap per_user_2 */ 587 #define QDF_MON_STATUS_STA_MCS_SHIFT 4 588 #define QDF_MON_STATUS_STA_DCM_SHIFT 5 589 590 /* HE radiotap per user known */ 591 #define QDF_MON_STATUS_USER_FIELD_POSITION_KNOWN 0x01 592 #define QDF_MON_STATUS_STA_ID_PER_USER_KNOWN 0x02 593 #define QDF_MON_STATUS_STA_NSTS_KNOWN 0x04 594 #define QDF_MON_STATUS_STA_TX_BF_KNOWN 0x08 595 #define QDF_MON_STATUS_STA_SPATIAL_CONFIG_KNOWN 0x10 596 #define QDF_MON_STATUS_STA_MCS_KNOWN 0x20 597 #define QDF_MON_STATUS_STA_DCM_KNOWN 0x40 598 #define QDF_MON_STATUS_STA_CODING_KNOWN 0x80 599 600 /** 601 * enum qdf_proto_type - protocol type 602 * @QDF_PROTO_TYPE_DHCP - DHCP 603 * @QDF_PROTO_TYPE_EAPOL - EAPOL 604 * @QDF_PROTO_TYPE_ARP - ARP 605 * @QDF_PROTO_TYPE_MGMT - MGMT 606 * @QDF_PROTO_TYPE_ICMP - ICMP 607 * @QDF_PROTO_TYPE_ICMPv6 - ICMPv6 608 * @QDF_PROTO_TYPE_EVENT - EVENT 609 * @QDF_PROTO_TYPE_DNS - DNS 610 */ 611 enum qdf_proto_type { 612 QDF_PROTO_TYPE_DHCP, 613 QDF_PROTO_TYPE_EAPOL, 614 QDF_PROTO_TYPE_ARP, 615 QDF_PROTO_TYPE_MGMT, 616 QDF_PROTO_TYPE_ICMP, 617 QDF_PROTO_TYPE_ICMPv6, 618 QDF_PROTO_TYPE_EVENT, 619 QDF_PROTO_TYPE_DNS, 620 QDF_PROTO_TYPE_MAX 621 }; 622 623 /** 624 * qdf_reception_type - reception type used by lithium phy TLV 625 * @QDF_RECEPTION_TYPE_ULOFMDA - UL OFDMA 626 * @QDF_RECEPTION_TYPE_ULMIMO - UL MIMO 627 * @QQDF_RECEPTION_TYPE_FRAMELESS - Frame less 628 * @QDF_RECEPTION_TYPE_OTHER - All the other types 629 */ 630 enum qdf_reception_type { 631 QDF_RECEPTION_TYPE_ULOFMDA, 632 QDF_RECEPTION_TYPE_ULMIMO, 633 QDF_RECEPTION_TYPE_OTHER, 634 QDF_RECEPTION_TYPE_FRAMELESS 635 }; 636 637 /** 638 * cb_ftype - Frame type information in skb cb 639 * @CB_FTYPE_INVALID - Invalid 640 * @CB_FTYPE_MCAST2UCAST - Multicast to Unicast converted packet 641 * @CB_FTYPE_TSO - TCP Segmentation Offload 642 * @CB_FTYPE_TSO_SG - TSO Scatter Gather 643 * @CB_FTYPE_SG - Scatter Gather 644 * @CB_FTYPE_INTRABSS_FWD - Intra BSS forwarding 645 * @CB_FTYPE_RX_INFO - Rx information 646 * @CB_FTYPE_MESH_RX_INFO - Mesh Rx information 647 * @CB_FTYPE_MESH_TX_INFO - Mesh Tx information 648 * @CB_FTYPE_DMS - Directed Multicast Service 649 */ 650 enum cb_ftype { 651 CB_FTYPE_INVALID = 0, 652 CB_FTYPE_MCAST2UCAST = 1, 653 CB_FTYPE_TSO = 2, 654 CB_FTYPE_TSO_SG = 3, 655 CB_FTYPE_SG = 4, 656 CB_FTYPE_INTRABSS_FWD = 5, 657 CB_FTYPE_RX_INFO = 6, 658 CB_FTYPE_MESH_RX_INFO = 7, 659 CB_FTYPE_MESH_TX_INFO = 8, 660 CB_FTYPE_DMS = 9, 661 }; 662 663 /** 664 * @qdf_nbuf_t - Platform indepedent packet abstraction 665 */ 666 typedef __qdf_nbuf_t qdf_nbuf_t; 667 668 /** 669 * struct qdf_nbuf_track_t - Network buffer track structure 670 * 671 * @p_next: Pointer to next 672 * @net_buf: Pointer to network buffer 673 * @func_name: Function name 674 * @line_num: Line number 675 * @size: Size 676 * @map_func_name: nbuf mapping function name 677 * @map_line_num: mapping function line number 678 * @unmap_func_name: nbuf unmapping function name 679 * @unmap_line_num: mapping function line number 680 * @is_nbuf_mapped: indicate mapped/unmapped nbuf 681 * @time: mapping function timestamp 682 */ 683 struct qdf_nbuf_track_t { 684 struct qdf_nbuf_track_t *p_next; 685 qdf_nbuf_t net_buf; 686 char func_name[QDF_MEM_FUNC_NAME_SIZE]; 687 uint32_t line_num; 688 size_t size; 689 char map_func_name[QDF_MEM_FUNC_NAME_SIZE]; 690 uint32_t map_line_num; 691 char unmap_func_name[QDF_MEM_FUNC_NAME_SIZE]; 692 uint32_t unmap_line_num; 693 bool is_nbuf_mapped; 694 qdf_time_t time; 695 }; 696 697 typedef struct qdf_nbuf_track_t QDF_NBUF_TRACK; 698 699 /** 700 * typedef qdf_nbuf_queue_head_t - Platform indepedent nbuf queue head 701 */ 702 typedef __qdf_nbuf_queue_head_t qdf_nbuf_queue_head_t; 703 704 /** 705 * @qdf_dma_map_cb_t - Dma map callback prototype 706 */ 707 typedef void (*qdf_dma_map_cb_t)(void *arg, qdf_nbuf_t buf, 708 qdf_dma_map_t dmap); 709 710 /** 711 * @qdf_nbuf_queue_t - Platform independent packet queue abstraction 712 */ 713 typedef __qdf_nbuf_queue_t qdf_nbuf_queue_t; 714 715 /* BUS/DMA mapping routines */ 716 717 static inline QDF_STATUS 718 qdf_nbuf_dmamap_create(qdf_device_t osdev, qdf_dma_map_t *dmap) 719 { 720 return __qdf_nbuf_dmamap_create(osdev, dmap); 721 } 722 723 static inline void 724 qdf_nbuf_dmamap_destroy(qdf_device_t osdev, qdf_dma_map_t dmap) 725 { 726 __qdf_nbuf_dmamap_destroy(osdev, dmap); 727 } 728 729 static inline void 730 qdf_nbuf_dmamap_set_cb(qdf_dma_map_t dmap, qdf_dma_map_cb_t cb, void *arg) 731 { 732 __qdf_nbuf_dmamap_set_cb(dmap, cb, arg); 733 } 734 735 static inline void 736 qdf_nbuf_set_send_complete_flag(qdf_nbuf_t buf, bool flag) 737 { 738 __qdf_nbuf_set_send_complete_flag(buf, flag); 739 } 740 741 #define QDF_NBUF_QUEUE_WALK_SAFE(queue, var, tvar) \ 742 __qdf_nbuf_queue_walk_safe(queue, var, tvar) 743 744 #ifdef NBUF_MAP_UNMAP_DEBUG 745 /** 746 * qdf_nbuf_map_check_for_leaks() - check for nbut map leaks 747 * 748 * Check for net buffers that have been mapped, but never unmapped. 749 * 750 * Returns: None 751 */ 752 void qdf_nbuf_map_check_for_leaks(void); 753 754 QDF_STATUS qdf_nbuf_map_debug(qdf_device_t osdev, 755 qdf_nbuf_t buf, 756 qdf_dma_dir_t dir, 757 const char *func, 758 uint32_t line); 759 760 #define qdf_nbuf_map(osdev, buf, dir) \ 761 qdf_nbuf_map_debug(osdev, buf, dir, __func__, __LINE__) 762 763 void qdf_nbuf_unmap_debug(qdf_device_t osdev, 764 qdf_nbuf_t buf, 765 qdf_dma_dir_t dir, 766 const char *func, 767 uint32_t line); 768 769 #define qdf_nbuf_unmap(osdev, buf, dir) \ 770 qdf_nbuf_unmap_debug(osdev, buf, dir, __func__, __LINE__) 771 772 QDF_STATUS qdf_nbuf_map_single_debug(qdf_device_t osdev, 773 qdf_nbuf_t buf, 774 qdf_dma_dir_t dir, 775 const char *func, 776 uint32_t line); 777 778 #define qdf_nbuf_map_single(osdev, buf, dir) \ 779 qdf_nbuf_map_single_debug(osdev, buf, dir, __func__, __LINE__) 780 781 void qdf_nbuf_unmap_single_debug(qdf_device_t osdev, 782 qdf_nbuf_t buf, 783 qdf_dma_dir_t dir, 784 const char *func, 785 uint32_t line); 786 787 #define qdf_nbuf_unmap_single(osdev, buf, dir) \ 788 qdf_nbuf_unmap_single_debug(osdev, buf, dir, __func__, __LINE__) 789 790 QDF_STATUS qdf_nbuf_map_nbytes_debug(qdf_device_t osdev, 791 qdf_nbuf_t buf, 792 qdf_dma_dir_t dir, 793 int nbytes, 794 const char *func, 795 uint32_t line); 796 797 #define qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes) \ 798 qdf_nbuf_map_nbytes_debug(osdev, buf, dir, nbytes, __func__, __LINE__) 799 800 void qdf_nbuf_unmap_nbytes_debug(qdf_device_t osdev, 801 qdf_nbuf_t buf, 802 qdf_dma_dir_t dir, 803 int nbytes, 804 const char *func, 805 uint32_t line); 806 807 #define qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes) \ 808 qdf_nbuf_unmap_nbytes_debug(osdev, buf, dir, nbytes, __func__, __LINE__) 809 810 QDF_STATUS qdf_nbuf_map_nbytes_single_debug(qdf_device_t osdev, 811 qdf_nbuf_t buf, 812 qdf_dma_dir_t dir, 813 int nbytes, 814 const char *func, 815 uint32_t line); 816 817 #define qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes) \ 818 qdf_nbuf_map_nbytes_single_debug(osdev, buf, dir, nbytes, \ 819 __func__, __LINE__) 820 821 void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev, 822 qdf_nbuf_t buf, 823 qdf_dma_dir_t dir, 824 int nbytes, 825 const char *func, 826 uint32_t line); 827 828 #define qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes) \ 829 qdf_nbuf_unmap_nbytes_single_debug(osdev, buf, dir, nbytes, \ 830 __func__, __LINE__) 831 832 #else /* NBUF_MAP_UNMAP_DEBUG */ 833 834 static inline void qdf_nbuf_map_check_for_leaks(void) {} 835 836 static inline QDF_STATUS 837 qdf_nbuf_map(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir) 838 { 839 return __qdf_nbuf_map(osdev, buf, dir); 840 } 841 842 static inline void 843 qdf_nbuf_unmap(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir) 844 { 845 __qdf_nbuf_unmap(osdev, buf, dir); 846 } 847 848 static inline QDF_STATUS 849 qdf_nbuf_map_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir) 850 { 851 return __qdf_nbuf_map_single(osdev, buf, dir); 852 } 853 854 static inline void 855 qdf_nbuf_unmap_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir) 856 { 857 __qdf_nbuf_unmap_single(osdev, buf, dir); 858 } 859 860 static inline QDF_STATUS 861 qdf_nbuf_map_nbytes(qdf_device_t osdev, qdf_nbuf_t buf, 862 qdf_dma_dir_t dir, int nbytes) 863 { 864 return __qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes); 865 } 866 867 static inline void 868 qdf_nbuf_unmap_nbytes(qdf_device_t osdev, 869 qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes) 870 { 871 __qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes); 872 } 873 874 static inline QDF_STATUS 875 qdf_nbuf_map_nbytes_single( 876 qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes) 877 { 878 return __qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes); 879 } 880 881 static inline void 882 qdf_nbuf_unmap_nbytes_single( 883 qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes) 884 { 885 return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes); 886 } 887 #endif /* NBUF_MAP_UNMAP_DEBUG */ 888 889 /** 890 * qdf_nbuf_queue_head_dequeue() - dequeue nbuf from the head of queue 891 * @nbuf_queue_head: pointer to nbuf queue head 892 * 893 * Return: pointer to network buffer dequeued 894 */ 895 static inline 896 qdf_nbuf_t qdf_nbuf_queue_head_dequeue(qdf_nbuf_queue_head_t *nbuf_queue_head) 897 { 898 return __qdf_nbuf_queue_head_dequeue(nbuf_queue_head); 899 } 900 901 /** 902 * qdf_nbuf_queue_head_qlen() - length of the queue 903 * @nbuf_queue_head: pointer to nbuf queue head 904 * 905 * Return: length of queue (number of nbufs) pointed by qdf_nbuf_queue_head_t 906 */ 907 static inline 908 uint32_t qdf_nbuf_queue_head_qlen(qdf_nbuf_queue_head_t *nbuf_queue_head) 909 { 910 return __qdf_nbuf_queue_head_qlen(nbuf_queue_head); 911 } 912 913 /** 914 * qdf_nbuf_queue_head_enqueue_tail() - enqueue nbuf into queue tail 915 * @nbuf_queue_head: pointer to nbuf queue head 916 * @nbuf: nbuf to be enqueued 917 * 918 * Return: None 919 */ 920 static inline 921 void qdf_nbuf_queue_head_enqueue_tail(qdf_nbuf_queue_head_t *nbuf_queue_head, 922 qdf_nbuf_t nbuf) 923 { 924 return __qdf_nbuf_queue_head_enqueue_tail(nbuf_queue_head, nbuf); 925 } 926 927 /** 928 * qdf_nbuf_queue_head_init() - initialize qdf_nbuf_queue_head_t 929 * @nbuf_queue_head: pointer to nbuf queue head to be initialized 930 * 931 * Return: None 932 */ 933 static inline 934 void qdf_nbuf_queue_head_init(qdf_nbuf_queue_head_t *nbuf_queue_head) 935 { 936 return __qdf_nbuf_queue_head_init(nbuf_queue_head); 937 } 938 939 /** 940 * qdf_nbuf_queue_head_purge() - purge qdf_nbuf_queue_head_t 941 * @nbuf_queue_head: pointer to nbuf queue head to be purged 942 * 943 * Return: None 944 */ 945 static inline 946 void qdf_nbuf_queue_head_purge(qdf_nbuf_queue_head_t *nbuf_queue_head) 947 { 948 return __qdf_nbuf_queue_head_purge(nbuf_queue_head); 949 } 950 951 /** 952 * qdf_nbuf_queue_head_lock() - Acquire the nbuf_queue_head lock 953 * @head: nbuf_queue_head of the nbuf_list for which lock is to be acquired 954 * 955 * Return: void 956 */ 957 static inline void qdf_nbuf_queue_head_lock(qdf_nbuf_queue_head_t *head) 958 { 959 __qdf_nbuf_queue_head_lock(head); 960 } 961 962 /** 963 * qdf_nbuf_queue_head_unlock() - Release the nbuf queue lock 964 * @head: nbuf_queue_head of the nbuf_list for which lock is to be release 965 * 966 * Return: void 967 */ 968 static inline void qdf_nbuf_queue_head_unlock(qdf_nbuf_queue_head_t *head) 969 { 970 __qdf_nbuf_queue_head_unlock(head); 971 } 972 973 static inline void 974 qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir) 975 { 976 __qdf_nbuf_sync_for_cpu(osdev, buf, dir); 977 } 978 979 /** 980 * qdf_nbuf_dma_inv_range() - Invalidate the specified virtual address range 981 * @buf_start: start address 982 * @buf_end: end address 983 * 984 * Return: none 985 */ 986 static inline void 987 qdf_nbuf_dma_inv_range(const void *buf_start, const void *buf_end) 988 { 989 __qdf_nbuf_dma_inv_range(buf_start, buf_end); 990 } 991 992 static inline int qdf_nbuf_get_num_frags(qdf_nbuf_t buf) 993 { 994 return __qdf_nbuf_get_num_frags(buf); 995 } 996 997 /** 998 * qdf_nbuf_get_frag_len() - get fragment length 999 * @buf: Network buffer 1000 * @frag_num: Fragment number 1001 * 1002 * Return: Fragment length 1003 */ 1004 static inline int qdf_nbuf_get_frag_len(qdf_nbuf_t buf, int frag_num) 1005 { 1006 QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS)); 1007 return __qdf_nbuf_get_frag_len(buf, frag_num); 1008 } 1009 1010 /** 1011 * qdf_nbuf_get_frag_vaddr() - get fragment virtual address 1012 * @buf: Network buffer 1013 * @frag_num: Fragment number 1014 * 1015 * Return: Fragment virtual address 1016 */ 1017 static inline unsigned char *qdf_nbuf_get_frag_vaddr(qdf_nbuf_t buf, 1018 int frag_num) 1019 { 1020 QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS)); 1021 return __qdf_nbuf_get_frag_vaddr(buf, frag_num); 1022 } 1023 1024 /** 1025 * qdf_nbuf_get_frag_vaddr_always() - get fragment virtual address 1026 * @buf: Network buffer 1027 * 1028 * Return: Fragment virtual address 1029 */ 1030 static inline unsigned char * 1031 qdf_nbuf_get_frag_vaddr_always(qdf_nbuf_t buf) 1032 { 1033 return __qdf_nbuf_get_frag_vaddr_always(buf); 1034 } 1035 1036 /** 1037 * qdf_nbuf_get_frag_paddr() - get physical address for skb linear buffer 1038 * or skb fragment, based on frag_num passed 1039 * @buf: Network buffer 1040 * @frag_num: Fragment number 1041 * 1042 * Return: Fragment physical address 1043 */ 1044 static inline qdf_dma_addr_t qdf_nbuf_get_frag_paddr(qdf_nbuf_t buf, 1045 unsigned int frag_num) 1046 { 1047 QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS)); 1048 return __qdf_nbuf_get_frag_paddr(buf, frag_num); 1049 } 1050 1051 /** 1052 * qdf_nbuf_get_tx_frag_paddr() - get physical address for skb fragments only 1053 * @buf: Network buffer 1054 * 1055 * Return: Fragment physical address 1056 * Usage guideline: Use “qdf_nbuf_frag_map()” to dma map the specific 1057 * skb fragment , followed by “qdf_nbuf_get_tx_frag_paddr” 1058 */ 1059 static inline qdf_dma_addr_t qdf_nbuf_get_tx_frag_paddr(qdf_nbuf_t buf) 1060 { 1061 return __qdf_nbuf_get_tx_frag_paddr(buf); 1062 } 1063 1064 /** 1065 * qdf_nbuf_get_frag_is_wordstream() - is fragment wordstream 1066 * @buf: Network buffer 1067 * @frag_num: Fragment number 1068 * 1069 * Return: Fragment wordstream or not 1070 */ 1071 static inline int qdf_nbuf_get_frag_is_wordstream(qdf_nbuf_t buf, int frag_num) 1072 { 1073 QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS)); 1074 return __qdf_nbuf_get_frag_is_wordstream(buf, frag_num); 1075 } 1076 1077 /** 1078 * qdf_nbuf_set_frag_is_wordstream() - set fragment wordstream 1079 * @buf: Network buffer 1080 * @frag_num: Fragment number 1081 * @is_wordstream: Wordstream 1082 * 1083 * Return: none 1084 */ 1085 static inline void 1086 qdf_nbuf_set_frag_is_wordstream(qdf_nbuf_t buf, 1087 int frag_num, int is_wordstream) 1088 { 1089 QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS)); 1090 __qdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream); 1091 } 1092 1093 static inline void 1094 qdf_nbuf_set_vdev_ctx(qdf_nbuf_t buf, uint8_t vdev_id) 1095 { 1096 __qdf_nbuf_set_vdev_ctx(buf, vdev_id); 1097 } 1098 1099 static inline void 1100 qdf_nbuf_set_tx_ftype(qdf_nbuf_t buf, enum cb_ftype type) 1101 { 1102 __qdf_nbuf_set_tx_ftype(buf, type); 1103 } 1104 1105 static inline void 1106 qdf_nbuf_set_rx_ftype(qdf_nbuf_t buf, enum cb_ftype type) 1107 { 1108 __qdf_nbuf_set_rx_ftype(buf, type); 1109 } 1110 1111 1112 1113 static inline uint8_t 1114 qdf_nbuf_get_vdev_ctx(qdf_nbuf_t buf) 1115 { 1116 return __qdf_nbuf_get_vdev_ctx(buf); 1117 } 1118 1119 static inline enum cb_ftype qdf_nbuf_get_tx_ftype(qdf_nbuf_t buf) 1120 { 1121 return __qdf_nbuf_get_tx_ftype(buf); 1122 } 1123 1124 static inline enum cb_ftype qdf_nbuf_get_rx_ftype(qdf_nbuf_t buf) 1125 { 1126 return __qdf_nbuf_get_rx_ftype(buf); 1127 } 1128 1129 1130 static inline qdf_dma_addr_t 1131 qdf_nbuf_mapped_paddr_get(qdf_nbuf_t buf) 1132 { 1133 return __qdf_nbuf_mapped_paddr_get(buf); 1134 } 1135 1136 static inline void 1137 qdf_nbuf_mapped_paddr_set(qdf_nbuf_t buf, qdf_dma_addr_t paddr) 1138 { 1139 __qdf_nbuf_mapped_paddr_set(buf, paddr); 1140 } 1141 1142 static inline void 1143 qdf_nbuf_frag_push_head(qdf_nbuf_t buf, 1144 int frag_len, char *frag_vaddr, 1145 qdf_dma_addr_t frag_paddr) 1146 { 1147 __qdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr); 1148 } 1149 1150 #define qdf_nbuf_num_frags_init(_nbuf) __qdf_nbuf_num_frags_init((_nbuf)) 1151 1152 /** 1153 * qdf_nbuf_set_rx_chfrag_start() - set msdu start bit 1154 * @buf: Network buffer 1155 * @val: 0/1 1156 * 1157 * Return: void 1158 */ 1159 static inline void 1160 qdf_nbuf_set_rx_chfrag_start(qdf_nbuf_t buf, uint8_t val) 1161 { 1162 __qdf_nbuf_set_rx_chfrag_start(buf, val); 1163 } 1164 1165 /** 1166 * qdf_nbuf_is_rx_chfrag_start() - get msdu start bit 1167 * @buf: Network buffer 1168 * 1169 * Return: integer value - 0/1 1170 */ 1171 static inline int qdf_nbuf_is_rx_chfrag_start(qdf_nbuf_t buf) 1172 { 1173 return __qdf_nbuf_is_rx_chfrag_start(buf); 1174 } 1175 1176 /** 1177 * qdf_nbuf_set_rx_chfrag_cont() - set msdu continuation bit 1178 * @buf: Network buffer 1179 * @val: 0/1 1180 * 1181 * Return: void 1182 */ 1183 static inline void 1184 qdf_nbuf_set_rx_chfrag_cont(qdf_nbuf_t buf, uint8_t val) 1185 { 1186 __qdf_nbuf_set_rx_chfrag_cont(buf, val); 1187 } 1188 1189 /** 1190 * qdf_nbuf_is_rx_chfrag_cont() - get msdu continuation bit 1191 * @buf: Network buffer 1192 * 1193 * Return: integer value - 0/1 1194 */ 1195 static inline int qdf_nbuf_is_rx_chfrag_cont(qdf_nbuf_t buf) 1196 { 1197 return __qdf_nbuf_is_rx_chfrag_cont(buf); 1198 } 1199 1200 /** 1201 * qdf_nbuf_set_rx_chfrag_end() - set msdu end bit 1202 * @buf: Network buffer 1203 * @val: 0/1 1204 * 1205 * Return: void 1206 */ 1207 static inline void qdf_nbuf_set_rx_chfrag_end(qdf_nbuf_t buf, uint8_t val) 1208 { 1209 __qdf_nbuf_set_rx_chfrag_end(buf, val); 1210 } 1211 1212 /** 1213 * qdf_nbuf_is_rx_chfrag_end() - set msdu end bit 1214 * @buf: Network buffer 1215 * 1216 * Return: integer value - 0/1 1217 */ 1218 static inline int qdf_nbuf_is_rx_chfrag_end(qdf_nbuf_t buf) 1219 { 1220 return __qdf_nbuf_is_rx_chfrag_end(buf); 1221 } 1222 1223 /** 1224 * qdf_nbuf_set_da_mcbc() - set da is mcbc 1225 * @buf: Network buffer 1226 * @val: 0/1 1227 * 1228 * Return: void 1229 */ 1230 static inline void 1231 qdf_nbuf_set_da_mcbc(qdf_nbuf_t buf, uint8_t val) 1232 { 1233 __qdf_nbuf_set_da_mcbc(buf, val); 1234 } 1235 1236 /** 1237 * qdf_nbuf_is_da_mcbc() - get da is mcbc bit 1238 * @buf: Network buffer 1239 * 1240 * Return: integer value - 0/1 1241 */ 1242 static inline int qdf_nbuf_is_da_mcbc(qdf_nbuf_t buf) 1243 { 1244 return __qdf_nbuf_is_da_mcbc(buf); 1245 } 1246 1247 /** 1248 * qdf_nbuf_set_da_valid() - set da valid bit 1249 * @buf: Network buffer 1250 * @val: 0/1 1251 * 1252 * Return: void 1253 */ 1254 static inline void qdf_nbuf_set_da_valid(qdf_nbuf_t buf, uint8_t val) 1255 { 1256 __qdf_nbuf_set_da_valid(buf, val); 1257 } 1258 1259 /** 1260 * qdf_nbuf_is_da_valid() - get da valid bit 1261 * @buf: Network buffer 1262 * 1263 * Return: integer value - 0/1 1264 */ 1265 static inline int qdf_nbuf_is_da_valid(qdf_nbuf_t buf) 1266 { 1267 return __qdf_nbuf_is_da_valid(buf); 1268 } 1269 1270 /** 1271 * qdf_nbuf_set_sa_valid() - set sa valid bit 1272 * @buf: Network buffer 1273 * @val: 0/1 1274 * 1275 * Return: void 1276 */ 1277 static inline void qdf_nbuf_set_sa_valid(qdf_nbuf_t buf, uint8_t val) 1278 { 1279 __qdf_nbuf_set_sa_valid(buf, val); 1280 } 1281 1282 /** 1283 * qdf_nbuf_is_sa_valid() - get da valid bit 1284 * @buf: Network buffer 1285 * 1286 * Return: integer value - 0/1 1287 */ 1288 static inline int qdf_nbuf_is_sa_valid(qdf_nbuf_t buf) 1289 { 1290 return __qdf_nbuf_is_sa_valid(buf); 1291 } 1292 1293 /** 1294 * qdf_nbuf_set_rx_retry_flag() - set rx retry flag bit 1295 * @buf: Network buffer 1296 * @val: 0/1 1297 * 1298 * Return: void 1299 */ 1300 static inline void qdf_nbuf_set_rx_retry_flag(qdf_nbuf_t buf, uint8_t val) 1301 { 1302 __qdf_nbuf_set_rx_retry_flag(buf, val); 1303 } 1304 1305 /** 1306 * qdf_nbuf_is_rx_retry_flag() - get rx retry flag bit 1307 * @buf: Network buffer 1308 * 1309 * Return: integer value - 0/1 1310 */ 1311 static inline int qdf_nbuf_is_rx_retry_flag(qdf_nbuf_t buf) 1312 { 1313 return __qdf_nbuf_is_rx_retry_flag(buf); 1314 } 1315 1316 /** 1317 * qdf_nbuf_set_raw_frame() - set raw_frame bit 1318 * @buf: Network buffer 1319 * @val: 0/1 1320 * 1321 * Return: void 1322 */ 1323 static inline void qdf_nbuf_set_raw_frame(qdf_nbuf_t buf, uint8_t val) 1324 { 1325 __qdf_nbuf_set_raw_frame(buf, val); 1326 } 1327 1328 /** 1329 * qdf_nbuf_is_raw_frame() - get raw_frame bit 1330 * @buf: Network buffer 1331 * 1332 * Return: integer value - 0/1 1333 */ 1334 static inline int qdf_nbuf_is_raw_frame(qdf_nbuf_t buf) 1335 { 1336 return __qdf_nbuf_is_raw_frame(buf); 1337 } 1338 1339 /** 1340 * qdf_nbuf_set_tid_val() - set tid_val 1341 * @buf: Network buffer 1342 * @val: 4 bits tid value 1343 */ 1344 static inline void qdf_nbuf_set_tid_val(qdf_nbuf_t buf, uint8_t val) 1345 { 1346 __qdf_nbuf_set_tid_val(buf, val); 1347 } 1348 1349 /** 1350 * qdf_nbuf_get_tid_val() - get tid_val 1351 * @buf: Network buffer 1352 * 1353 * Return: integer value[4 bits tid value] 1354 */ 1355 static inline uint8_t qdf_nbuf_get_tid_val(qdf_nbuf_t buf) 1356 { 1357 return __qdf_nbuf_get_tid_val(buf); 1358 } 1359 1360 /** 1361 * qdf_nbuf_set_frag_list() - set frag list bit 1362 * @buf: Network buffer 1363 * @val: 0/1 1364 * 1365 * Return: void 1366 */ 1367 static inline void qdf_nbuf_set_is_frag(qdf_nbuf_t buf, uint8_t val) 1368 { 1369 __qdf_nbuf_set_is_frag(buf, val); 1370 } 1371 1372 /** 1373 * qdf_nbuf_is_sa_valid() - get da frag list bit 1374 * @buf: Network buffer 1375 * 1376 * Return: integer value - 0/1 1377 */ 1378 static inline int qdf_nbuf_is_frag(qdf_nbuf_t buf) 1379 { 1380 return __qdf_nbuf_is_frag(buf); 1381 } 1382 1383 /** 1384 * qdf_nbuf_set_tx_chfrag_start() - set msdu start bit 1385 * @buf: Network buffer 1386 * @val: 0/1 1387 * 1388 * Return: void 1389 */ 1390 static inline void 1391 qdf_nbuf_set_tx_chfrag_start(qdf_nbuf_t buf, uint8_t val) 1392 { 1393 __qdf_nbuf_set_tx_chfrag_start(buf, val); 1394 } 1395 1396 /** 1397 * qdf_nbuf_is_tx_chfrag_start() - get msdu start bit 1398 * @buf: Network buffer 1399 * 1400 * Return: integer value - 0/1 1401 */ 1402 static inline int qdf_nbuf_is_tx_chfrag_start(qdf_nbuf_t buf) 1403 { 1404 return __qdf_nbuf_is_tx_chfrag_start(buf); 1405 } 1406 1407 /** 1408 * qdf_nbuf_set_tx_chfrag_cont() - set msdu continuation bit 1409 * @buf: Network buffer 1410 * @val: 0/1 1411 * 1412 * Return: void 1413 */ 1414 static inline void 1415 qdf_nbuf_set_tx_chfrag_cont(qdf_nbuf_t buf, uint8_t val) 1416 { 1417 __qdf_nbuf_set_tx_chfrag_cont(buf, val); 1418 } 1419 1420 /** 1421 * qdf_nbuf_is_tx_chfrag_cont() - get msdu continuation bit 1422 * @buf: Network buffer 1423 * 1424 * Return: integer value - 0/1 1425 */ 1426 static inline int qdf_nbuf_is_tx_chfrag_cont(qdf_nbuf_t buf) 1427 { 1428 return __qdf_nbuf_is_tx_chfrag_cont(buf); 1429 } 1430 1431 /** 1432 * qdf_nbuf_set_tx_chfrag_end() - set msdu end bit 1433 * @buf: Network buffer 1434 * @val: 0/1 1435 * 1436 * Return: void 1437 */ 1438 static inline void qdf_nbuf_set_tx_chfrag_end(qdf_nbuf_t buf, uint8_t val) 1439 { 1440 __qdf_nbuf_set_tx_chfrag_end(buf, val); 1441 } 1442 1443 /** 1444 * qdf_nbuf_is_tx_chfrag_end() - set msdu end bit 1445 * @buf: Network buffer 1446 * 1447 * Return: integer value - 0/1 1448 */ 1449 static inline int qdf_nbuf_is_tx_chfrag_end(qdf_nbuf_t buf) 1450 { 1451 return __qdf_nbuf_is_tx_chfrag_end(buf); 1452 } 1453 1454 static inline void 1455 qdf_nbuf_dma_map_info(qdf_dma_map_t bmap, qdf_dmamap_info_t *sg) 1456 { 1457 __qdf_nbuf_dma_map_info(bmap, sg); 1458 } 1459 1460 /** 1461 * qdf_nbuf_is_tso() - is the network buffer a jumbo packet? 1462 * @buf: Network buffer 1463 * 1464 * Return: 1 - this is a jumbo packet 0 - not a jumbo packet 1465 */ 1466 static inline uint8_t qdf_nbuf_is_tso(qdf_nbuf_t nbuf) 1467 { 1468 return __qdf_nbuf_is_tso(nbuf); 1469 } 1470 1471 /** 1472 * qdf_nbuf_get_users() - function to get the number of users referencing this 1473 * network buffer 1474 * 1475 * @nbuf: network buffer 1476 * 1477 * Return: number of user references to nbuf. 1478 */ 1479 static inline int qdf_nbuf_get_users(qdf_nbuf_t nbuf) 1480 { 1481 return __qdf_nbuf_get_users(nbuf); 1482 } 1483 1484 /** 1485 * qdf_nbuf_next() - get the next packet in the linked list 1486 * @buf: Network buffer 1487 * 1488 * This function can be used when nbufs are directly linked into a list, 1489 * rather than using a separate network buffer queue object. 1490 * 1491 * Return: next network buffer in the linked list 1492 */ 1493 static inline qdf_nbuf_t qdf_nbuf_next(qdf_nbuf_t buf) 1494 { 1495 return __qdf_nbuf_next(buf); 1496 } 1497 1498 #ifdef NBUF_MEMORY_DEBUG 1499 1500 #define QDF_NET_BUF_TRACK_MAX_SIZE (1024) 1501 1502 void qdf_net_buf_debug_init(void); 1503 void qdf_net_buf_debug_exit(void); 1504 void qdf_net_buf_debug_clean(void); 1505 void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size, 1506 const char *func_name, uint32_t line_num); 1507 /** 1508 * qdf_net_buf_debug_update_node() - update nbuf in debug hash table 1509 * 1510 * Return: none 1511 */ 1512 void qdf_net_buf_debug_update_node(qdf_nbuf_t net_buf, const char *func_name, 1513 uint32_t line_num); 1514 void qdf_net_buf_debug_delete_node(qdf_nbuf_t net_buf); 1515 1516 /** 1517 * qdf_net_buf_debug_update_map_node() - update nbuf in debug 1518 * hash table with the mapping function info 1519 * @nbuf: network buffer 1520 * @func: function name that requests for mapping the nbuf 1521 * @line_num: function line number 1522 * 1523 * Return: none 1524 */ 1525 void qdf_net_buf_debug_update_map_node(qdf_nbuf_t net_buf, 1526 const char *func_name, 1527 uint32_t line_num); 1528 1529 /** 1530 * qdf_net_buf_debug_update_unmap_node() - update nbuf in debug 1531 * hash table with the unmap function info 1532 * @nbuf: network buffer 1533 * @func: function name that requests for unmapping the nbuf 1534 * @line_num: function line number 1535 * 1536 * Return: none 1537 */ 1538 void qdf_net_buf_debug_update_unmap_node(qdf_nbuf_t net_buf, 1539 const char *func_name, 1540 uint32_t line_num); 1541 1542 /** 1543 * qdf_net_buf_debug_acquire_skb() - acquire skb to avoid memory leak 1544 * @net_buf: Network buf holding head segment (single) 1545 * @func_name: pointer to function name 1546 * @line_num: line number 1547 * 1548 * WLAN driver module's SKB which are allocated by network stack are 1549 * suppose to call this API before freeing it such that the SKB 1550 * is not reported as memory leak. 1551 * 1552 * Return: none 1553 */ 1554 void qdf_net_buf_debug_acquire_skb(qdf_nbuf_t net_buf, 1555 const char *func_name, 1556 uint32_t line_num); 1557 void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf); 1558 1559 /* nbuf allocation rouines */ 1560 1561 #define qdf_nbuf_alloc(d, s, r, a, p) \ 1562 qdf_nbuf_alloc_debug(d, s, r, a, p, __func__, __LINE__) 1563 1564 qdf_nbuf_t qdf_nbuf_alloc_debug(qdf_device_t osdev, qdf_size_t size, 1565 int reserve, int align, int prio, 1566 const char *func, uint32_t line); 1567 1568 /** 1569 * qdf_nbuf_alloc_no_recycler() - Allocates skb 1570 * @size: Size to be allocated for skb 1571 * @reserve: Reserved headroom size 1572 * @align: Align 1573 * @func: Function name of the call site 1574 * @line: Line number of the callsite 1575 * 1576 * This API allocates skb of required size and aligns if needed and reserves 1577 * some space in the front. This skb allocation is not from skb recycler pool. 1578 * 1579 * Return: Allocated nbuf pointer 1580 */ 1581 #define qdf_nbuf_alloc_no_recycler(s, r, a) \ 1582 qdf_nbuf_alloc_no_recycler_debug(s, r, a, __func__, __LINE__) 1583 1584 qdf_nbuf_t qdf_nbuf_alloc_no_recycler_debug(size_t size, int reserve, int align, 1585 const char *func, uint32_t line); 1586 1587 #define qdf_nbuf_free(d) \ 1588 qdf_nbuf_free_debug(d, __func__, __LINE__) 1589 1590 void qdf_nbuf_free_debug(qdf_nbuf_t nbuf, const char *func, uint32_t line); 1591 1592 #define qdf_nbuf_clone(buf) \ 1593 qdf_nbuf_clone_debug(buf, __func__, __LINE__) 1594 1595 /** 1596 * qdf_nbuf_clone_debug() - clone the nbuf (copy is readonly) 1597 * @buf: nbuf to clone from 1598 * @func: name of the calling function 1599 * @line: line number of the callsite 1600 * 1601 * This function clones the nbuf and creates a memory tracking 1602 * node corresponding to that cloned skbuff structure. 1603 * 1604 * Return: cloned buffer 1605 */ 1606 qdf_nbuf_t qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func, 1607 uint32_t line); 1608 1609 #define qdf_nbuf_copy(buf) \ 1610 qdf_nbuf_copy_debug(buf, __func__, __LINE__) 1611 1612 /** 1613 * qdf_nbuf_copy_debug() - returns a private copy of the buf 1614 * @buf: nbuf to copy from 1615 * @func: name of the calling function 1616 * @line: line number of the callsite 1617 * 1618 * This API returns a private copy of the buf, the buf returned is completely 1619 * modifiable by callers. It also creates a memory tracking node corresponding 1620 * to that new skbuff structure. 1621 * 1622 * Return: copied buffer 1623 */ 1624 qdf_nbuf_t qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func, uint32_t line); 1625 1626 #define qdf_nbuf_copy_expand(buf, headroom, tailroom) \ 1627 qdf_nbuf_copy_expand_debug(buf, headroom, tailroom, __func__, __LINE__) 1628 1629 /** 1630 * qdf_nbuf_copy_expand_debug() - copy and expand nbuf 1631 * @buf: Network buf instance 1632 * @headroom: Additional headroom to be added 1633 * @tailroom: Additional tailroom to be added 1634 * @func: name of the calling function 1635 * @line: line number of the callsite 1636 * 1637 * Return: New nbuf that is a copy of buf, with additional head and tailroom 1638 * or NULL if there is no memory 1639 */ 1640 qdf_nbuf_t 1641 qdf_nbuf_copy_expand_debug(qdf_nbuf_t buf, int headroom, int tailroom, 1642 const char *func, uint32_t line); 1643 1644 /** 1645 * qdf_nbuf_unshare() - make a copy of the shared nbuf 1646 * @buf: Network buf instance 1647 * 1648 * Return: New nbuf which is a copy of the received nbuf if it is cloned, 1649 * else, return the original nbuf 1650 */ 1651 #define qdf_nbuf_unshare(d) \ 1652 qdf_nbuf_unshare_debug(d, __func__, __LINE__) 1653 1654 qdf_nbuf_t 1655 qdf_nbuf_unshare_debug(qdf_nbuf_t buf, const char *func_name, 1656 uint32_t line_num); 1657 1658 #else /* NBUF_MEMORY_DEBUG */ 1659 1660 static inline void qdf_net_buf_debug_init(void) {} 1661 static inline void qdf_net_buf_debug_exit(void) {} 1662 1663 static inline void qdf_net_buf_debug_acquire_skb(qdf_nbuf_t net_buf, 1664 const char *func_name, 1665 uint32_t line_num) 1666 { 1667 } 1668 1669 static inline void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf) 1670 { 1671 } 1672 1673 static inline void 1674 qdf_net_buf_debug_update_node(qdf_nbuf_t net_buf, const char *func_name, 1675 uint32_t line_num) 1676 { 1677 } 1678 1679 static inline void 1680 qdf_net_buf_debug_update_map_node(qdf_nbuf_t net_buf, 1681 const char *func_name, 1682 uint32_t line_num) 1683 { 1684 } 1685 1686 static inline void 1687 qdf_net_buf_debug_update_unmap_node(qdf_nbuf_t net_buf, 1688 const char *func_name, 1689 uint32_t line_num) 1690 { 1691 } 1692 /* Nbuf allocation rouines */ 1693 1694 #define qdf_nbuf_alloc(osdev, size, reserve, align, prio) \ 1695 qdf_nbuf_alloc_fl(osdev, size, reserve, align, prio, \ 1696 __func__, __LINE__) 1697 1698 #define qdf_nbuf_alloc_no_recycler(size, reserve, align) \ 1699 qdf_nbuf_alloc_no_recycler_fl(size, reserve, align, __func__, __LINE__) 1700 1701 static inline qdf_nbuf_t 1702 qdf_nbuf_alloc_fl(qdf_device_t osdev, qdf_size_t size, int reserve, int align, 1703 int prio, const char *func, uint32_t line) 1704 { 1705 return __qdf_nbuf_alloc(osdev, size, reserve, align, prio, func, line); 1706 } 1707 1708 /** 1709 * qdf_nbuf_alloc_no_recycler_fl() - Allocate SKB 1710 * @size: Size to be allocated for skb 1711 * @reserve: Reserved headroom size 1712 * @align: Align 1713 * @func: Function name of the call site 1714 * @line: Line number of the callsite 1715 * 1716 * This API allocates skb of required size and aligns if needed and reserves 1717 * some space in the front. This skb allocation is not from skb recycler pool. 1718 * 1719 * Return: Allocated nbuf pointer 1720 */ 1721 static inline qdf_nbuf_t 1722 qdf_nbuf_alloc_no_recycler_fl(size_t size, int reserve, int align, 1723 const char *func, uint32_t line) 1724 { 1725 return __qdf_nbuf_alloc_no_recycler(size, reserve, align, func, line); 1726 } 1727 1728 static inline void qdf_nbuf_free(qdf_nbuf_t buf) 1729 { 1730 if (qdf_likely(buf)) 1731 __qdf_nbuf_free(buf); 1732 } 1733 1734 /** 1735 * qdf_nbuf_clone() - clone the nbuf (copy is readonly) 1736 * @buf: Pointer to network buffer 1737 * 1738 * This function clones the nbuf and returns new sk_buff 1739 * structure. 1740 * 1741 * Return: cloned skb 1742 */ 1743 static inline qdf_nbuf_t qdf_nbuf_clone(qdf_nbuf_t buf) 1744 { 1745 return __qdf_nbuf_clone(buf); 1746 } 1747 1748 /** 1749 * qdf_nbuf_copy() - returns a private copy of the buf 1750 * @buf: Pointer to network buffer 1751 * 1752 * This API returns a private copy of the buf, the buf returned is completely 1753 * modifiable by callers 1754 * 1755 * Return: skb or NULL 1756 */ 1757 static inline qdf_nbuf_t qdf_nbuf_copy(qdf_nbuf_t buf) 1758 { 1759 return __qdf_nbuf_copy(buf); 1760 } 1761 1762 /** 1763 * qdf_nbuf_copy_expand() - copy and expand nbuf 1764 * @buf: Network buf instance 1765 * @headroom: Additional headroom to be added 1766 * @tailroom: Additional tailroom to be added 1767 * 1768 * Return: New nbuf that is a copy of buf, with additional head and tailroom 1769 * or NULL if there is no memory 1770 */ 1771 static inline qdf_nbuf_t qdf_nbuf_copy_expand(qdf_nbuf_t buf, int headroom, 1772 int tailroom) 1773 { 1774 return __qdf_nbuf_copy_expand(buf, headroom, tailroom); 1775 } 1776 1777 static inline qdf_nbuf_t qdf_nbuf_unshare(qdf_nbuf_t buf) 1778 { 1779 return __qdf_nbuf_unshare(buf); 1780 } 1781 #endif /* NBUF_MEMORY_DEBUG */ 1782 1783 /** 1784 * qdf_nbuf_copy_expand_fraglist() - copy and expand nbuf and 1785 * get reference of the fraglist. 1786 * @buf: Network buf instance 1787 * @headroom: Additional headroom to be added 1788 * @tailroom: Additional tailroom to be added 1789 * 1790 * Return: New nbuf that is a copy of buf, with additional head and tailroom 1791 * or NULL if there is no memory 1792 */ 1793 static inline qdf_nbuf_t 1794 qdf_nbuf_copy_expand_fraglist(qdf_nbuf_t buf, int headroom, 1795 int tailroom) 1796 { 1797 buf = qdf_nbuf_copy_expand(buf, headroom, tailroom); 1798 1799 /* get fraglist reference */ 1800 if (buf) 1801 __qdf_nbuf_get_ref_fraglist(buf); 1802 1803 return buf; 1804 } 1805 1806 #ifdef WLAN_FEATURE_FASTPATH 1807 /** 1808 * qdf_nbuf_init_fast() - before put buf into pool,turn it to init state 1809 * 1810 * @buf: buf instance 1811 * Return: data pointer of this buf where new data has to be 1812 * put, or NULL if there is not enough room in this buf. 1813 */ 1814 void qdf_nbuf_init_fast(qdf_nbuf_t nbuf); 1815 #endif /* WLAN_FEATURE_FASTPATH */ 1816 1817 /** 1818 * @qdf_nbuf_list_free() - free a list of nbufs 1819 * @buf_list: A list of nbufs to be freed 1820 * 1821 * Return: none 1822 */ 1823 1824 static inline void qdf_nbuf_list_free(qdf_nbuf_t buf_list) 1825 { 1826 while (buf_list) { 1827 qdf_nbuf_t next = qdf_nbuf_next(buf_list); 1828 qdf_nbuf_free(buf_list); 1829 buf_list = next; 1830 } 1831 } 1832 1833 static inline void qdf_nbuf_tx_free(qdf_nbuf_t buf_list, int tx_err) 1834 { 1835 qdf_nbuf_list_free(buf_list); 1836 } 1837 1838 static inline void qdf_nbuf_ref(qdf_nbuf_t buf) 1839 { 1840 __qdf_nbuf_ref(buf); 1841 } 1842 1843 static inline int qdf_nbuf_shared(qdf_nbuf_t buf) 1844 { 1845 return __qdf_nbuf_shared(buf); 1846 } 1847 1848 static inline QDF_STATUS qdf_nbuf_cat(qdf_nbuf_t dst, qdf_nbuf_t src) 1849 { 1850 return __qdf_nbuf_cat(dst, src); 1851 } 1852 1853 /** 1854 * @qdf_nbuf_copy_bits() - return the length of the copy bits for skb 1855 * @skb: SKB pointer 1856 * @offset: offset 1857 * @len: Length 1858 * @to: To 1859 * 1860 * Return: int32_t 1861 */ 1862 static inline int32_t 1863 qdf_nbuf_copy_bits(qdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to) 1864 { 1865 return __qdf_nbuf_copy_bits(nbuf, offset, len, to); 1866 } 1867 1868 1869 /* nbuf manipulation routines */ 1870 1871 /** 1872 * @qdf_nbuf_head() - return the address of an nbuf's buffer 1873 * @buf: netbuf 1874 * 1875 * Return: head address 1876 */ 1877 static inline uint8_t *qdf_nbuf_head(qdf_nbuf_t buf) 1878 { 1879 return __qdf_nbuf_head(buf); 1880 } 1881 1882 /** 1883 * qdf_nbuf_data() - Return the address of the start of data within an nbuf 1884 * @buf: Network buffer 1885 * 1886 * Return: Data address 1887 */ 1888 static inline uint8_t *qdf_nbuf_data(qdf_nbuf_t buf) 1889 { 1890 return __qdf_nbuf_data(buf); 1891 } 1892 1893 /** 1894 * qdf_nbuf_data_addr() - Return the address of skb->data 1895 * @buf: Network buffer 1896 * 1897 * Return: Data address 1898 */ 1899 static inline uint8_t *qdf_nbuf_data_addr(qdf_nbuf_t buf) 1900 { 1901 return __qdf_nbuf_data_addr(buf); 1902 } 1903 1904 /** 1905 * qdf_nbuf_headroom() - amount of headroom int the current nbuf 1906 * @buf: Network buffer 1907 * 1908 * Return: Amount of head room 1909 */ 1910 static inline uint32_t qdf_nbuf_headroom(qdf_nbuf_t buf) 1911 { 1912 return __qdf_nbuf_headroom(buf); 1913 } 1914 1915 /** 1916 * qdf_nbuf_tailroom() - amount of tail space available 1917 * @buf: Network buffer 1918 * 1919 * Return: amount of tail room 1920 */ 1921 static inline uint32_t qdf_nbuf_tailroom(qdf_nbuf_t buf) 1922 { 1923 return __qdf_nbuf_tailroom(buf); 1924 } 1925 1926 /** 1927 * qdf_nbuf_push_head() - push data in the front 1928 * @buf: Network buf instance 1929 * @size: Size to be pushed 1930 * 1931 * Return: New data pointer of this buf after data has been pushed, 1932 * or NULL if there is not enough room in this buf. 1933 */ 1934 static inline uint8_t *qdf_nbuf_push_head(qdf_nbuf_t buf, qdf_size_t size) 1935 { 1936 return __qdf_nbuf_push_head(buf, size); 1937 } 1938 1939 /** 1940 * qdf_nbuf_put_tail() - puts data in the end 1941 * @buf: Network buf instance 1942 * @size: Size to be pushed 1943 * 1944 * Return: Data pointer of this buf where new data has to be 1945 * put, or NULL if there is not enough room in this buf. 1946 */ 1947 static inline uint8_t *qdf_nbuf_put_tail(qdf_nbuf_t buf, qdf_size_t size) 1948 { 1949 return __qdf_nbuf_put_tail(buf, size); 1950 } 1951 1952 /** 1953 * qdf_nbuf_pull_head() - pull data out from the front 1954 * @buf: Network buf instance 1955 * @size: Size to be popped 1956 * 1957 * Return: New data pointer of this buf after data has been popped, 1958 * or NULL if there is not sufficient data to pull. 1959 */ 1960 static inline uint8_t *qdf_nbuf_pull_head(qdf_nbuf_t buf, qdf_size_t size) 1961 { 1962 return __qdf_nbuf_pull_head(buf, size); 1963 } 1964 1965 /** 1966 * qdf_nbuf_trim_tail() - trim data out from the end 1967 * @buf: Network buf instance 1968 * @size: Size to be popped 1969 * 1970 * Return: none 1971 */ 1972 static inline void qdf_nbuf_trim_tail(qdf_nbuf_t buf, qdf_size_t size) 1973 { 1974 __qdf_nbuf_trim_tail(buf, size); 1975 } 1976 1977 /** 1978 * qdf_nbuf_len() - get the length of the buf 1979 * @buf: Network buf instance 1980 * 1981 * Return: total length of this buf. 1982 */ 1983 static inline qdf_size_t qdf_nbuf_len(qdf_nbuf_t buf) 1984 { 1985 return __qdf_nbuf_len(buf); 1986 } 1987 1988 /** 1989 * qdf_nbuf_set_pktlen() - set the length of the buf 1990 * @buf: Network buf instance 1991 * @size: Size to be set 1992 * 1993 * Return: none 1994 */ 1995 static inline void qdf_nbuf_set_pktlen(qdf_nbuf_t buf, uint32_t len) 1996 { 1997 __qdf_nbuf_set_pktlen(buf, len); 1998 } 1999 2000 /** 2001 * qdf_nbuf_reserve() - trim data out from the end 2002 * @buf: Network buf instance 2003 * @size: Size to be popped 2004 * 2005 * Return: none 2006 */ 2007 static inline void qdf_nbuf_reserve(qdf_nbuf_t buf, qdf_size_t size) 2008 { 2009 __qdf_nbuf_reserve(buf, size); 2010 } 2011 2012 /** 2013 * qdf_nbuf_set_data_pointer() - set data pointer 2014 * @buf: Network buf instance 2015 * @data: data pointer 2016 * 2017 * Return: none 2018 */ 2019 static inline void qdf_nbuf_set_data_pointer(qdf_nbuf_t buf, uint8_t *data) 2020 { 2021 __qdf_nbuf_set_data_pointer(buf, data); 2022 } 2023 2024 /** 2025 * qdf_nbuf_set_len() - set data length 2026 * @buf: Network buf instance 2027 * @len: data length 2028 * Return: none 2029 */ 2030 static inline void qdf_nbuf_set_len(qdf_nbuf_t buf, uint32_t len) 2031 { 2032 __qdf_nbuf_set_len(buf, len); 2033 } 2034 2035 /** 2036 * qdf_nbuf_set_tail_pointer() - set data tail pointer 2037 * @buf: Network buf instance 2038 * @len: length of data 2039 * 2040 * Return: none 2041 */ 2042 static inline void qdf_nbuf_set_tail_pointer(qdf_nbuf_t buf, int len) 2043 { 2044 __qdf_nbuf_set_tail_pointer(buf, len); 2045 } 2046 2047 /** 2048 * qdf_nbuf_unlink_no_lock() - unlink a nbuf from nbuf list 2049 * @buf: Network buf instance 2050 * @list: list to use 2051 * 2052 * This is a lockless version, driver must acquire locks if it 2053 * needs to synchronize 2054 * 2055 * Return: none 2056 */ 2057 static inline void 2058 qdf_nbuf_unlink_no_lock(qdf_nbuf_t buf, qdf_nbuf_queue_head_t *list) 2059 { 2060 __qdf_nbuf_unlink_no_lock(buf, list); 2061 } 2062 2063 /** 2064 * qdf_nbuf_reset() - reset the buffer data and pointer 2065 * @buf: Network buf instance 2066 * @reserve: reserve 2067 * @align: align 2068 * 2069 * Return: none 2070 */ 2071 static inline void qdf_nbuf_reset(qdf_nbuf_t buf, int reserve, int align) 2072 { 2073 __qdf_nbuf_reset(buf, reserve, align); 2074 } 2075 2076 /** 2077 * qdf_nbuf_dev_scratch_is_supported() - dev_scratch support for network buffer 2078 * in kernel 2079 * 2080 * Return: true if dev_scratch is supported 2081 * false if dev_scratch is not supported 2082 */ 2083 static inline bool qdf_nbuf_is_dev_scratch_supported(void) 2084 { 2085 return __qdf_nbuf_is_dev_scratch_supported(); 2086 } 2087 2088 /** 2089 * qdf_nbuf_get_dev_scratch() - get dev_scratch of network buffer 2090 * @buf: Pointer to network buffer 2091 * 2092 * Return: dev_scratch if dev_scratch supported 2093 * 0 if dev_scratch not supported 2094 */ 2095 static inline unsigned long qdf_nbuf_get_dev_scratch(qdf_nbuf_t buf) 2096 { 2097 return __qdf_nbuf_get_dev_scratch(buf); 2098 } 2099 2100 /** 2101 * qdf_nbuf_set_dev_scratch() - set dev_scratch of network buffer 2102 * @buf: Pointer to network buffer 2103 * @value: value to be set in dev_scratch of network buffer 2104 * 2105 * Return: void 2106 */ 2107 static inline void qdf_nbuf_set_dev_scratch(qdf_nbuf_t buf, unsigned long value) 2108 { 2109 __qdf_nbuf_set_dev_scratch(buf, value); 2110 } 2111 2112 /** 2113 * qdf_nbuf_peek_header() - return the data pointer & length of the header 2114 * @buf: Network nbuf 2115 * @addr: Data pointer 2116 * @len: Length of the data 2117 * 2118 * Return: none 2119 */ 2120 static inline void 2121 qdf_nbuf_peek_header(qdf_nbuf_t buf, uint8_t **addr, uint32_t *len) 2122 { 2123 __qdf_nbuf_peek_header(buf, addr, len); 2124 } 2125 2126 /* nbuf queue routines */ 2127 2128 /** 2129 * qdf_nbuf_queue_init() - initialize buf queue 2130 * @head: Network buf queue head 2131 * 2132 * Return: none 2133 */ 2134 static inline void qdf_nbuf_queue_init(qdf_nbuf_queue_t *head) 2135 { 2136 __qdf_nbuf_queue_init(head); 2137 } 2138 2139 /** 2140 * qdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue 2141 * @head: Network buf queue head 2142 * @buf: Network buf 2143 * 2144 * Return: none 2145 */ 2146 static inline void qdf_nbuf_queue_add(qdf_nbuf_queue_t *head, qdf_nbuf_t buf) 2147 { 2148 __qdf_nbuf_queue_add(head, buf); 2149 } 2150 2151 /** 2152 * qdf_nbuf_queue_insert_head() - insert nbuf at the head of queue 2153 * @head: Network buf queue head 2154 * @buf: Network buf 2155 * 2156 * Return: none 2157 */ 2158 static inline void 2159 qdf_nbuf_queue_insert_head(qdf_nbuf_queue_t *head, qdf_nbuf_t buf) 2160 { 2161 __qdf_nbuf_queue_insert_head(head, buf); 2162 } 2163 2164 /** 2165 * qdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue 2166 * @head: Network buf queue head 2167 * 2168 * Return: The head buf in the buf queue. 2169 */ 2170 static inline qdf_nbuf_t qdf_nbuf_queue_remove(qdf_nbuf_queue_t *head) 2171 { 2172 return __qdf_nbuf_queue_remove(head); 2173 } 2174 2175 /** 2176 * qdf_nbuf_queue_len() - get the length of the queue 2177 * @head: Network buf queue head 2178 * 2179 * Return: length of the queue 2180 */ 2181 static inline uint32_t qdf_nbuf_queue_len(qdf_nbuf_queue_t *head) 2182 { 2183 return __qdf_nbuf_queue_len(head); 2184 } 2185 2186 /** 2187 * qdf_nbuf_queue_next() - get the next guy/packet of the given buffer 2188 * @buf: Network buffer 2189 * 2190 * Return: next buffer/packet 2191 */ 2192 static inline qdf_nbuf_t qdf_nbuf_queue_next(qdf_nbuf_t buf) 2193 { 2194 return __qdf_nbuf_queue_next(buf); 2195 } 2196 2197 /** 2198 * @qdf_nbuf_is_queue_empty() - check if the buf queue is empty 2199 * @nbq: Network buf queue handle 2200 * 2201 * Return: true if queue is empty 2202 * false if queue is not emty 2203 */ 2204 static inline bool qdf_nbuf_is_queue_empty(qdf_nbuf_queue_t *nbq) 2205 { 2206 return __qdf_nbuf_is_queue_empty(nbq); 2207 } 2208 2209 static inline qdf_nbuf_queue_t * 2210 qdf_nbuf_queue_append(qdf_nbuf_queue_t *dest, qdf_nbuf_queue_t *src) 2211 { 2212 return __qdf_nbuf_queue_append(dest, src); 2213 } 2214 2215 static inline void 2216 qdf_nbuf_queue_free(qdf_nbuf_queue_t *head) 2217 { 2218 qdf_nbuf_t buf = NULL; 2219 2220 while ((buf = qdf_nbuf_queue_remove(head)) != NULL) 2221 qdf_nbuf_free(buf); 2222 } 2223 2224 static inline qdf_nbuf_t 2225 qdf_nbuf_queue_first(qdf_nbuf_queue_t *head) 2226 { 2227 return __qdf_nbuf_queue_first(head); 2228 } 2229 2230 static inline qdf_nbuf_t 2231 qdf_nbuf_queue_last(qdf_nbuf_queue_t *head) 2232 { 2233 return __qdf_nbuf_queue_last(head); 2234 } 2235 2236 /** 2237 * qdf_nbuf_get_protocol() - return the protocol value of the skb 2238 * @skb: Pointer to network buffer 2239 * 2240 * Return: skb protocol 2241 */ 2242 static inline uint16_t qdf_nbuf_get_protocol(struct sk_buff *skb) 2243 { 2244 return __qdf_nbuf_get_protocol(skb); 2245 } 2246 2247 /** 2248 * qdf_nbuf_get_ip_summed() - return the ip checksum value of the skb 2249 * @skb: Pointer to network buffer 2250 * 2251 * Return: skb ip_summed 2252 */ 2253 static inline uint8_t qdf_nbuf_get_ip_summed(struct sk_buff *skb) 2254 { 2255 return __qdf_nbuf_get_ip_summed(skb); 2256 } 2257 2258 /** 2259 * qdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb 2260 * @skb: Pointer to network buffer 2261 * @ip_summed: ip checksum 2262 * 2263 * Return: none 2264 */ 2265 static inline void qdf_nbuf_set_ip_summed(struct sk_buff *skb, 2266 uint8_t ip_summed) 2267 { 2268 __qdf_nbuf_set_ip_summed(skb, ip_summed); 2269 } 2270 2271 /** 2272 * qdf_nbuf_set_next() - add a packet to a linked list 2273 * @this_buf: Predecessor buffer 2274 * @next_buf: Successor buffer 2275 * 2276 * This function can be used to directly link nbufs, rather than using 2277 * a separate network buffer queue object. 2278 * 2279 * Return: none 2280 */ 2281 static inline void qdf_nbuf_set_next(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf) 2282 { 2283 __qdf_nbuf_set_next(this_buf, next_buf); 2284 } 2285 2286 /* nbuf extension routines */ 2287 2288 /** 2289 * qdf_nbuf_set_next_ext() - link extension of this packet contained in a new 2290 * nbuf 2291 * @this_buf: predecessor buffer 2292 * @next_buf: successor buffer 2293 * 2294 * This function is used to link up many nbufs containing a single logical 2295 * packet - not a collection of packets. Do not use for linking the first 2296 * extension to the head 2297 * 2298 * Return: none 2299 */ 2300 static inline void 2301 qdf_nbuf_set_next_ext(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf) 2302 { 2303 __qdf_nbuf_set_next_ext(this_buf, next_buf); 2304 } 2305 2306 /** 2307 * qdf_nbuf_next_ext() - get the next packet extension in the linked list 2308 * @buf: Network buffer 2309 * 2310 * Return: Next network buffer in the linked list 2311 */ 2312 static inline qdf_nbuf_t qdf_nbuf_next_ext(qdf_nbuf_t buf) 2313 { 2314 return __qdf_nbuf_next_ext(buf); 2315 } 2316 2317 /** 2318 * qdf_nbuf_append_ext_list() - link list of packet extensions to the head 2319 * segment 2320 * @head_buf: Network buf holding head segment (single) 2321 * @ext_list: Network buf list holding linked extensions to the head 2322 * @ext_len: Total length of all buffers in the extension list 2323 * 2324 * This function is used to link up a list of packet extensions (seg1, 2, 2325 * ...) to the nbuf holding the head segment (seg0) 2326 * 2327 * Return: none 2328 */ 2329 static inline void 2330 qdf_nbuf_append_ext_list(qdf_nbuf_t head_buf, qdf_nbuf_t ext_list, 2331 qdf_size_t ext_len) 2332 { 2333 __qdf_nbuf_append_ext_list(head_buf, ext_list, ext_len); 2334 } 2335 2336 /** 2337 * qdf_nbuf_get_ext_list() - Get the link to extended nbuf list. 2338 * @head_buf: Network buf holding head segment (single) 2339 * 2340 * This ext_list is populated when we have Jumbo packet, for example in case of 2341 * monitor mode amsdu packet reception, and are stiched using frags_list. 2342 * 2343 * Return: Network buf list holding linked extensions from head buf. 2344 */ 2345 static inline qdf_nbuf_t qdf_nbuf_get_ext_list(qdf_nbuf_t head_buf) 2346 { 2347 return (qdf_nbuf_t)__qdf_nbuf_get_ext_list(head_buf); 2348 } 2349 2350 /** 2351 * qdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand 2352 * @buf: Network buffer 2353 * 2354 * Return: qdf_nbuf_tx_cksum_t checksum offload demand for the frame 2355 */ 2356 static inline qdf_nbuf_tx_cksum_t qdf_nbuf_get_tx_cksum(qdf_nbuf_t buf) 2357 { 2358 return __qdf_nbuf_get_tx_cksum(buf); 2359 } 2360 2361 /** 2362 * qdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to 2363 * indicate checksum info to the stack. 2364 * @buf: Network buffer 2365 * @cksum: Checksum 2366 * 2367 * Return: none 2368 */ 2369 static inline void 2370 qdf_nbuf_set_rx_cksum(qdf_nbuf_t buf, qdf_nbuf_rx_cksum_t *cksum) 2371 { 2372 __qdf_nbuf_set_rx_cksum(buf, cksum); 2373 } 2374 2375 /** 2376 * qdf_nbuf_get_tid() - this function extracts the TID value from nbuf 2377 * @buf: Network buffer 2378 * 2379 * Return: TID value 2380 */ 2381 static inline uint8_t qdf_nbuf_get_tid(qdf_nbuf_t buf) 2382 { 2383 return __qdf_nbuf_get_tid(buf); 2384 } 2385 2386 /** 2387 * qdf_nbuf_set_tid() - this function sets the TID value in nbuf 2388 * @buf: Network buffer 2389 * @tid: TID value 2390 * 2391 * Return: none 2392 */ 2393 static inline void qdf_nbuf_set_tid(qdf_nbuf_t buf, uint8_t tid) 2394 { 2395 __qdf_nbuf_set_tid(buf, tid); 2396 } 2397 2398 /** 2399 * qdf_nbuf_get_exemption_type() - this function extracts the exemption type 2400 * from nbuf 2401 * @buf: Network buffer 2402 * 2403 * Return: Exemption type 2404 */ 2405 static inline uint8_t qdf_nbuf_get_exemption_type(qdf_nbuf_t buf) 2406 { 2407 return __qdf_nbuf_get_exemption_type(buf); 2408 } 2409 2410 /** 2411 * qdf_nbuf_set_protocol() - this function peeks data into the buffer at given 2412 * offset 2413 * @buf: Network buffer 2414 * @proto: Protocol 2415 * 2416 * Return: none 2417 */ 2418 static inline void qdf_nbuf_set_protocol(qdf_nbuf_t buf, uint16_t proto) 2419 { 2420 __qdf_nbuf_set_protocol(buf, proto); 2421 } 2422 2423 /** 2424 * qdf_nbuf_trace_get_proto_type() - this function return packet proto type 2425 * @buf: Network buffer 2426 * 2427 * Return: Packet protocol type 2428 */ 2429 static inline uint8_t qdf_nbuf_trace_get_proto_type(qdf_nbuf_t buf) 2430 { 2431 return __qdf_nbuf_trace_get_proto_type(buf); 2432 } 2433 2434 /** 2435 * qdf_nbuf_reg_trace_cb() - this function registers protocol trace callback 2436 * @cb_func_ptr: Callback pointer 2437 * 2438 * Return: none 2439 */ 2440 static inline void qdf_nbuf_reg_trace_cb(qdf_nbuf_trace_update_t cb_func_ptr) 2441 { 2442 __qdf_nbuf_reg_trace_cb(cb_func_ptr); 2443 } 2444 2445 2446 /** 2447 * qdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download 2448 * @buf: Network buffer 2449 * @candi: Candidate of parallel download frame 2450 * 2451 * This function stores a flag specifying this TX frame is suitable for 2452 * downloading though a 2nd TX data pipe that is used for short frames for 2453 * protocols that can accept out-of-order delivery. 2454 * 2455 * Return: none 2456 */ 2457 static inline void 2458 qdf_nbuf_set_tx_parallel_dnload_frm(qdf_nbuf_t buf, uint8_t candi) 2459 { 2460 __qdf_nbuf_set_tx_htt2_frm(buf, candi); 2461 } 2462 2463 /** 2464 * qdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download 2465 * @buf: Network buffer 2466 * 2467 * This function return whether this TX frame is allow to download though a 2nd 2468 * TX data pipe or not. 2469 * 2470 * Return: none 2471 */ 2472 static inline uint8_t qdf_nbuf_get_tx_parallel_dnload_frm(qdf_nbuf_t buf) 2473 { 2474 return __qdf_nbuf_get_tx_htt2_frm(buf); 2475 } 2476 2477 /** 2478 * qdf_nbuf_get_dhcp_subtype() - get the subtype 2479 * of DHCP packet. 2480 * @buf: Pointer to DHCP packet buffer 2481 * 2482 * This func. returns the subtype of DHCP packet. 2483 * 2484 * Return: subtype of the DHCP packet. 2485 */ 2486 static inline enum qdf_proto_subtype 2487 qdf_nbuf_get_dhcp_subtype(qdf_nbuf_t buf) 2488 { 2489 return __qdf_nbuf_data_get_dhcp_subtype(qdf_nbuf_data(buf)); 2490 } 2491 2492 /** 2493 * qdf_nbuf_data_get_dhcp_subtype() - get the subtype 2494 * of DHCP packet. 2495 * @buf: Pointer to DHCP packet data buffer 2496 * 2497 * This func. returns the subtype of DHCP packet. 2498 * 2499 * Return: subtype of the DHCP packet. 2500 */ 2501 static inline enum qdf_proto_subtype 2502 qdf_nbuf_data_get_dhcp_subtype(uint8_t *data) 2503 { 2504 return __qdf_nbuf_data_get_dhcp_subtype(data); 2505 } 2506 2507 /** 2508 * qdf_nbuf_get_eapol_subtype() - get the subtype 2509 * of EAPOL packet. 2510 * @buf: Pointer to EAPOL packet buffer 2511 * 2512 * This func. returns the subtype of EAPOL packet. 2513 * 2514 * Return: subtype of the EAPOL packet. 2515 */ 2516 static inline enum qdf_proto_subtype 2517 qdf_nbuf_get_eapol_subtype(qdf_nbuf_t buf) 2518 { 2519 return __qdf_nbuf_data_get_eapol_subtype(qdf_nbuf_data(buf)); 2520 } 2521 2522 /** 2523 * qdf_nbuf_data_get_eapol_subtype() - get the subtype 2524 * of EAPOL packet. 2525 * @data: Pointer to EAPOL packet data buffer 2526 * 2527 * This func. returns the subtype of EAPOL packet. 2528 * 2529 * Return: subtype of the EAPOL packet. 2530 */ 2531 static inline enum qdf_proto_subtype 2532 qdf_nbuf_data_get_eapol_subtype(uint8_t *data) 2533 { 2534 return __qdf_nbuf_data_get_eapol_subtype(data); 2535 } 2536 2537 /** 2538 * qdf_nbuf_get_arp_subtype() - get the subtype 2539 * of ARP packet. 2540 * @buf: Pointer to ARP packet buffer 2541 * 2542 * This func. returns the subtype of ARP packet. 2543 * 2544 * Return: subtype of the ARP packet. 2545 */ 2546 static inline enum qdf_proto_subtype 2547 qdf_nbuf_get_arp_subtype(qdf_nbuf_t buf) 2548 { 2549 return __qdf_nbuf_data_get_arp_subtype(qdf_nbuf_data(buf)); 2550 } 2551 2552 /** 2553 * qdf_nbuf_data_get_arp_subtype() - get the subtype 2554 * of ARP packet. 2555 * @data: Pointer to ARP packet data buffer 2556 * 2557 * This func. returns the subtype of ARP packet. 2558 * 2559 * Return: subtype of the ARP packet. 2560 */ 2561 static inline enum qdf_proto_subtype 2562 qdf_nbuf_data_get_arp_subtype(uint8_t *data) 2563 { 2564 return __qdf_nbuf_data_get_arp_subtype(data); 2565 } 2566 2567 /** 2568 * qdf_nbuf_get_icmp_subtype() - get the subtype 2569 * of IPV4 ICMP packet. 2570 * @buf: Pointer to IPV4 ICMP packet buffer 2571 * 2572 * This func. returns the subtype of ICMP packet. 2573 * 2574 * Return: subtype of the ICMP packet. 2575 */ 2576 static inline enum qdf_proto_subtype 2577 qdf_nbuf_get_icmp_subtype(qdf_nbuf_t buf) 2578 { 2579 return __qdf_nbuf_data_get_icmp_subtype(qdf_nbuf_data(buf)); 2580 } 2581 2582 /** 2583 * qdf_nbuf_data_get_icmp_subtype() - get the subtype 2584 * of IPV4 ICMP packet. 2585 * @data: Pointer to IPV4 ICMP packet data buffer 2586 * 2587 * This func. returns the subtype of ICMP packet. 2588 * 2589 * Return: subtype of the ICMP packet. 2590 */ 2591 static inline enum qdf_proto_subtype 2592 qdf_nbuf_data_get_icmp_subtype(uint8_t *data) 2593 { 2594 return __qdf_nbuf_data_get_icmp_subtype(data); 2595 } 2596 2597 /** 2598 * qdf_nbuf_get_icmpv6_subtype() - get the subtype 2599 * of IPV6 ICMPV6 packet. 2600 * @buf: Pointer to IPV6 ICMPV6 packet buffer 2601 * 2602 * This func. returns the subtype of ICMPV6 packet. 2603 * 2604 * Return: subtype of the ICMPV6 packet. 2605 */ 2606 static inline enum qdf_proto_subtype 2607 qdf_nbuf_get_icmpv6_subtype(qdf_nbuf_t buf) 2608 { 2609 return __qdf_nbuf_data_get_icmpv6_subtype(qdf_nbuf_data(buf)); 2610 } 2611 2612 /** 2613 * qdf_nbuf_data_get_icmpv6_subtype() - get the subtype 2614 * of IPV6 ICMPV6 packet. 2615 * @data: Pointer to IPV6 ICMPV6 packet data buffer 2616 * 2617 * This func. returns the subtype of ICMPV6 packet. 2618 * 2619 * Return: subtype of the ICMPV6 packet. 2620 */ 2621 static inline enum qdf_proto_subtype 2622 qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data) 2623 { 2624 return __qdf_nbuf_data_get_icmpv6_subtype(data); 2625 } 2626 2627 /** 2628 * qdf_nbuf_data_get_ipv4_proto() - get the proto type 2629 * of IPV4 packet. 2630 * @data: Pointer to IPV4 packet data buffer 2631 * 2632 * This func. returns the proto type of IPV4 packet. 2633 * 2634 * Return: proto type of IPV4 packet. 2635 */ 2636 static inline uint8_t 2637 qdf_nbuf_data_get_ipv4_proto(uint8_t *data) 2638 { 2639 return __qdf_nbuf_data_get_ipv4_proto(data); 2640 } 2641 2642 /** 2643 * qdf_nbuf_data_get_ipv6_proto() - get the proto type 2644 * of IPV6 packet. 2645 * @data: Pointer to IPV6 packet data buffer 2646 * 2647 * This func. returns the proto type of IPV6 packet. 2648 * 2649 * Return: proto type of IPV6 packet. 2650 */ 2651 static inline uint8_t 2652 qdf_nbuf_data_get_ipv6_proto(uint8_t *data) 2653 { 2654 return __qdf_nbuf_data_get_ipv6_proto(data); 2655 } 2656 2657 /** 2658 * qdf_nbuf_is_ipv4_pkt() - check if packet is a ipv4 packet or not 2659 * @buf: buffer 2660 * 2661 * This api is for Tx packets. 2662 * 2663 * Return: true if packet is ipv4 packet 2664 */ 2665 static inline 2666 bool qdf_nbuf_is_ipv4_pkt(qdf_nbuf_t buf) 2667 { 2668 return __qdf_nbuf_data_is_ipv4_pkt(qdf_nbuf_data(buf)); 2669 } 2670 2671 /** 2672 * qdf_nbuf_data_is_ipv4_pkt() - check if packet is a ipv4 packet or not 2673 * @data: data 2674 * 2675 * This api is for Tx packets. 2676 * 2677 * Return: true if packet is ipv4 packet 2678 */ 2679 static inline 2680 bool qdf_nbuf_data_is_ipv4_pkt(uint8_t *data) 2681 { 2682 return __qdf_nbuf_data_is_ipv4_pkt(data); 2683 } 2684 2685 /** 2686 * qdf_nbuf_is_ipv4_dhcp_pkt() - check if packet is a dhcp packet or not 2687 * @buf: buffer 2688 * 2689 * This api is for ipv4 packet. 2690 * 2691 * Return: true if packet is DHCP packet 2692 */ 2693 static inline 2694 bool qdf_nbuf_is_ipv4_dhcp_pkt(qdf_nbuf_t buf) 2695 { 2696 return __qdf_nbuf_data_is_ipv4_dhcp_pkt(qdf_nbuf_data(buf)); 2697 } 2698 2699 /** 2700 * qdf_nbuf_data_is_ipv4_dhcp_pkt() - check if it is DHCP packet. 2701 * @data: Pointer to DHCP packet data buffer 2702 * 2703 * This func. checks whether it is a DHCP packet or not. 2704 * 2705 * Return: true if it is a DHCP packet 2706 * false if not 2707 */ 2708 static inline 2709 bool qdf_nbuf_data_is_ipv4_dhcp_pkt(uint8_t *data) 2710 { 2711 return __qdf_nbuf_data_is_ipv4_dhcp_pkt(data); 2712 } 2713 2714 /** 2715 * qdf_nbuf_data_is_ipv6_mdsn_pkt() - check if it is MDNS packet. 2716 * @data: Pointer to packet data buffer 2717 * 2718 * This func. checks whether it is a MDNS packet or not. 2719 * 2720 * Return: true if it is a MDNS packet, false if not 2721 */ 2722 static inline 2723 bool qdf_nbuf_is_ipv6_mdns_pkt(qdf_nbuf_t buf) 2724 { 2725 return __qdf_nbuf_data_is_ipv6_mdns_pkt(qdf_nbuf_data(buf)); 2726 } 2727 2728 /** 2729 * qdf_nbuf_data_is_ipv6_dhcp_pkt() - check if it is DHCP packet. 2730 * @data: Pointer to DHCP packet data buffer 2731 * 2732 * This func. checks whether it is a DHCP packet or not. 2733 * 2734 * Return: true if it is a DHCP packet 2735 * false if not 2736 */ 2737 static inline 2738 bool qdf_nbuf_is_ipv6_dhcp_pkt(qdf_nbuf_t buf) 2739 { 2740 return __qdf_nbuf_data_is_ipv6_dhcp_pkt(qdf_nbuf_data(buf)); 2741 } 2742 2743 /** 2744 * qdf_nbuf_is_ipv4_eapol_pkt() - check if packet is a eapol packet or not 2745 * @buf: buffer 2746 * 2747 * This api is for ipv4 packet. 2748 * 2749 * Return: true if packet is EAPOL packet 2750 */ 2751 static inline 2752 bool qdf_nbuf_is_ipv4_eapol_pkt(qdf_nbuf_t buf) 2753 { 2754 return __qdf_nbuf_data_is_ipv4_eapol_pkt(qdf_nbuf_data(buf)); 2755 } 2756 2757 /** 2758 * qdf_nbuf_data_is_ipv4_eapol_pkt() - check if it is EAPOL packet. 2759 * @data: Pointer to EAPOL packet data buffer 2760 * 2761 * This func. checks whether it is a EAPOL packet or not. 2762 * 2763 * Return: true if it is a EAPOL packet 2764 * false if not 2765 */ 2766 static inline 2767 bool qdf_nbuf_data_is_ipv4_eapol_pkt(uint8_t *data) 2768 { 2769 return __qdf_nbuf_data_is_ipv4_eapol_pkt(data); 2770 } 2771 2772 /** 2773 * qdf_nbuf_is_ipv4_wapi_pkt() - check if packet is a wapi packet or not 2774 * @buf: buffer 2775 * 2776 * This api is for ipv4 packet. 2777 * 2778 * Return: true if packet is WAPI packet 2779 */ 2780 static inline 2781 bool qdf_nbuf_is_ipv4_wapi_pkt(qdf_nbuf_t buf) 2782 { 2783 return __qdf_nbuf_is_ipv4_wapi_pkt(buf); 2784 } 2785 2786 /** 2787 * qdf_nbuf_is_ipv4_tdls_pkt() - check if packet is a tdls packet or not 2788 * @buf: buffer 2789 * 2790 * This api is for ipv4 packet. 2791 * 2792 * Return: true if packet is TDLS packet 2793 */ 2794 static inline 2795 bool qdf_nbuf_is_ipv4_tdls_pkt(qdf_nbuf_t buf) 2796 { 2797 return __qdf_nbuf_is_ipv4_tdls_pkt(buf); 2798 } 2799 2800 /** 2801 * qdf_nbuf_is_ipv4_arp_pkt() - check if packet is a arp packet or not 2802 * @buf: buffer 2803 * 2804 * This api is for ipv4 packet. 2805 * 2806 * Return: true if packet is ARP packet 2807 */ 2808 static inline 2809 bool qdf_nbuf_is_ipv4_arp_pkt(qdf_nbuf_t buf) 2810 { 2811 return __qdf_nbuf_data_is_ipv4_arp_pkt(qdf_nbuf_data(buf)); 2812 } 2813 2814 /** 2815 * qdf_nbuf_data_is_ipv4_arp_pkt() - check if it is ARP packet. 2816 * @data: Pointer to ARP packet data buffer 2817 * 2818 * This func. checks whether it is a ARP packet or not. 2819 * 2820 * Return: TRUE if it is a ARP packet 2821 * FALSE if not 2822 */ 2823 static inline 2824 bool qdf_nbuf_data_is_ipv4_arp_pkt(uint8_t *data) 2825 { 2826 return __qdf_nbuf_data_is_ipv4_arp_pkt(data); 2827 } 2828 2829 /** 2830 * qdf_nbuf_data_is_arp_req() - check if ARP packet is request. 2831 * @buf: buffer 2832 * 2833 * This func. checks whether it is a ARP request or not. 2834 * 2835 * Return: true if it is a ARP request or FALSE if not 2836 */ 2837 static inline 2838 bool qdf_nbuf_data_is_arp_req(qdf_nbuf_t buf) 2839 { 2840 return __qdf_nbuf_data_is_arp_req(qdf_nbuf_data(buf)); 2841 } 2842 2843 /** 2844 * qdf_nbuf_data_is_arp_rsp() - check if ARP packet is response. 2845 * @buf: buffer 2846 * 2847 * This func. checks whether it is a ARP response or not. 2848 * 2849 * Return: true if it is a ARP response or FALSE if not 2850 */ 2851 static inline 2852 bool qdf_nbuf_data_is_arp_rsp(qdf_nbuf_t buf) 2853 { 2854 return __qdf_nbuf_data_is_arp_rsp(qdf_nbuf_data(buf)); 2855 } 2856 2857 /** 2858 * qdf_nbuf_data_get_arp_src_ip() - get ARP packet source IP gateway. 2859 * @buf: buffer 2860 * 2861 * Return: ARP packet source IP value. 2862 */ 2863 static inline 2864 uint32_t qdf_nbuf_get_arp_src_ip(qdf_nbuf_t buf) 2865 { 2866 return __qdf_nbuf_get_arp_src_ip(qdf_nbuf_data(buf)); 2867 } 2868 2869 /** 2870 * qdf_nbuf_data_get_arp_tgt_ip() - get ARP packet target IP gateway. 2871 * @buf: buffer 2872 * 2873 * Return: ARP packet target IP value. 2874 */ 2875 static inline 2876 uint32_t qdf_nbuf_get_arp_tgt_ip(qdf_nbuf_t buf) 2877 { 2878 return __qdf_nbuf_get_arp_tgt_ip(qdf_nbuf_data(buf)); 2879 } 2880 2881 /** 2882 * qdf_nbuf_get_dns_domain_name() - get dns domain name of required length 2883 * @buf: buffer 2884 * @len: length to copy 2885 * 2886 * Return: dns domain name 2887 */ 2888 static inline 2889 uint8_t *qdf_nbuf_get_dns_domain_name(qdf_nbuf_t buf, uint32_t len) 2890 { 2891 return __qdf_nbuf_get_dns_domain_name(qdf_nbuf_data(buf), len); 2892 } 2893 2894 /** 2895 * qdf_nbuf_data_is_dns_query() - check if skb data is a dns query 2896 * @buf: buffer 2897 * 2898 * Return: true if packet is dns query packet. 2899 * false otherwise. 2900 */ 2901 static inline 2902 bool qdf_nbuf_data_is_dns_query(qdf_nbuf_t buf) 2903 { 2904 return __qdf_nbuf_data_is_dns_query(qdf_nbuf_data(buf)); 2905 } 2906 2907 /** 2908 * qdf_nbuf_data_is_dns_response() - check if skb data is a dns response 2909 * @buf: buffer 2910 * 2911 * Return: true if packet is dns response packet. 2912 * false otherwise. 2913 */ 2914 static inline 2915 bool qdf_nbuf_data_is_dns_response(qdf_nbuf_t buf) 2916 { 2917 return __qdf_nbuf_data_is_dns_response(qdf_nbuf_data(buf)); 2918 } 2919 2920 /** 2921 * qdf_nbuf_data_is_tcp_syn() - check if skb data is a tcp syn 2922 * @buf: buffer 2923 * 2924 * Return: true if packet is tcp syn packet. 2925 * false otherwise. 2926 */ 2927 static inline 2928 bool qdf_nbuf_data_is_tcp_syn(qdf_nbuf_t buf) 2929 { 2930 return __qdf_nbuf_data_is_tcp_syn(qdf_nbuf_data(buf)); 2931 } 2932 2933 /** 2934 * qdf_nbuf_data_is_tcp_syn_ack() - check if skb data is a tcp syn ack 2935 * @buf: buffer 2936 * 2937 * Return: true if packet is tcp syn ack packet. 2938 * false otherwise. 2939 */ 2940 static inline 2941 bool qdf_nbuf_data_is_tcp_syn_ack(qdf_nbuf_t buf) 2942 { 2943 return __qdf_nbuf_data_is_tcp_syn_ack(qdf_nbuf_data(buf)); 2944 } 2945 2946 /** 2947 * qdf_nbuf_data_is_tcp_ack() - check if skb data is a tcp ack 2948 * @buf: buffer 2949 * 2950 * Return: true if packet is tcp ack packet. 2951 * false otherwise. 2952 */ 2953 static inline 2954 bool qdf_nbuf_data_is_tcp_ack(qdf_nbuf_t buf) 2955 { 2956 return __qdf_nbuf_data_is_tcp_ack(qdf_nbuf_data(buf)); 2957 } 2958 2959 /** 2960 * qdf_nbuf_data_get_tcp_src_port() - get tcp src port 2961 * @buf: buffer 2962 * 2963 * Return: tcp source port value. 2964 */ 2965 static inline 2966 uint16_t qdf_nbuf_data_get_tcp_src_port(qdf_nbuf_t buf) 2967 { 2968 return __qdf_nbuf_data_get_tcp_src_port(qdf_nbuf_data(buf)); 2969 } 2970 2971 /** 2972 * qdf_nbuf_data_get_tcp_dst_port() - get tcp dst port 2973 * @buf: buffer 2974 * 2975 * Return: tcp destination port value. 2976 */ 2977 static inline 2978 uint16_t qdf_nbuf_data_get_tcp_dst_port(qdf_nbuf_t buf) 2979 { 2980 return __qdf_nbuf_data_get_tcp_dst_port(qdf_nbuf_data(buf)); 2981 } 2982 2983 /** 2984 * qdf_nbuf_data_is_icmpv4_req() - check if ICMPv4 packet is request. 2985 * @buf: buffer 2986 * 2987 * This func. checks whether it is a ICMPv4 request or not. 2988 * 2989 * Return: true if it is a ICMPv4 request or fALSE if not 2990 */ 2991 static inline 2992 bool qdf_nbuf_data_is_icmpv4_req(qdf_nbuf_t buf) 2993 { 2994 return __qdf_nbuf_data_is_icmpv4_req(qdf_nbuf_data(buf)); 2995 } 2996 2997 /** 2998 * qdf_nbuf_data_is_icmpv4_rsp() - check if ICMPv4 packet is res 2999 * @buf: buffer 3000 * 3001 * Return: true if packet is icmpv4 response 3002 * false otherwise. 3003 */ 3004 static inline 3005 bool qdf_nbuf_data_is_icmpv4_rsp(qdf_nbuf_t buf) 3006 { 3007 return __qdf_nbuf_data_is_icmpv4_rsp(qdf_nbuf_data(buf)); 3008 } 3009 3010 /** 3011 * qdf_nbuf_get_icmpv4_src_ip() - get icmpv4 src IP 3012 * @buf: buffer 3013 * 3014 * Return: icmpv4 packet source IP value. 3015 */ 3016 static inline 3017 uint32_t qdf_nbuf_get_icmpv4_src_ip(qdf_nbuf_t buf) 3018 { 3019 return __qdf_nbuf_get_icmpv4_src_ip(qdf_nbuf_data(buf)); 3020 } 3021 3022 /** 3023 * qdf_nbuf_data_get_icmpv4_tgt_ip() - get icmpv4 target IP 3024 * @buf: buffer 3025 * 3026 * Return: icmpv4 packet target IP value. 3027 */ 3028 static inline 3029 uint32_t qdf_nbuf_get_icmpv4_tgt_ip(qdf_nbuf_t buf) 3030 { 3031 return __qdf_nbuf_get_icmpv4_tgt_ip(qdf_nbuf_data(buf)); 3032 } 3033 3034 /** 3035 * qdf_nbuf_is_ipv6_pkt() - check if it is IPV6 packet. 3036 * @buf: Pointer to IPV6 packet buffer 3037 * 3038 * This func. checks whether it is a IPV6 packet or not. 3039 * 3040 * Return: TRUE if it is a IPV6 packet 3041 * FALSE if not 3042 */ 3043 static inline 3044 bool qdf_nbuf_is_ipv6_pkt(qdf_nbuf_t buf) 3045 { 3046 return __qdf_nbuf_data_is_ipv6_pkt(qdf_nbuf_data(buf)); 3047 } 3048 3049 /** 3050 * qdf_nbuf_data_is_ipv6_pkt() - check if it is IPV6 packet. 3051 * @data: Pointer to IPV6 packet data buffer 3052 * 3053 * This func. checks whether it is a IPV6 packet or not. 3054 * 3055 * Return: TRUE if it is a IPV6 packet 3056 * FALSE if not 3057 */ 3058 static inline 3059 bool qdf_nbuf_data_is_ipv6_pkt(uint8_t *data) 3060 { 3061 return __qdf_nbuf_data_is_ipv6_pkt(data); 3062 } 3063 3064 /** 3065 * qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet. 3066 * @data: Pointer to IPV4 packet data buffer 3067 * 3068 * This func. checks whether it is a IPV4 multicast packet or not. 3069 * 3070 * Return: TRUE if it is a IPV4 multicast packet 3071 * FALSE if not 3072 */ 3073 static inline 3074 bool qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data) 3075 { 3076 return __qdf_nbuf_data_is_ipv4_mcast_pkt(data); 3077 } 3078 3079 /** 3080 * qdf_nbuf_data_is_ipv6_mcast_pkt() - check if it is IPV6 multicast packet. 3081 * @data: Pointer to IPV6 packet data buffer 3082 * 3083 * This func. checks whether it is a IPV6 multicast packet or not. 3084 * 3085 * Return: TRUE if it is a IPV6 multicast packet 3086 * FALSE if not 3087 */ 3088 static inline 3089 bool qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data) 3090 { 3091 return __qdf_nbuf_data_is_ipv6_mcast_pkt(data); 3092 } 3093 3094 /** 3095 * qdf_nbuf_is_icmp_pkt() - check if it is IPV4 ICMP packet. 3096 * @buf: Pointer to IPV4 ICMP packet buffer 3097 * 3098 * This func. checks whether it is a ICMP packet or not. 3099 * 3100 * Return: TRUE if it is a ICMP packet 3101 * FALSE if not 3102 */ 3103 static inline 3104 bool qdf_nbuf_is_icmp_pkt(qdf_nbuf_t buf) 3105 { 3106 return __qdf_nbuf_data_is_icmp_pkt(qdf_nbuf_data(buf)); 3107 } 3108 3109 /** 3110 * qdf_nbuf_data_is_icmp_pkt() - check if it is IPV4 ICMP packet. 3111 * @data: Pointer to IPV4 ICMP packet data buffer 3112 * 3113 * This func. checks whether it is a ICMP packet or not. 3114 * 3115 * Return: TRUE if it is a ICMP packet 3116 * FALSE if not 3117 */ 3118 static inline 3119 bool qdf_nbuf_data_is_icmp_pkt(uint8_t *data) 3120 { 3121 return __qdf_nbuf_data_is_icmp_pkt(data); 3122 } 3123 3124 /** 3125 * qdf_nbuf_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet. 3126 * @buf: Pointer to IPV6 ICMPV6 packet buffer 3127 * 3128 * This func. checks whether it is a ICMPV6 packet or not. 3129 * 3130 * Return: TRUE if it is a ICMPV6 packet 3131 * FALSE if not 3132 */ 3133 static inline 3134 bool qdf_nbuf_is_icmpv6_pkt(qdf_nbuf_t buf) 3135 { 3136 return __qdf_nbuf_data_is_icmpv6_pkt(qdf_nbuf_data(buf)); 3137 } 3138 3139 /** 3140 * qdf_nbuf_data_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet. 3141 * @data: Pointer to IPV6 ICMPV6 packet data buffer 3142 * 3143 * This func. checks whether it is a ICMPV6 packet or not. 3144 * 3145 * Return: TRUE if it is a ICMPV6 packet 3146 * FALSE if not 3147 */ 3148 static inline 3149 bool qdf_nbuf_data_is_icmpv6_pkt(uint8_t *data) 3150 { 3151 return __qdf_nbuf_data_is_icmpv6_pkt(data); 3152 } 3153 3154 /** 3155 * qdf_nbuf_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet. 3156 * @buf: Pointer to IPV4 UDP packet buffer 3157 * 3158 * This func. checks whether it is a IPV4 UDP packet or not. 3159 * 3160 * Return: TRUE if it is a IPV4 UDP packet 3161 * FALSE if not 3162 */ 3163 static inline 3164 bool qdf_nbuf_is_ipv4_udp_pkt(qdf_nbuf_t buf) 3165 { 3166 return __qdf_nbuf_data_is_ipv4_udp_pkt(qdf_nbuf_data(buf)); 3167 } 3168 3169 /** 3170 * qdf_nbuf_data_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet. 3171 * @data: Pointer to IPV4 UDP packet data buffer 3172 * 3173 * This func. checks whether it is a IPV4 UDP packet or not. 3174 * 3175 * Return: TRUE if it is a IPV4 UDP packet 3176 * FALSE if not 3177 */ 3178 static inline 3179 bool qdf_nbuf_data_is_ipv4_udp_pkt(uint8_t *data) 3180 { 3181 return __qdf_nbuf_data_is_ipv4_udp_pkt(data); 3182 } 3183 3184 /** 3185 * qdf_nbuf_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet. 3186 * @buf: Pointer to IPV4 TCP packet buffer 3187 * 3188 * This func. checks whether it is a IPV4 TCP packet or not. 3189 * 3190 * Return: TRUE if it is a IPV4 TCP packet 3191 * FALSE if not 3192 */ 3193 static inline 3194 bool qdf_nbuf_is_ipv4_tcp_pkt(qdf_nbuf_t buf) 3195 { 3196 return __qdf_nbuf_data_is_ipv4_tcp_pkt(qdf_nbuf_data(buf)); 3197 } 3198 3199 /** 3200 * qdf_nbuf_data_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet. 3201 * @data: Pointer to IPV4 TCP packet data buffer 3202 * 3203 * This func. checks whether it is a IPV4 TCP packet or not. 3204 * 3205 * Return: TRUE if it is a IPV4 TCP packet 3206 * FALSE if not 3207 */ 3208 static inline 3209 bool qdf_nbuf_data_is_ipv4_tcp_pkt(uint8_t *data) 3210 { 3211 return __qdf_nbuf_data_is_ipv4_tcp_pkt(data); 3212 } 3213 3214 /** 3215 * qdf_nbuf_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet. 3216 * @buf: Pointer to IPV6 UDP packet buffer 3217 * 3218 * This func. checks whether it is a IPV6 UDP packet or not. 3219 * 3220 * Return: TRUE if it is a IPV6 UDP packet 3221 * FALSE if not 3222 */ 3223 static inline 3224 bool qdf_nbuf_is_ipv6_udp_pkt(qdf_nbuf_t buf) 3225 { 3226 return __qdf_nbuf_data_is_ipv6_udp_pkt(qdf_nbuf_data(buf)); 3227 } 3228 3229 /** 3230 * qdf_nbuf_data_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet. 3231 * @data: Pointer to IPV6 UDP packet data buffer 3232 * 3233 * This func. checks whether it is a IPV6 UDP packet or not. 3234 * 3235 * Return: TRUE if it is a IPV6 UDP packet 3236 * FALSE if not 3237 */ 3238 static inline 3239 bool qdf_nbuf_data_is_ipv6_udp_pkt(uint8_t *data) 3240 { 3241 return __qdf_nbuf_data_is_ipv6_udp_pkt(data); 3242 } 3243 3244 /** 3245 * qdf_nbuf_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet. 3246 * @buf: Pointer to IPV6 TCP packet buffer 3247 * 3248 * This func. checks whether it is a IPV6 TCP packet or not. 3249 * 3250 * Return: TRUE if it is a IPV6 TCP packet 3251 * FALSE if not 3252 */ 3253 static inline 3254 bool qdf_nbuf_is_ipv6_tcp_pkt(qdf_nbuf_t buf) 3255 { 3256 return __qdf_nbuf_data_is_ipv6_tcp_pkt(qdf_nbuf_data(buf)); 3257 } 3258 3259 /** 3260 * qdf_nbuf_data_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet. 3261 * @data: Pointer to IPV6 TCP packet data buffer 3262 * 3263 * This func. checks whether it is a IPV6 TCP packet or not. 3264 * 3265 * Return: TRUE if it is a IPV6 TCP packet 3266 * FALSE if not 3267 */ 3268 static inline 3269 bool qdf_nbuf_data_is_ipv6_tcp_pkt(uint8_t *data) 3270 { 3271 return __qdf_nbuf_data_is_ipv6_tcp_pkt(data); 3272 } 3273 3274 /** 3275 * qdf_nbuf_is_bcast_pkt() - check if it is broadcast packet. 3276 * @buf: Network buffer 3277 * 3278 * This func. checks whether packet is broadcast or not. 3279 * 3280 * Return: TRUE if it is broadcast packet 3281 * FALSE if not 3282 */ 3283 static inline 3284 bool qdf_nbuf_is_bcast_pkt(qdf_nbuf_t buf) 3285 { 3286 return __qdf_nbuf_is_bcast_pkt(buf); 3287 } 3288 3289 /** 3290 * qdf_nbuf_reset_num_frags() - decrement the number of fragments 3291 * @buf: Network buffer 3292 * 3293 * Return: Number of fragments 3294 */ 3295 static inline void qdf_nbuf_reset_num_frags(qdf_nbuf_t buf) 3296 { 3297 __qdf_nbuf_reset_num_frags(buf); 3298 } 3299 3300 /** 3301 * qdf_dmaaddr_to_32s - return high and low parts of dma_addr 3302 * 3303 * Returns the high and low 32-bits of the DMA addr in the provided ptrs 3304 * 3305 * Return: N/A 3306 */ 3307 static inline void qdf_dmaaddr_to_32s(qdf_dma_addr_t dmaaddr, 3308 uint32_t *lo, uint32_t *hi) 3309 { 3310 return __qdf_dmaaddr_to_32s(dmaaddr, lo, hi); 3311 } 3312 3313 /** 3314 * qdf_nbuf_get_tso_info() - function to divide a jumbo TSO 3315 * network buffer into segments 3316 * @nbuf: network buffer to be segmented 3317 * @tso_info: This is the output. The information about the 3318 * TSO segments will be populated within this. 3319 * 3320 * This function fragments a TCP jumbo packet into smaller 3321 * segments to be transmitted by the driver. It chains the TSO 3322 * segments created into a list. 3323 * 3324 * Return: number of TSO segments 3325 */ 3326 static inline uint32_t qdf_nbuf_get_tso_info(qdf_device_t osdev, 3327 qdf_nbuf_t nbuf, struct qdf_tso_info_t *tso_info) 3328 { 3329 return __qdf_nbuf_get_tso_info(osdev, nbuf, tso_info); 3330 } 3331 3332 /** 3333 * qdf_nbuf_unmap_tso_segment() - function to dma unmap TSO segment element 3334 * 3335 * @osdev: qdf device handle 3336 * @tso_seg: TSO segment element to be unmapped 3337 * @is_last_seg: whether this is last tso seg or not 3338 * 3339 * Return: none 3340 */ 3341 static inline void qdf_nbuf_unmap_tso_segment(qdf_device_t osdev, 3342 struct qdf_tso_seg_elem_t *tso_seg, 3343 bool is_last_seg) 3344 { 3345 return __qdf_nbuf_unmap_tso_segment(osdev, tso_seg, is_last_seg); 3346 } 3347 3348 /** 3349 * qdf_nbuf_get_tcp_payload_len() - function to return the tso payload len 3350 * @nbuf: network buffer 3351 * 3352 * Return: size of the tso packet 3353 */ 3354 static inline size_t qdf_nbuf_get_tcp_payload_len(qdf_nbuf_t nbuf) 3355 { 3356 return __qdf_nbuf_get_tcp_payload_len(nbuf); 3357 } 3358 3359 /** 3360 * qdf_nbuf_get_tso_num_seg() - function to calculate the number 3361 * of TCP segments within the TSO jumbo packet 3362 * @nbuf: TSO jumbo network buffer to be segmented 3363 * 3364 * This function calculates the number of TCP segments that the 3365 network buffer can be divided into. 3366 * 3367 * Return: number of TCP segments 3368 */ 3369 static inline uint32_t qdf_nbuf_get_tso_num_seg(qdf_nbuf_t nbuf) 3370 { 3371 return __qdf_nbuf_get_tso_num_seg(nbuf); 3372 } 3373 3374 /** 3375 * qdf_nbuf_get_gso_segs() - Return the number of gso segments in 3376 * nbuf 3377 * @nbuf: Network buffer 3378 * 3379 * Return: number of gso segments in nbuf 3380 */ 3381 static inline uint16_t qdf_nbuf_get_gso_segs(qdf_nbuf_t nbuf) 3382 { 3383 return __qdf_nbuf_get_gso_segs(nbuf); 3384 } 3385 3386 /** 3387 * qdf_nbuf_inc_users() - function to increment the number of 3388 * users referencing this network buffer 3389 * 3390 * @nbuf: network buffer 3391 * 3392 * This function increments the number of users referencing this 3393 * network buffer 3394 * 3395 * Return: the network buffer 3396 */ 3397 static inline qdf_nbuf_t qdf_nbuf_inc_users(qdf_nbuf_t nbuf) 3398 { 3399 return __qdf_nbuf_inc_users(nbuf); 3400 } 3401 3402 /** 3403 * qdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb 3404 * 3405 * @nbuf: Network buffer (skb on linux) 3406 * 3407 * This function returns the values of data_attr field 3408 * in struct cvg_nbuf_cb{}, to which skb->cb is typecast. 3409 * This value is actually the value programmed in CE descriptor. 3410 * 3411 * Return: Value of data_attr 3412 */ 3413 static inline uint32_t qdf_nbuf_data_attr_get(qdf_nbuf_t buf) 3414 { 3415 return __qdf_nbuf_data_attr_get(buf); 3416 } 3417 3418 /** 3419 * qdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb 3420 * 3421 * @nbuf: Network buffer (skb on linux) 3422 * @data_attr: Value to be stored cvg_nbuf_cb->data_attr 3423 * 3424 * This function stores the value to be programmed in CE 3425 * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{} 3426 * 3427 * Return: void 3428 */ 3429 static inline 3430 void qdf_nbuf_data_attr_set(qdf_nbuf_t buf, uint32_t data_attr) 3431 { 3432 __qdf_nbuf_data_attr_set(buf, data_attr); 3433 } 3434 3435 /** 3436 * qdf_nbuf_tx_info_get() - Parse skb and get Tx metadata 3437 * 3438 * @nbuf: Network buffer (skb on linux) 3439 * 3440 * This function parses the payload to figure out relevant 3441 * Tx meta-data e.g. whether to enable tx_classify bit 3442 * in CE. 3443 * 3444 * Return: void 3445 */ 3446 #define qdf_nbuf_tx_info_get __qdf_nbuf_tx_info_get 3447 3448 void qdf_nbuf_set_state(qdf_nbuf_t nbuf, uint8_t current_state); 3449 void qdf_nbuf_tx_desc_count_display(void); 3450 void qdf_nbuf_tx_desc_count_clear(void); 3451 3452 static inline qdf_nbuf_t 3453 qdf_nbuf_realloc_headroom(qdf_nbuf_t buf, uint32_t headroom) 3454 { 3455 return __qdf_nbuf_realloc_headroom(buf, headroom); 3456 } 3457 3458 static inline qdf_nbuf_t 3459 qdf_nbuf_realloc_tailroom(qdf_nbuf_t buf, uint32_t tailroom) 3460 { 3461 return __qdf_nbuf_realloc_tailroom(buf, tailroom); 3462 } 3463 3464 static inline qdf_nbuf_t 3465 qdf_nbuf_expand(qdf_nbuf_t buf, uint32_t headroom, uint32_t tailroom) 3466 { 3467 return __qdf_nbuf_expand(buf, headroom, tailroom); 3468 } 3469 3470 static inline int 3471 qdf_nbuf_linearize(qdf_nbuf_t buf) 3472 { 3473 return __qdf_nbuf_linearize(buf); 3474 } 3475 3476 static inline bool 3477 qdf_nbuf_is_cloned(qdf_nbuf_t buf) 3478 { 3479 return __qdf_nbuf_is_cloned(buf); 3480 } 3481 3482 static inline void 3483 qdf_nbuf_frag_info(qdf_nbuf_t buf, qdf_sglist_t *sg) 3484 { 3485 __qdf_nbuf_frag_info(buf, sg); 3486 } 3487 3488 static inline qdf_nbuf_tx_cksum_t 3489 qdf_nbuf_tx_cksum_info(qdf_nbuf_t buf, uint8_t **hdr_off, uint8_t **where) 3490 { 3491 return __qdf_nbuf_tx_cksum_info(buf, hdr_off, where); 3492 } 3493 3494 static inline void qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf) 3495 { 3496 __qdf_nbuf_reset_ctxt(nbuf); 3497 } 3498 3499 static inline void qdf_nbuf_init(qdf_nbuf_t buf) 3500 { 3501 __qdf_nbuf_init(buf); 3502 } 3503 3504 static inline void *qdf_nbuf_network_header(qdf_nbuf_t buf) 3505 { 3506 return __qdf_nbuf_network_header(buf); 3507 } 3508 3509 static inline void *qdf_nbuf_transport_header(qdf_nbuf_t buf) 3510 { 3511 return __qdf_nbuf_transport_header(buf); 3512 } 3513 3514 static inline qdf_size_t qdf_nbuf_tcp_tso_size(qdf_nbuf_t buf) 3515 { 3516 return __qdf_nbuf_tcp_tso_size(buf); 3517 } 3518 3519 static inline void *qdf_nbuf_get_cb(qdf_nbuf_t nbuf) 3520 { 3521 return __qdf_nbuf_get_cb(nbuf); 3522 } 3523 3524 static inline uint32_t qdf_nbuf_get_nr_frags(qdf_nbuf_t nbuf) 3525 { 3526 return __qdf_nbuf_get_nr_frags(nbuf); 3527 } 3528 3529 static inline qdf_size_t qdf_nbuf_headlen(qdf_nbuf_t buf) 3530 { 3531 return __qdf_nbuf_headlen(buf); 3532 } 3533 3534 static inline QDF_STATUS qdf_nbuf_frag_map(qdf_device_t osdev, 3535 qdf_nbuf_t buf, int offset, 3536 qdf_dma_dir_t dir, int cur_frag) 3537 { 3538 return __qdf_nbuf_frag_map(osdev, buf, offset, dir, cur_frag); 3539 } 3540 3541 static inline bool qdf_nbuf_tso_tcp_v4(qdf_nbuf_t buf) 3542 { 3543 return __qdf_nbuf_tso_tcp_v4(buf); 3544 } 3545 3546 static inline bool qdf_nbuf_tso_tcp_v6(qdf_nbuf_t buf) 3547 { 3548 return __qdf_nbuf_tso_tcp_v6(buf); 3549 } 3550 3551 static inline uint32_t qdf_nbuf_tcp_seq(qdf_nbuf_t buf) 3552 { 3553 return __qdf_nbuf_tcp_seq(buf); 3554 } 3555 3556 static inline qdf_size_t qdf_nbuf_l2l3l4_hdr_len(qdf_nbuf_t buf) 3557 { 3558 return __qdf_nbuf_l2l3l4_hdr_len(buf); 3559 } 3560 3561 static inline bool qdf_nbuf_is_nonlinear(qdf_nbuf_t buf) 3562 { 3563 return __qdf_nbuf_is_nonlinear(buf); 3564 } 3565 3566 static inline uint32_t 3567 qdf_nbuf_get_frag_size(qdf_nbuf_t buf, uint32_t frag_num) 3568 { 3569 return __qdf_nbuf_get_frag_size(buf, frag_num); 3570 } 3571 3572 static inline uint32_t qdf_nbuf_get_priority(qdf_nbuf_t buf) 3573 { 3574 return __qdf_nbuf_get_priority(buf); 3575 } 3576 3577 static inline void qdf_nbuf_set_priority(qdf_nbuf_t buf, uint32_t p) 3578 { 3579 __qdf_nbuf_set_priority(buf, p); 3580 } 3581 3582 static inline void qdf_nbuf_record_rx_queue(qdf_nbuf_t buf, uint32_t queue_id) 3583 { 3584 __qdf_nbuf_record_rx_queue(buf, queue_id); 3585 } 3586 3587 static inline uint16_t 3588 qdf_nbuf_get_queue_mapping(qdf_nbuf_t buf) 3589 { 3590 return __qdf_nbuf_get_queue_mapping(buf); 3591 } 3592 3593 static inline uint8_t * 3594 qdf_nbuf_get_priv_ptr(qdf_nbuf_t buf) 3595 { 3596 return __qdf_nbuf_get_priv_ptr(buf); 3597 } 3598 3599 /** 3600 * qdf_nbuf_update_radiotap() - update radiotap at head of nbuf. 3601 * @rx_status: rx_status containing required info to update radiotap 3602 * @nbuf: Pointer to nbuf 3603 * @headroom_sz: Available headroom size 3604 * 3605 * Return: radiotap length. 3606 */ 3607 unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status, 3608 qdf_nbuf_t nbuf, uint32_t headroom_sz); 3609 3610 /** 3611 * qdf_nbuf_mark_wakeup_frame() - mark wakeup frame. 3612 * @buf: Pointer to nbuf 3613 * 3614 * Return: None 3615 */ 3616 static inline void 3617 qdf_nbuf_mark_wakeup_frame(qdf_nbuf_t buf) 3618 { 3619 __qdf_nbuf_mark_wakeup_frame(buf); 3620 } 3621 3622 /** 3623 * qdf_nbuf_reg_free_cb - Registers nbuf free callback 3624 * @cb_func_ptr: Callback pointer 3625 * 3626 * This function registers nbuf free callback 3627 * 3628 * Return: void 3629 */ 3630 static inline void 3631 qdf_nbuf_reg_free_cb(qdf_nbuf_free_t cb_func_ptr) 3632 { 3633 __qdf_nbuf_reg_free_cb(cb_func_ptr); 3634 } 3635 3636 /** 3637 * qdf_nbuf_set_timestamp() - set the timestamp for frame 3638 * 3639 * @buf: sk buff 3640 * 3641 * Return: void 3642 */ 3643 static inline void 3644 qdf_nbuf_set_timestamp(struct sk_buff *skb) 3645 { 3646 __qdf_nbuf_set_timestamp(skb); 3647 } 3648 3649 /** 3650 * qdf_nbuf_get_timestamp() - get the timestamp for frame 3651 * 3652 * @buf: sk buff 3653 * 3654 * Return: timestamp stored in skb in ms 3655 */ 3656 static inline uint64_t 3657 qdf_nbuf_get_timestamp(struct sk_buff *skb) 3658 { 3659 return __qdf_nbuf_get_timestamp(skb); 3660 } 3661 3662 /** 3663 * qdf_nbuf_get_timedelta_ms() - get time difference in ms 3664 * 3665 * @buf: sk buff 3666 * 3667 * Return: time difference ms 3668 */ 3669 static inline uint64_t 3670 qdf_nbuf_get_timedelta_ms(struct sk_buff *skb) 3671 { 3672 return __qdf_nbuf_get_timedelta_ms(skb); 3673 } 3674 3675 /** 3676 * qdf_nbuf_get_timedelta_us() - get time difference in micro seconds 3677 * 3678 * @buf: sk buff 3679 * 3680 * Return: time difference in micro seconds 3681 */ 3682 static inline uint64_t 3683 qdf_nbuf_get_timedelta_us(struct sk_buff *skb) 3684 { 3685 return __qdf_nbuf_get_timedelta_us(skb); 3686 } 3687 3688 /** 3689 * qdf_nbuf_count_get() - get global nbuf gauge 3690 * 3691 * Return: global nbuf gauge 3692 */ 3693 static inline int qdf_nbuf_count_get(void) 3694 { 3695 return __qdf_nbuf_count_get(); 3696 } 3697 3698 /** 3699 * qdf_nbuf_count_inc() - increment nbuf global count 3700 * 3701 * @buf: sk buff 3702 * 3703 * Return: void 3704 */ 3705 static inline void qdf_nbuf_count_inc(qdf_nbuf_t buf) 3706 { 3707 return __qdf_nbuf_count_inc(buf); 3708 } 3709 3710 /** 3711 * qdf_nbuf_count_dec() - decrement nbuf global count 3712 * 3713 * @buf: sk buff 3714 * 3715 * Return: void 3716 */ 3717 static inline void qdf_nbuf_count_dec(qdf_nbuf_t buf) 3718 { 3719 return __qdf_nbuf_count_dec(buf); 3720 } 3721 3722 /** 3723 * qdf_nbuf_mod_init() - Intialization routine for qdf_nbuf 3724 * 3725 * Return void 3726 */ 3727 static inline void qdf_nbuf_mod_init(void) 3728 { 3729 return __qdf_nbuf_mod_init(); 3730 } 3731 3732 /** 3733 * qdf_nbuf_mod_init() - Unintialization routine for qdf_nbuf 3734 * 3735 * Return void 3736 */ 3737 static inline void qdf_nbuf_mod_exit(void) 3738 { 3739 return __qdf_nbuf_mod_exit(); 3740 } 3741 3742 /** 3743 * qdf_nbuf_orphan() - orphan a nbuf 3744 * @buf: Pointer to network buffer 3745 * 3746 * If a buffer currently has an owner then we call the 3747 * owner's destructor function 3748 * 3749 * Return: void 3750 */ 3751 static inline void qdf_nbuf_orphan(qdf_nbuf_t buf) 3752 { 3753 return __qdf_nbuf_orphan(buf); 3754 } 3755 3756 /** 3757 * qdf_nbuf_get_frag_size_by_idx() - Get size of nbuf frag at index idx 3758 * @nbuf: qdf_nbuf_t 3759 * @idx: Frag index for which frag size is requested 3760 * 3761 * Return: Frag size 3762 */ 3763 static inline unsigned int qdf_nbuf_get_frag_size_by_idx(qdf_nbuf_t nbuf, 3764 uint8_t idx) 3765 { 3766 return __qdf_nbuf_get_frag_size_by_idx(nbuf, idx); 3767 } 3768 3769 /** 3770 * qdf_nbuf_get_frag_addr() - Get nbuf frag address at index idx 3771 * @nbuf: qdf_nbuf_t 3772 * @idx: Frag index for which frag address is requested 3773 * 3774 * Return: Frag address 3775 */ 3776 static inline qdf_frag_t qdf_nbuf_get_frag_addr(qdf_nbuf_t nbuf, uint8_t idx) 3777 { 3778 return __qdf_nbuf_get_frag_addr(nbuf, idx); 3779 } 3780 3781 /** 3782 * qdf_nbuf_trim_add_frag_size() - Increase/Decrease frag_size by size 3783 * @nbuf: qdf_nbuf_t 3784 * @idx: Frag index 3785 * @size: Size by which frag_size needs to be increased/decreased 3786 * +Ve means increase, -Ve means decrease 3787 * @truesize: truesize 3788 */ 3789 static inline void qdf_nbuf_trim_add_frag_size(qdf_nbuf_t nbuf, uint8_t idx, 3790 int size, unsigned int truesize) 3791 { 3792 __qdf_nbuf_trim_add_frag_size(nbuf, idx, size, truesize); 3793 } 3794 3795 /** 3796 * qdf_nbuf_set_mark() - Set nbuf mark 3797 * @nbuf: qdf_nbuf_t 3798 * @mark: Value to set mark 3799 * 3800 * Return: none 3801 */ 3802 static inline void qdf_nbuf_set_mark(qdf_nbuf_t nbuf, uint32_t mark) 3803 { 3804 __qdf_nbuf_set_mark(nbuf, mark); 3805 } 3806 3807 /** 3808 * qdf_nbuf_get_mark() - Get nbuf mark 3809 * @nbuf: qdf_nbuf_t 3810 * 3811 * Return: mark value 3812 */ 3813 static inline uint32_t qdf_nbuf_get_mark(qdf_nbuf_t nbuf) 3814 { 3815 return __qdf_nbuf_get_mark(nbuf); 3816 } 3817 3818 /** 3819 * qdf_nbuf_get_data_len() - Return the size of the nbuf from 3820 * data pointer to end pointer 3821 * @nbuf: qdf_nbuf_t 3822 * 3823 * Return: size of network buffer from data pointer to end 3824 * pointer 3825 */ 3826 static inline qdf_size_t qdf_nbuf_get_data_len(qdf_nbuf_t nbuf) 3827 { 3828 return __qdf_nbuf_get_data_len(nbuf); 3829 } 3830 3831 /** 3832 * qdf_nbuf_get_end_offset() - Return the size of the nbuf from 3833 * head pointer to end pointer 3834 * @nbuf: qdf_nbuf_t 3835 * 3836 * Return: size of network buffer from head pointer to end 3837 * pointer 3838 */ 3839 static inline qdf_size_t qdf_nbuf_get_end_offset(qdf_nbuf_t nbuf) 3840 { 3841 return __qdf_nbuf_get_end_offset(nbuf); 3842 } 3843 3844 #ifdef NBUF_FRAG_MEMORY_DEBUG 3845 3846 #define qdf_nbuf_move_frag_page_offset(f, i, o) \ 3847 qdf_nbuf_move_frag_page_offset_debug(f, i, o, __func__, __LINE__) 3848 3849 /** 3850 * qdf_nbuf_move_frag_page_offset_debug() - Move frag page_offset by size 3851 * and adjust length by size. 3852 * @nbuf: qdf_nbuf_t 3853 * @idx: Frag index 3854 * @offset: Frag page offset should be moved by offset. 3855 * +Ve - Move offset forward. 3856 * -Ve - Move offset backward. 3857 * @func: Caller function name 3858 * @line: Caller function line no. 3859 * 3860 * Return: QDF_STATUS 3861 */ 3862 QDF_STATUS qdf_nbuf_move_frag_page_offset_debug(qdf_nbuf_t nbuf, uint8_t idx, 3863 int offset, const char *func, 3864 uint32_t line); 3865 3866 #define qdf_nbuf_add_rx_frag(f, b, o, l, s, r) \ 3867 qdf_nbuf_add_rx_frag_debug(f, b, o, l, s, r, __func__, __LINE__) 3868 3869 /** 3870 * qdf_nbuf_add_rx_frag_debug() - Add frag to nbuf at index frag_idx 3871 * @buf: Frag pointer needs to be added in nbuf 3872 * @nbuf: qdf_nbuf_t where frag will be added 3873 * @offset: Offset in frag to be added to nbuf_frags 3874 * @frag_len: Frag length 3875 * @truesize: truesize 3876 * @take_frag_ref: Whether to take ref for frag or not 3877 * This bool must be set as per below comdition: 3878 * 1. False: If this frag is being added in any nbuf 3879 * for the first time after allocation 3880 * 2. True: If frag is already attached part of any 3881 * nbuf 3882 * @func: Caller function name 3883 * @line: Caller function line no. 3884 * 3885 * Return: none 3886 */ 3887 void qdf_nbuf_add_rx_frag_debug(qdf_frag_t buf, qdf_nbuf_t nbuf, 3888 int offset, int frag_len, 3889 unsigned int truesize, bool take_frag_ref, 3890 const char *func, uint32_t line); 3891 3892 /** 3893 * qdf_net_buf_debug_acquire_frag() - Add frag nodes to frag debug tracker 3894 * when nbuf is received from network stack 3895 * @buf: qdf_nbuf_t 3896 * @func: Caller function name 3897 * @line: Caller function line no. 3898 * 3899 * Return: none 3900 */ 3901 void qdf_net_buf_debug_acquire_frag(qdf_nbuf_t buf, const char *func, 3902 uint32_t line); 3903 3904 /** 3905 * qdf_net_buf_debug_release_frag() - Update frag nodes in frag debug tracker 3906 * when nbuf is sent to network stack 3907 * @buf: qdf_nbuf_t 3908 * @func: Caller function name 3909 * @line: Caller function line no. 3910 * 3911 * Return: none 3912 */ 3913 void qdf_net_buf_debug_release_frag(qdf_nbuf_t buf, const char *func, 3914 uint32_t line); 3915 3916 /** 3917 * qdf_nbuf_frag_count_inc() - Increment global frag counter 3918 * @buf: qdf_nbuf_t 3919 * 3920 * Return: none 3921 */ 3922 void qdf_nbuf_frag_count_inc(qdf_nbuf_t buf); 3923 3924 /** 3925 * qdf_nbuf_frag_count_dec() - Decrement global frag counter 3926 * @buf: qdf_nbuf_t 3927 * 3928 * Return: none 3929 */ 3930 void qdf_nbuf_frag_count_dec(qdf_nbuf_t buf); 3931 3932 #else /* NBUF_FRAG_MEMORY_DEBUG */ 3933 3934 /** 3935 * qdf_nbuf_move_frag_page_offset() - Move frag page_offset by size 3936 * and adjust length by size. 3937 * @nbuf: qdf_nbuf_t 3938 * @idx: Frag index 3939 * @offset: Frag page offset should be moved by offset. 3940 * +Ve - Move offset forward. 3941 * -Ve - Move offset backward. 3942 */ 3943 static inline QDF_STATUS qdf_nbuf_move_frag_page_offset(qdf_nbuf_t nbuf, 3944 uint8_t idx, 3945 int offset) 3946 { 3947 return __qdf_nbuf_move_frag_page_offset(nbuf, idx, offset); 3948 } 3949 3950 /** 3951 * qdf_nbuf_add_rx_frag() - Add frag to nbuf at index frag_idx 3952 * @buf: Frag pointer needs to be added in nbuf frag 3953 * @nbuf: qdf_nbuf_t where frag will be added 3954 * @offset: Offset in frag to be added to nbuf_frags 3955 * @frag_len: Frag length 3956 * @truesize: truesize 3957 * @take_frag_ref: Whether to take ref for frag or not 3958 * This bool must be set as per below comdition: 3959 * 1. False: If this frag is being added in any nbuf 3960 * for the first time after allocation 3961 * 2. True: If frag is already attached part of any 3962 * nbuf 3963 * 3964 * qdf_nbuf_add_rx_frag takes ref_count based on boolean flag take_frag_ref 3965 */ 3966 static inline void qdf_nbuf_add_rx_frag(qdf_frag_t buf, qdf_nbuf_t nbuf, 3967 int offset, int frag_len, 3968 unsigned int truesize, 3969 bool take_frag_ref) 3970 { 3971 __qdf_nbuf_add_rx_frag(buf, nbuf, offset, 3972 frag_len, truesize, take_frag_ref); 3973 } 3974 3975 static inline void qdf_net_buf_debug_acquire_frag(qdf_nbuf_t buf, 3976 const char *func, 3977 uint32_t line) 3978 { 3979 } 3980 3981 static inline void qdf_net_buf_debug_release_frag(qdf_nbuf_t buf, 3982 const char *func, 3983 uint32_t line) 3984 { 3985 } 3986 3987 static inline void qdf_nbuf_frag_count_inc(qdf_nbuf_t buf) 3988 { 3989 } 3990 3991 static inline void qdf_nbuf_frag_count_dec(qdf_nbuf_t buf) 3992 { 3993 } 3994 3995 #endif /* NBUF_FRAG_MEMORY_DEBUG */ 3996 3997 #ifdef MEMORY_DEBUG 3998 /** 3999 * qdf_nbuf_acquire_track_lock - acquire the nbuf spinlock at the 4000 * specified index 4001 * @index: index to get the lock 4002 * @irq_flag: lock flag for using nbuf lock 4003 * 4004 * Return: none 4005 */ 4006 void qdf_nbuf_acquire_track_lock(uint32_t index, 4007 unsigned long irq_flag); 4008 4009 /** 4010 * qdf_nbuf_release_track_lock - release the nbuf spinlock at the 4011 * specified index 4012 * @index: index of the lock to be released 4013 * @irq_flag: lock flag for using nbuf lock 4014 * 4015 * Return: none 4016 */ 4017 void qdf_nbuf_release_track_lock(uint32_t index, 4018 unsigned long irq_flag); 4019 4020 /** 4021 * qdf_nbuf_get_track_tbl - get the QDF_NBUF_TRACK entry from the track 4022 * table at the specified index 4023 * @index: index to get the table entry 4024 * 4025 * Return: the QDF_NBUF_TRACK entry at the specified index in the table 4026 */ 4027 QDF_NBUF_TRACK *qdf_nbuf_get_track_tbl(uint32_t index); 4028 #endif /* MEMORY_DEBUG */ 4029 4030 #ifdef CONFIG_WLAN_SYSFS_MEM_STATS 4031 /** 4032 * qdf_record_nbuf_nbytes() - add or subtract the size of the nbuf 4033 * from the total skb mem and DP tx/rx skb mem 4034 * @nbytes: number of bytes 4035 * @dir: direction 4036 * @is_mapped: is mapped or unmapped memory 4037 * 4038 * Return: none 4039 */ 4040 void qdf_record_nbuf_nbytes( 4041 uint32_t nbytes, qdf_dma_dir_t dir, bool is_mapped); 4042 4043 #else /* CONFIG_WLAN_SYSFS_MEM_STATS */ 4044 static inline void qdf_record_nbuf_nbytes( 4045 int nbytes, qdf_dma_dir_t dir, bool is_mapped) 4046 { 4047 } 4048 #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */ 4049 4050 #ifdef CONFIG_NBUF_AP_PLATFORM 4051 #include <i_qdf_nbuf_api_w.h> 4052 #else 4053 #include <i_qdf_nbuf_api_m.h> 4054 #endif 4055 #endif /* _QDF_NBUF_H */ 4056