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