blob: 5094c4236cf9bc044eabd5c4140fed6fdf8af324 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2011, 2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * @file ol_tx_desc.h
30 * @brief API definitions for the tx descriptor module within the data SW.
31 */
32#ifndef _OL_TX_DESC__H_
33#define _OL_TX_DESC__H_
34
35#include <cds_queue.h> /* TAILQ_HEAD */
36#include <cdf_nbuf.h> /* cdf_nbuf_t */
37#include <ol_txrx_types.h> /* ol_tx_desc_t */
38#include <ol_txrx_internal.h> /*TXRX_ASSERT2 */
39
40struct ol_tx_desc_t *
41ol_tx_desc_alloc_wrapper(struct ol_txrx_pdev_t *pdev,
42 struct ol_txrx_vdev_t *vdev,
43 struct ol_txrx_msdu_info_t *msdu_info);
44
45
46/**
47 * @brief Allocate and initialize a tx descriptor for a LL system.
48 * @details
49 * Allocate a tx descriptor pair for a new tx frame - a SW tx descriptor
50 * for private use within the host data SW, and a HTT tx descriptor for
51 * downloading tx meta-data to the target FW/HW.
52 * Fill in the fields of this pair of tx descriptors based on the
53 * information in the netbuf.
54 * For LL, this includes filling in a fragmentation descriptor to
55 * specify to the MAC HW where to find the tx frame's fragments.
56 *
57 * @param pdev - the data physical device sending the data
58 * (for accessing the tx desc pool)
59 * @param vdev - the virtual device sending the data
60 * (for specifying the transmitter address for multicast / broadcast data)
61 * @param netbuf - the tx frame
62 * @param msdu_info - tx meta-data
63 */
64struct ol_tx_desc_t *ol_tx_desc_ll(struct ol_txrx_pdev_t *pdev,
65 struct ol_txrx_vdev_t *vdev,
66 cdf_nbuf_t netbuf,
67 struct ol_txrx_msdu_info_t *msdu_info);
68
69/**
70 * @brief Use a tx descriptor ID to find the corresponding desriptor object.
71 *
72 * @param pdev - the data physical device sending the data
73 * @param tx_desc_id - the ID of the descriptor in question
74 * @return the descriptor object that has the specified ID
75 */
76struct ol_tx_desc_t *ol_tx_desc_find(struct ol_txrx_pdev_t *pdev,
77 uint16_t tx_desc_id);
78
79/**
80 * @brief Free a list of tx descriptors and the tx frames they refer to.
81 * @details
82 * Free a batch of "standard" tx descriptors and their tx frames.
83 * Free each tx descriptor, by returning it to the freelist.
84 * Unmap each netbuf, and free the netbufs as a batch.
85 * Irregular tx frames like TSO or managment frames that require
86 * special handling are processed by the ol_tx_desc_frame_free_nonstd
87 * function rather than this function.
88 *
89 * @param pdev - the data physical device that sent the data
90 * @param tx_descs - a list of SW tx descriptors for the tx frames
91 * @param had_error - bool indication of whether the transmission failed.
92 * This is provided to callback functions that get notified of
93 * the tx frame completion.
94 */
95void ol_tx_desc_frame_list_free(struct ol_txrx_pdev_t *pdev,
96 ol_tx_desc_list *tx_descs, int had_error);
97
98/**
99 * @brief Free a non-standard tx frame and its tx descriptor.
100 * @details
101 * Check the tx frame type (e.g. TSO vs. management) to determine what
102 * special steps, if any, need to be performed prior to freeing the
103 * tx frame and its tx descriptor.
104 * This function can also be used to free single standard tx frames.
105 * After performing any special steps based on tx frame type, free the
106 * tx descriptor, i.e. return it to the freelist, and unmap and
107 * free the netbuf referenced by the tx descriptor.
108 *
109 * @param pdev - the data physical device that sent the data
110 * @param tx_desc - the SW tx descriptor for the tx frame that was sent
111 * @param had_error - bool indication of whether the transmission failed.
112 * This is provided to callback functions that get notified of
113 * the tx frame completion.
114 */
115void ol_tx_desc_frame_free_nonstd(struct ol_txrx_pdev_t *pdev,
116 struct ol_tx_desc_t *tx_desc, int had_error);
117
118/*
119 * @brief Determine the ID of a tx descriptor.
120 *
121 * @param pdev - the physical device that is sending the data
122 * @param tx_desc - the descriptor whose ID is being determined
123 * @return numeric ID that uniquely identifies the tx descriptor
124 */
125static inline uint16_t
126ol_tx_desc_id(struct ol_txrx_pdev_t *pdev, struct ol_tx_desc_t *tx_desc)
127{
128 TXRX_ASSERT2(((union ol_tx_desc_list_elem_t *)tx_desc -
129 pdev->tx_desc.array) < pdev->tx_desc.pool_size);
130 return (uint16_t)
131 ((union ol_tx_desc_list_elem_t *)tx_desc - pdev->tx_desc.array);
132}
133
134/*
135 * @brief Retrieves the beacon headr for the vdev
136 * @param pdev - opaque pointe to scn
137 * @param vdevid - vdev id
138 * @return void pointer to the beacon header for the given vdev
139 */
140
141void *ol_ath_get_bcn_header(ol_pdev_handle pdev, A_UINT32 vdev_id);
142
143/*
144 * @brief Free a tx descriptor, without freeing the matching frame.
145 * @details
146 * This function is using during the function call that submits tx frames
147 * into the txrx layer, for cases where a tx descriptor is successfully
148 * allocated, but for other reasons the frame could not be accepted.
149 *
150 * @param pdev - the data physical device that is sending the data
151 * @param tx_desc - the descriptor being freed
152 */
153void ol_tx_desc_free(struct ol_txrx_pdev_t *pdev, struct ol_tx_desc_t *tx_desc);
154
155#if defined(FEATURE_TSO)
156struct cdf_tso_seg_elem_t *ol_tso_alloc_segment(struct ol_txrx_pdev_t *pdev);
157
158void ol_tso_free_segment(struct ol_txrx_pdev_t *pdev,
159 struct cdf_tso_seg_elem_t *tso_seg);
160#endif
161
162#ifdef QCA_LL_TX_FLOW_CONTROL_V2
163int ol_tx_free_invalid_flow_pool(struct ol_tx_flow_pool_t *pool);
164#else
165static inline int ol_tx_free_invalid_flow_pool(void *pool)
166{
167 return 0;
168}
169#endif
170
171#endif /* _OL_TX_DESC__H_ */