forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/net/wireless/ath/ath10k/htc.h
....@@ -1,18 +1,7 @@
1
+/* SPDX-License-Identifier: ISC */
12 /*
23 * Copyright (c) 2005-2011 Atheros Communications Inc.
34 * Copyright (c) 2011-2016 Qualcomm Atheros, Inc.
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
165 */
176
187 #ifndef _HTC_H_
....@@ -23,6 +12,7 @@
2312 #include <linux/bug.h>
2413 #include <linux/skbuff.h>
2514 #include <linux/timer.h>
15
+#include <linux/bitfield.h>
2616
2717 struct ath10k;
2818
....@@ -50,8 +40,7 @@
5040 * 4-byte aligned.
5141 */
5242
53
-#define HTC_HOST_MAX_MSG_PER_RX_BUNDLE 8
54
-#define HTC_HOST_MAX_MSG_PER_TX_BUNDLE 16
43
+#define HTC_HOST_MAX_MSG_PER_RX_BUNDLE 32
5544
5645 enum ath10k_htc_tx_flags {
5746 ATH10K_HTC_FLAG_NEED_CREDIT_UPDATE = 0x01,
....@@ -61,8 +50,26 @@
6150 enum ath10k_htc_rx_flags {
6251 ATH10K_HTC_FLAGS_RECV_1MORE_BLOCK = 0x01,
6352 ATH10K_HTC_FLAG_TRAILER_PRESENT = 0x02,
64
- ATH10K_HTC_FLAG_BUNDLE_MASK = 0xF0
6553 };
54
+
55
+#define ATH10K_HTC_FLAG_BUNDLE_MASK GENMASK(7, 4)
56
+
57
+/* bits 2-3 are for extra bundle count bits 4-5 */
58
+#define ATH10K_HTC_BUNDLE_EXTRA_MASK GENMASK(3, 2)
59
+#define ATH10K_HTC_BUNDLE_EXTRA_SHIFT 4
60
+
61
+static inline unsigned int ath10k_htc_get_bundle_count(u8 max_msgs, u8 flags)
62
+{
63
+ unsigned int count, extra_count = 0;
64
+
65
+ count = FIELD_GET(ATH10K_HTC_FLAG_BUNDLE_MASK, flags);
66
+
67
+ if (max_msgs > 16)
68
+ extra_count = FIELD_GET(ATH10K_HTC_BUNDLE_EXTRA_MASK, flags) <<
69
+ ATH10K_HTC_BUNDLE_EXTRA_SHIFT;
70
+
71
+ return count + extra_count;
72
+}
6673
6774 struct ath10k_htc_hdr {
6875 u8 eid; /* @enum ath10k_htc_ep_id */
....@@ -76,8 +83,14 @@
7683 u8 seq_no; /* for tx */
7784 u8 control_byte1;
7885 } __packed;
79
- u8 pad0;
80
- u8 pad1;
86
+ union {
87
+ __le16 pad_len;
88
+ struct {
89
+ u8 pad0;
90
+ u8 pad1;
91
+ } __packed;
92
+ } __packed;
93
+
8194 } __packed __aligned(4);
8295
8396 enum ath10k_ath10k_htc_msg_id {
....@@ -106,6 +119,8 @@
106119 #define ATH10K_HTC_CONN_FLAGS_RECV_ALLOC_LSB 8
107120 };
108121
122
+#define ATH10K_HTC_MSG_READY_EXT_ALT_DATA_MASK 0xFFF
123
+
109124 enum ath10k_htc_conn_svc_status {
110125 ATH10K_HTC_CONN_SVC_STATUS_SUCCESS = 0,
111126 ATH10K_HTC_CONN_SVC_STATUS_NOT_FOUND = 1,
....@@ -113,6 +128,10 @@
113128 ATH10K_HTC_CONN_SVC_STATUS_NO_RESOURCES = 3,
114129 ATH10K_HTC_CONN_SVC_STATUS_NO_MORE_EP = 4
115130 };
131
+
132
+#define ATH10K_MAX_MSG_PER_HTC_TX_BUNDLE 32
133
+#define ATH10K_MIN_MSG_PER_HTC_TX_BUNDLE 2
134
+#define ATH10K_MIN_CREDIT_PER_HTC_TX_BUNDLE 2
116135
117136 enum ath10k_htc_setup_complete_flags {
118137 ATH10K_HTC_SETUP_COMPLETE_FLAGS_RX_BNDL_EN = 1
....@@ -138,8 +157,14 @@
138157 struct ath10k_htc_ready base;
139158 u8 htc_version; /* @enum ath10k_htc_version */
140159 u8 max_msgs_per_htc_bundle;
141
- u8 pad0;
142
- u8 pad1;
160
+ union {
161
+ __le16 reserved;
162
+ struct {
163
+ u8 pad0;
164
+ u8 pad1;
165
+ } __packed;
166
+ } __packed;
167
+
143168 } __packed;
144169
145170 struct ath10k_htc_conn_svc {
....@@ -346,7 +371,12 @@
346371
347372 u8 seq_no; /* for debugging */
348373 int tx_credits;
374
+ int tx_credit_size;
349375 bool tx_credit_flow_enabled;
376
+ bool bundle_tx;
377
+ struct sk_buff_head tx_req_head;
378
+ struct sk_buff_head tx_complete_head;
379
+
350380 };
351381
352382 struct ath10k_htc_svc_tx_credits {
....@@ -371,16 +401,25 @@
371401 int total_transmit_credits;
372402 int target_credit_size;
373403 u8 max_msgs_per_htc_bundle;
404
+ int alt_data_credit_size;
374405 };
375406
376407 int ath10k_htc_init(struct ath10k *ar);
377408 int ath10k_htc_wait_target(struct ath10k_htc *htc);
409
+void ath10k_htc_setup_tx_req(struct ath10k_htc_ep *ep);
378410 int ath10k_htc_start(struct ath10k_htc *htc);
379411 int ath10k_htc_connect_service(struct ath10k_htc *htc,
380412 struct ath10k_htc_svc_conn_req *conn_req,
381413 struct ath10k_htc_svc_conn_resp *conn_resp);
414
+void ath10k_htc_change_tx_credit_flow(struct ath10k_htc *htc,
415
+ enum ath10k_htc_ep_id eid,
416
+ bool enable);
382417 int ath10k_htc_send(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid,
383418 struct sk_buff *packet);
419
+void ath10k_htc_stop_hl(struct ath10k *ar);
420
+
421
+int ath10k_htc_send_hl(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid,
422
+ struct sk_buff *packet);
384423 struct sk_buff *ath10k_htc_alloc_skb(struct ath10k *ar, int size);
385424 void ath10k_htc_tx_completion_handler(struct ath10k *ar, struct sk_buff *skb);
386425 void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb);