aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ozwpan/ozpd.h
blob: ad5fe7a6e619c5e321f30d91713a15c76fbdd878 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* -----------------------------------------------------------------------------
 * Copyright (c) 2011 Ozmo Inc
 * Released under the GNU General Public License Version 2 (GPLv2).
 * -----------------------------------------------------------------------------
 */
#ifndef _OZPD_H_
#define _OZPD_H_

#include <linux/interrupt.h>
#include "ozeltbuf.h"

/* PD state
 */
#define OZ_PD_S_IDLE		0x1
#define OZ_PD_S_CONNECTED	0x2
#define OZ_PD_S_SLEEP		0x4
#define OZ_PD_S_STOPPED		0x8

/* Timer event types.
 */
#define OZ_TIMER_TOUT		1
#define OZ_TIMER_HEARTBEAT	2
#define OZ_TIMER_STOP		3

/*
 *External spinlock variable
 */
extern spinlock_t g_polling_lock;

/* Data structure that hold information on a frame for transmisson. This is
 * built when the frame is first transmitted and is used to rebuild the frame
 * if a re-transmission is required.
 */
struct oz_tx_frame {
	struct list_head link;
	struct list_head elt_list;
	struct oz_hdr hdr;
	struct sk_buff *skb;
	int total_size;
};

struct oz_isoc_stream {
	struct list_head link;
	u8 ep_num;
	u8 frame_num;
	u8 nb_units;
	int size;
	struct sk_buff *skb;
	struct oz_hdr *oz_hdr;
};

struct oz_farewell {
	struct list_head link;
	u8 ep_num;
	u8 index;
	u8 len;
	u8 report[0];
};

/* Data structure that holds information on a specific peripheral device (PD).
 */
struct oz_pd {
	struct list_head link;
	atomic_t	ref_count;
	u8		mac_addr[ETH_ALEN];
	unsigned	state;
	unsigned	state_flags;
	unsigned	send_flags;
	u16		total_apps;
	u16		paused_apps;
	u8		session_id;
	u8		param_rsp_status;
	u8		pd_info;
	u8		isoc_sent;
	u32		last_rx_pkt_num;
	u32		last_tx_pkt_num;
	struct timespec last_rx_timestamp;
	u32		trigger_pkt_num;
	unsigned long	pulse_time;
	unsigned long	pulse_period;
	unsigned long	presleep;
	unsigned long	keep_alive;
	struct oz_elt_buf elt_buff;
	void		*app_ctx[OZ_APPID_MAX];
	spinlock_t	app_lock[OZ_APPID_MAX];
	int		max_tx_size;
	u8		mode;
	u8		ms_per_isoc;
	unsigned	isoc_latency;
	unsigned	max_stream_buffering;
	int		nb_queued_frames;
	int		nb_queued_isoc_frames;
	struct list_head *tx_pool;
	int		tx_pool_count;
	spinlock_t	tx_frame_lock;
	struct list_head *last_sent_frame;
	struct list_head tx_queue;
	struct list_head farewell_list;
	spinlock_t	stream_lock;
	struct list_head stream_list;
	struct net_device *net_dev;
	struct hrtimer  heartbeat;
	struct hrtimer  timeout;
	u8      timeout_type;
	struct tasklet_struct   heartbeat_tasklet;
	struct tasklet_struct   timeout_tasklet;
	struct work_struct workitem;
};

#define OZ_MAX_QUEUED_FRAMES	4

struct oz_pd *oz_pd_alloc(const u8 *mac_addr);
void oz_pd_destroy(struct oz_pd *pd);
void oz_pd_get(struct oz_pd *pd);
void oz_pd_put(struct oz_pd *pd);
void oz_pd_set_state(struct oz_pd *pd, unsigned state);
void oz_pd_indicate_farewells(struct oz_pd *pd);
int oz_pd_sleep(struct oz_pd *pd);
void oz_pd_stop(struct oz_pd *pd);
void oz_pd_heartbeat(struct oz_pd *pd, u16 apps);
int oz_services_start(struct oz_pd *pd, u16 apps, int resume);
void oz_services_stop(struct oz_pd *pd, u16 apps, int pause);
int oz_prepare_frame(struct oz_pd *pd, int empty);
void oz_send_queued_frames(struct oz_pd *pd, int backlog);
void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn);
int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num);
int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num);
int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len);
void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt);
void oz_apps_init(void);
void oz_apps_term(void);

#endif /* Sentry */