1 /* 2 * Copyright (c) 2013-2020 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 int hif_get_send_address(struct hif_sdio_device *pdev, 69 uint8_t pipe, unsigned long *addr); 70 71 QDF_STATUS hif_dev_alloc_and_prepare_rx_packets(struct hif_sdio_device *pdev, 72 uint32_t look_aheads[], 73 int messages, 74 HTC_PACKET_QUEUE *queue); 75 76 QDF_STATUS hif_dev_process_trailer(struct hif_sdio_device *pdev, 77 uint8_t *buffer, int length, 78 uint32_t *next_look_aheads, 79 int *num_look_aheads, 80 HTC_ENDPOINT_ID from_endpoint); 81 82 void hif_dev_free_recv_pkt_queue(HTC_PACKET_QUEUE *recv_pkt_queue); 83 84 QDF_STATUS hif_dev_process_recv_header(struct hif_sdio_device *pdev, 85 HTC_PACKET *packet, 86 uint32_t *next_look_aheads, 87 int *num_look_aheads); 88 void hif_fixup_write_param(struct hif_sdio_dev *pdev, uint32_t req, 89 uint32_t *length, uint32_t *addr); 90 91 #ifdef CONFIG_SDIO_TRANSFER_MAILBOX 92 static inline uint32_t hif_get_send_buffer_flags(struct hif_sdio_device *pdev) 93 { 94 if (pdev) 95 return (uint32_t)HIF_WR_ASYNC_BLOCK_INC; 96 97 hif_err("hif obj is null. Not populating xfer flags"); 98 99 return 0; 100 } 101 102 static inline int hif_sdio_bus_configure(struct hif_softc *hif_sc) 103 { 104 return 0; 105 } 106 107 #elif defined(CONFIG_SDIO_TRANSFER_ADMA) 108 static inline uint32_t hif_get_send_buffer_flags(struct hif_sdio_device *pdev) 109 { 110 /* ADAM-TODO */ 111 return (uint32_t)HIF_WR_ASYNC_BLOCK_FIX; 112 } 113 114 int hif_sdio_bus_configure(struct hif_softc *hif_sc); 115 #endif 116 117 #endif /* __TRANSFER_H__ */ 118