1 /* 2 * OS Abstraction Layer 3 * 4 * Copyright (C) 1999-2017, Broadcom Corporation 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 of 16 * the license of that module. An independent module is a module which is not 17 * 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: osl.h 642189 2016-06-07 21:12:50Z $ 28 */ 29 30 #ifndef _osl_h_ 31 #define _osl_h_ 32 33 #include <osl_decl.h> 34 35 #define OSL_PKTTAG_SZ 32 /* Size of PktTag */ 36 37 /* Drivers use PKTFREESETCB to register a callback function when a packet is freed by OSL */ 38 typedef void (*pktfree_cb_fn_t)(void *ctx, void *pkt, unsigned int status); 39 40 /* Drivers use REGOPSSET() to register register read/write funcitons */ 41 typedef unsigned int (*osl_rreg_fn_t)(void *ctx, volatile void *reg, unsigned int size); 42 typedef void (*osl_wreg_fn_t)(void *ctx, volatile void *reg, unsigned int val, unsigned int size); 43 44 45 #if defined(WL_UNITTEST) 46 #include <utest_osl.h> 47 #else 48 #include <linux_osl.h> 49 #endif 50 51 #ifndef PKTDBG_TRACE 52 #define PKTDBG_TRACE(osh, pkt, bit) BCM_REFERENCE(osh) 53 #endif 54 55 #define PKTCTFMAP(osh, p) BCM_REFERENCE(osh) 56 57 /* -------------------------------------------------------------------------- 58 ** Register manipulation macros. 59 */ 60 61 #define SET_REG(osh, r, mask, val) W_REG((osh), (r), ((R_REG((osh), r) & ~(mask)) | (val))) 62 63 #ifndef AND_REG 64 #define AND_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) & (v)) 65 #endif /* !AND_REG */ 66 67 #ifndef OR_REG 68 #define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v)) 69 #endif /* !OR_REG */ 70 71 #if !defined(OSL_SYSUPTIME) 72 #define OSL_SYSUPTIME() (0) 73 #define OSL_SYSUPTIME_SUPPORT FALSE 74 #else 75 #define OSL_SYSUPTIME_SUPPORT TRUE 76 #endif /* OSL_SYSUPTIME */ 77 78 #if !defined(OSL_SYSUPTIME_US) 79 #define OSL_SYSUPTIME_US() (0) 80 #endif /* OSL_SYSUPTIME */ 81 82 #ifndef OSL_SYS_HALT 83 #define OSL_SYS_HALT() do {} while (0) 84 #endif 85 86 #ifndef OSL_MEM_AVAIL 87 #define OSL_MEM_AVAIL() (0xffffffff) 88 #endif 89 90 #if !(defined(PKTC) || defined(PKTC_DONGLE)) 91 92 #ifndef OSL_OBFUSCATE_BUF 93 /* For security reasons printing pointers is not allowed. 94 * Some OSLs implement OSL_OBFUSCATE_BUF to OS specific obfuscate API. 95 * If OSL_OBFUSCATE_BUF() is not implemented in OSL, then default to 96 * printing the input pointer 97 */ 98 #define OSL_OBFUSCATE_BUF(x) (x) 99 #endif /* OSL_OBFUSCATE_BUF */ 100 101 #define PKTCGETATTR(skb) (0) 102 #define PKTCSETATTR(skb, f, p, b) BCM_REFERENCE(skb) 103 #define PKTCCLRATTR(skb) BCM_REFERENCE(skb) 104 #define PKTCCNT(skb) (1) 105 #define PKTCLEN(skb) PKTLEN(NULL, skb) 106 #define PKTCGETFLAGS(skb) (0) 107 #define PKTCSETFLAGS(skb, f) BCM_REFERENCE(skb) 108 #define PKTCCLRFLAGS(skb) BCM_REFERENCE(skb) 109 #define PKTCFLAGS(skb) (0) 110 #define PKTCSETCNT(skb, c) BCM_REFERENCE(skb) 111 #define PKTCINCRCNT(skb) BCM_REFERENCE(skb) 112 #define PKTCADDCNT(skb, c) BCM_REFERENCE(skb) 113 #define PKTCSETLEN(skb, l) BCM_REFERENCE(skb) 114 #define PKTCADDLEN(skb, l) BCM_REFERENCE(skb) 115 #define PKTCSETFLAG(skb, fb) BCM_REFERENCE(skb) 116 #define PKTCCLRFLAG(skb, fb) BCM_REFERENCE(skb) 117 #define PKTCLINK(skb) NULL 118 #define PKTSETCLINK(skb, x) BCM_REFERENCE(skb) 119 #define FOREACH_CHAINED_PKT(skb, nskb) \ 120 for ((nskb) = NULL; (skb) != NULL; (skb) = (nskb)) 121 #define PKTCFREE PKTFREE 122 #define PKTCENQTAIL(h, t, p) \ 123 do { \ 124 if ((t) == NULL) { \ 125 (h) = (t) = (p); \ 126 } \ 127 } while (0) 128 #endif /* !linux || !PKTC */ 129 130 #if !(defined(HNDCTF) || defined(PKTC_TX_DONGLE) || defined(PKTC)) 131 #define PKTSETCHAINED(osh, skb) BCM_REFERENCE(osh) 132 #define PKTCLRCHAINED(osh, skb) BCM_REFERENCE(osh) 133 #define PKTISCHAINED(skb) FALSE 134 #endif 135 136 /* Lbuf with fraglist */ 137 #ifndef PKTFRAGPKTID 138 #define PKTFRAGPKTID(osh, lb) (0) 139 #endif 140 #ifndef PKTSETFRAGPKTID 141 #define PKTSETFRAGPKTID(osh, lb, id) BCM_REFERENCE(osh) 142 #endif 143 #ifndef PKTFRAGTOTNUM 144 #define PKTFRAGTOTNUM(osh, lb) (0) 145 #endif 146 #ifndef PKTSETFRAGTOTNUM 147 #define PKTSETFRAGTOTNUM(osh, lb, tot) BCM_REFERENCE(osh) 148 #endif 149 #ifndef PKTFRAGTOTLEN 150 #define PKTFRAGTOTLEN(osh, lb) (0) 151 #endif 152 #ifndef PKTSETFRAGTOTLEN 153 #define PKTSETFRAGTOTLEN(osh, lb, len) BCM_REFERENCE(osh) 154 #endif 155 #ifndef PKTIFINDEX 156 #define PKTIFINDEX(osh, lb) (0) 157 #endif 158 #ifndef PKTSETIFINDEX 159 #define PKTSETIFINDEX(osh, lb, idx) BCM_REFERENCE(osh) 160 #endif 161 #ifndef PKTGETLF 162 #define PKTGETLF(osh, len, send, lbuf_type) (0) 163 #endif 164 165 /* in rx path, reuse totlen as used len */ 166 #ifndef PKTFRAGUSEDLEN 167 #define PKTFRAGUSEDLEN(osh, lb) (0) 168 #endif 169 #ifndef PKTSETFRAGUSEDLEN 170 #define PKTSETFRAGUSEDLEN(osh, lb, len) BCM_REFERENCE(osh) 171 #endif 172 #ifndef PKTFRAGLEN 173 #define PKTFRAGLEN(osh, lb, ix) (0) 174 #endif 175 #ifndef PKTSETFRAGLEN 176 #define PKTSETFRAGLEN(osh, lb, ix, len) BCM_REFERENCE(osh) 177 #endif 178 #ifndef PKTFRAGDATA_LO 179 #define PKTFRAGDATA_LO(osh, lb, ix) (0) 180 #endif 181 #ifndef PKTSETFRAGDATA_LO 182 #define PKTSETFRAGDATA_LO(osh, lb, ix, addr) BCM_REFERENCE(osh) 183 #endif 184 #ifndef PKTFRAGDATA_HI 185 #define PKTFRAGDATA_HI(osh, lb, ix) (0) 186 #endif 187 #ifndef PKTSETFRAGDATA_HI 188 #define PKTSETFRAGDATA_HI(osh, lb, ix, addr) BCM_REFERENCE(osh) 189 #endif 190 191 /* RX FRAG */ 192 #ifndef PKTISRXFRAG 193 #define PKTISRXFRAG(osh, lb) (0) 194 #endif 195 #ifndef PKTSETRXFRAG 196 #define PKTSETRXFRAG(osh, lb) BCM_REFERENCE(osh) 197 #endif 198 #ifndef PKTRESETRXFRAG 199 #define PKTRESETRXFRAG(osh, lb) BCM_REFERENCE(osh) 200 #endif 201 202 /* TX FRAG */ 203 #ifndef PKTISTXFRAG 204 #define PKTISTXFRAG(osh, lb) (0) 205 #endif 206 #ifndef PKTSETTXFRAG 207 #define PKTSETTXFRAG(osh, lb) BCM_REFERENCE(osh) 208 #endif 209 210 /* Need Rx completion used for AMPDU reordering */ 211 #ifndef PKTNEEDRXCPL 212 #define PKTNEEDRXCPL(osh, lb) (TRUE) 213 #endif 214 #ifndef PKTSETNORXCPL 215 #define PKTSETNORXCPL(osh, lb) BCM_REFERENCE(osh) 216 #endif 217 #ifndef PKTRESETNORXCPL 218 #define PKTRESETNORXCPL(osh, lb) BCM_REFERENCE(osh) 219 #endif 220 #ifndef PKTISFRAG 221 #define PKTISFRAG(osh, lb) (0) 222 #endif 223 #ifndef PKTFRAGISCHAINED 224 #define PKTFRAGISCHAINED(osh, i) (0) 225 #endif 226 /* TRIM Tail bytes from lfrag */ 227 #ifndef PKTFRAG_TRIM_TAILBYTES 228 #define PKTFRAG_TRIM_TAILBYTES(osh, p, len, type) PKTSETLEN(osh, p, PKTLEN(osh, p) - len) 229 #endif 230 #ifndef PKTISHDRCONVTD 231 #define PKTISHDRCONVTD(osh, lb) (0) 232 #endif 233 234 #ifdef BCM_SECURE_DMA 235 #define SECURE_DMA_ENAB(osh) (1) 236 #else 237 238 #define SECURE_DMA_ENAB(osh) (0) 239 #ifndef BCMDMA64OSL 240 #define SECURE_DMA_MAP(osh, va, size, direction, p, dmah, pcma, offset) ((dmaaddr_t) ((0))) 241 #else 242 #define SECURE_DMA_MAP(osh, va, size, direction, p, dmah, pcma, offset) ((dmaaddr_t) {(0)}) 243 #endif 244 #define SECURE_DMA_DD_MAP(osh, va, size, direction, p, dmah) 0 245 #ifndef BCMDMA64OSL 246 #define SECURE_DMA_MAP_TXMETA(osh, va, size, direction, p, dmah, pcma) ((dmaaddr_t) ((0))) 247 #else 248 #define SECURE_DMA_MAP_TXMETA(osh, va, size, direction, p, dmah, pcma) ((dmaaddr_t) {(0)}) 249 #endif 250 #define SECURE_DMA_UNMAP(osh, pa, size, direction, p, dmah, pcma, offset) 251 #define SECURE_DMA_UNMAP_ALL(osh, pcma) 252 253 #endif /* BCMDMA64OSL */ 254 255 256 #ifndef ROMMABLE_ASSERT 257 #define ROMMABLE_ASSERT(exp) ASSERT(exp) 258 #endif /* ROMMABLE_ASSERT */ 259 260 #endif /* _osl_h_ */ 261