7 #include <linux/module.h>
9 #include <linux/sched.h>
10 #include <linux/netdevice.h>
11 #include <linux/errno.h>
21 #include <asm/unaligned.h>
26 #define OZ_MAX_TX_POOL_SIZE 6
33 static int oz_send_isoc_frame(
struct oz_pd *pd);
36 static int oz_send_next_queued_frame(
struct oz_pd *pd,
int more_data);
37 static void oz_isoc_destructor(
struct sk_buff *
skb);
38 static int oz_def_app_init(
void);
39 static void oz_def_app_term(
void);
40 static int oz_def_app_start(
struct oz_pd *pd,
int resume);
41 static void oz_def_app_stop(
struct oz_pd *pd,
int pause);
42 static void oz_def_app_rx(
struct oz_pd *pd,
struct oz_elt *elt);
89 static int oz_def_app_init(
void)
96 static void oz_def_app_term(
void)
102 static int oz_def_app_start(
struct oz_pd *pd,
int resume)
109 static void oz_def_app_stop(
struct oz_pd *pd,
int pause)
115 static void oz_def_app_rx(
struct oz_pd *pd,
struct oz_elt *elt)
128 oz_trace(
"PD State: OZ_PD_S_IDLE\n");
131 oz_trace(
"PD State: OZ_PD_S_CONNECTED\n");
134 oz_trace(
"PD State: OZ_PD_S_STOPPED\n");
137 oz_trace(
"PD State: OZ_PD_S_SLEEP\n");
201 oz_isoc_stream_free(st);
211 oz_retire_frame(pd, f);
240 oz_trace(
"oz_services_start(0x%x) resume(%d)\n", apps, resume);
241 for (ai = g_app_if; ai < &g_app_if[
OZ_APPID_MAX]; ai++) {
242 if (apps & (1<<ai->
app_id)) {
243 if (ai->
start(pd, resume)) {
245 oz_trace(
"Unabled to start service %d\n",
264 oz_trace(
"oz_stop_services(0x%x) pause(%d)\n", apps, pause);
265 for (ai = g_app_if; ai < &g_app_if[
OZ_APPID_MAX]; ai++) {
266 if (apps & (1<<ai->
app_id)) {
286 for (ai = g_app_if; ai < &g_app_if[
OZ_APPID_MAX]; ai++) {
296 while (count-- && (oz_send_isoc_frame(pd) >= 0))
338 oz_trace(
"Sleep Now %lu until %lu\n",
370 INIT_LIST_HEAD(&f->
link);
381 list_del_init(&f->
link);
413 struct oz_hdr *
oz_hdr = (
struct oz_hdr *)skb_network_header(skb);
421 struct oz_hdr *
oz_hdr = (
struct oz_hdr *)skb_network_header(skb);
436 f = oz_tx_frame_alloc(pd);
473 skb_reset_network_header(skb);
483 memcpy(oz_hdr, &f->
hdr,
sizeof(
struct oz_hdr));
486 elt = (
struct oz_elt *)(oz_hdr+1);
509 list_del_init(&ei->
link);
516 oz_tx_frame_free(pd, f);
523 static int oz_send_next_queued_frame(
struct oz_pd *pd,
int more_data)
538 oz_tx_isoc_free(pd, f);
547 "Dropping ISOC Frame\n");
553 "Sending ISOC Frame, nb_isoc= %d\n",
565 skb = oz_build_frame(pd, f);
573 (((
u16)f->
hdr.control)<<8)|f->
hdr.last_pkt_num,
600 if ((backlog <= 0) && (pd->
isoc_sent == 0))
611 if (oz_send_next_queued_frame(pd, backlog) < 0)
617 oz_send_next_queued_frame(pd, 0);
622 static int oz_send_isoc_frame(
struct oz_pd *pd)
626 struct oz_hdr *oz_hdr;
631 INIT_LIST_HEAD(&
list);
644 skb_reset_network_header(skb);
652 oz_hdr = (
struct oz_hdr *)
skb_put(skb, total_size);
655 elt = (
struct oz_elt *)(oz_hdr+1);
706 oz_retire_frame(pd, f);
735 if (!pd_stream_find(pd, ep_num)) {
759 st = pd_stream_find(pd, ep_num);
764 oz_isoc_stream_free(st);
770 static void oz_isoc_destructor(
struct sk_buff *skb)
785 struct oz_hdr *oz_hdr = 0;
788 st = pd_stream_find(pd, ep_num);
808 skb_reset_network_header(skb);
813 size =
sizeof(
struct oz_hdr) + sizeof(struct oz_isoc_large);
814 oz_hdr = (
struct oz_hdr *)
skb_put(skb, size);
818 if (++nb_units < pd->ms_per_isoc) {
839 memcpy(oz_hdr, &oz,
sizeof(oz));
840 memcpy(oz_hdr+1, &iso,
sizeof(iso));
852 "Dropping ISOC Unit nb= %d\n",
856 isoc_unit = oz_tx_frame_alloc(pd);
857 if (isoc_unit ==
NULL)
866 "Added ISOC Frame to Tx Queue isoc_nb= %d, nb= %d\n",
899 if (g_app_if[i].
init)
910 if (g_app_if[i].term)
921 ai = &g_app_if[app_id-1];