]> Pileus Git - ~andy/linux/blob - drivers/staging/ozwpan/ozpd.h
Merge branch 'topic/misc' into for-linus
[~andy/linux] / drivers / staging / ozwpan / ozpd.h
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 "ozeltbuf.h"
10
11 /* PD state
12  */
13 #define OZ_PD_S_IDLE            0x1
14 #define OZ_PD_S_CONNECTED       0x2
15 #define OZ_PD_S_SLEEP           0x4
16 #define OZ_PD_S_STOPPED         0x8
17
18 /* Timer event types.
19  */
20 #define OZ_TIMER_TOUT           1
21 #define OZ_TIMER_HEARTBEAT      2
22 #define OZ_TIMER_STOP           3
23
24 /* Data structure that hold information on a frame for transmisson. This is
25  * built when the frame is first transmitted and is used to rebuild the frame
26  * if a re-transmission is required.
27  */
28 struct oz_tx_frame {
29         struct list_head link;
30         struct list_head elt_list;
31         struct oz_hdr hdr;
32         int total_size;
33 };
34
35 struct oz_isoc_stream {
36         struct list_head link;
37         u8 ep_num;
38         u8 frame_num;
39         u8 nb_units;
40         int size;
41         struct sk_buff *skb;
42         struct oz_hdr *oz_hdr;
43 };
44
45 struct oz_farewell {
46         struct list_head link;
47         u8 ep_num;
48         u8 index;
49         u8 report[1];
50         u8 len;
51 };
52
53 /* Data structure that holds information on a specific peripheral device (PD).
54  */
55 struct oz_pd {
56         struct list_head link;
57         atomic_t        ref_count;
58         u8              mac_addr[ETH_ALEN];
59         unsigned        state;
60         unsigned        state_flags;
61         unsigned        send_flags;
62         u16             total_apps;
63         u16             paused_apps;
64         u8              session_id;
65         u8              param_rsp_status;
66         u8              pd_info;
67         u8              isoc_sent;
68         u32             last_rx_pkt_num;
69         u32             last_tx_pkt_num;
70         u32             trigger_pkt_num;
71         unsigned long   pulse_time_j;
72         unsigned long   timeout_time_j;
73         unsigned long   pulse_period_j;
74         unsigned long   presleep_j;
75         unsigned long   keep_alive_j;
76         unsigned long   last_rx_time_j;
77         struct oz_elt_buf elt_buff;
78         void            *app_ctx[OZ_APPID_MAX];
79         spinlock_t      app_lock[OZ_APPID_MAX];
80         int             max_tx_size;
81         u8              heartbeat_requested;
82         u8              mode;
83         u8              ms_per_isoc;
84         unsigned        max_stream_buffering;
85         int             nb_queued_frames;
86         struct list_head *tx_pool;
87         int             tx_pool_count;
88         spinlock_t      tx_frame_lock;
89         struct list_head *last_sent_frame;
90         struct list_head tx_queue;
91         struct list_head farewell_list;
92         spinlock_t      stream_lock;
93         struct list_head stream_list;
94         struct net_device *net_dev;
95 };
96
97 #define OZ_MAX_QUEUED_FRAMES    4
98
99 struct oz_pd *oz_pd_alloc(u8 *mac_addr);
100 void oz_pd_destroy(struct oz_pd *pd);
101 void oz_pd_get(struct oz_pd *pd);
102 void oz_pd_put(struct oz_pd *pd);
103 void oz_pd_set_state(struct oz_pd *pd, unsigned state);
104 void oz_pd_indicate_farewells(struct oz_pd *pd);
105 int oz_pd_sleep(struct oz_pd *pd);
106 void oz_pd_stop(struct oz_pd *pd);
107 void oz_pd_heartbeat(struct oz_pd *pd, u16 apps);
108 int oz_services_start(struct oz_pd *pd, u16 apps, int resume);
109 void oz_services_stop(struct oz_pd *pd, u16 apps, int pause);
110 int oz_prepare_frame(struct oz_pd *pd, int empty);
111 void oz_send_queued_frames(struct oz_pd *pd, int backlog);
112 void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn);
113 int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num);
114 int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num);
115 int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len);
116 void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt);
117 void oz_apps_init(void);
118 void oz_apps_term(void);
119
120 #endif /* Sentry */
121