1 /* 2 * Copyright 2022, Cypress Semiconductor Corporation (an Infineon company) 3 * SPDX-License-Identifier: Apache-2.0 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /** @file 19 * Provides whd with function prototypes for IOCTL commands, 20 * and for communicating with the SDPCM module 21 * 22 */ 23 24 #ifndef INCLUDED_WHD_SDPCM_H 25 #define INCLUDED_WHD_SDPCM_H 26 27 #include "whd.h" 28 #include "whd_events_int.h" 29 #include "cyabs_rtos.h" 30 #include "whd_network_types.h" 31 #include "whd_types_int.h" 32 #include "whd_cdc_bdc.h" 33 34 #ifdef __cplusplus 35 extern "C" 36 { 37 #endif 38 39 /****************************************************** 40 * Constants 41 ******************************************************/ 42 typedef enum 43 { 44 DATA_HEADER = 2, 45 ASYNCEVENT_HEADER = 1, 46 CONTROL_HEADER = 0 47 } sdpcm_header_type_t; 48 49 /****************************************************** 50 * Macros 51 ******************************************************/ 52 53 #define BUS_HEADER_LEN (12) 54 #define IOCTL_OFFSET (sizeof(whd_buffer_header_t) + 12 + 16) 55 56 /****************************************************** 57 * Structures 58 ******************************************************/ 59 typedef struct whd_sdpcm_info 60 { 61 /* Bus data credit variables */ 62 uint8_t tx_seq; 63 uint8_t tx_max; 64 65 66 /* Packet send queue variables */ 67 cy_semaphore_t send_queue_mutex; 68 whd_buffer_t send_queue_head[5]; 69 whd_buffer_t send_queue_tail[5]; 70 uint32_t npkt_in_q[5]; /** 4 AC queues + 1 Contol queue(IOVAR/IOCTLs) */ 71 uint32_t totpkt_in_q; 72 } whd_sdpcm_info_t; 73 74 typedef struct 75 { 76 whd_buffer_header_t buffer_header; 77 uint8_t bus_header[BUS_HEADER_LEN]; 78 } bus_common_header_t; 79 80 #pragma pack(1) 81 typedef struct 82 { 83 bus_common_header_t common; 84 cdc_header_t cdc_header; 85 } control_header_t; 86 87 typedef struct 88 { 89 bus_common_header_t common; 90 uint8_t _padding[2]; 91 bdc_header_t bdc_header; 92 } data_header_t; 93 #pragma pack() 94 95 /****************************************************** 96 * Function declarations 97 ******************************************************/ 98 99 extern void whd_sdpcm_process_rx_packet(whd_driver_t whd_driver, whd_buffer_t buffer); 100 extern whd_result_t whd_sdpcm_init(whd_driver_t whd_driver); 101 extern void whd_sdpcm_quit(whd_driver_t whd_driver); 102 extern void whd_sdpcm_bus_vars_init(whd_driver_t whd_driver); 103 extern void whd_sdpcm_quit(whd_driver_t whd_driver); 104 extern whd_bool_t whd_sdpcm_has_tx_packet(whd_driver_t whd_driver); 105 106 extern whd_result_t whd_sdpcm_get_packet_to_send(whd_driver_t whd_driver, whd_buffer_t *buffer); 107 extern void whd_sdpcm_update_credit(whd_driver_t whd_driver, uint8_t *data); 108 extern uint8_t whd_sdpcm_get_available_credits(whd_driver_t whd_driver); 109 extern void whd_update_host_interface_to_bss_index_mapping(whd_driver_t whd_driver, whd_interface_t interface, 110 uint32_t bssid_index); 111 112 extern whd_result_t whd_send_to_bus(whd_driver_t whd_driver, whd_buffer_t buffer, 113 sdpcm_header_type_t header_type, uint8_t prio); 114 115 /****************************************************** 116 * Global variables 117 ******************************************************/ 118 119 #ifdef __cplusplus 120 } /* extern "C" */ 121 #endif 122 123 #endif /* ifndef INCLUDED_WHD_SDPCM_H */ 124