staging: brcm80211: merged dngl_stats.h into dhd.h
[cascardo/linux.git] / drivers / staging / brcm80211 / brcmfmac / dhd.h
index 9b1a7f4..82bf04d 100644 (file)
@@ -18,8 +18,8 @@
  * Common types *
  */
 
-#ifndef _dhd_h_
-#define _dhd_h_
+#ifndef _BRCMF_H_
+#define _BRCMF_H_
 
 #define BRCMF_VERSION_STR              "4.218.248.5"
 
 #define BRCMF_EVENT_MSG_FLUSHTXQ       0x02
 #define BRCMF_EVENT_MSG_GROUP          0x04
 
-typedef struct brcmf_event_msg {
+struct brcmf_event_msg {
        u16 version;
        u16 flags;
        u32 event_type;
@@ -145,7 +145,7 @@ typedef struct brcmf_event_msg {
        u32 datalen;
        u8 addr[ETH_ALEN];
        char ifname[IFNAMSIZ];
-} __packed brcmf_event_msg_t;
+} __packed;
 
 struct brcm_ethhdr {
        u16 subtype;
@@ -155,11 +155,23 @@ struct brcm_ethhdr {
        u16 usr_subtype;
 } __packed;
 
-typedef struct brcmf_event {
+struct brcmf_event {
        struct ethhdr eth;
        struct brcm_ethhdr hdr;
        struct brcmf_event_msg msg;
-} __packed brcmf_event_t;
+} __packed;
+
+struct dngl_stats {
+       unsigned long rx_packets;       /* total packets received */
+       unsigned long tx_packets;       /* total packets transmitted */
+       unsigned long rx_bytes; /* total bytes received */
+       unsigned long tx_bytes; /* total bytes transmitted */
+       unsigned long rx_errors;        /* bad packets received */
+       unsigned long tx_errors;        /* packet transmit problems */
+       unsigned long rx_dropped;       /* packets dropped by dongle */
+       unsigned long tx_dropped;       /* packets dropped by dongle */
+       unsigned long multicast;        /* multicast packets received */
+};
 
 #define BRCMF_E_SET_SSID                       0
 #define BRCMF_E_JOIN                           1
@@ -310,10 +322,10 @@ typedef struct brcmf_event {
 #define BRCMF_E_LINK_BSSCFG_DIS                        4
 
 /* The level of bus communication with the dongle */
-enum dhd_bus_state {
-       DHD_BUS_DOWN,           /* Not ready for frame transfers */
-       DHD_BUS_LOAD,           /* Download access only (CPU reset) */
-       DHD_BUS_DATA            /* Ready for frame transfers */
+enum brcmf_bus_state {
+       BRCMF_BUS_DOWN,         /* Not ready for frame transfers */
+       BRCMF_BUS_LOAD,         /* Download access only (CPU reset) */
+       BRCMF_BUS_DATA          /* Ready for frame transfers */
 };
 
 /* Pattern matching filter. Specifies an offset within received packets to
@@ -521,24 +533,24 @@ struct brcmf_ioctl {
        uint needed;            /* bytes needed (optional) */
 };
 
-/* Forward decls for struct dhd_pub (see below) */
-struct dhd_bus;                /* device bus info */
+/* Forward decls for struct brcmf_pub (see below) */
+struct brcmf_bus;              /* device bus info */
 struct brcmf_proto;    /* device communication protocol info */
-struct dhd_info;       /* device driver info */
+struct brcmf_info;     /* device driver info */
 
 /* Common structure for module and instance linkage */
-typedef struct dhd_pub {
+struct brcmf_pub {
        /* Linkage ponters */
-       struct dhd_bus *bus;
+       struct brcmf_bus *bus;
        struct brcmf_proto *prot;
-       struct dhd_info *info;
+       struct brcmf_info *info;
 
-       /* Internal dhd items */
+       /* Internal brcmf items */
        bool up;                /* Driver up/down (to OS) */
        bool txoff;             /* Transmit flow-controlled */
        bool dongle_reset;      /* true = DEVRESET put dongle into reset */
-       enum dhd_bus_state busstate;
-       uint hdrlen;            /* Total DHD header length (proto + bus) */
+       enum brcmf_bus_state busstate;
+       uint hdrlen;            /* Total BRCMF header length (proto + bus) */
        uint maxctl;            /* Max size rxctl request from proto to bus */
        uint rxsz;              /* Rx buffer size bus module should use */
        u8 wme_dp;              /* wme discard priority */
@@ -547,7 +559,7 @@ typedef struct dhd_pub {
        bool iswl;              /* Dongle-resident driver is wl */
        unsigned long drv_version;      /* Version of dongle-resident driver */
        u8 mac[ETH_ALEN];                       /* MAC address obtained from dongle */
-       dngl_stats_t dstats;            /* Stats for dongle-based data */
+       struct dngl_stats dstats;       /* Stats for dongle-based data */
 
        /* Additional stats for the bus level */
        unsigned long tx_packets;       /* Data packets sent to dongle */
@@ -564,7 +576,7 @@ typedef struct dhd_pub {
        unsigned long rx_dropped;       /* Packets dropped locally (no memory) */
        unsigned long rx_flushed;       /* Packets flushed due to
                                unscheduled sendup thread */
-       unsigned long wd_dpc_sched;     /* Number of times dhd dpc scheduled by
+       unsigned long wd_dpc_sched;     /* Number of times dpc scheduled by
                                         watchdog timer */
 
        unsigned long rx_readahead_cnt; /* Number of packets where header read-ahead
@@ -590,29 +602,29 @@ typedef struct dhd_pub {
        char *pktfilter[100];
        int pktfilter_count;
 
-       u8 country_code[WLC_CNTRY_BUF_SZ];
+       u8 country_code[BRCM_CNTRY_BUF_SZ];
        char eventmask[BRCMF_EVENTING_MASK_LEN];
 
-} dhd_pub_t;
+};
 
-typedef struct dhd_if_event {
+struct brcmf_if_event {
        u8 ifidx;
        u8 action;
        u8 flags;
        u8 bssidx;
-} dhd_if_event_t;
+};
 
-typedef struct {
+struct brcmf_timeout {
        u32 limit;              /* Expiration time (usec) */
        u32 increment;  /* Current expiration increment (usec) */
        u32 elapsed;            /* Current elapsed time (usec) */
        u32 tick;               /* O/S tick time (usec) */
-} dhd_timeout_t;
+};
 
-typedef struct {
+struct bcmevent_name {
        uint event;
        const char *name;
-} bcmevent_name_t;
+};
 
 #if defined(CONFIG_PM_SLEEP)
 extern atomic_t brcmf_mmc_suspend;
@@ -624,13 +636,8 @@ extern atomic_t brcmf_mmc_suspend;
                } \
        }       while (0)
 #define BRCMF_PM_RESUME_WAIT(a)        _BRCMF_PM_RESUME_WAIT(a, 30)
-#define DHD_PM_RESUME_WAIT_FOREVER(a)  _BRCMF_PM_RESUME_WAIT(a, ~0)
 #define BRCMF_PM_RESUME_RETURN_ERROR(a)        \
        do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0)
-#define DHD_PM_RESUME_RETURN   do { \
-       if (atomic_read(&brcmf_mmc_suspend)) \
-               return; \
-       } while (0)
 
 #define BRCMF_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
 #define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \
@@ -645,9 +652,7 @@ extern atomic_t brcmf_mmc_suspend;
 
 #define BRCMF_PM_RESUME_WAIT_INIT(a)
 #define BRCMF_PM_RESUME_WAIT(a)
-#define DHD_PM_RESUME_WAIT_FOREVER(a)
 #define BRCMF_PM_RESUME_RETURN_ERROR(a)
-#define DHD_PM_RESUME_RETURN
 
 #define BRCMF_SPINWAIT_SLEEP_INIT(a)
 #define BRCMF_SPINWAIT_SLEEP(a, exp, us)  do { \
@@ -710,32 +715,31 @@ extern uint brcmf_pktgen_len;
 #define BRCMF_MAX_PKTGEN_LEN 1800
 #endif
 
-extern u32 g_assert_type;
-extern const bcmevent_name_t bcmevent_names[];
+extern const struct bcmevent_name bcmevent_names[];
 extern const int bcmevent_names_size;
 
 
-static inline void MUTEX_LOCK_INIT(dhd_pub_t *dhdp)
+static inline void MUTEX_LOCK_INIT(struct brcmf_pub *drvr)
 {
 }
 
-static inline void MUTEX_LOCK(dhd_pub_t *dhdp)
+static inline void MUTEX_LOCK(struct brcmf_pub *drvr)
 {
 }
 
-static inline void MUTEX_UNLOCK(dhd_pub_t *dhdp)
+static inline void MUTEX_UNLOCK(struct brcmf_pub *drvr)
 {
 }
 
-static inline void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t *dhdp)
+static inline void MUTEX_LOCK_SOFTAP_SET_INIT(struct brcmf_pub *drvr)
 {
 }
 
