linux_osl_priv.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Private header file for Linux OS Independent Layer
  3. *
  4. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  5. *
  6. * Copyright (C) 1999-2020, 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. #ifndef _LINUX_OSL_PRIV_H_
  32. #define _LINUX_OSL_PRIV_H_
  33. #define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognize osh */
  34. #define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */
  35. /* dependancy check */
  36. #if !defined(BCMPCIE) && defined(DHD_USE_STATIC_CTRLBUF)
  37. #error "DHD_USE_STATIC_CTRLBUF suppored PCIE target only"
  38. #endif /* !BCMPCIE && DHD_USE_STATIC_CTRLBUF */
  39. #ifdef CONFIG_DHD_USE_STATIC_BUF
  40. #ifdef DHD_USE_STATIC_CTRLBUF
  41. #define DHD_SKB_1PAGE_BUFSIZE (PAGE_SIZE*1)
  42. #define DHD_SKB_2PAGE_BUFSIZE (PAGE_SIZE*2)
  43. #define DHD_SKB_4PAGE_BUFSIZE (PAGE_SIZE*4)
  44. #define PREALLOC_FREE_MAGIC 0xFEDC
  45. #define PREALLOC_USED_MAGIC 0xFCDE
  46. #else
  47. #define DHD_SKB_HDRSIZE 336
  48. #define DHD_SKB_1PAGE_BUFSIZE ((PAGE_SIZE*1)-DHD_SKB_HDRSIZE)
  49. #define DHD_SKB_2PAGE_BUFSIZE ((PAGE_SIZE*2)-DHD_SKB_HDRSIZE)
  50. #define DHD_SKB_4PAGE_BUFSIZE ((PAGE_SIZE*4)-DHD_SKB_HDRSIZE)
  51. #endif /* DHD_USE_STATIC_CTRLBUF */
  52. #define STATIC_BUF_MAX_NUM 16
  53. #define STATIC_BUF_SIZE (PAGE_SIZE*2)
  54. #define STATIC_BUF_TOTAL_LEN (STATIC_BUF_MAX_NUM * STATIC_BUF_SIZE)
  55. typedef struct bcm_static_buf {
  56. spinlock_t static_lock;
  57. unsigned char *buf_ptr;
  58. unsigned char buf_use[STATIC_BUF_MAX_NUM];
  59. } bcm_static_buf_t;
  60. extern bcm_static_buf_t *bcm_static_buf;
  61. #ifdef DHD_USE_STATIC_CTRLBUF
  62. #define STATIC_PKT_4PAGE_NUM 0
  63. #define DHD_SKB_MAX_BUFSIZE DHD_SKB_2PAGE_BUFSIZE
  64. #elif defined(ENHANCED_STATIC_BUF)
  65. #define STATIC_PKT_4PAGE_NUM 1
  66. #define DHD_SKB_MAX_BUFSIZE DHD_SKB_4PAGE_BUFSIZE
  67. #else
  68. #define STATIC_PKT_4PAGE_NUM 0
  69. #define DHD_SKB_MAX_BUFSIZE DHD_SKB_2PAGE_BUFSIZE
  70. #endif /* DHD_USE_STATIC_CTRLBUF */
  71. #ifdef DHD_USE_STATIC_CTRLBUF
  72. #define STATIC_PKT_1PAGE_NUM 0
  73. #define STATIC_PKT_2PAGE_NUM 128
  74. #else
  75. #define STATIC_PKT_1PAGE_NUM 8
  76. #define STATIC_PKT_2PAGE_NUM 8
  77. #endif /* DHD_USE_STATIC_CTRLBUF */
  78. #define STATIC_PKT_1_2PAGE_NUM \
  79. ((STATIC_PKT_1PAGE_NUM) + (STATIC_PKT_2PAGE_NUM))
  80. #define STATIC_PKT_MAX_NUM \
  81. ((STATIC_PKT_1_2PAGE_NUM) + (STATIC_PKT_4PAGE_NUM))
  82. typedef struct bcm_static_pkt {
  83. #ifdef DHD_USE_STATIC_CTRLBUF
  84. struct sk_buff *skb_8k[STATIC_PKT_2PAGE_NUM];
  85. unsigned char pkt_invalid[STATIC_PKT_2PAGE_NUM];
  86. spinlock_t osl_pkt_lock;
  87. uint32 last_allocated_index;
  88. #else
  89. struct sk_buff *skb_4k[STATIC_PKT_1PAGE_NUM];
  90. struct sk_buff *skb_8k[STATIC_PKT_2PAGE_NUM];
  91. #ifdef ENHANCED_STATIC_BUF
  92. struct sk_buff *skb_16k;
  93. #endif /* ENHANCED_STATIC_BUF */
  94. struct semaphore osl_pkt_sem;
  95. #endif /* DHD_USE_STATIC_CTRLBUF */
  96. unsigned char pkt_use[STATIC_PKT_MAX_NUM];
  97. } bcm_static_pkt_t;
  98. extern bcm_static_pkt_t *bcm_static_skb;
  99. #endif /* CONFIG_DHD_USE_STATIC_BUF */
  100. typedef struct bcm_mem_link {
  101. struct bcm_mem_link *prev;
  102. struct bcm_mem_link *next;
  103. uint size;
  104. int line;
  105. void *osh;
  106. char file[BCM_MEM_FILENAME_LEN];
  107. } bcm_mem_link_t;
  108. struct osl_cmn_info {
  109. atomic_t malloced;
  110. atomic_t pktalloced; /* Number of allocated packet buffers */
  111. spinlock_t dbgmem_lock;
  112. bcm_mem_link_t *dbgmem_list;
  113. bcm_mem_link_t *dbgvmem_list;
  114. spinlock_t pktalloc_lock;
  115. atomic_t refcount; /* Number of references to this shared structure. */
  116. };
  117. typedef struct osl_cmn_info osl_cmn_t;
  118. #if defined(BCM_BACKPLANE_TIMEOUT)
  119. typedef uint32 (*bpt_cb_fn)(void *ctx, void *addr);
  120. #endif /* BCM_BACKPLANE_TIMEOUT */
  121. struct osl_info {
  122. osl_pubinfo_t pub;
  123. uint32 flags; /* If specific cases to be handled in the OSL */
  124. uint magic;
  125. void *pdev;
  126. uint failed;
  127. uint bustype;
  128. osl_cmn_t *cmn; /* Common OSL related data shred between two OSH's */
  129. void *bus_handle;
  130. #ifdef BCM_SECURE_DMA
  131. struct sec_mem_elem *sec_list_4096;
  132. struct sec_mem_elem *sec_list_base_4096;
  133. phys_addr_t contig_base;
  134. void *contig_base_va;
  135. phys_addr_t contig_base_alloc;
  136. void *contig_base_alloc_va;
  137. phys_addr_t contig_base_alloc_coherent;
  138. void *contig_base_alloc_coherent_va;
  139. void *contig_base_coherent_va;
  140. void *contig_delta_va_pa;
  141. struct {
  142. phys_addr_t pa;
  143. void *va;
  144. bool avail;
  145. } sec_cma_coherent[SEC_CMA_COHERENT_MAX];
  146. int stb_ext_params;
  147. #endif /* BCM_SECURE_DMA */
  148. #if defined(BCM_BACKPLANE_TIMEOUT)
  149. bpt_cb_fn bpt_cb;
  150. void *sih;
  151. #endif /* BCM_BACKPLANE_TIMEOUT */
  152. #ifdef USE_DMA_LOCK
  153. spinlock_t dma_lock;
  154. bool dma_lock_bh;
  155. #endif /* USE_DMA_LOCK */
  156. #ifdef DHD_MAP_LOGGING
  157. void *dhd_map_log;
  158. void *dhd_unmap_log;
  159. #endif /* DHD_MAP_LOGGING */
  160. };
  161. #endif /* _LINUX_OSL_PRIV_H_ */