• Home
  • Raw
  • Download

Lines Matching refs:app

239 static struct mrp_attr *mrp_attr_lookup(const struct mrp_applicant *app,  in mrp_attr_lookup()  argument
242 struct rb_node *parent = app->mad.rb_node; in mrp_attr_lookup()
259 static struct mrp_attr *mrp_attr_create(struct mrp_applicant *app, in mrp_attr_create() argument
262 struct rb_node *parent = NULL, **p = &app->mad.rb_node; in mrp_attr_create()
288 rb_insert_color(&attr->node, &app->mad); in mrp_attr_create()
292 static void mrp_attr_destroy(struct mrp_applicant *app, struct mrp_attr *attr) in mrp_attr_destroy() argument
294 rb_erase(&attr->node, &app->mad); in mrp_attr_destroy()
298 static int mrp_pdu_init(struct mrp_applicant *app) in mrp_pdu_init() argument
303 skb = alloc_skb(app->dev->mtu + LL_RESERVED_SPACE(app->dev), in mrp_pdu_init()
308 skb->dev = app->dev; in mrp_pdu_init()
309 skb->protocol = app->app->pkttype.type; in mrp_pdu_init()
310 skb_reserve(skb, LL_RESERVED_SPACE(app->dev)); in mrp_pdu_init()
315 ph->version = app->app->version; in mrp_pdu_init()
317 app->pdu = skb; in mrp_pdu_init()
321 static int mrp_pdu_append_end_mark(struct mrp_applicant *app) in mrp_pdu_append_end_mark() argument
325 if (skb_tailroom(app->pdu) < sizeof(*endmark)) in mrp_pdu_append_end_mark()
327 endmark = (__be16 *)__skb_put(app->pdu, sizeof(*endmark)); in mrp_pdu_append_end_mark()
332 static void mrp_pdu_queue(struct mrp_applicant *app) in mrp_pdu_queue() argument
334 if (!app->pdu) in mrp_pdu_queue()
337 if (mrp_cb(app->pdu)->mh) in mrp_pdu_queue()
338 mrp_pdu_append_end_mark(app); in mrp_pdu_queue()
339 mrp_pdu_append_end_mark(app); in mrp_pdu_queue()
341 dev_hard_header(app->pdu, app->dev, ntohs(app->app->pkttype.type), in mrp_pdu_queue()
342 app->app->group_address, app->dev->dev_addr, in mrp_pdu_queue()
343 app->pdu->len); in mrp_pdu_queue()
345 skb_queue_tail(&app->queue, app->pdu); in mrp_pdu_queue()
346 app->pdu = NULL; in mrp_pdu_queue()
349 static void mrp_queue_xmit(struct mrp_applicant *app) in mrp_queue_xmit() argument
353 while ((skb = skb_dequeue(&app->queue))) in mrp_queue_xmit()
357 static int mrp_pdu_append_msg_hdr(struct mrp_applicant *app, in mrp_pdu_append_msg_hdr() argument
362 if (mrp_cb(app->pdu)->mh) { in mrp_pdu_append_msg_hdr()
363 if (mrp_pdu_append_end_mark(app) < 0) in mrp_pdu_append_msg_hdr()
365 mrp_cb(app->pdu)->mh = NULL; in mrp_pdu_append_msg_hdr()
366 mrp_cb(app->pdu)->vah = NULL; in mrp_pdu_append_msg_hdr()
369 if (skb_tailroom(app->pdu) < sizeof(*mh)) in mrp_pdu_append_msg_hdr()
371 mh = (struct mrp_msg_hdr *)__skb_put(app->pdu, sizeof(*mh)); in mrp_pdu_append_msg_hdr()
374 mrp_cb(app->pdu)->mh = mh; in mrp_pdu_append_msg_hdr()
378 static int mrp_pdu_append_vecattr_hdr(struct mrp_applicant *app, in mrp_pdu_append_vecattr_hdr() argument
383 if (skb_tailroom(app->pdu) < sizeof(*vah) + attrlen) in mrp_pdu_append_vecattr_hdr()
385 vah = (struct mrp_vecattr_hdr *)__skb_put(app->pdu, in mrp_pdu_append_vecattr_hdr()
389 mrp_cb(app->pdu)->vah = vah; in mrp_pdu_append_vecattr_hdr()
390 memcpy(mrp_cb(app->pdu)->attrvalue, firstattrvalue, attrlen); in mrp_pdu_append_vecattr_hdr()
394 static int mrp_pdu_append_vecattr_event(struct mrp_applicant *app, in mrp_pdu_append_vecattr_event() argument
402 if (!app->pdu) { in mrp_pdu_append_vecattr_event()
403 err = mrp_pdu_init(app); in mrp_pdu_append_vecattr_event()
412 if (!mrp_cb(app->pdu)->mh || in mrp_pdu_append_vecattr_event()
413 mrp_cb(app->pdu)->mh->attrtype != attr->type || in mrp_pdu_append_vecattr_event()
414 mrp_cb(app->pdu)->mh->attrlen != attr->len) { in mrp_pdu_append_vecattr_event()
415 if (mrp_pdu_append_msg_hdr(app, attr->type, attr->len) < 0) in mrp_pdu_append_vecattr_event()
423 if (!mrp_cb(app->pdu)->vah || in mrp_pdu_append_vecattr_event()
424 memcmp(mrp_cb(app->pdu)->attrvalue, attr->value, attr->len)) { in mrp_pdu_append_vecattr_event()
425 if (mrp_pdu_append_vecattr_hdr(app, attr->value, attr->len) < 0) in mrp_pdu_append_vecattr_event()
429 len = be16_to_cpu(get_unaligned(&mrp_cb(app->pdu)->vah->lenflags)); in mrp_pdu_append_vecattr_event()
436 if (skb_tailroom(app->pdu) < sizeof(u8)) in mrp_pdu_append_vecattr_event()
438 vaevents = (u8 *)__skb_put(app->pdu, sizeof(u8)); in mrp_pdu_append_vecattr_event()
440 vaevents = (u8 *)(skb_tail_pointer(app->pdu) - sizeof(u8)); in mrp_pdu_append_vecattr_event()
461 put_unaligned(cpu_to_be16(++len), &mrp_cb(app->pdu)->vah->lenflags); in mrp_pdu_append_vecattr_event()
462 mrp_attrvalue_inc(mrp_cb(app->pdu)->attrvalue, attr->len); in mrp_pdu_append_vecattr_event()
467 mrp_pdu_queue(app); in mrp_pdu_append_vecattr_event()
471 static void mrp_attr_event(struct mrp_applicant *app, in mrp_attr_event() argument
494 app, attr, MRP_VECATTR_EVENT_NEW) < 0) in mrp_attr_event()
499 app, attr, MRP_VECATTR_EVENT_JOIN_IN) < 0) in mrp_attr_event()
504 app, attr, MRP_VECATTR_EVENT_LV) < 0) in mrp_attr_event()
510 mrp_attr_destroy(app, attr); in mrp_attr_event()
525 struct mrp_applicant *app = rtnl_dereference( in mrp_request_join() local
533 spin_lock_bh(&app->lock); in mrp_request_join()
534 attr = mrp_attr_create(app, value, len, type); in mrp_request_join()
536 spin_unlock_bh(&app->lock); in mrp_request_join()
539 mrp_attr_event(app, attr, MRP_EVENT_JOIN); in mrp_request_join()
540 spin_unlock_bh(&app->lock); in mrp_request_join()
550 struct mrp_applicant *app = rtnl_dereference( in mrp_request_leave() local
558 spin_lock_bh(&app->lock); in mrp_request_leave()
559 attr = mrp_attr_lookup(app, value, len, type); in mrp_request_leave()
561 spin_unlock_bh(&app->lock); in mrp_request_leave()
564 mrp_attr_event(app, attr, MRP_EVENT_LV); in mrp_request_leave()
565 spin_unlock_bh(&app->lock); in mrp_request_leave()
569 static void mrp_mad_event(struct mrp_applicant *app, enum mrp_event event) in mrp_mad_event() argument
574 for (node = rb_first(&app->mad); in mrp_mad_event()
578 mrp_attr_event(app, attr, event); in mrp_mad_event()
582 static void mrp_join_timer_arm(struct mrp_applicant *app) in mrp_join_timer_arm() argument
587 mod_timer(&app->join_timer, jiffies + delay); in mrp_join_timer_arm()
592 struct mrp_applicant *app = (struct mrp_applicant *)data; in mrp_join_timer() local
594 spin_lock(&app->lock); in mrp_join_timer()
595 mrp_mad_event(app, MRP_EVENT_TX); in mrp_join_timer()
596 mrp_pdu_queue(app); in mrp_join_timer()
597 spin_unlock(&app->lock); in mrp_join_timer()
599 mrp_queue_xmit(app); in mrp_join_timer()
600 mrp_join_timer_arm(app); in mrp_join_timer()
603 static void mrp_periodic_timer_arm(struct mrp_applicant *app) in mrp_periodic_timer_arm() argument
605 mod_timer(&app->periodic_timer, in mrp_periodic_timer_arm()
611 struct mrp_applicant *app = (struct mrp_applicant *)data; in mrp_periodic_timer() local
613 spin_lock(&app->lock); in mrp_periodic_timer()
614 mrp_mad_event(app, MRP_EVENT_PERIODIC); in mrp_periodic_timer()
615 mrp_pdu_queue(app); in mrp_periodic_timer()
616 spin_unlock(&app->lock); in mrp_periodic_timer()
618 mrp_periodic_timer_arm(app); in mrp_periodic_timer()
634 static void mrp_pdu_parse_vecattr_event(struct mrp_applicant *app, in mrp_pdu_parse_vecattr_event() argument
641 attr = mrp_attr_lookup(app, mrp_cb(skb)->attrvalue, in mrp_pdu_parse_vecattr_event()
670 mrp_attr_event(app, attr, event); in mrp_pdu_parse_vecattr_event()
673 static int mrp_pdu_parse_vecattr(struct mrp_applicant *app, in mrp_pdu_parse_vecattr() argument
688 mrp_mad_event(app, MRP_EVENT_R_LA); in mrp_pdu_parse_vecattr()
722 mrp_pdu_parse_vecattr_event(app, skb, vaevent); in mrp_pdu_parse_vecattr()
732 mrp_pdu_parse_vecattr_event(app, skb, vaevent); in mrp_pdu_parse_vecattr()
741 mrp_pdu_parse_vecattr_event(app, skb, vaevent); in mrp_pdu_parse_vecattr()
746 static int mrp_pdu_parse_msg(struct mrp_applicant *app, struct sk_buff *skb, in mrp_pdu_parse_msg() argument
757 mrp_cb(skb)->mh->attrtype > app->app->maxattr || in mrp_pdu_parse_msg()
764 if (mrp_pdu_parse_vecattr(app, skb, offset) < 0) in mrp_pdu_parse_msg()
776 struct mrp_applicant *app; in mrp_rcv() local
792 app = rcu_dereference(port->applicants[appl->type]); in mrp_rcv()
793 if (unlikely(!app)) in mrp_rcv()
801 if (ph->version != app->app->version) in mrp_rcv()
804 spin_lock(&app->lock); in mrp_rcv()
808 if (mrp_pdu_parse_msg(app, skb, &offset) < 0) in mrp_rcv()
811 spin_unlock(&app->lock); in mrp_rcv()
843 struct mrp_applicant *app; in mrp_init_applicant() local
855 app = kzalloc(sizeof(*app), GFP_KERNEL); in mrp_init_applicant()
856 if (!app) in mrp_init_applicant()
863 app->dev = dev; in mrp_init_applicant()
864 app->app = appl; in mrp_init_applicant()
865 app->mad = RB_ROOT; in mrp_init_applicant()
866 spin_lock_init(&app->lock); in mrp_init_applicant()
867 skb_queue_head_init(&app->queue); in mrp_init_applicant()
868 rcu_assign_pointer(dev->mrp_port->applicants[appl->type], app); in mrp_init_applicant()
869 setup_timer(&app->join_timer, mrp_join_timer, (unsigned long)app); in mrp_init_applicant()
870 mrp_join_timer_arm(app); in mrp_init_applicant()
871 setup_timer(&app->periodic_timer, mrp_periodic_timer, in mrp_init_applicant()
872 (unsigned long)app); in mrp_init_applicant()
873 mrp_periodic_timer_arm(app); in mrp_init_applicant()
877 kfree(app); in mrp_init_applicant()
888 struct mrp_applicant *app = rtnl_dereference( in mrp_uninit_applicant() local
898 del_timer_sync(&app->join_timer); in mrp_uninit_applicant()
899 del_timer_sync(&app->periodic_timer); in mrp_uninit_applicant()
901 spin_lock_bh(&app->lock); in mrp_uninit_applicant()
902 mrp_mad_event(app, MRP_EVENT_TX); in mrp_uninit_applicant()
903 mrp_pdu_queue(app); in mrp_uninit_applicant()
904 spin_unlock_bh(&app->lock); in mrp_uninit_applicant()
906 mrp_queue_xmit(app); in mrp_uninit_applicant()
909 kfree_rcu(app, rcu); in mrp_uninit_applicant()