-static inline void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t *dhdp)
+static inline void MUTEX_LOCK_SOFTAP_SET(struct brcmf_pub *drvr)
 {
 }
 
-static inline void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t *dhdp)
+static inline void MUTEX_UNLOCK_SOFTAP_SET(struct brcmf_pub *drvr)
 {
 }
 
@@ -751,106 +755,79 @@ static inline void MUTEX_UNLOCK_WL_SCAN_SET(void)
 {
 }
 
-/*
- * Exported from dhd OS modules (dhd_linux/dhd_ndis)
- */
-
 /* Indication from bus module regarding presence/insertion of dongle.
- * Return dhd_pub_t pointer, used as handle to OS module in later calls.
+ * Return struct brcmf_pub pointer, used as handle to OS module in later calls.
  * Returned structure should have bus and prot pointers filled in.
  * bus_hdrlen specifies required headroom for bus module header.
  */
-extern dhd_pub_t *brcmf_attach(struct dhd_bus *bus,
-                               uint bus_hdrlen);
-extern int brcmf_net_attach(dhd_pub_t *dhdp, int idx);
+extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus,
+                                     uint bus_hdrlen);
+extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx);
 extern int brcmf_netdev_wait_pend8021x(struct net_device *dev);
 
 /* Indication from bus module regarding removal/absence of dongle */
