net: wifi: rockchip: update broadcom drivers for kernel4.4
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / include / hnd_pktpool.h
index 3e6878a1174717715972e6aec394f196b56df4ff..3cf46727b044fa3d394fd5fe791de0590e5cafe7 100755 (executable)
@@ -1,36 +1,60 @@
 /*
  * HND generic packet pool operation primitives
  *
- * $Copyright Open Broadcom Corporation$
+ * Copyright (C) 1999-2016, Broadcom Corporation
+ * 
+ *      Unless you and Broadcom execute a separate written software license
+ * agreement governing use of this software, this software is licensed to you
+ * under the terms of the GNU General Public License version 2 (the "GPL"),
+ * available at http://www.broadcom.com/licenses/GPLv2.php, with the
+ * following added to such license:
+ * 
+ *      As a special exception, the copyright holders of this software give you
+ * permission to link this software with independent modules, and to copy and
+ * distribute the resulting executable under terms of your choice, provided that
+ * you also meet, for each linked independent module, the terms and conditions of
+ * the license of that module.  An independent module is a module which is not
+ * derived from this software.  The special exception does not apply to any
+ * modifications of the software.
+ * 
+ *      Notwithstanding the above, under no circumstances may you combine this
+ * software in any way with any other Broadcom software provided under a license
+ * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: $
+ *
+ * <<Broadcom-WL-IPTag/Open:>>
+ *
+ * $Id: hnd_pktpool.h 591285 2015-10-07 11:56:29Z $
  */
 
 #ifndef _hnd_pktpool_h_
 #define _hnd_pktpool_h_
 
+#include <osl_ext.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+/* mutex macros for thread safe */
+#ifdef HND_PKTPOOL_THREAD_SAFE
+#define HND_PKTPOOL_MUTEX_DECL(mutex)          OSL_EXT_MUTEX_DECL(mutex)
+#else
+#define HND_PKTPOOL_MUTEX_DECL(mutex)
+#endif
+
 #ifdef BCMPKTPOOL
 #define POOL_ENAB(pool)                ((pool) && (pool)->inited)
-#define SHARED_POOL            (pktpool_shared)
 #else /* BCMPKTPOOL */
 #define POOL_ENAB(bus)         0
-#define SHARED_POOL            ((struct pktpool *)NULL)
 #endif /* BCMPKTPOOL */
 
-#ifdef BCMFRAGPOOL
-#define SHARED_FRAG_POOL       (pktpool_shared_lfrag)
-#endif
-#define SHARED_RXFRAG_POOL     (pktpool_shared_rxlfrag)
-
-
 #ifndef PKTPOOL_LEN_MAX
 #define PKTPOOL_LEN_MAX                40
 #endif /* PKTPOOL_LEN_MAX */
 #define PKTPOOL_CB_MAX         3
+#define PKTPOOL_CB_MAX_AVL     4
+
 
 /* forward declaration */
 struct pktpool;
@@ -40,7 +64,8 @@ typedef struct {
        pktpool_cb_t cb;
        void *arg;
 } pktpool_cbinfo_t;
