From 5aeabd612dcd746d8478bd7431edf66cf211cf1b Mon Sep 17 00:00:00 2001 From: Rakshith Suresh Patkar Date: Tue, 4 Dec 2018 21:12:00 +0530 Subject: [PATCH] qcacmn: Add support to handle new htt format If FW supports new htt format include only payload length in the header length. Change-Id: Ia5ec9a474bc5fe68de28273e6f9615d36de94a7c CRs-Fixed: 2359253 --- htc/htc.c | 1 + htc/htc_api.h | 13 ++++++++++++- htc/htc_internal.h | 2 ++ htc/htc_send.c | 33 ++++++++++++++++++++++----------- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/htc/htc.c b/htc/htc.c index a62b02f4c8..98e9e45bcd 100644 --- a/htc/htc.c +++ b/htc/htc.c @@ -283,6 +283,7 @@ HTC_HANDLE htc_create(void *ol_sc, struct htc_init_info *pInfo, qdf_spinlock_create(&pEndpoint->lookup_queue_lock); } target->is_nodrop_pkt = false; + target->htc_hdr_length_check = false; target->wmi_ep_count = 1; do { diff --git a/htc/htc_api.h b/htc/htc_api.h index 86336a5c4c..0950ba5d30 100644 --- a/htc/htc_api.h +++ b/htc/htc_api.h @@ -634,11 +634,22 @@ bool htc_is_endpoint_active(HTC_HANDLE HTCHandle, * @isNodropPkt - indicates whether it is nodrop pkt * * Return: None - * Return: * */ void htc_set_nodrop_pkt(HTC_HANDLE HTCHandle, A_BOOL isNodropPkt); +/** + * htc_enable_hdr_length_check - Set up htc_hdr_length_check flag + * @HTCHandle - HTC handle + * @htc_hdr_length_check - flag to indicate whether htc header length check is + * required + * + * Return: None + * + */ +void +htc_enable_hdr_length_check(HTC_HANDLE htc_handle, bool htc_hdr_length_check); + /** * htc_get_num_recv_buffers - Get the number of recv buffers currently queued * into an HTC endpoint diff --git a/htc/htc_internal.h b/htc/htc_internal.h index 888ee68cb7..32b527821f 100644 --- a/htc/htc_internal.h +++ b/htc/htc_internal.h @@ -240,6 +240,8 @@ typedef struct _HTC_TARGET { * reflect the actual count. */ uint8_t wmi_ep_count; + /* Flag to indicate whether htc header length check is required */ + bool htc_hdr_length_check; } HTC_TARGET; diff --git a/htc/htc_send.c b/htc/htc_send.c index a1c41b9822..5acce1d86a 100644 --- a/htc/htc_send.c +++ b/htc/htc_send.c @@ -1500,17 +1500,18 @@ qdf_export_symbol(htc_send_pkt); * * Return: QDF_STATUS_SUCCESS for success or an appropriate QDF_STATUS error */ -QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf, int Epid, - int ActualLength) +QDF_STATUS htc_send_data_pkt(HTC_HANDLE htc_hdl, qdf_nbuf_t netbuf, int ep_id, + int actual_length) { - HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(htc_hdl); HTC_ENDPOINT *pEndpoint; - HTC_FRAME_HDR *pHtcHdr; + HTC_FRAME_HDR *p_htc_hdr; QDF_STATUS status = QDF_STATUS_SUCCESS; int tx_resources; uint32_t data_attr = 0; + int htc_payload_len = actual_length; - pEndpoint = &target->endpoint[Epid]; + pEndpoint = &target->endpoint[ep_id]; tx_resources = hif_get_free_queue_number(target->hif_dev, pEndpoint->UL_PipeID); @@ -1530,13 +1531,16 @@ QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf, int Epid, if (hif_pm_runtime_get(target->hif_dev)) return QDF_STATUS_E_FAILURE; - pHtcHdr = (HTC_FRAME_HDR *) qdf_nbuf_get_frag_vaddr(netbuf, 0); - AR_DEBUG_ASSERT(pHtcHdr); + p_htc_hdr = (HTC_FRAME_HDR *)qdf_nbuf_get_frag_vaddr(netbuf, 0); + AR_DEBUG_ASSERT(p_htc_hdr); data_attr = qdf_nbuf_data_attr_get(netbuf); - HTC_WRITE32(pHtcHdr, SM(ActualLength, HTC_FRAME_HDR_PAYLOADLEN) | - SM(Epid, HTC_FRAME_HDR_ENDPOINTID)); + if (target->htc_hdr_length_check) + htc_payload_len = actual_length - HTC_HEADER_LEN; + + HTC_WRITE32(p_htc_hdr, SM(htc_payload_len, HTC_FRAME_HDR_PAYLOADLEN) + | SM(ep_id, HTC_FRAME_HDR_ENDPOINTID)); /* * If the HIF pipe for the data endpoint is polled rather than * interrupt-driven, this is a good point to check whether any @@ -1554,7 +1558,7 @@ QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf, int Epid, LOCK_HTC_TX(target); - HTC_WRITE32(((uint32_t *) pHtcHdr) + 1, + HTC_WRITE32(((uint32_t *)p_htc_hdr) + 1, SM(pEndpoint->SeqNo, HTC_FRAME_HDR_CONTROLBYTES1)); pEndpoint->SeqNo++; @@ -1565,7 +1569,7 @@ QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf, int Epid, sizeof(qdf_nbuf_data(netbuf)), QDF_TX)); status = hif_send_head(target->hif_dev, pEndpoint->UL_PipeID, - pEndpoint->Id, ActualLength, netbuf, data_attr); + pEndpoint->Id, actual_length, netbuf, data_attr); UNLOCK_HTC_TX(target); return status; @@ -2131,6 +2135,13 @@ void htc_set_nodrop_pkt(HTC_HANDLE HTCHandle, A_BOOL isNodropPkt) target->is_nodrop_pkt = isNodropPkt; } +void htc_enable_hdr_length_check(HTC_HANDLE htc_hdl, bool htc_hdr_length_check) +{ + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(htc_hdl); + + target->htc_hdr_length_check = htc_hdr_length_check; +} + /** * htc_process_credit_rpt() - process credit report, call distribution function * @target: pointer to HTC_TARGET