Commit | Line | Data |
---|---|---|
1619cb6f CK |
1 | /* ----------------------------------------------------------------------------- |
2 | * Copyright (c) 2011 Ozmo Inc | |
3 | * Released under the GNU General Public License Version 2 (GPLv2). | |
4 | * ----------------------------------------------------------------------------- | |
5 | */ | |
6 | #ifndef _OZPROTO_H | |
7 | #define _OZPROTO_H | |
8 | ||
9 | #include <asm/byteorder.h> | |
10 | #include "ozconfig.h" | |
11 | #include "ozappif.h" | |
12 | ||
13 | #define OZ_ALLOCATED_SPACE(__x) (LL_RESERVED_SPACE(__x)+(__x)->needed_tailroom) | |
14 | ||
15 | /* Converts millisecs to jiffies. | |
16 | */ | |
17 | #define oz_ms_to_jiffies(__x) (((__x)*1000)/HZ) | |
18 | ||
19 | /* Quantum milliseconds. | |
20 | */ | |
21 | #define OZ_QUANTUM_MS 8 | |
22 | /* Quantum jiffies | |
23 | */ | |
24 | #define OZ_QUANTUM_J (oz_ms_to_jiffies(OZ_QUANTUM_MS)) | |
25 | /* Default timeouts. | |
26 | */ | |
27 | #define OZ_CONNECTION_TOUT_J (2*HZ) | |
28 | #define OZ_PRESLEEP_TOUT_J (11*HZ) | |
29 | ||
30 | /* Maximun sizes of tx frames. */ | |
31 | #define OZ_MAX_TX_SIZE 1514 | |
32 | ||
33 | /* Application handler functions. | |
34 | */ | |
35 | typedef int (*oz_app_init_fn_t)(void); | |
36 | typedef void (*oz_app_term_fn_t)(void); | |
37 | typedef int (*oz_app_start_fn_t)(struct oz_pd *pd, int resume); | |
38 | typedef void (*oz_app_stop_fn_t)(struct oz_pd *pd, int pause); | |
39 | typedef void (*oz_app_rx_fn_t)(struct oz_pd *pd, struct oz_elt *elt); | |
40 | typedef int (*oz_app_hearbeat_fn_t)(struct oz_pd *pd); | |
41 | typedef void (*oz_app_farewell_fn_t)(struct oz_pd *pd, u8 ep_num, | |
42 | u8 *data, u8 len); | |
43 | ||
44 | struct oz_app_if { | |
45 | oz_app_init_fn_t init; | |
46 | oz_app_term_fn_t term; | |
47 | oz_app_start_fn_t start; | |
48 | oz_app_stop_fn_t stop; | |
49 | oz_app_rx_fn_t rx; | |
50 | oz_app_hearbeat_fn_t heartbeat; | |
51 | oz_app_farewell_fn_t farewell; | |
52 | int app_id; | |
53 | }; | |
54 | ||
55 | int oz_protocol_init(char *devs); | |
56 | void oz_protocol_term(void); | |
57 | int oz_get_pd_list(struct oz_mac_addr *addr, int max_count); | |
58 | void oz_app_enable(int app_id, int enable); | |
59 | struct oz_pd *oz_pd_find(u8 *mac_addr); | |
60 | void oz_binding_add(char *net_dev); | |
61 | void oz_binding_remove(char *net_dev); | |
62 | void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, | |
63 | int remove); | |
64 | void oz_timer_delete(struct oz_pd *pd, int type); | |
65 | void oz_pd_request_heartbeat(struct oz_pd *pd); | |
66 | void oz_polling_lock_bh(void); | |
67 | void oz_polling_unlock_bh(void); | |
68 | ||
69 | #endif /* _OZPROTO_H */ |