1 /* 2 * Private header file for Linux OS Independent Layer 3 * 4 * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation 5 * 6 * Copyright (C) 1999-2017, Broadcom Corporation 7 * 8 * Unless you and Broadcom execute a separate written software license 9 * agreement governing use of this software, this software is licensed to you 10 * under the terms of the GNU General Public License version 2 (the "GPL"), 11 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 12 * following added to such license: 13 * 14 * As a special exception, the copyright holders of this software give you 15 * permission to link this software with independent modules, and to copy and 16 * distribute the resulting executable under terms of your choice, provided that 17 * you also meet, for each linked independent module, the terms and conditions of 18 * the license of that module. An independent module is a module which is not 19 * derived from this software. The special exception does not apply to any 20 * modifications of the software. 21 * 22 * Notwithstanding the above, under no circumstances may you combine this 23 * software in any way with any other Broadcom software provided under a license 24 * other than the GPL, without Broadcom's express prior written consent. 25 * 26 * 27 * <<Broadcom-WL-IPTag/Open:>> 28 * 29 * $Id: linux_osl_priv.h 690260 2017-03-15 09:34:11Z $ 30 */ 31 32 #ifndef _LINUX_OSL_PRIV_H_ 33 #define _LINUX_OSL_PRIV_H_ 34 35 #define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognize osh */ 36 #define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */ 37 38 /* dependancy check */ 39 #if !defined(BCMPCIE) && defined(DHD_USE_STATIC_CTRLBUF) 40 #error "DHD_USE_STATIC_CTRLBUF suppored PCIE target only" 41 #endif /* !BCMPCIE && DHD_USE_STATIC_CTRLBUF */ 42 43 #ifdef CONFIG_DHD_USE_STATIC_BUF 44 #ifdef DHD_USE_STATIC_CTRLBUF 45 #define DHD_SKB_1PAGE_BUFSIZE (PAGE_SIZE*1) 46 #define DHD_SKB_2PAGE_BUFSIZE (PAGE_SIZE*2) 47 #define DHD_SKB_4PAGE_BUFSIZE (PAGE_SIZE*4) 48 49 #define PREALLOC_FREE_MAGIC 0xFEDC 50 #define PREALLOC_USED_MAGIC 0xFCDE 51 #else 52 #define DHD_SKB_HDRSIZE 336 53 #define DHD_SKB_1PAGE_BUFSIZE ((PAGE_SIZE*1)-DHD_SKB_HDRSIZE) 54 #define DHD_SKB_2PAGE_BUFSIZE ((PAGE_SIZE*2)-DHD_SKB_HDRSIZE) 55 #define DHD_SKB_4PAGE_BUFSIZE ((PAGE_SIZE*4)-DHD_SKB_HDRSIZE) 56 #endif /* DHD_USE_STATIC_CTRLBUF */ 57 58 #define STATIC_BUF_MAX_NUM 16 59 #define STATIC_BUF_SIZE (PAGE_SIZE*2) 60 #define STATIC_BUF_TOTAL_LEN (STATIC_BUF_MAX_NUM * STATIC_BUF_SIZE) 61 62 typedef struct bcm_static_buf { 63 spinlock_t static_lock; 64 unsigned char *buf_ptr; 65 unsigned char buf_use[STATIC_BUF_MAX_NUM]; 66 } bcm_static_buf_t; 67 68 extern bcm_static_buf_t *bcm_static_buf; 69 70 #ifdef DHD_USE_STATIC_CTRLBUF 71 #define STATIC_PKT_4PAGE_NUM 0 72 #define DHD_SKB_MAX_BUFSIZE DHD_SKB_2PAGE_BUFSIZE 73 #elif defined(ENHANCED_STATIC_BUF) 74 #define STATIC_PKT_4PAGE_NUM 1 75 #define DHD_SKB_MAX_BUFSIZE DHD_SKB_4PAGE_BUFSIZE 76 #else 77 #define STATIC_PKT_4PAGE_NUM 0 78 #define DHD_SKB_MAX_BUFSIZE DHD_SKB_2PAGE_BUFSIZE 79 #endif /* DHD_USE_STATIC_CTRLBUF */ 80 81 #ifdef DHD_USE_STATIC_CTRLBUF 82 #define STATIC_PKT_1PAGE_NUM 0 83 #define STATIC_PKT_2PAGE_NUM 128 84 #else 85 #define STATIC_PKT_1PAGE_NUM 8 86 #define STATIC_PKT_2PAGE_NUM 8 87 #endif /* DHD_USE_STATIC_CTRLBUF */ 88 89 #define STATIC_PKT_1_2PAGE_NUM \ 90 ((STATIC_PKT_1PAGE_NUM) + (STATIC_PKT_2PAGE_NUM)) 91 #define STATIC_PKT_MAX_NUM \ 92 ((STATIC_PKT_1_2PAGE_NUM) + (STATIC_PKT_4PAGE_NUM)) 93 94 typedef struct bcm_static_pkt { 95 #ifdef DHD_USE_STATIC_CTRLBUF 96 struct sk_buff *skb_8k[STATIC_PKT_2PAGE_NUM]; 97 unsigned char pkt_invalid[STATIC_PKT_2PAGE_NUM]; 98 spinlock_t osl_pkt_lock; 99 uint32 last_allocated_index; 100 #else 101 struct sk_buff *skb_4k[STATIC_PKT_1PAGE_NUM]; 102 struct sk_buff *skb_8k[STATIC_PKT_2PAGE_NUM]; 103 #ifdef ENHANCED_STATIC_BUF 104 struct sk_buff *skb_16k; 105 #endif /* ENHANCED_STATIC_BUF */ 106 struct semaphore osl_pkt_sem; 107 #endif /* DHD_USE_STATIC_CTRLBUF */ 108 unsigned char pkt_use[STATIC_PKT_MAX_NUM]; 109 } bcm_static_pkt_t; 110 111 extern bcm_static_pkt_t *bcm_static_skb; 112 #endif /* CONFIG_DHD_USE_STATIC_BUF */ 113 114 typedef struct bcm_mem_link { 115 struct bcm_mem_link *prev; 116 struct bcm_mem_link *next; 117 uint size; 118 int line; 119 void *osh; 120 char file[BCM_MEM_FILENAME_LEN]; 121 } bcm_mem_link_t; 122 123 struct osl_cmn_info { 124 atomic_t malloced; 125 atomic_t pktalloced; /* Number of allocated packet buffers */ 126 spinlock_t dbgmem_lock; 127 bcm_mem_link_t *dbgmem_list; 128 bcm_mem_link_t *dbgvmem_list; 129 spinlock_t pktalloc_lock; 130 atomic_t refcount; /* Number of references to this shared structure. */ 131 }; 132 typedef struct osl_cmn_info osl_cmn_t; 133 134 #if defined(BCM_BACKPLANE_TIMEOUT) 135 typedef uint32 (*bpt_cb_fn)(void *ctx, void *addr); 136 #endif /* BCM_BACKPLANE_TIMEOUT */ 137 138 struct osl_info { 139 osl_pubinfo_t pub; 140 uint32 flags; /* If specific cases to be handled in the OSL */ 141 uint magic; 142 void *pdev; 143 uint failed; 144 uint bustype; 145 osl_cmn_t *cmn; /* Common OSL related data shred between two OSH's */ 146 147 void *bus_handle; 148 #ifdef BCM_SECURE_DMA 149 struct sec_mem_elem *sec_list_4096; 150 struct sec_mem_elem *sec_list_base_4096; 151 phys_addr_t contig_base; 152 void *contig_base_va; 153 phys_addr_t contig_base_alloc; 154 void *contig_base_alloc_va; 155 phys_addr_t contig_base_alloc_coherent; 156 void *contig_base_alloc_coherent_va; 157 void *contig_base_coherent_va; 158 void *contig_delta_va_pa; 159 struct { 160 phys_addr_t pa; 161 void *va; 162 bool avail; 163 } sec_cma_coherent[SEC_CMA_COHERENT_MAX]; 164 int stb_ext_params; 165 #endif /* BCM_SECURE_DMA */ 166 #if defined(BCM_BACKPLANE_TIMEOUT) 167 bpt_cb_fn bpt_cb; 168 void *sih; 169 #endif /* BCM_BACKPLANE_TIMEOUT */ 170 #ifdef USE_DMA_LOCK 171 spinlock_t dma_lock; 172 bool dma_lock_bh; 173 #endif /* USE_DMA_LOCK */ 174 #ifdef DHD_MAP_LOGGING 175 void *dhd_map_log; 176 void *dhd_unmap_log; 177 #endif /* DHD_MAP_LOGGING */ 178 }; 179 180 #endif /* _LINUX_OSL_PRIV_H_ */ 181