Staging: Add initial release of brcm80211 - Broadcom 802.11n wireless LAN driver.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / brcm80211 / include / bcm_rpc_tp.h
1 /*
2 * Copyright (c) 2010 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef _bcm_rpc_tp_h_
18 #define _bcm_rpc_tp_h_
19 #include <bcm_rpc.h>
20
21 #define DBUS_RX_BUFFER_SIZE_RPC (2100) /* rxbufsize for dbus_attach, linux only for now */
22
23 #define BCM_RPC_TP_ENCAP_LEN 4 /* TP header is 4 bytes */
24
25 #define BCM_RPC_TP_HOST_AGG_MASK 0xffff0000
26 #define BCM_RPC_TP_HOST_AGG_SHIFT 16
27 #define BCM_RPC_TP_HOST_AGG_AMPDU 0x00010000 /* HOST->DNGL ampdu aggregation */
28 #define BCM_RPC_TP_HOST_AGG_TEST 0x00100000 /* HOST->DNGL test aggregation */
29 #define BCM_RPC_TP_DNGL_AGG_MASK 0x0000ffff
30 #define BCM_RPC_TP_DNGL_AGG_DPC 0x00000001 /* DNGL->HOST data aggregation */
31 #define BCM_RPC_TP_DNGL_AGG_FLOWCTL 0x00000002 /* DNGL->HOST tx flowcontrol agg */
32 #define BCM_RPC_TP_DNGL_AGG_TEST 0x00000010 /* DNGL->HOST test agg */
33
34 #define BCM_RPC_TP_DNGL_AGG_MAX_SFRAME 3 /* max agg subframes, must be <= USB_NTXD */
35 #define BCM_RPC_TP_DNGL_AGG_MAX_BYTE 4000 /* max agg bytes */
36
37 #define BCM_RPC_TP_HOST_AGG_MAX_SFRAME 3 /* max agg subframes, AMPDU only, 3 is enough */
38 #define BCM_RPC_TP_HOST_AGG_MAX_BYTE 3400 /* max agg bytes; to fit 2+ tcp/udp pkts. Each one:
39 * 802.3pkt + 802.11 hdr + rpc hdr + tp hdr < 1700B
40 * Need to be in sync with dongle usb rx dma
41 * rxbufsize(USBBULK_RXBUF_GIANT in usbdev_sb.c)
42 */
43 /* TP-DBUS pkts flowcontrol */
44 #define BCM_RPC_TP_DBUS_NTXQ 50 /* queue size for TX on bulk OUT, aggregation possible */
45 #define BCM_RPC_TP_DBUS_NRXQ 50 /* queue size for RX on bulk IN, aggregation possible */
46 #define BCM_RPC_TP_DBUS_NRXQ_CTRL 1 /* queue size for RX on ctl EP0 */
47
48 #define BCM_RPC_TP_DBUS_NRXQ_PKT (BCM_RPC_TP_DBUS_NRXQ * BCM_RPC_TP_DNGL_AGG_MAX_SFRAME)
49 #define BCM_RPC_TP_DBUS_NTXQ_PKT (BCM_RPC_TP_DBUS_NTXQ * BCM_RPC_TP_HOST_AGG_MAX_SFRAME)
50
51 typedef struct rpc_transport_info rpc_tp_info_t;
52
53 typedef void (*rpc_tx_complete_fn_t) (void *, rpc_buf_t *, int status);
54 typedef void (*rpc_rx_fn_t) (void *, rpc_buf_t *);
55
56 #ifdef WLC_LOW
57 typedef void (*rpc_txflowctl_cb_t) (void *ctx, bool on);
58 #endif
59
60 extern rpc_tp_info_t *bcm_rpc_tp_attach(osl_t * osh, void *bus);
61 extern void bcm_rpc_tp_detach(rpc_tp_info_t * rpcb);
62 extern void bcm_rpc_tp_down(rpc_tp_info_t * rpcb);
63 extern void bcm_rpc_tp_watchdog(rpc_tp_info_t * rpcb);
64
65 extern int bcm_rpc_tp_buf_send(rpc_tp_info_t * rpcb, rpc_buf_t * buf);
66
67 /* callback for tx_complete, rx_pkt */
68 extern void bcm_rpc_tp_register_cb(rpc_tp_info_t * rpcb,
69 rpc_tx_complete_fn_t txcmplt,
70 void *tx_context, rpc_rx_fn_t rxpkt,
71 void *rx_context, rpc_osl_t * rpc_osh);
72 extern void bcm_rpc_tp_deregister_cb(rpc_tp_info_t * rpcb);
73
74 /* Buffer manipulation */
75 extern uint bcm_rpc_buf_tp_header_len(rpc_tp_info_t * rpcb);
76 extern rpc_buf_t *bcm_rpc_tp_buf_alloc(rpc_tp_info_t * rpcb, int len);
77 extern void bcm_rpc_tp_buf_free(rpc_tp_info_t * rpcb, rpc_buf_t * buf);
78 extern int bcm_rpc_buf_len_get(rpc_tp_info_t * rpcb, rpc_buf_t * b);
79 extern int bcm_rpc_buf_len_set(rpc_tp_info_t * rpcb, rpc_buf_t * b, uint len);
80 extern rpc_buf_t *bcm_rpc_buf_next_get(rpc_tp_info_t * rpcb, rpc_buf_t * b);
81 extern void bcm_rpc_buf_next_set(rpc_tp_info_t * rpcb, rpc_buf_t * b,
82 rpc_buf_t * nextb);
83 extern unsigned char *bcm_rpc_buf_data(rpc_tp_info_t * rpcb, rpc_buf_t * b);
84 extern unsigned char *bcm_rpc_buf_push(rpc_tp_info_t * rpcb, rpc_buf_t * b,
85 uint delta);
86 extern unsigned char *bcm_rpc_buf_pull(rpc_tp_info_t * rpcb, rpc_buf_t * b,
87 uint delta);
88 extern void bcm_rpc_tp_buf_release(rpc_tp_info_t * rpcb, rpc_buf_t * buf);
89 extern void bcm_rpc_tp_buf_cnt_adjust(rpc_tp_info_t * rpcb, int adjust);
90 /* RPC call_with_return */
91 extern int bcm_rpc_tp_recv_rtn(rpc_tp_info_t * rpcb);
92 extern int bcm_rpc_tp_get_device_speed(rpc_tp_info_t * rpc_th);
93 #ifdef BCMDBG
94 extern int bcm_rpc_tp_dump(rpc_tp_info_t * rpcb, struct bcmstrbuf *b);
95 #endif
96
97 #ifdef WLC_LOW
98 /* intercept USB pkt to parse RPC header: USB driver rx-> wl_send -> this -> wl driver */
99 extern void bcm_rpc_tp_rx_from_dnglbus(rpc_tp_info_t * rpc_th, struct lbuf *lb);
100
101 /* RPC callreturn pkt, go to USB driver tx */
102 extern int bcm_rpc_tp_send_callreturn(rpc_tp_info_t * rpc_th, rpc_buf_t * b);
103
104 extern void bcm_rpc_tp_dump(rpc_tp_info_t * rpcb);
105 extern void bcm_rpc_tp_txflowctl(rpc_tp_info_t * rpcb, bool state, int prio);
106 extern void bcm_rpc_tp_txflowctlcb_init(rpc_tp_info_t * rpc_th, void *ctx,
107 rpc_txflowctl_cb_t cb);
108 extern void bcm_rpc_tp_txflowctlcb_deinit(rpc_tp_info_t * rpc_th);
109 extern void bcm_rpc_tp_txq_wm_set(rpc_tp_info_t * rpc_th, uint8 hiwm,
110 uint8 lowm);
111 extern void bcm_rpc_tp_txq_wm_get(rpc_tp_info_t * rpc_th, uint8 * hiwm,
112 uint8 * lowm);
113 #endif /* WLC_LOW */
114
115 extern void bcm_rpc_tp_agg_set(rpc_tp_info_t * rpcb, uint32 reason, bool set);
116 extern void bcm_rpc_tp_agg_limit_set(rpc_tp_info_t * rpc_th, uint8 sf,
117 uint16 bytes);
118 extern void bcm_rpc_tp_agg_limit_get(rpc_tp_info_t * rpc_th, uint8 * sf,
119 uint16 * bytes);
120
121 #define BCM_RPC_TP_MSG_LEVEL_MASK 0x00ff
122 /* dongle msg level */
123 #define RPC_TP_MSG_DNGL_ERR_VAL 0x0001 /* DNGL TP error msg */
124 #define RPC_TP_MSG_DNGL_DBG_VAL 0x0002 /* DNGL TP dbg msg */
125 #define RPC_TP_MSG_DNGL_AGG_VAL 0x0004 /* DNGL TP agg msg */
126 #define RPC_TP_MSG_DNGL_DEA_VAL 0x0008 /* DNGL TP deag msg */
127
128 /* host msg level */
129 #define RPC_TP_MSG_HOST_ERR_VAL 0x0001 /* DNGL TP error msg */
130 #define RPC_TP_MSG_HOST_DBG_VAL 0x0002 /* DNGL TP dbg msg */
131 #define RPC_TP_MSG_HOST_AGG_VAL 0x0004 /* DNGL TP agg msg */
132 #define RPC_TP_MSG_HOST_DEA_VAL 0x0008 /* DNGL TP deag msg */
133
134 extern void bcm_rpc_tp_msglevel_set(rpc_tp_info_t * rpc_th, uint8 msglevel,
135 bool high_low);
136
137 #endif /* _bcm_rpc_tp_h_ */