xref: /wlan-driver/qcacld-3.0/core/dp/txrx/ol_txrx_encap.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012, 2014-2016, 2018 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  * @file ol_txrx_encap.h
21  * @brief definitions for txrx encap/decap function and struct
22  */
23 #ifndef _OL_TXRX_ENCAP__H_
24 #define _OL_TXRX_ENCAP__H_
25 
26 #ifdef QCA_SUPPORT_SW_TXRX_ENCAP
27 
28 #include <qdf_nbuf.h>               /* qdf_nbuf_t */
29 #include <cds_ieee80211_common.h>   /* ieee80211_qosframe_htc_addr4 */
30 #include <cdp_txrx_cmn.h>           /* ol_txrx_vdev_t, etc. */
31 
32 /**
33  * @brief Encap outgoing frm from OS dependent format to Target
34  *        acceptable frm format
35  * @details
36  *     For native wifi format, the function will add Qos control field
37  *  based on peer's QOS capbabilities .
38  *     For 802.3 format, the function will transform to 802.11 format
39  *  with or without QOS control field based on peer's QOS capabilities.
40  * @param vdev - handle to vdev object
41  * @param tx_desc - tx desc struct,some fields will be updated.
42  * @param msdu - qdf_nbuf_t
43  * @param msdu_info - information from tx classification.
44  * @return
45  *     A_OK: encap operation successful
46  *     other: operation failed,the msdu need be dropped.
47  */
48 A_STATUS
49 ol_tx_encap(struct ol_txrx_vdev_t *vdev,
50 	    struct ol_tx_desc_t *tx_desc,
51 	    qdf_nbuf_t msdu, struct ol_txrx_msdu_info_t *msdu_info);
52 
53 struct ol_rx_decap_info_t {
54 	uint8_t hdr[sizeof(struct ieee80211_qosframe_htc_addr4)];
55 	int hdr_len;
56 	uint8_t is_subfrm:1, is_first_subfrm:1, is_msdu_cmpl_mpdu:1;
57 };
58 
59 /**
60  * @brief decap incoming frm from Target to Host OS
61  *        acceptable frm format
62  * @details
63  *     For native wifi format, the function will remove Qos control field
64  *  and HT control field if any.
65  *     For 802.3 format, the function will will do llc snap header process
66  *  if Target haven't done that.
67  * @param vdev - handle to vdev object
68  * @param peer - the peer object.
69  * @param msdu - qdf_nbuf_t
70  * @param info - ol_rx_decap_info_t: context info for decap
71  * @return
72  *     A_OK: decap operation successful
73  *     other: operation failed,the msdu need be dropped.
74  */
75 A_STATUS
76 ol_rx_decap(struct ol_txrx_vdev_t *vdev,
77 	    struct ol_txrx_peer_t *peer,
78 	    qdf_nbuf_t msdu, struct ol_rx_decap_info_t *info);
79 
80 static inline A_STATUS
OL_TX_ENCAP(struct ol_txrx_vdev_t * vdev,struct ol_tx_desc_t * tx_desc,qdf_nbuf_t msdu,struct ol_txrx_msdu_info_t * msdu_info)81 OL_TX_ENCAP(struct ol_txrx_vdev_t *vdev,
82 	    struct ol_tx_desc_t *tx_desc,
83 	    qdf_nbuf_t msdu, struct ol_txrx_msdu_info_t *msdu_info)
84 {
85 	if (vdev->pdev->sw_tx_encap)
86 		return ol_tx_encap(vdev, tx_desc, msdu, msdu_info);
87 	return A_OK;
88 }
89 
90 static inline A_STATUS
OL_RX_DECAP(struct ol_txrx_vdev_t * vdev,struct ol_txrx_peer_t * peer,qdf_nbuf_t msdu,struct ol_rx_decap_info_t * info)91 OL_RX_DECAP(struct ol_txrx_vdev_t *vdev,
92 	    struct ol_txrx_peer_t *peer,
93 	    qdf_nbuf_t msdu, struct ol_rx_decap_info_t *info)
94 {
95 	if (vdev->pdev->sw_rx_decap)
96 		return ol_rx_decap(vdev, peer, msdu, info);
97 	return A_OK;
98 }
99 
100 #define OL_TX_RESTORE_HDR(__tx_desc, __msdu)  \
101 	do {								\
102 		if (__tx_desc->orig_l2_hdr_bytes != 0)			\
103 			qdf_nbuf_push_head(__msdu,			\
104 					   __tx_desc->orig_l2_hdr_bytes); \
105 	} while (0)
106 #else
107 #define OL_TX_ENCAP(vdev, tx_desc, msdu, msdu_info) A_OK
108 #define OL_RX_DECAP(vdev, peer, msdu, info) A_OK
109 #define OL_TX_RESTORE_HDR(__tx_desc, __msdu)
110 #endif
111 #endif /* _OL_TXRX_ENCAP__H_ */
112