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