2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
22 typedef struct rpc_info rpc_info_t;
23 typedef struct rpc_buf rpc_buf_t;
24 struct rpc_transport_info;
25 typedef void (*rpc_dispatch_cb_t) (void *ctx, struct rpc_buf *buf);
26 typedef void (*rpc_resync_cb_t) (void *ctx);
27 typedef void (*rpc_down_cb_t) (void *ctx);
28 typedef void (*rpc_txdone_cb_t) (void *ctx, struct rpc_buf *buf);
29 extern struct rpc_info *bcm_rpc_attach(void *pdev, osl_t *osh,
30 struct rpc_transport_info *rpc_th);
32 extern void bcm_rpc_detach(struct rpc_info *rpc);
33 extern void bcm_rpc_down(struct rpc_info *rpc);
34 extern void bcm_rpc_watchdog(struct rpc_info *rpc);
36 extern struct rpc_buf *bcm_rpc_buf_alloc(struct rpc_info *rpc, int len);
37 extern void bcm_rpc_buf_free(struct rpc_info *rpc, struct rpc_buf *b);
38 /* get rpc transport handle */
39 extern struct rpc_transport_info *bcm_rpc_tp_get(struct rpc_info *rpc);
41 /* callback for: data_rx, down, resync */
42 extern void bcm_rpc_rxcb_init(struct rpc_info *rpc, void *ctx,
43 rpc_dispatch_cb_t cb, void *dnctx,
44 rpc_down_cb_t dncb, rpc_resync_cb_t resync_cb,
46 extern void bcm_rpc_rxcb_deinit(struct rpc_info *rpci);
48 /* HOST or CLIENT rpc call, requiring no return value */
49 extern int bcm_rpc_call(struct rpc_info *rpc, struct rpc_buf *b);
51 /* HOST rpc call, demanding return.
52 * The thread may be suspended and control returns back to OS
53 * The thread will resume(waked up) on either the return signal received or timeout
54 * The implementation details depend on OS
56 extern struct rpc_buf *bcm_rpc_call_with_return(struct rpc_info *rpc,
59 /* CLIENT rpc call to respond to bcm_rpc_call_with_return, requiring no return value */
60 extern int bcm_rpc_call_return(struct rpc_info *rpc, struct rpc_buf *retb);
62 extern uint bcm_rpc_buf_header_len(struct rpc_info *rpci);
64 #define RPC_PKTLOG_SIZE 50 /* Depth of the history */
65 #define RPC_PKTLOG_RD_LEN 3
66 #define RPC_PKTLOG_DUMP_SIZE 150 /* dump size should be more than the product of above two */
67 extern int bcm_rpc_pktlog_get(struct rpc_info *rpci, u32 *buf,
68 uint buf_size, bool send);
69 extern int bcm_rpc_dump(rpc_info_t *rpci, struct bcmstrbuf *b);
71 /* HIGH/BMAC: bit 15-8: RPC module, bit 7-0: TP module */
72 #define RPC_ERROR_VAL 0x0001
73 #define RPC_TRACE_VAL 0x0002
74 #define RPC_PKTTRACE_VAL 0x0004
75 #define RPC_PKTLOG_VAL 0x0008
76 extern void bcm_rpc_msglevel_set(struct rpc_info *rpci, u16 msglevel,
79 #endif /* _BCM_RPC_H_ */