1 /* 2 * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. 3 * 4 * 5 * 6 * Permission to use, copy, modify, and/or distribute this software for 7 * any purpose with or without fee is hereby granted, provided that the 8 * above copyright notice and this permission notice appear in all 9 * copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 15 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 16 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 17 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 18 * PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21 #ifndef __TRANSFER_H_ 22 #define __TRANSFER_H_ 23 24 #include <qdf_types.h> 25 #include <qdf_status.h> 26 #include <qdf_timer.h> 27 #include <qdf_time.h> 28 #include <qdf_lock.h> 29 #include <qdf_mem.h> 30 #include <qdf_util.h> 31 #include <qdf_defer.h> 32 #include <qdf_atomic.h> 33 #include <qdf_nbuf.h> 34 #include <athdefs.h> 35 #include <qdf_net_types.h> 36 #include <a_types.h> 37 #include <athdefs.h> 38 #include <a_osapi.h> 39 #include <hif.h> 40 #include <htc_services.h> 41 #include <a_debug.h> 42 #include "hif_sdio_internal.h" 43 44 #if defined(CONFIG_SDIO_TRANSFER_MAILBOX) && defined(CONFIG_SDIO_TRANSFER_ADMA) 45 #error "-----------------------------------------------" 46 #error "Error - Both transfer methods cannot be enabled" 47 #error "-----------------------------------------------" 48 #endif 49 50 #define NBUF_ALLOC_FAIL_WAIT_TIME 100 51 /* high nibble */ 52 #define BUNDLE_COUNT_HIGH(f) (((f) & 0x0C) << 2) 53 /* low nibble */ 54 #define BUNDLE_COUNT_LOW(f) (((f) & 0xF0) >> 4) 55 #define GET_RECV_BUNDLE_COUNT(f) (BUNDLE_COUNT_HIGH(f) + BUNDLE_COUNT_LOW(f)) 56 57 /* 58 * Data structure to record required sending context data 59 */ 60 struct hif_sendContext { 61 bool bNewAlloc; 62 struct hif_sdio_device *pDev; 63 qdf_nbuf_t netbuf; 64 unsigned int transferID; 65 unsigned int head_data_len; 66 }; 67 68 void hif_dev_dump_registers(struct hif_sdio_device *pdev, 69 struct MBOX_IRQ_PROC_REGISTERS *irq_proc, 70 struct MBOX_IRQ_ENABLE_REGISTERS *irq_en, 71 struct MBOX_COUNTER_REGISTERS *mbox_regs); 72 73 int hif_get_send_address(struct hif_sdio_device *pdev, 74 uint8_t pipe, uint32_t *addr); 75 76 QDF_STATUS hif_dev_alloc_and_prepare_rx_packets(struct hif_sdio_device *pdev, 77 uint32_t look_aheads[], 78 int messages, 79 HTC_PACKET_QUEUE *queue); 80 81 QDF_STATUS hif_dev_process_trailer(struct hif_sdio_device *pdev, 82 uint8_t *buffer, int length, 83 uint32_t *next_look_aheads, 84 int *num_look_aheads, 85 HTC_ENDPOINT_ID from_endpoint); 86 87 void hif_dev_free_recv_pkt_queue(HTC_PACKET_QUEUE *recv_pkt_queue); 88 89 QDF_STATUS hif_dev_process_recv_header(struct hif_sdio_device *pdev, 90 HTC_PACKET *packet, 91 uint32_t *next_look_aheads, 92 int *num_look_aheads); 93 void hif_fixup_write_param(struct hif_sdio_dev *pdev, uint32_t req, 94 uint32_t *length, uint32_t *addr); 95 96 #ifdef CONFIG_SDIO_TRANSFER_MAILBOX 97 static inline uint32_t hif_get_send_buffer_flags(struct hif_sdio_device *pdev) 98 { 99 if (pdev) 100 return (uint32_t)HIF_WR_ASYNC_BLOCK_INC; 101 102 HIF_ERROR("%s: hif obj is null. Not populating xfer flags", __func__); 103 104 return 0; 105 } 106 #elif defined(CONFIG_SDIO_TRANSFER_ADMA) 107 #error "Error - Not implemented yet" 108 #endif 109 110 #endif /* __TRANSFER_H__ */ 111