ozpd.h revision 9c165f1bb2bc6208eaf2ab729f1de67ee89811a3
1/* ----------------------------------------------------------------------------- 2 * Copyright (c) 2011 Ozmo Inc 3 * Released under the GNU General Public License Version 2 (GPLv2). 4 * ----------------------------------------------------------------------------- 5 */ 6#ifndef _OZPD_H_ 7#define _OZPD_H_ 8 9#include <linux/interrupt.h> 10#include "ozeltbuf.h" 11 12/* PD state 13 */ 14#define OZ_PD_S_IDLE 0x1 15#define OZ_PD_S_CONNECTED 0x2 16#define OZ_PD_S_SLEEP 0x4 17#define OZ_PD_S_STOPPED 0x8 18 19/* Timer event types. 20 */ 21#define OZ_TIMER_TOUT 1 22#define OZ_TIMER_HEARTBEAT 2 23#define OZ_TIMER_STOP 3 24 25/* 26 *External spinlock variable 27 */ 28extern spinlock_t g_polling_lock; 29 30/* Data structure that hold information on a frame for transmisson. This is 31 * built when the frame is first transmitted and is used to rebuild the frame 32 * if a re-transmission is required. 33 */ 34struct oz_tx_frame { 35 struct list_head link; 36 struct list_head elt_list; 37 struct oz_hdr hdr; 38 struct sk_buff *skb; 39 int total_size; 40}; 41 42struct oz_isoc_stream { 43 struct list_head link; 44 u8 ep_num; 45 u8 frame_num; 46 u8 nb_units; 47 int size; 48 struct sk_buff *skb; 49 struct oz_hdr *oz_hdr; 50}; 51 52struct oz_farewell { 53 struct list_head link; 54 u8 ep_num; 55 u8 index; 56 u8 len; 57 u8 report[0]; 58}; 59 60/* Data structure that holds information on a specific peripheral device (PD). 61 */ 62struct oz_pd { 63 struct list_head link; 64 atomic_t ref_count; 65 u8 mac_addr[ETH_ALEN]; 66 unsigned state; 67 unsigned state_flags; 68 unsigned send_flags; 69 u16 total_apps; 70 u16 paused_apps; 71 u8 session_id; 72 u8 param_rsp_status; 73 u8 pd_info; 74 u8 isoc_sent; 75 u32 last_rx_pkt_num; 76 u32 last_tx_pkt_num; 77 struct timespec last_rx_timestamp; 78 u32 trigger_pkt_num; 79 unsigned long pulse_time; 80 unsigned long pulse_period; 81 unsigned long presleep; 82 unsigned long keep_alive; 83 struct oz_elt_buf elt_buff; 84 void *app_ctx[OZ_APPID_MAX]; 85 spinlock_t app_lock[OZ_APPID_MAX]; 86 int max_tx_size; 87 u8 mode; 88 u8 ms_per_isoc; 89 unsigned isoc_latency; 90 unsigned max_stream_buffering; 91 int nb_queued_frames; 92 int nb_queued_isoc_frames; 93 struct list_head *tx_pool; 94 int tx_pool_count; 95 spinlock_t tx_frame_lock; 96 struct list_head *last_sent_frame; 97 struct list_head tx_queue; 98 struct list_head farewell_list; 99 spinlock_t stream_lock; 100 struct list_head stream_list; 101 struct net_device *net_dev; 102 struct hrtimer heartbeat; 103 struct hrtimer timeout; 104 u8 timeout_type; 105 struct tasklet_struct heartbeat_tasklet; 106 struct tasklet_struct timeout_tasklet; 107 struct work_struct workitem; 108}; 109 110#define OZ_MAX_QUEUED_FRAMES 4 111 112struct oz_pd *oz_pd_alloc(const u8 *mac_addr); 113void oz_pd_destroy(struct oz_pd *pd); 114void oz_pd_get(struct oz_pd *pd); 115void oz_pd_put(struct oz_pd *pd); 116void oz_pd_set_state(struct oz_pd *pd, unsigned state); 117void oz_pd_indicate_farewells(struct oz_pd *pd); 118int oz_pd_sleep(struct oz_pd *pd); 119void oz_pd_stop(struct oz_pd *pd); 120void oz_pd_heartbeat(struct oz_pd *pd, u16 apps); 121int oz_services_start(struct oz_pd *pd, u16 apps, int resume); 122void oz_services_stop(struct oz_pd *pd, u16 apps, int pause); 123int oz_prepare_frame(struct oz_pd *pd, int empty); 124void oz_send_queued_frames(struct oz_pd *pd, int backlog); 125void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn); 126int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num); 127int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num); 128int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len); 129void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt); 130void oz_apps_init(void); 131void oz_apps_term(void); 132 133#endif /* Sentry */ 134