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