-extern void brcmf_detach(dhd_pub_t *dhdp);
+extern void brcmf_detach(struct brcmf_pub *drvr);
 
 /* Indication from bus module to change flow-control state */
-extern void brcmf_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
+extern void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool on);
 
-extern bool brcmf_c_prec_enq(dhd_pub_t *dhdp, struct pktq *q,
+extern bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q,
                         struct sk_buff *pkt, int prec);
 
 /* Receive frame for delivery to OS.  Callee disposes of rxp. */
-extern void brcmf_rx_frame(dhd_pub_t *dhdp, int ifidx,
+extern void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx,
                         struct sk_buff *rxp, int numpkt);
 
 /* Return pointer to interface name */
-extern char *brcmf_ifname(dhd_pub_t *dhdp, int idx);
-
-/* Request scheduling of the bus dpc */
-extern void brcmf_sched_dpc(dhd_pub_t *dhdp);
+extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
 
 /* Notify tx completion */
-extern void brcmf_txcomplete(dhd_pub_t *dhdp, struct sk_buff *txp,
+extern void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp,
                             bool success);
 
 /* Query ioctl */
-extern int brcmf_proto_cdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd,
-                                      void *buf, uint len);
+extern int brcmf_proto_cdc_query_ioctl(struct brcmf_pub *drvr, int ifidx,
+                                      uint cmd, void *buf, uint len);
 
 /* OS independent layer functions */
-extern int brcmf_os_proto_block(dhd_pub_t *pub);
-extern int brcmf_os_proto_unblock(dhd_pub_t *pub);
-extern int brcmf_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition,
+extern int brcmf_os_proto_block(struct brcmf_pub *drvr);
+extern int brcmf_os_proto_unblock(struct brcmf_pub *drvr);
+extern int brcmf_os_ioctl_resp_wait(struct brcmf_pub *drvr, uint *condition,
                                  bool *pending);
-extern int brcmf_os_ioctl_resp_wake(dhd_pub_t *pub);
+extern int brcmf_os_ioctl_resp_wake(struct brcmf_pub *drvr);
 extern unsigned int brcmf_os_get_ioctl_resp_timeout(void);
 extern void brcmf_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
-extern void brcmf_os_sdlock_sndup_rxq(dhd_pub_t *pub);
-extern void brcmf_customer_gpio_wlan_ctrl(int onoff);
-extern int brcmf_custom_get_mac_address(unsigned char *buf);
-extern void brcmf_os_sdunlock_sndup_rxq(dhd_pub_t *pub);
-extern void brcmf_os_sdlock_eventq(dhd_pub_t *pub);
-extern void brcmf_os_sdunlock_eventq(dhd_pub_t *pub);
 #ifdef BCMDBG
-extern int brcmf_write_to_file(dhd_pub_t *dhd, u8 *buf, int size);
+extern int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size);
 #endif                         /* BCMDBG */
 
-extern void brcmf_timeout_start(dhd_timeout_t *tmo, uint usec);
-extern int brcmf_timeout_expired(dhd_timeout_t *tmo);
+extern void brcmf_timeout_start(struct brcmf_timeout *tmo, uint usec);
+extern int brcmf_timeout_expired(struct brcmf_timeout *tmo);
 