-/* call back fn extension to populate host address in pool pkt */
+
+/** PCIe SPLITRX related: call back fn extension to populate host address in pool pkt */
 typedef int (*pktpool_cb_extn_t)(struct pktpool *pool, void *arg1, void* pkt, bool arg2);
 typedef struct {
        pktpool_cb_extn_t cb;
@@ -77,26 +102,27 @@ typedef struct {
 #endif /* BCMDBG_POOL */
 
 typedef struct pktpool {
-       bool inited;            /* pktpool_init was successful */
-       uint8 type;             /* type of lbuf: basic, frag, etc */
-       uint8 id;               /* pktpool ID:  index in registry */
-       bool istx;              /* direction: transmit or receive data path */
-
-       void * freelist;        /* free list: see PKTNEXTFREE(), PKTSETNEXTFREE() */
-       uint16 avail;           /* number of packets in pool's free list */
-       uint16 len;             /* number of packets managed by pool */
-       uint16 maxlen;          /* maximum size of pool <= PKTPOOL_LEN_MAX */
-       uint16 plen;            /* size of pkt buffer, excluding lbuf|lbuf_frag */
+       bool inited;            /**< pktpool_init was successful */
+       uint8 type;             /**< type of lbuf: basic, frag, etc */
+       uint8 id;               /**< pktpool ID:  index in registry */
+       bool istx;              /**< direction: transmit or receive data path */
+       HND_PKTPOOL_MUTEX_DECL(mutex)   /**< thread-safe mutex */
+
+       void * freelist;        /**< free list: see PKTNEXTFREE(), PKTSETNEXTFREE() */
+       uint16 avail;           /**< number of packets in pool's free list */
+       uint16 len;             /**< number of packets managed by pool */
+       uint16 maxlen;          /**< maximum size of pool <= PKTPOOL_LEN_MAX */
+       uint16 plen;            /**< size of pkt buffer, excluding lbuf|lbuf_frag */
 
        bool empty;
        uint8 cbtoggle;
        uint8 cbcnt;
        uint8 ecbcnt;
-       bool emptycb_disable;
+       uint8 emptycb_disable;  /**< Value of type enum pktpool_empty_cb_state */
        pktpool_cbinfo_t *availcb_excl;
-       pktpool_cbinfo_t cbs[PKTPOOL_CB_MAX];
+       pktpool_cbinfo_t cbs[PKTPOOL_CB_MAX_AVL];
        pktpool_cbinfo_t ecbs[PKTPOOL_CB_MAX];
-       pktpool_cbextn_info_t cbext;
+       pktpool_cbextn_info_t cbext;    /**< PCIe SPLITRX related */
        pktpool_cbextn_info_t rxcplidfn;
 #ifdef BCMDBG_POOL
        uint8 dbg_cbcnt;
@@ -107,11 +133,8 @@ typedef struct pktpool {
        pktpool_cbinfo_t dmarxfill;
 } pktpool_t;
 
-extern pktpool_t *pktpool_shared;
-#ifdef BCMFRAGPOOL
-extern pktpool_t *pktpool_shared_lfrag;
-#endif
-extern pktpool_t *pktpool_shared_rxlfrag;
+
+pktpool_t *get_pktpools_registry(int id);
 
 /* Incarnate a pktpool registry. On success returns total_pools. */
 extern int pktpool_attach(osl_t *osh, uint32 total_pools);
@@ -164,13 +187,10 @@ extern int pkpool_haddr_avail_register_cb(pktpool_t *pktp, pktpool_cb_t cb, void
 #define PKTPOOL_MAXIMUM_ID          (15)
 
 /* Registry of pktpool(s) */
-extern pktpool_t *pktpools_registry[PKTPOOL_MAXIMUM_ID + 1];
-
 /* Pool ID to/from Pool Pointer converters */
-#define PKTPOOL_ID2PTR(id)          (pktpools_registry[id])
+#define PKTPOOL_ID2PTR(id)          (get_pktpools_registry(id))
 #define PKTPOOL_PTR2ID(pp)          (POOLID(pp))
 
-
 #ifdef BCMDBG_POOL
 extern int pktpool_dbg_register(pktpool_t *pktp, pktpool_cb_t cb, void *arg);
 extern int pktpool_start_trigger(pktpool_t *pktp, void *p);
@@ -179,6 +199,25 @@ extern int pktpool_dbg_notify(pktpool_t *pktp);
 extern int pktpool_stats_dump(pktpool_t *pktp, pktpool_stats_t *stats);
 #endif /* BCMDBG_POOL */
 
+#ifdef BCMPKTPOOL
+#define SHARED_POOL            (pktpool_shared)
+extern pktpool_t *pktpool_shared;
+#ifdef BCMFRAGPOOL
+#define SHARED_FRAG_POOL       (pktpool_shared_lfrag)
+extern pktpool_t *pktpool_shared_lfrag;
+#endif
+
+/** PCIe SPLITRX related */
+#define SHARED_RXFRAG_POOL     (pktpool_shared_rxlfrag)
+extern pktpool_t *pktpool_shared_rxlfrag;
+
+void hnd_pktpool_init(osl_t *osh);
+void hnd_pktpool_fill(pktpool_t *pktpool, bool minimal);
+void hnd_pktpool_refill(bool minimal);
+#else /* BCMPKTPOOL */
+#define SHARED_POOL            ((struct pktpool *)NULL)
+#endif /* BCMPKTPOOL */
+
 #ifdef __cplusplus
        }
 #endif