rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2014 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * Filename: |
| 38 | * --------- |
| 39 | * hif_spd_ext.h |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * UMOLY |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * Defines the common spd ext macros for HIF middleware |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *============================================================================== |
| 54 | * HISTORY |
| 55 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | *------------------------------------------------------------------------------ |
| 57 | * removed! |
| 58 | * removed! |
| 59 | *------------------------------------------------------------------------------ |
| 60 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 61 | *============================================================================== |
| 62 | *******************************************************************************/ |
| 63 | #ifndef HIF_SPD_EXT_H |
| 64 | #define HIF_SPD_EXT_H |
| 65 | |
| 66 | #include "kal_public_api.h" |
| 67 | #include "qmu_bm_spd.h" |
| 68 | |
| 69 | |
| 70 | /*------------------------------------------------------------------------------ |
| 71 | * Type definitions |
| 72 | *----------------------------------------------------------------------------*/ |
| 73 | typedef struct _hif_spd_ext_header hif_spd_ext_header; |
| 74 | typedef struct _hif_spd_packet_header hif_spd_packet_header; |
| 75 | |
| 76 | /*------------------------------------------------------------------------------ |
| 77 | * Data structures |
| 78 | *----------------------------------------------------------------------------*/ |
| 79 | struct _hif_spd_ext_header |
| 80 | { |
| 81 | kal_uint16 pkt_num; // |
| 82 | kal_uint8 spd1_header_len; // the header length of SPD type 1 |
| 83 | kal_uint8 reserved; |
| 84 | }; |
| 85 | |
| 86 | struct _hif_spd_packet_header |
| 87 | { |
| 88 | kal_uint16 payload_len; // the length of packet payload |
| 89 | kal_uint8 spd2_header_len; // the header length of SPD type 2 |
| 90 | kal_uint8 flags; // includes IGR and EOL |
| 91 | }; |
| 92 | |
| 93 | /*------------------------------------------------------------------------------ |
| 94 | * Macros |
| 95 | *----------------------------------------------------------------------------*/ |
| 96 | #define SPD_PH_FLAG_BIT_EOL ((kal_uint8)0x40) |
| 97 | #define SPD_PH_FLAG_BIT_IGR ((kal_uint8)0x80) |
| 98 | |
| 99 | #define HIF_SPD_PH_SET_EOL(_p) \ |
| 100 | (HIF_GET_SPD_PH_PTR(_p)->flags |= SPD_PH_FLAG_BIT_EOL) |
| 101 | |
| 102 | #define HIF_SPD_PH_CLR_EOL(_p) \ |
| 103 | (HIF_GET_SPD_PH_PTR(_p)->flags &= ~SPD_PH_FLAG_BIT_EOL) |
| 104 | |
| 105 | #define HIF_SPD_PH_GET_EOL(_p) \ |
| 106 | (HIF_GET_SPD_PH_PTR(_p)->flags & SPD_PH_FLAG_BIT_EOL) |
| 107 | |
| 108 | #define HIF_SPD_PH_SET_IGR(_p) \ |
| 109 | (HIF_GET_SPD_PH_PTR(_p)->flags |= SPD_PH_FLAG_BIT_IGR) |
| 110 | |
| 111 | #define HIF_SPD_PH_CLR_IGR(_p) \ |
| 112 | (HIF_GET_SPD_PH_PTR(_p)->flags &= ~SPD_PH_FLAG_BIT_IGR) |
| 113 | |
| 114 | #define HIF_SPD_PH_GET_IGR(_p) \ |
| 115 | (HIF_GET_SPD_PH_PTR(_p)->flags & SPD_PH_FLAG_BIT_IGR) |
| 116 | |
| 117 | /*------------------------------------------------------------------------------ |
| 118 | * Inline functions |
| 119 | *----------------------------------------------------------------------------*/ |
| 120 | INLINE_MODIFIER INLINE void HIF_SPD_EXT_SET_PKTNUM(hif_spd_ext_header *p_spdext, kal_uint16 num) |
| 121 | { |
| 122 | p_spdext->pkt_num = num; |
| 123 | } |
| 124 | |
| 125 | INLINE_MODIFIER INLINE kal_uint16 HIF_SPD_EXT_GET_PKTNUM(hif_spd_ext_header *p_spdext) |
| 126 | { |
| 127 | return p_spdext->pkt_num; |
| 128 | } |
| 129 | |
| 130 | INLINE_MODIFIER INLINE void HIF_SPD_EXT_SET_SPD1_HEADERLEN(hif_spd_ext_header *p_spdext, kal_uint8 len) |
| 131 | { |
| 132 | DEBUG_ASSERT( len <= QBM_SPD_MAX_HEADER_LEN ); |
| 133 | p_spdext->spd1_header_len = len; |
| 134 | } |
| 135 | |
| 136 | INLINE_MODIFIER INLINE kal_uint8 HIF_SPD_EXT_GET_SPD1_HEADERLEN(hif_spd_ext_header *p_spdext) |
| 137 | { |
| 138 | return p_spdext->spd1_header_len; |
| 139 | } |
| 140 | |
| 141 | INLINE_MODIFIER INLINE hif_spd_packet_header* HIF_SPD_EXT_GET_FIRST_PH(void *p) |
| 142 | { |
| 143 | return (hif_spd_packet_header*)((kal_uint8 *)(p) + sizeof(hif_spd_ext_header)); |
| 144 | } |
| 145 | |
| 146 | INLINE_MODIFIER INLINE hif_spd_packet_header* HIF_GET_SPD_PH_PTR(void *p) |
| 147 | { |
| 148 | return (hif_spd_packet_header*)p; |
| 149 | } |
| 150 | |
| 151 | INLINE_MODIFIER INLINE void HIF_SPD_PH_SET_PAYLOAD_LEN(hif_spd_packet_header *p_spdph, kal_uint16 len) |
| 152 | { |
| 153 | p_spdph->payload_len = len; |
| 154 | } |
| 155 | |
| 156 | INLINE_MODIFIER INLINE kal_uint16 HIF_SPD_PH_GET_PAYLOAD_LEN(hif_spd_packet_header *p_spdph) |
| 157 | { |
| 158 | return p_spdph->payload_len; |
| 159 | } |
| 160 | |
| 161 | INLINE_MODIFIER INLINE void HIF_SPD_PH_SET_SPD2_HEADERLEN(hif_spd_packet_header *p_spdph, kal_uint8 len) |
| 162 | { |
| 163 | p_spdph->spd2_header_len = len; |
| 164 | } |
| 165 | |
| 166 | INLINE_MODIFIER INLINE kal_uint8 HIF_SPD_PH_GET_SPD2_HEADERLEN(hif_spd_packet_header *p_spdph) |
| 167 | { |
| 168 | return p_spdph->spd2_header_len; |
| 169 | } |
| 170 | |
| 171 | INLINE_MODIFIER INLINE kal_uint8* HIF_SPD_PH_GET_HEADER(hif_spd_packet_header *p_ph) |
| 172 | { |
| 173 | return ((kal_uint8 *)(p_ph) + sizeof(hif_spd_packet_header)); |
| 174 | } |
| 175 | |
| 176 | INLINE_MODIFIER INLINE hif_spd_packet_header* HIF_SPD_PH_NEXT(hif_spd_packet_header *p_ph, kal_uint8 header_len) |
| 177 | { |
| 178 | kal_uint8* addr = ((kal_uint8 *)(p_ph) + sizeof(hif_spd_packet_header) + ((header_len + 3) & ~(0x3)));// 4-bytes alignment |
| 179 | |
| 180 | return (hif_spd_packet_header *)addr; |
| 181 | } |
| 182 | |
| 183 | #endif /* HIF_SPD_EXT_H */ |