blob: 12f1abe413d63e2407426c900d88004f4abd6883 [file] [log] [blame]
Dhanashri Atre9c222b12016-03-22 13:26:13 -07001/*
Sravan Kumar Kairamfc3c8cf2018-11-19 18:32:50 +05302 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
Dhanashri Atre9c222b12016-03-22 13:26:13 -07003 *
Dhanashri Atre9c222b12016-03-22 13:26:13 -07004 * 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
Yun Park3bac7292017-04-03 07:36:30 -070019/**
Dhanashri Atre9c222b12016-03-22 13:26:13 -070020 * @file cdp_txrx_ipa.h
21 * @brief Define the host data path IP Acceleraor API functions
22 */
23#ifndef _CDP_TXRX_IPA_H_
24#define _CDP_TXRX_IPA_H_
Dustin Brown833077d2017-09-18 14:55:42 -070025
26#ifdef IPA_OFFLOAD
Yun Park1ba3ada2018-01-11 11:38:41 -080027#ifdef CONFIG_IPA_WDI_UNIFIED_API
28#include <qdf_ipa_wdi3.h>
29#else
Yun Parkfd269b52017-10-05 14:41:32 -070030#include <qdf_ipa.h>
Yun Park1ba3ada2018-01-11 11:38:41 -080031#endif
Sravan Kumar Kairamf1822ba2018-02-20 02:07:51 +053032#include <cdp_txrx_cmn.h>
Venkata Sharath Chandra Manchalaf2a125a2016-11-28 18:10:11 -080033#include "cdp_txrx_handle.h"
Yun Parkfde6b9e2017-06-26 17:13:11 -070034
Dhanashri Atre9c222b12016-03-22 13:26:13 -070035/**
Yun Parkfde6b9e2017-06-26 17:13:11 -070036 * cdp_ipa_get_resource() - Get allocated WLAN resources for IPA data path
Leo Changdb6358c2016-09-27 17:00:52 -070037 * @soc - data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053038 * @pdev_id - device instance id
Leo Changdb6358c2016-09-27 17:00:52 -070039 *
Yun Parkfde6b9e2017-06-26 17:13:11 -070040 * Get allocated WLAN resources for IPA data path
Leo Changdb6358c2016-09-27 17:00:52 -070041 *
Yun Parkfde6b9e2017-06-26 17:13:11 -070042 * return QDF_STATUS_SUCCESS
Dhanashri Atre9c222b12016-03-22 13:26:13 -070043 */
Yun Parkfde6b9e2017-06-26 17:13:11 -070044static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053045cdp_ipa_get_resource(ol_txrx_soc_handle soc, uint8_t pdev_id)
Dhanashri Atre9c222b12016-03-22 13:26:13 -070046{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053047 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Leo Changdb6358c2016-09-27 17:00:52 -070048 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
49 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -070050 return QDF_STATUS_E_FAILURE;
Leo Changdb6358c2016-09-27 17:00:52 -070051 }
52
53 if (soc->ops->ipa_ops->ipa_get_resource)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053054 return soc->ops->ipa_ops->ipa_get_resource(soc, pdev_id);
Leo Changdb6358c2016-09-27 17:00:52 -070055
Yun Parkfde6b9e2017-06-26 17:13:11 -070056 return QDF_STATUS_SUCCESS;
Dhanashri Atre9c222b12016-03-22 13:26:13 -070057}
58
Leo Changdb6358c2016-09-27 17:00:52 -070059/**
Yun Parkfde6b9e2017-06-26 17:13:11 -070060 * cdp_ipa_set_doorbell_paddr() - give IPA db paddr to FW
Leo Changdb6358c2016-09-27 17:00:52 -070061 * @soc - data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053062 * @pdev_id - device instance id
Leo Changdb6358c2016-09-27 17:00:52 -070063 *
Yun Parkfde6b9e2017-06-26 17:13:11 -070064 * give IPA db paddr to FW
Leo Changdb6358c2016-09-27 17:00:52 -070065 *
Yun Parkfde6b9e2017-06-26 17:13:11 -070066 * return QDF_STATUS_SUCCESS
Leo Changdb6358c2016-09-27 17:00:52 -070067 */
Yun Parkfde6b9e2017-06-26 17:13:11 -070068static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053069cdp_ipa_set_doorbell_paddr(ol_txrx_soc_handle soc, uint8_t pdev_id)
Dhanashri Atre9c222b12016-03-22 13:26:13 -070070{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053071 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Leo Changdb6358c2016-09-27 17:00:52 -070072 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
73 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -070074 return QDF_STATUS_E_FAILURE;
Leo Changdb6358c2016-09-27 17:00:52 -070075 }
76
77 if (soc->ops->ipa_ops->ipa_set_doorbell_paddr)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053078 return soc->ops->ipa_ops->ipa_set_doorbell_paddr(soc, pdev_id);
Leo Changdb6358c2016-09-27 17:00:52 -070079
Yun Parkfde6b9e2017-06-26 17:13:11 -070080 return QDF_STATUS_SUCCESS;
Dhanashri Atre9c222b12016-03-22 13:26:13 -070081}
82
Leo Changdb6358c2016-09-27 17:00:52 -070083/**
Yun Parkfde6b9e2017-06-26 17:13:11 -070084 * cdp_ipa_set_active() - activate/de-ctivate IPA offload path
Leo Changdb6358c2016-09-27 17:00:52 -070085 * @soc - data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053086 * @pdev_id - device instance id
Leo Changdb6358c2016-09-27 17:00:52 -070087 * @uc_active - activate or de-activate
88 * @is_tx - toggle tx or rx data path
89 *
Yun Parkfde6b9e2017-06-26 17:13:11 -070090 * activate/de-ctivate IPA offload path
Leo Changdb6358c2016-09-27 17:00:52 -070091 *
Yun Parkfde6b9e2017-06-26 17:13:11 -070092 * return QDF_STATUS_SUCCESS
Leo Changdb6358c2016-09-27 17:00:52 -070093 */
Yun Parkfde6b9e2017-06-26 17:13:11 -070094static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053095cdp_ipa_set_active(ol_txrx_soc_handle soc, uint8_t pdev_id, bool uc_active,
96 bool is_tx)
Dhanashri Atre9c222b12016-03-22 13:26:13 -070097{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +053098 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Leo Changdb6358c2016-09-27 17:00:52 -070099 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
100 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700101 return QDF_STATUS_E_FAILURE;
Leo Changdb6358c2016-09-27 17:00:52 -0700102 }
103
104 if (soc->ops->ipa_ops->ipa_set_active)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530105 return soc->ops->ipa_ops->ipa_set_active(soc, pdev_id,
106 uc_active, is_tx);
Leo Changdb6358c2016-09-27 17:00:52 -0700107
Yun Parkfde6b9e2017-06-26 17:13:11 -0700108 return QDF_STATUS_SUCCESS;
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700109}
110
Leo Changdb6358c2016-09-27 17:00:52 -0700111/**
Yun Parkfde6b9e2017-06-26 17:13:11 -0700112 * cdp_ipa_op_response() - event handler from FW
Leo Changdb6358c2016-09-27 17:00:52 -0700113 * @soc - data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530114 * @pdev_id - device instance id
Leo Changdb6358c2016-09-27 17:00:52 -0700115 * @op_msg - event contents from firmware
116 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700117 * event handler from FW
Leo Changdb6358c2016-09-27 17:00:52 -0700118 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700119 * return QDF_STATUS_SUCCESS
Leo Changdb6358c2016-09-27 17:00:52 -0700120 */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700121static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530122cdp_ipa_op_response(ol_txrx_soc_handle soc, uint8_t pdev_id, uint8_t *op_msg)
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700123{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530124 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Leo Changdb6358c2016-09-27 17:00:52 -0700125 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
126 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700127 return QDF_STATUS_E_FAILURE;
Leo Changdb6358c2016-09-27 17:00:52 -0700128 }
129
130 if (soc->ops->ipa_ops->ipa_op_response)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530131 return soc->ops->ipa_ops->ipa_op_response(soc, pdev_id, op_msg);
Leo Changdb6358c2016-09-27 17:00:52 -0700132
Yun Parkfde6b9e2017-06-26 17:13:11 -0700133 return QDF_STATUS_SUCCESS;
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700134}
135
Leo Changdb6358c2016-09-27 17:00:52 -0700136/**
137 * cdp_ipa_register_op_cb() - register event handler function pointer
138 * @soc - data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530139 * @pdev_id - device instance id
Leo Changdb6358c2016-09-27 17:00:52 -0700140 * @op_cb - event handler callback function pointer
Yun Parkfde6b9e2017-06-26 17:13:11 -0700141 * @usr_ctxt - user context to registered
Leo Changdb6358c2016-09-27 17:00:52 -0700142 *
143 * register event handler function pointer
144 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700145 * return QDF_STATUS_SUCCESS
Leo Changdb6358c2016-09-27 17:00:52 -0700146 */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700147static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530148cdp_ipa_register_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id,
149 ipa_uc_op_cb_type op_cb, void *usr_ctxt)
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700150{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530151 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Leo Changdb6358c2016-09-27 17:00:52 -0700152 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
153 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700154 return QDF_STATUS_E_FAILURE;
Leo Changdb6358c2016-09-27 17:00:52 -0700155 }
156
157 if (soc->ops->ipa_ops->ipa_register_op_cb)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530158 return soc->ops->ipa_ops->ipa_register_op_cb(soc, pdev_id,
159 op_cb, usr_ctxt);
Leo Changdb6358c2016-09-27 17:00:52 -0700160
Yun Parkfde6b9e2017-06-26 17:13:11 -0700161 return QDF_STATUS_SUCCESS;
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700162}
163
Leo Changdb6358c2016-09-27 17:00:52 -0700164/**
Yun Parkfde6b9e2017-06-26 17:13:11 -0700165 * cdp_ipa_get_stat() - get IPA data path stats from FW
Leo Changdb6358c2016-09-27 17:00:52 -0700166 * @soc - data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530167 * @pdev_id - device instance id
Leo Changdb6358c2016-09-27 17:00:52 -0700168 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700169 * get IPA data path stats from FW async
Leo Changdb6358c2016-09-27 17:00:52 -0700170 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700171 * return QDF_STATUS_SUCCESS
Leo Changdb6358c2016-09-27 17:00:52 -0700172 */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700173static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530174cdp_ipa_get_stat(ol_txrx_soc_handle soc, uint8_t pdev_id)
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700175{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530176 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Leo Changdb6358c2016-09-27 17:00:52 -0700177 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
178 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700179 return QDF_STATUS_E_FAILURE;
Leo Changdb6358c2016-09-27 17:00:52 -0700180 }
181
182 if (soc->ops->ipa_ops->ipa_get_stat)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530183 return soc->ops->ipa_ops->ipa_get_stat(soc, pdev_id);
Leo Changdb6358c2016-09-27 17:00:52 -0700184
Yun Parkfde6b9e2017-06-26 17:13:11 -0700185 return QDF_STATUS_SUCCESS;
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700186}
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700187
Leo Changdb6358c2016-09-27 17:00:52 -0700188/**
189 * cdp_tx_send_ipa_data_frame() - send IPA data frame
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530190 * @soc - data path soc handle
191 * @vdev_id: vdev id
Leo Changdb6358c2016-09-27 17:00:52 -0700192 * @skb: skb
193 *
194 * Return: skb/ NULL is for success
195 */
196static inline qdf_nbuf_t cdp_ipa_tx_send_data_frame(ol_txrx_soc_handle soc,
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530197 uint8_t vdev_id,
198 qdf_nbuf_t skb)
Leo Changdb6358c2016-09-27 17:00:52 -0700199{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530200 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Leo Changdb6358c2016-09-27 17:00:52 -0700201 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
202 "%s invalid instance", __func__);
203 return skb;
204 }
205
206 if (soc->ops->ipa_ops->ipa_tx_data_frame)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530207 return soc->ops->ipa_ops->ipa_tx_data_frame(soc, vdev_id, skb);
Leo Changdb6358c2016-09-27 17:00:52 -0700208
209 return skb;
210}
211
212/**
213 * cdp_ipa_set_uc_tx_partition_base() - set tx packet partition base
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530214 * @soc - data path soc handle
215 * @cfg_pdev: physical device instance config
Leo Changdb6358c2016-09-27 17:00:52 -0700216 * @value: partition base value
217 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700218 * Return: QDF_STATUS
Leo Changdb6358c2016-09-27 17:00:52 -0700219 */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700220static inline QDF_STATUS
221cdp_ipa_set_uc_tx_partition_base(ol_txrx_soc_handle soc,
Venkata Sharath Chandra Manchalaf2a125a2016-11-28 18:10:11 -0800222 struct cdp_cfg *cfg_pdev, uint32_t value)
Leo Changdb6358c2016-09-27 17:00:52 -0700223{
Yun Parkfde6b9e2017-06-26 17:13:11 -0700224 if (!soc || !soc->ops || !soc->ops->ipa_ops || !cfg_pdev) {
Leo Changdb6358c2016-09-27 17:00:52 -0700225 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
226 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700227 return QDF_STATUS_E_FAILURE;
Leo Changdb6358c2016-09-27 17:00:52 -0700228 }
229
230 if (soc->ops->ipa_ops->ipa_set_uc_tx_partition_base)
Yun Parkfde6b9e2017-06-26 17:13:11 -0700231 soc->ops->ipa_ops->ipa_set_uc_tx_partition_base(cfg_pdev,
232 value);
Leo Changdb6358c2016-09-27 17:00:52 -0700233
Yun Parkfde6b9e2017-06-26 17:13:11 -0700234 return QDF_STATUS_SUCCESS;
Leo Changdb6358c2016-09-27 17:00:52 -0700235}
Yun Park6716dff2016-10-26 14:34:49 -0700236
Yun Parkfde6b9e2017-06-26 17:13:11 -0700237#ifdef FEATURE_METERING
Yun Park6716dff2016-10-26 14:34:49 -0700238/**
239 * cdp_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530240 * @soc - data path soc handle
241 * @pdev_id: physical device instance number
Yun Park6716dff2016-10-26 14:34:49 -0700242 * @value: reset stats
243 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700244 * Return: QDF_STATUS
Yun Park6716dff2016-10-26 14:34:49 -0700245 */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700246static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530247cdp_ipa_uc_get_share_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
248 uint8_t value)
Yun Park6716dff2016-10-26 14:34:49 -0700249{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530250 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Park6716dff2016-10-26 14:34:49 -0700251 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
252 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700253 return QDF_STATUS_E_FAILURE;
Yun Park6716dff2016-10-26 14:34:49 -0700254 }
255
256 if (soc->ops->ipa_ops->ipa_uc_get_share_stats)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530257 return soc->ops->ipa_ops->ipa_uc_get_share_stats(soc, pdev_id,
Yun Park6716dff2016-10-26 14:34:49 -0700258 value);
259
Yun Parkfde6b9e2017-06-26 17:13:11 -0700260 return QDF_STATUS_SUCCESS;
Yun Park6716dff2016-10-26 14:34:49 -0700261}
262
263/**
264 * cdp_ipa_uc_set_quota() - set quota limit to FW
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530265 * @soc - data path soc handle
266 * @pdev_id: physical device instance number
Yun Park6716dff2016-10-26 14:34:49 -0700267 * @value: quota limit bytes
268 *
Yun Parkfde6b9e2017-06-26 17:13:11 -0700269 * Return: QDF_STATUS
Yun Park6716dff2016-10-26 14:34:49 -0700270 */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700271static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530272cdp_ipa_uc_set_quota(ol_txrx_soc_handle soc, uint8_t pdev_id, uint64_t value)
Yun Parkfde6b9e2017-06-26 17:13:11 -0700273{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530274 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Parkfde6b9e2017-06-26 17:13:11 -0700275 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
276 "%s invalid instance", __func__);
277 return QDF_STATUS_E_FAILURE;
278 }
279
280 if (soc->ops->ipa_ops->ipa_uc_set_quota)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530281 return soc->ops->ipa_ops->ipa_uc_set_quota(soc, pdev_id, value);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700282
283 return QDF_STATUS_SUCCESS;
284}
285#endif
286
287/**
288 * cdp_ipa_enable_autonomy() - Enable autonomy RX data path
289 * @soc: data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530290 * @pdev_id: physical device instance number
Yun Parkfde6b9e2017-06-26 17:13:11 -0700291 *
292 * IPA Data path is enabled and resumed.
293 * All autonomy data path elements are ready to deliver packet
294 * All RX packet should routed to IPA_REO ring, then IPA can receive packet
295 * from WLAN
296 *
297 * Return: QDF_STATUS
298 */
299static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530300cdp_ipa_enable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
Yun Parkfde6b9e2017-06-26 17:13:11 -0700301{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530302 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Parkfde6b9e2017-06-26 17:13:11 -0700303 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
304 "%s invalid instance", __func__);
305 return QDF_STATUS_E_FAILURE;
306 }
307
308 if (soc->ops->ipa_ops->ipa_enable_autonomy)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530309 return soc->ops->ipa_ops->ipa_enable_autonomy(soc, pdev_id);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700310
311 return QDF_STATUS_SUCCESS;
312}
313
314/**
315 * cdp_ipa_disable_autonomy() - Disable autonomy RX data path
316 * @soc: data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530317 * @pdev_id: physical device instance number
Yun Parkfde6b9e2017-06-26 17:13:11 -0700318 *
319 * IPA Data path is enabled and resumed.
320 * All autonomy datapath elements are ready to deliver packet
321 * All RX packet should routed to IPA_REO ring, then IPA can receive packet
322 * from WLAN
323 *
324 * Return: QDF_STATUS
325 */
326static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530327cdp_ipa_disable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
Yun Parkfde6b9e2017-06-26 17:13:11 -0700328{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530329 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Parkfde6b9e2017-06-26 17:13:11 -0700330 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
331 "%s invalid instance", __func__);
332 return QDF_STATUS_E_FAILURE;
333 }
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530334 if (soc->ops->ipa_ops->ipa_disable_autonomy)
335 return soc->ops->ipa_ops->ipa_disable_autonomy(soc, pdev_id);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700336
337 return QDF_STATUS_SUCCESS;
338}
339
Yun Park1ba3ada2018-01-11 11:38:41 -0800340#ifdef CONFIG_IPA_WDI_UNIFIED_API
341/**
342 * cdp_ipa_setup() - Setup and connect IPA pipes
343 * @soc: data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530344 * @pdev_id: handle to the device instance number
Yun Park1ba3ada2018-01-11 11:38:41 -0800345 * @ipa_i2w_cb: IPA to WLAN callback
346 * @ipa_w2i_cb: WLAN to IPA callback
347 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
348 * @ipa_desc_size: IPA descriptor size
349 * @ipa_priv: handle to the HTT instance
350 * @is_rm_enabled: Is IPA RM enabled or not
351 * @tx_pipe_handle: pointer to Tx pipe handle
352 * @rx_pipe_handle: pointer to Rx pipe handle
353 * @is_smmu_enabled: Is SMMU enabled or not
354 * @sys_in: parameters to setup sys pipe in mcc mode
Sravan Kumar Kairamfc3c8cf2018-11-19 18:32:50 +0530355 * @over_gsi: Is IPA using GSI
Yun Park1ba3ada2018-01-11 11:38:41 -0800356 *
357 * Return: QDF_STATUS
358 */
359static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530360cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
Yun Park1ba3ada2018-01-11 11:38:41 -0800361 void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
362 uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
363 uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
Sravan Kumar Kairamfc3c8cf2018-11-19 18:32:50 +0530364 bool is_smmu_enabled, qdf_ipa_sys_connect_params_t *sys_in,
365 bool over_gsi)
Yun Park1ba3ada2018-01-11 11:38:41 -0800366{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530367 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Park1ba3ada2018-01-11 11:38:41 -0800368 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
369 "%s invalid instance", __func__);
370 return QDF_STATUS_E_FAILURE;
371 }
372
373 if (soc->ops->ipa_ops->ipa_setup)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530374 return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
Yun Park1ba3ada2018-01-11 11:38:41 -0800375 ipa_w2i_cb,
376 ipa_wdi_meter_notifier_cb,
377 ipa_desc_size, ipa_priv,
378 is_rm_enabled,
379 tx_pipe_handle,
380 rx_pipe_handle,
381 is_smmu_enabled,
Sravan Kumar Kairamfc3c8cf2018-11-19 18:32:50 +0530382 sys_in, over_gsi);
Yun Park1ba3ada2018-01-11 11:38:41 -0800383
384 return QDF_STATUS_SUCCESS;
385}
386#else /* CONFIG_IPA_WDI_UNIFIED_API */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700387/**
388 * cdp_ipa_setup() - Setup and connect IPA pipes
389 * @soc: data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530390 * @pdev_id: handle to the device instance number
Yun Parkfde6b9e2017-06-26 17:13:11 -0700391 * @ipa_i2w_cb: IPA to WLAN callback
392 * @ipa_w2i_cb: WLAN to IPA callback
393 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
394 * @ipa_desc_size: IPA descriptor size
395 * @ipa_priv: handle to the HTT instance
396 * @is_rm_enabled: Is IPA RM enabled or not
397 * @tx_pipe_handle: pointer to Tx pipe handle
398 * @rx_pipe_handle: pointer to Rx pipe handle
399 *
400 * Return: QDF_STATUS
401 */
402static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530403cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
Yun Parkfde6b9e2017-06-26 17:13:11 -0700404 void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
405 uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
406 uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle)
Yun Parkfde6b9e2017-06-26 17:13:11 -0700407{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530408 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Parkfde6b9e2017-06-26 17:13:11 -0700409 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
410 "%s invalid instance", __func__);
411 return QDF_STATUS_E_FAILURE;
412 }
413
414 if (soc->ops->ipa_ops->ipa_setup)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530415 return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
Yun Parkfde6b9e2017-06-26 17:13:11 -0700416 ipa_w2i_cb,
417 ipa_wdi_meter_notifier_cb,
418 ipa_desc_size, ipa_priv,
419 is_rm_enabled,
420 tx_pipe_handle,
421 rx_pipe_handle);
422
423 return QDF_STATUS_SUCCESS;
424}
Yun Park1ba3ada2018-01-11 11:38:41 -0800425#endif /* CONFIG_IPA_WDI_UNIFIED_API */
Yun Parkfde6b9e2017-06-26 17:13:11 -0700426
427/**
428 * cdp_ipa_cleanup() - Disconnect IPA pipes
429 * @soc: data path soc handle
430 * @tx_pipe_handle: Tx pipe handle
431 * @rx_pipe_handle: Rx pipe handle
432 *
433 * Return: QDF_STATUS
434 */
435static inline QDF_STATUS
436cdp_ipa_cleanup(ol_txrx_soc_handle soc, uint32_t tx_pipe_handle,
437 uint32_t rx_pipe_handle)
Yun Park6716dff2016-10-26 14:34:49 -0700438{
439 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
440 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
441 "%s invalid instance", __func__);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700442 return QDF_STATUS_E_FAILURE;
Yun Park6716dff2016-10-26 14:34:49 -0700443 }
444
Yun Parkfde6b9e2017-06-26 17:13:11 -0700445 if (soc->ops->ipa_ops->ipa_cleanup)
446 return soc->ops->ipa_ops->ipa_cleanup(tx_pipe_handle,
447 rx_pipe_handle);
Yun Park6716dff2016-10-26 14:34:49 -0700448
Yun Parkfde6b9e2017-06-26 17:13:11 -0700449 return QDF_STATUS_SUCCESS;
Yun Park6716dff2016-10-26 14:34:49 -0700450}
Yun Parkfde6b9e2017-06-26 17:13:11 -0700451
452/**
453 * cdp_ipa_setup_iface() - Setup IPA header and register interface
454 * @soc: data path soc handle
455 * @ifname: Interface name
456 * @mac_addr: Interface MAC address
457 * @prod_client: IPA prod client type
458 * @cons_client: IPA cons client type
459 * @session_id: Session ID
460 * @is_ipv6_enabled: Is IPV6 enabled or not
461 *
462 * Return: QDF_STATUS
463 */
464static inline QDF_STATUS
465cdp_ipa_setup_iface(ol_txrx_soc_handle soc, char *ifname, uint8_t *mac_addr,
Yun Parkfd269b52017-10-05 14:41:32 -0700466 qdf_ipa_client_type_t prod_client,
467 qdf_ipa_client_type_t cons_client,
Yun Parkfde6b9e2017-06-26 17:13:11 -0700468 uint8_t session_id, bool is_ipv6_enabled)
469{
470 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
471 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
472 "%s invalid instance", __func__);
473 return QDF_STATUS_E_FAILURE;
474 }
475
476 if (soc->ops->ipa_ops->ipa_setup_iface)
477 return soc->ops->ipa_ops->ipa_setup_iface(ifname, mac_addr,
478 prod_client,
479 cons_client,
480 session_id,
481 is_ipv6_enabled);
482
483 return QDF_STATUS_SUCCESS;
484}
485
486/**
487 * cdp_ipa_cleanup_iface() - Cleanup IPA header and deregister interface
488 * @soc: data path soc handle
489 * @ifname: Interface name
490 * @is_ipv6_enabled: Is IPV6 enabled or not
491 *
492 * Return: QDF_STATUS
493 */
494static inline QDF_STATUS
495cdp_ipa_cleanup_iface(ol_txrx_soc_handle soc, char *ifname,
496 bool is_ipv6_enabled)
497{
498 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
499 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
500 "%s invalid instance", __func__);
501 return QDF_STATUS_E_FAILURE;
502 }
503
504 if (soc->ops->ipa_ops->ipa_cleanup_iface)
505 return soc->ops->ipa_ops->ipa_cleanup_iface(ifname,
506 is_ipv6_enabled);
507
508 return QDF_STATUS_SUCCESS;
509}
510
511 /**
512 * cdp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530513 * @soc - data path soc handle
514 * @pdev_id - device instance id
Yun Parkfde6b9e2017-06-26 17:13:11 -0700515 *
516 * Return: QDF_STATUS
517 */
518static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530519cdp_ipa_enable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id)
Yun Parkfde6b9e2017-06-26 17:13:11 -0700520{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530521 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Parkfde6b9e2017-06-26 17:13:11 -0700522 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
523 "%s invalid instance", __func__);
524 return QDF_STATUS_E_FAILURE;
525 }
526
527 if (soc->ops->ipa_ops->ipa_enable_pipes)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530528 return soc->ops->ipa_ops->ipa_enable_pipes(soc, pdev_id);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700529
530 return QDF_STATUS_SUCCESS;
531}
532
533/**
534 * cdp_ipa_uc_disable_pipes() - Suspend traffic and disable Tx/Rx pipes
535 * @soc: data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530536 * @pdev_id - device instance id
Yun Parkfde6b9e2017-06-26 17:13:11 -0700537 *
538 * Return: QDF_STATUS
539 */
540static inline QDF_STATUS
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530541cdp_ipa_disable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id)
Yun Parkfde6b9e2017-06-26 17:13:11 -0700542{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530543 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
Yun Parkfde6b9e2017-06-26 17:13:11 -0700544 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
545 "%s invalid instance", __func__);
546 return QDF_STATUS_E_FAILURE;
547 }
548
549 if (soc->ops->ipa_ops->ipa_disable_pipes)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530550 return soc->ops->ipa_ops->ipa_disable_pipes(soc, pdev_id);
Yun Parkfde6b9e2017-06-26 17:13:11 -0700551
552 return QDF_STATUS_SUCCESS;
553}
554
555/**
556 * cdp_ipa_set_perf_level() - Set IPA clock bandwidth based on data rates
557 * @soc: data path soc handle
558 * @client: WLAN Client ID
559 * @max_supported_bw_mbps: Maximum bandwidth needed (in Mbps)
560 *
561 * Return: 0 on success, negative errno on error
562 */
563static inline QDF_STATUS
564cdp_ipa_set_perf_level(ol_txrx_soc_handle soc, int client,
565 uint32_t max_supported_bw_mbps)
566{
567 if (!soc || !soc->ops || !soc->ops->ipa_ops) {
568 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
569 "%s invalid instance", __func__);
570 return QDF_STATUS_E_FAILURE;
571 }
572
573 if (soc->ops->ipa_ops->ipa_set_perf_level)
574 return soc->ops->ipa_ops->ipa_set_perf_level(client,
575 max_supported_bw_mbps);
576
577 return QDF_STATUS_SUCCESS;
578}
jiad5a4530f2019-03-25 15:33:52 +0800579
580/**
581 * cdp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
582 *
583 * @soc: data path soc handle
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530584 * @vdev_id: vdev id
jiad5a4530f2019-03-25 15:33:52 +0800585 * @nbuf: pointer to skb of ethernet packet received from IPA RX path
586 * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
587 *
588 * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
589 *
590 * Return: true if packet is intra-bss fwd-ed and no need to pass to
591 * network stack. false if packet needs to be passed to network stack.
592 */
593static inline bool
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530594cdp_ipa_rx_intrabss_fwd(ol_txrx_soc_handle soc, uint8_t vdev_id,
jiad5a4530f2019-03-25 15:33:52 +0800595 qdf_nbuf_t nbuf, bool *fwd_success)
596{
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530597 if (!soc || !soc->ops || !soc->ops->ipa_ops || !fwd_success) {
jiad5a4530f2019-03-25 15:33:52 +0800598 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
599 "%s invalid instance", __func__);
600 return QDF_STATUS_E_FAILURE;
601 }
602
603 if (soc->ops->ipa_ops->ipa_rx_intrabss_fwd)
Vevek Venkatesan2cc8c5d2019-08-22 16:29:46 +0530604 return soc->ops->ipa_ops->ipa_rx_intrabss_fwd(soc, vdev_id,
605 nbuf,
jiad5a4530f2019-03-25 15:33:52 +0800606 fwd_success);
607
608 /* Fall back to pass up to stack */
609 return false;
610}
611
Yun Parkfde6b9e2017-06-26 17:13:11 -0700612#endif /* IPA_OFFLOAD */
613
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700614#endif /* _CDP_TXRX_IPA_H_ */
615