| 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) msecs_to_jiffies(__x) |
| 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 | /* Maximum number of uncompleted isoc frames that can be pending in network. */ |
| 34 | #define OZ_MAX_SUBMITTED_ISOC 16 |
| 35 | |
| 36 | /* Maximum number of uncompleted isoc frames that can be pending in Tx Queue. */ |
| 37 | #define OZ_MAX_TX_QUEUE_ISOC 32 |
| 38 | |
| 39 | /* Application handler functions. |
| 40 | */ |
| 41 | typedef int (*oz_app_init_fn_t)(void); |
| 42 | typedef void (*oz_app_term_fn_t)(void); |
| 43 | typedef int (*oz_app_start_fn_t)(struct oz_pd *pd, int resume); |
| 44 | typedef void (*oz_app_stop_fn_t)(struct oz_pd *pd, int pause); |
| 45 | typedef void (*oz_app_rx_fn_t)(struct oz_pd *pd, struct oz_elt *elt); |
| 46 | typedef int (*oz_app_hearbeat_fn_t)(struct oz_pd *pd); |
| 47 | typedef void (*oz_app_farewell_fn_t)(struct oz_pd *pd, u8 ep_num, |
| 48 | u8 *data, u8 len); |
| 49 | |
| 50 | struct oz_app_if { |
| 51 | oz_app_init_fn_t init; |
| 52 | oz_app_term_fn_t term; |
| 53 | oz_app_start_fn_t start; |
| 54 | oz_app_stop_fn_t stop; |
| 55 | oz_app_rx_fn_t rx; |
| 56 | oz_app_hearbeat_fn_t heartbeat; |
| 57 | oz_app_farewell_fn_t farewell; |
| 58 | int app_id; |
| 59 | }; |
| 60 | |
| 61 | int oz_protocol_init(char *devs); |
| 62 | void oz_protocol_term(void); |
| 63 | int oz_get_pd_list(struct oz_mac_addr *addr, int max_count); |
| 64 | void oz_app_enable(int app_id, int enable); |
| 65 | struct oz_pd *oz_pd_find(const u8 *mac_addr); |
| 66 | void oz_binding_add(char *net_dev); |
| 67 | void oz_binding_remove(char *net_dev); |
| 68 | void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, |
| 69 | int remove); |
| 70 | void oz_timer_delete(struct oz_pd *pd, int type); |
| 71 | void oz_pd_request_heartbeat(struct oz_pd *pd); |
| 72 | void oz_polling_lock_bh(void); |
| 73 | void oz_polling_unlock_bh(void); |
| 74 | |
| 75 | #endif /* _OZPROTO_H */ |