-extern int brcmf_ifname2idx(struct dhd_info *dhd, char *name);
-extern int brcmf_c_host_event(struct dhd_info *dhd, int *idx, void *pktdata,
-                        brcmf_event_msg_t *, void **data_ptr);
+extern int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name);
+extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx,
+                             void *pktdata, struct brcmf_event_msg *,
+                             void **data_ptr);
 
 extern void brcmf_c_init(void);
 
-extern int brcmf_add_if(struct dhd_info *dhd, int ifidx, void *handle,
+extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle,
                      char *name, u8 *mac_addr, u32 flags, u8 bssidx);
-extern void brcmf_del_if(struct dhd_info *dhd, int ifidx);
-
-extern void brcmf_vif_add(struct dhd_info *dhd, int ifidx, char *name);
-extern void brcmf_vif_del(struct dhd_info *dhd, int ifidx);
-
-extern void brcmf_event(struct dhd_info *dhd, char *evpkt, int evlen,
-                       int ifidx);
-extern void brcmf_vif_sendup(struct dhd_info *dhd, int ifidx,
-                            unsigned char *cp, int len);
+extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx);
 
 /* Send packet to dongle via data channel */
-extern int brcmf_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pkt);
+extern int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx,\
+                        struct sk_buff *pkt);
 
-extern int brcmf_bus_devreset(dhd_pub_t *dhdp, u8 flag);
-extern int brcmf_bus_start(dhd_pub_t *dhdp);
+extern int brcmf_bus_devreset(struct brcmf_pub *drvr, u8 flag);
+extern int brcmf_bus_start(struct brcmf_pub *drvr);
 
-extern void brcmf_c_pktfilter_offload_set(dhd_pub_t *dhd, char *arg);
-extern void brcmf_c_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg,
+extern void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg);
+extern void brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg,
                                             int enable, int master_mode);
 
-#ifdef BCMDBG
-#define ASSERT(exp) \
-         do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
-extern void osl_assert(char *exp, char *file, int line);
-#else
-#define ASSERT(exp)    do {} while (0)
-#endif  /* defined(BCMDBG) */
-
 /* Linux network driver ioctl encoding */
-typedef struct dhd_ioctl {
+struct brcmf_c_ioctl {
        uint cmd;               /* common ioctl definition */
        void *buf;              /* pointer to user buffer */
        uint len;               /* length of user buffer */
@@ -858,16 +835,14 @@ typedef struct dhd_ioctl {
        uint used;              /* bytes read or written (optional) */
        uint needed;            /* bytes needed (optional) */
        uint driver;            /* to identify target driver */
-} dhd_ioctl_t;
+};
 
 /* per-driver magic numbers */
 #define BRCMF_IOCTL_MAGIC              0x00444944
 
 /* bump this number if you change the ioctl interface */
 #define BRCMF_IOCTL_VERSION    1
-
 #define        BRCMF_IOCTL_MAXLEN      8192    /* max length ioctl buffer required */
-#define        DHD_IOCTL_SMLEN 256     /* "small" length ioctl buffer required */
 
 /* common ioctl definitions */
 #define BRCMF_GET_MAGIC                                0
@@ -885,7 +860,6 @@ typedef struct dhd_ioctl {
 #define BRCMF_HDRS_VAL 0x0040
 #define BRCMF_BYTES_VAL        0x0080
 #define BRCMF_INTR_VAL 0x0100
-#define DHD_LOG_VAL    0x0200
 #define BRCMF_GLOM_VAL 0x0400
 #define BRCMF_EVENT_VAL        0x0800
 #define BRCMF_BTA_VAL  0x1000
@@ -893,7 +867,7 @@ typedef struct dhd_ioctl {
 
 #ifdef SDTEST
 /* For pktgen iovar */
-typedef struct brcmf_pktgen {
+struct brcmf_pktgen {
        uint version;           /* To allow structure change tracking */
        uint freq;              /* Max ticks between tx/rx attempts */
        uint count;             /* Test packets to send/rcv each attempt */
@@ -906,7 +880,7 @@ typedef struct brcmf_pktgen {
        uint numfail;           /* Count of test send failures */
        uint mode;              /* Test mode (type of test packets) */
        uint stop;              /* Stop after this many tx failures */
-} brcmf_pktgen_t;
+};
 
 /* Version in case structure changes */
 #define BRCMF_PKTGEN_VERSION   2
@@ -926,7 +900,5 @@ typedef struct brcmf_pktgen {
         when idle */
 #define BRCMF_IDLE_ACTIVE      0       /* Do not request any SD clock change
                                 when idle */
-#define DHD_IDLE_STOP   (-1)   /* Request SD clock be stopped
-                                (and use SD1 mode) */
 
-#endif                         /* _dhd_h_ */
+#endif                         /* _BRCMF_H_ */