1 /* -----------------------------------------------------------------------------
2 * Copyright (c) 2011 Ozmo Inc
3 * Released under the GNU General Public License Version 2 (GPLv2).
4 * -----------------------------------------------------------------------------
6 #include <linux/init.h>
7 #include <linux/module.h>
8 #include <linux/timer.h>
9 #include <linux/sched.h>
10 #include <linux/netdevice.h>
11 #include <linux/errno.h>
12 #include <linux/ieee80211.h>
14 #include "ozprotocol.h"
21 #include <asm/unaligned.h>
22 #include <linux/uaccess.h>
23 #include <net/psnap.h>
24 /*------------------------------------------------------------------------------
26 #define OZ_CF_CONN_SUCCESS 1
27 #define OZ_CF_CONN_FAILURE 2
32 /* States of the timer.
34 #define OZ_TIMER_IDLE 0
35 #define OZ_TIMER_SET 1
36 #define OZ_TIMER_IN_HANDLER 2
38 #define OZ_MAX_TIMER_POOL_SIZE 16
40 /*------------------------------------------------------------------------------
43 struct packet_type ptype;
44 char name[OZ_MAX_BINDING_LEN];
45 struct oz_binding *next;
49 struct list_head link;
51 unsigned long due_time;
54 /*------------------------------------------------------------------------------
55 * Static external variables.
57 static DEFINE_SPINLOCK(g_polling_lock);
58 static LIST_HEAD(g_pd_list);
59 static struct oz_binding *g_binding ;
60 static DEFINE_SPINLOCK(g_binding_lock);
61 static struct sk_buff_head g_rx_queue;
62 static u8 g_session_id;
63 static u16 g_apps = 0x1;
64 static int g_processing_rx;
65 static struct timer_list g_timer;
66 static struct oz_timer *g_cur_timer;
67 static struct list_head *g_timer_pool;
68 static int g_timer_pool_count;
69 static int g_timer_state = OZ_TIMER_IDLE;
70 static LIST_HEAD(g_timer_list);
71 /*------------------------------------------------------------------------------
73 static void oz_protocol_timer_start(void);
74 /*------------------------------------------------------------------------------
75 * Context: softirq-serialized
77 static u8 oz_get_new_session_id(u8 exclude)
79 if (++g_session_id == 0)
81 if (g_session_id == exclude) {
82 if (++g_session_id == 0)
87 /*------------------------------------------------------------------------------
88 * Context: softirq-serialized
90 static void oz_send_conn_rsp(struct oz_pd *pd, u8 status)
93 struct net_device *dev = pd->net_dev;
94 struct oz_hdr *oz_hdr;
96 struct oz_elt_connect_rsp *body;
97 int sz = sizeof(struct oz_hdr) + sizeof(struct oz_elt) +
98 sizeof(struct oz_elt_connect_rsp);
99 skb = alloc_skb(sz + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC);
102 skb_reserve(skb, LL_RESERVED_SPACE(dev));
103 skb_reset_network_header(skb);
104 oz_hdr = (struct oz_hdr *)skb_put(skb, sz);
105 elt = (struct oz_elt *)(oz_hdr+1);
106 body = (struct oz_elt_connect_rsp *)(elt+1);
108 skb->protocol = htons(OZ_ETHERTYPE);
109 /* Fill in device header */
110 if (dev_hard_header(skb, dev, OZ_ETHERTYPE, pd->mac_addr,
111 dev->dev_addr, skb->len) < 0) {
115 oz_hdr->control = (OZ_PROTOCOL_VERSION<<OZ_VERSION_SHIFT);
116 oz_hdr->last_pkt_num = 0;
117 put_unaligned(0, &oz_hdr->pkt_num);
118 elt->type = OZ_ELT_CONNECT_RSP;
119 elt->length = sizeof(struct oz_elt_connect_rsp);
120 memset(body, 0, sizeof(struct oz_elt_connect_rsp));
121 body->status = status;
123 body->mode = pd->mode;
124 body->session_id = pd->session_id;
125 put_unaligned(cpu_to_le16(pd->total_apps), &body->apps);
127 oz_trace("TX: OZ_ELT_CONNECT_RSP %d", status);
131 /*------------------------------------------------------------------------------
132 * Context: softirq-serialized
134 static void pd_set_keepalive(struct oz_pd *pd, u8 kalive)
136 unsigned long keep_alive = kalive & OZ_KALIVE_VALUE_MASK;
138 switch (kalive & OZ_KALIVE_TYPE_MASK) {
139 case OZ_KALIVE_SPECIAL:
141 oz_ms_to_jiffies(keep_alive * 1000*60*60*24*20);
144 pd->keep_alive_j = oz_ms_to_jiffies(keep_alive*1000);
147 pd->keep_alive_j = oz_ms_to_jiffies(keep_alive*1000*60);
149 case OZ_KALIVE_HOURS:
150 pd->keep_alive_j = oz_ms_to_jiffies(keep_alive*1000*60*60);
153 pd->keep_alive_j = 0;
155 oz_trace("Keepalive = %lu jiffies\n", pd->keep_alive_j);
157 /*------------------------------------------------------------------------------
158 * Context: softirq-serialized
160 static void pd_set_presleep(struct oz_pd *pd, u8 presleep)
163 pd->presleep_j = oz_ms_to_jiffies(presleep*100);
165 pd->presleep_j = OZ_PRESLEEP_TOUT_J;
166 oz_trace("Presleep time = %lu jiffies\n", pd->presleep_j);
168 /*------------------------------------------------------------------------------
169 * Context: softirq-serialized
171 static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt,
172 const u8 *pd_addr, struct net_device *net_dev)
175 struct oz_elt_connect_req *body =
176 (struct oz_elt_connect_req *)(elt+1);
177 u8 rsp_status = OZ_STATUS_SUCCESS;
179 u16 new_apps = g_apps;
180 struct net_device *old_net_dev = NULL;
181 struct oz_pd *free_pd = NULL;
184 spin_lock_bh(&g_polling_lock);
186 struct oz_pd *pd2 = NULL;
188 pd = oz_pd_alloc(pd_addr);
191 pd->last_rx_time_j = jiffies;
192 spin_lock_bh(&g_polling_lock);
193 list_for_each(e, &g_pd_list) {
194 pd2 = container_of(e, struct oz_pd, link);
195 if (memcmp(pd2->mac_addr, pd_addr, ETH_ALEN) == 0) {
202 list_add_tail(&pd->link, &g_pd_list);
205 spin_unlock_bh(&g_polling_lock);
208 if (pd->net_dev != net_dev) {
209 old_net_dev = pd->net_dev;
211 pd->net_dev = net_dev;
213 oz_trace("Host vendor: %d\n", body->host_vendor);
214 pd->max_tx_size = OZ_MAX_TX_SIZE;
215 pd->mode = body->mode;
216 pd->pd_info = body->pd_info;
217 if (pd->mode & OZ_F_ISOC_NO_ELTS) {
218 pd->ms_per_isoc = body->ms_per_isoc;
219 if (!pd->ms_per_isoc)
222 switch (body->ms_isoc_latency & OZ_LATENCY_MASK) {
223 case OZ_ONE_MS_LATENCY:
224 pd->isoc_latency = (body->ms_isoc_latency &
225 ~OZ_LATENCY_MASK) / pd->ms_per_isoc;
227 case OZ_TEN_MS_LATENCY:
228 pd->isoc_latency = ((body->ms_isoc_latency &
229 ~OZ_LATENCY_MASK) * 10) / pd->ms_per_isoc;
232 pd->isoc_latency = OZ_MAX_TX_QUEUE_ISOC;
235 if (body->max_len_div16)
236 pd->max_tx_size = ((u16)body->max_len_div16)<<4;
237 oz_trace("Max frame:%u Ms per isoc:%u\n",
238 pd->max_tx_size, pd->ms_per_isoc);
239 pd->max_stream_buffering = 3*1024;
240 pd->timeout_time_j = jiffies + OZ_CONNECTION_TOUT_J;
241 pd->pulse_period_j = OZ_QUANTUM_J;
242 pd_set_presleep(pd, body->presleep);
243 pd_set_keepalive(pd, body->keep_alive);
245 new_apps &= le16_to_cpu(get_unaligned(&body->apps));
246 if ((new_apps & 0x1) && (body->session_id)) {
247 if (pd->session_id) {
248 if (pd->session_id != body->session_id) {
249 rsp_status = OZ_STATUS_SESSION_MISMATCH;
253 new_apps &= ~0x1; /* Resume not permitted */
255 oz_get_new_session_id(body->session_id);
258 if (pd->session_id && !body->session_id) {
259 rsp_status = OZ_STATUS_SESSION_TEARDOWN;
262 new_apps &= ~0x1; /* Resume not permitted */
264 oz_get_new_session_id(body->session_id);
268 if (rsp_status == OZ_STATUS_SUCCESS) {
269 u16 start_apps = new_apps & ~pd->total_apps & ~0x1;
270 u16 stop_apps = pd->total_apps & ~new_apps & ~0x1;
271 u16 resume_apps = new_apps & pd->paused_apps & ~0x1;
272 spin_unlock_bh(&g_polling_lock);
273 oz_pd_set_state(pd, OZ_PD_S_CONNECTED);
274 oz_timer_delete(pd, OZ_TIMER_STOP);
275 oz_trace("new_apps=0x%x total_apps=0x%x paused_apps=0x%x\n",
276 new_apps, pd->total_apps, pd->paused_apps);
278 if (oz_services_start(pd, start_apps, 0))
279 rsp_status = OZ_STATUS_TOO_MANY_PDS;
282 if (oz_services_start(pd, resume_apps, 1))
283 rsp_status = OZ_STATUS_TOO_MANY_PDS;
285 oz_services_stop(pd, stop_apps, 0);
286 oz_pd_request_heartbeat(pd);
288 spin_unlock_bh(&g_polling_lock);
290 oz_send_conn_rsp(pd, rsp_status);
291 if (rsp_status != OZ_STATUS_SUCCESS) {
298 dev_put(old_net_dev);
300 oz_pd_destroy(free_pd);
303 /*------------------------------------------------------------------------------
304 * Context: softirq-serialized
306 static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index,
307 const u8 *report, u8 len)
309 struct oz_farewell *f;
310 struct oz_farewell *f2;
312 f = kmalloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC);
317 memcpy(f->report, report, len);
318 oz_trace("RX: Adding farewell report\n");
319 spin_lock(&g_polling_lock);
320 list_for_each_entry(f2, &pd->farewell_list, link) {
321 if ((f2->ep_num == ep_num) && (f2->index == index)) {
327 list_add_tail(&f->link, &pd->farewell_list);
328 spin_unlock(&g_polling_lock);
332 /*------------------------------------------------------------------------------
333 * Context: softirq-serialized
335 static void oz_rx_frame(struct sk_buff *skb)
341 struct oz_pd *pd = NULL;
342 struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb);
346 oz_trace2(OZ_TRACE_RX_FRAMES,
347 "RX frame PN=0x%x LPN=0x%x control=0x%x\n",
348 oz_hdr->pkt_num, oz_hdr->last_pkt_num, oz_hdr->control);
349 mac_hdr = skb_mac_header(skb);
350 src_addr = &mac_hdr[ETH_ALEN] ;
353 /* Check the version field */
354 if (oz_get_prot_ver(oz_hdr->control) != OZ_PROTOCOL_VERSION) {
355 oz_trace("Incorrect protocol version: %d\n",
356 oz_get_prot_ver(oz_hdr->control));
360 pkt_num = le32_to_cpu(get_unaligned(&oz_hdr->pkt_num));
362 pd = oz_pd_find(src_addr);
364 pd->last_rx_time_j = jiffies;
365 oz_timer_add(pd, OZ_TIMER_TOUT,
366 pd->last_rx_time_j + pd->presleep_j, 1);
367 if (pkt_num != pd->last_rx_pkt_num) {
368 pd->last_rx_pkt_num = pkt_num;
371 oz_trace("Duplicate frame\n");
375 if (pd && !dup && ((pd->mode & OZ_MODE_MASK) == OZ_MODE_TRIGGERED)) {
376 oz_trace2(OZ_TRACE_RX_FRAMES, "Received TRIGGER Frame\n");
377 pd->last_sent_frame = &pd->tx_queue;
378 if (oz_hdr->control & OZ_F_ACK) {
379 /* Retire completed frames */
380 oz_retire_tx_frames(pd, oz_hdr->last_pkt_num);
382 if ((oz_hdr->control & OZ_F_ACK_REQUESTED) &&
383 (pd->state == OZ_PD_S_CONNECTED)) {
384 int backlog = pd->nb_queued_frames;
385 pd->trigger_pkt_num = pkt_num;
386 /* Send queued frames */
387 oz_send_queued_frames(pd, backlog);
391 length -= sizeof(struct oz_hdr);
392 elt = (struct oz_elt *)((u8 *)oz_hdr + sizeof(struct oz_hdr));
394 while (length >= sizeof(struct oz_elt)) {
395 length -= sizeof(struct oz_elt) + elt->length;
399 case OZ_ELT_CONNECT_REQ:
400 oz_trace("RX: OZ_ELT_CONNECT_REQ\n");
401 pd = oz_connect_req(pd, elt, src_addr, skb->dev);
403 case OZ_ELT_DISCONNECT:
404 oz_trace("RX: OZ_ELT_DISCONNECT\n");
408 case OZ_ELT_UPDATE_PARAM_REQ: {
409 struct oz_elt_update_param *body =
410 (struct oz_elt_update_param *)(elt + 1);
411 oz_trace("RX: OZ_ELT_UPDATE_PARAM_REQ\n");
412 if (pd && (pd->state & OZ_PD_S_CONNECTED)) {
413 spin_lock(&g_polling_lock);
414 pd_set_keepalive(pd, body->keepalive);
415 pd_set_presleep(pd, body->presleep);
416 spin_unlock(&g_polling_lock);
420 case OZ_ELT_FAREWELL_REQ: {
421 struct oz_elt_farewell *body =
422 (struct oz_elt_farewell *)(elt + 1);
423 oz_trace("RX: OZ_ELT_FAREWELL_REQ\n");
424 oz_add_farewell(pd, body->ep_num,
425 body->index, body->report,
426 elt->length + 1 - sizeof(*body));
429 case OZ_ELT_APP_DATA:
430 if (pd && (pd->state & OZ_PD_S_CONNECTED)) {
431 struct oz_app_hdr *app_hdr =
432 (struct oz_app_hdr *)(elt+1);
435 oz_handle_app_elt(pd, app_hdr->app_id, elt);
439 oz_trace("RX: Unknown elt %02x\n", elt->type);
441 elt = oz_next_elt(elt);
448 /*------------------------------------------------------------------------------
451 void oz_protocol_term(void)
453 struct list_head *chain;
454 del_timer_sync(&g_timer);
455 /* Walk the list of bindings and remove each one.
457 spin_lock_bh(&g_binding_lock);
459 struct oz_binding *b = g_binding;
461 spin_unlock_bh(&g_binding_lock);
462 dev_remove_pack(&b->ptype);
464 dev_put(b->ptype.dev);
466 spin_lock_bh(&g_binding_lock);
468 spin_unlock_bh(&g_binding_lock);
469 /* Walk the list of PDs and stop each one. This causes the PD to be
470 * removed from the list so we can just pull each one from the head
473 spin_lock_bh(&g_polling_lock);
474 while (!list_empty(&g_pd_list)) {
476 list_first_entry(&g_pd_list, struct oz_pd, link);
478 spin_unlock_bh(&g_polling_lock);
481 spin_lock_bh(&g_polling_lock);
483 chain = g_timer_pool;
485 spin_unlock_bh(&g_polling_lock);
487 struct oz_timer *t = container_of(chain, struct oz_timer, link);
491 oz_trace("Protocol stopped\n");
493 /*------------------------------------------------------------------------------
496 static void oz_pd_handle_timer(struct oz_pd *pd, int type)
505 case OZ_TIMER_HEARTBEAT: {
507 spin_lock_bh(&g_polling_lock);
508 pd->heartbeat_requested = 0;
509 if (pd->state & OZ_PD_S_CONNECTED)
510 apps = pd->total_apps;
511 spin_unlock_bh(&g_polling_lock);
513 oz_pd_heartbeat(pd, apps);
518 /*------------------------------------------------------------------------------
521 static void oz_protocol_timer(unsigned long arg)
526 spin_lock_bh(&g_polling_lock);
528 /* This happens if we remove the current timer but can't stop
529 * the timer from firing. In this case just get out.
531 spin_unlock_bh(&g_polling_lock);
534 g_timer_state = OZ_TIMER_IN_HANDLER;
538 spin_unlock_bh(&g_polling_lock);
541 oz_pd_handle_timer(pd, t->type);
542 spin_lock_bh(&g_polling_lock);
543 if (g_timer_pool_count < OZ_MAX_TIMER_POOL_SIZE) {
544 t->link.next = g_timer_pool;
545 g_timer_pool = &t->link;
546 g_timer_pool_count++;
549 if (!list_empty(&g_timer_list)) {
550 t2 = container_of(g_timer_list.next,
551 struct oz_timer, link);
552 if (time_before_eq(t2->due_time, jiffies))
559 spin_unlock_bh(&g_polling_lock);
564 g_timer_state = OZ_TIMER_IDLE;
565 oz_protocol_timer_start();
567 /*------------------------------------------------------------------------------
570 static void oz_protocol_timer_start(void)
572 spin_lock_bh(&g_polling_lock);
573 if (!list_empty(&g_timer_list)) {
575 container_of(g_timer_list.next, struct oz_timer, link);
576 if (g_timer_state == OZ_TIMER_SET) {
577 mod_timer(&g_timer, g_cur_timer->due_time);
579 g_timer.expires = g_cur_timer->due_time;
580 g_timer.function = oz_protocol_timer;
584 g_timer_state = OZ_TIMER_SET;
586 oz_trace("No queued timers\n");
588 spin_unlock_bh(&g_polling_lock);
590 /*------------------------------------------------------------------------------
591 * Context: softirq or process
593 void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time,
597 struct oz_timer *t = NULL;
598 int restart_needed = 0;
599 spin_lock(&g_polling_lock);
601 list_for_each(e, &g_timer_list) {
602 t = container_of(e, struct oz_timer, link);
603 if ((t->pd == pd) && (t->type == type)) {
604 if (g_cur_timer == t) {
616 t = container_of(g_timer_pool, struct oz_timer, link);
617 g_timer_pool = g_timer_pool->next;
618 g_timer_pool_count--;
620 t = kmalloc(sizeof(struct oz_timer), GFP_ATOMIC);
630 t->due_time = due_time;
631 list_for_each(e, &g_timer_list) {
632 t2 = container_of(e, struct oz_timer, link);
633 if (time_before(due_time, t2->due_time)) {
634 if (t2 == g_cur_timer) {
641 list_add_tail(&t->link, e);
643 if (g_timer_state == OZ_TIMER_IDLE)
645 else if (g_timer_state == OZ_TIMER_IN_HANDLER)
647 spin_unlock(&g_polling_lock);
649 oz_protocol_timer_start();
651 /*------------------------------------------------------------------------------
652 * Context: softirq or process
654 void oz_timer_delete(struct oz_pd *pd, int type)
656 struct list_head *chain = NULL;
659 int restart_needed = 0;
661 spin_lock(&g_polling_lock);
662 list_for_each_entry_safe(t, n, &g_timer_list, link) {
663 if ((t->pd == pd) && ((type == 0) || (t->type == type))) {
664 if (g_cur_timer == t) {
671 if (g_timer_pool_count < OZ_MAX_TIMER_POOL_SIZE) {
672 t->link.next = g_timer_pool;
673 g_timer_pool = &t->link;
674 g_timer_pool_count++;
676 t->link.next = chain;
683 if (g_timer_state == OZ_TIMER_IN_HANDLER)
685 else if (restart_needed)
686 g_timer_state = OZ_TIMER_IDLE;
687 spin_unlock(&g_polling_lock);
689 oz_protocol_timer_start();
693 t = container_of(chain, struct oz_timer, link);
698 /*------------------------------------------------------------------------------
699 * Context: softirq or process
701 void oz_pd_request_heartbeat(struct oz_pd *pd)
703 unsigned long now = jiffies;
705 spin_lock(&g_polling_lock);
706 if (pd->heartbeat_requested) {
707 spin_unlock(&g_polling_lock);
710 if (pd->pulse_period_j)
711 t = ((now / pd->pulse_period_j) + 1) * pd->pulse_period_j;
714 pd->heartbeat_requested = 1;
715 spin_unlock(&g_polling_lock);
716 oz_timer_add(pd, OZ_TIMER_HEARTBEAT, t, 0);
718 /*------------------------------------------------------------------------------
719 * Context: softirq or process
721 struct oz_pd *oz_pd_find(const u8 *mac_addr)
725 spin_lock_bh(&g_polling_lock);
726 list_for_each(e, &g_pd_list) {
727 pd = container_of(e, struct oz_pd, link);
728 if (memcmp(pd->mac_addr, mac_addr, ETH_ALEN) == 0) {
729 atomic_inc(&pd->ref_count);
730 spin_unlock_bh(&g_polling_lock);
734 spin_unlock_bh(&g_polling_lock);
737 /*------------------------------------------------------------------------------
740 void oz_app_enable(int app_id, int enable)
742 if (app_id <= OZ_APPID_MAX) {
743 spin_lock_bh(&g_polling_lock);
745 g_apps |= (1<<app_id);
747 g_apps &= ~(1<<app_id);
748 spin_unlock_bh(&g_polling_lock);
751 /*------------------------------------------------------------------------------
754 static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev,
755 struct packet_type *pt, struct net_device *orig_dev)
757 skb = skb_share_check(skb, GFP_ATOMIC);
760 spin_lock_bh(&g_rx_queue.lock);
761 if (g_processing_rx) {
762 /* We already hold the lock so use __ variant.
764 __skb_queue_head(&g_rx_queue, skb);
765 spin_unlock_bh(&g_rx_queue.lock);
770 spin_unlock_bh(&g_rx_queue.lock);
772 spin_lock_bh(&g_rx_queue.lock);
773 if (skb_queue_empty(&g_rx_queue)) {
775 spin_unlock_bh(&g_rx_queue.lock);
778 /* We already hold the lock so use __ variant.
780 skb = __skb_dequeue(&g_rx_queue);
785 /*------------------------------------------------------------------------------
788 void oz_binding_add(char *net_dev)
790 struct oz_binding *binding;
792 binding = kmalloc(sizeof(struct oz_binding), GFP_KERNEL);
794 binding->ptype.type = __constant_htons(OZ_ETHERTYPE);
795 binding->ptype.func = oz_pkt_recv;
796 memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN);
797 if (net_dev && *net_dev) {
798 oz_trace("Adding binding: %s\n", net_dev);
800 dev_get_by_name(&init_net, net_dev);
801 if (binding->ptype.dev == NULL) {
802 oz_trace("Netdev %s not found\n", net_dev);
807 oz_trace("Binding to all netcards\n");
808 binding->ptype.dev = NULL;
811 dev_add_pack(&binding->ptype);
812 spin_lock_bh(&g_binding_lock);
813 binding->next = g_binding;
815 spin_unlock_bh(&g_binding_lock);
819 /*------------------------------------------------------------------------------
822 static int compare_binding_name(char *s1, char *s2)
825 for (i = 0; i < OZ_MAX_BINDING_LEN; i++) {
834 /*------------------------------------------------------------------------------
837 static void pd_stop_all_for_device(struct net_device *net_dev)
843 spin_lock_bh(&g_polling_lock);
844 list_for_each_entry_safe(pd, n, &g_pd_list, link) {
845 if (pd->net_dev == net_dev) {
846 list_move(&pd->link, &h);
850 spin_unlock_bh(&g_polling_lock);
851 while (!list_empty(&h)) {
852 pd = list_first_entry(&h, struct oz_pd, link);
857 /*------------------------------------------------------------------------------
860 void oz_binding_remove(char *net_dev)
862 struct oz_binding *binding;
863 struct oz_binding **link;
864 oz_trace("Removing binding: %s\n", net_dev);
865 spin_lock_bh(&g_binding_lock);
869 if (compare_binding_name(binding->name, net_dev)) {
870 oz_trace("Binding '%s' found\n", net_dev);
871 *link = binding->next;
875 binding = binding->next;
878 spin_unlock_bh(&g_binding_lock);
880 dev_remove_pack(&binding->ptype);
881 if (binding->ptype.dev) {
882 dev_put(binding->ptype.dev);
883 pd_stop_all_for_device(binding->ptype.dev);
888 /*------------------------------------------------------------------------------
891 static char *oz_get_next_device_name(char *s, char *dname, int max_size)
895 while (*s && (*s != ',') && max_size > 1) {
902 /*------------------------------------------------------------------------------
905 int oz_protocol_init(char *devs)
907 skb_queue_head_init(&g_rx_queue);
908 if (devs && (devs[0] == '*')) {
909 oz_binding_add(NULL);
913 devs = oz_get_next_device_name(devs, d, sizeof(d));
918 init_timer(&g_timer);
921 /*------------------------------------------------------------------------------
924 int oz_get_pd_list(struct oz_mac_addr *addr, int max_count)
929 spin_lock_bh(&g_polling_lock);
930 list_for_each(e, &g_pd_list) {
931 if (count >= max_count)
933 pd = container_of(e, struct oz_pd, link);
934 memcpy(&addr[count++], pd->mac_addr, ETH_ALEN);
936 spin_unlock_bh(&g_polling_lock);
939 /*------------------------------------------------------------------------------
941 void oz_polling_lock_bh(void)
943 spin_lock_bh(&g_polling_lock);
945 /*------------------------------------------------------------------------------
947 void oz_polling_unlock_bh(void)
949 spin_unlock_bh(&g_polling_lock);