Lines Matching refs:mgr

49 static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)  in a2mp_send()  argument
51 struct l2cap_chan *chan = mgr->a2mp_chan; in a2mp_send()
73 static u8 __next_ident(struct amp_mgr *mgr) in __next_ident() argument
75 if (++mgr->ident == 0) in __next_ident()
76 mgr->ident = 1; in __next_ident()
78 return mgr->ident; in __next_ident()
83 struct amp_mgr *mgr; in amp_mgr_lookup_by_state() local
86 list_for_each_entry(mgr, &amp_mgr_list, list) { in amp_mgr_lookup_by_state()
87 if (test_and_clear_bit(state, &mgr->state)) { in amp_mgr_lookup_by_state()
88 amp_mgr_get(mgr); in amp_mgr_lookup_by_state()
90 return mgr; in amp_mgr_lookup_by_state()
99 static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl) in __a2mp_add_cl() argument
122 static int a2mp_command_rej(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_command_rej() argument
137 static int a2mp_discover_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_req() argument
187 __a2mp_add_cl(mgr, rsp->cl); in a2mp_discover_req()
191 a2mp_send(mgr, A2MP_DISCOVER_RSP, hdr->ident, len, rsp); in a2mp_discover_req()
197 static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_rsp() argument
237 a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr), in a2mp_discover_rsp()
247 struct l2cap_conn *conn = mgr->l2cap_conn; in a2mp_discover_rsp()
274 static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_change_notify() argument
298 static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_req() argument
318 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), in a2mp_getinfo_req()
324 set_bit(READ_LOC_AMP_INFO, &mgr->state); in a2mp_getinfo_req()
339 static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_rsp() argument
354 ctrl = amp_ctrl_add(mgr, rsp->id); in a2mp_getinfo_rsp()
359 a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req), in a2mp_getinfo_rsp()
366 static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_req() argument
393 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp), in a2mp_getampassoc_req()
399 amp_read_loc_assoc(hdev, mgr); in a2mp_getampassoc_req()
409 static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_rsp() argument
431 ctrl = amp_ctrl_lookup(mgr, rsp->id); in a2mp_getampassoc_rsp()
454 hcon = phylink_add(hdev, mgr, rsp->id, true); in a2mp_getampassoc_rsp()
460 mgr->bredr_chan->remote_amp_id = rsp->id; in a2mp_getampassoc_rsp()
462 amp_create_phylink(hdev, mgr, hcon); in a2mp_getampassoc_rsp()
470 static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_createphyslink_req() argument
494 ctrl = amp_ctrl_lookup(mgr, rsp.remote_id); in a2mp_createphyslink_req()
496 ctrl = amp_ctrl_add(mgr, rsp.remote_id); in a2mp_createphyslink_req()
523 hcon = phylink_add(hdev, mgr, req->local_id, false); in a2mp_createphyslink_req()
525 amp_accept_phylink(hdev, mgr, hcon); in a2mp_createphyslink_req()
539 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident, in a2mp_createphyslink_req()
542 set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state); in a2mp_createphyslink_req()
543 mgr->ident = hdr->ident; in a2mp_createphyslink_req()
550 static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discphyslink_req() argument
574 &mgr->l2cap_conn->hcon->dst); in a2mp_discphyslink_req()
587 a2mp_send(mgr, A2MP_DISCONNPHYSLINK_RSP, hdr->ident, sizeof(rsp), &rsp); in a2mp_discphyslink_req()
593 static inline int a2mp_cmd_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_cmd_rsp() argument
606 struct amp_mgr *mgr = chan->data; in a2mp_chan_recv_cb() local
609 amp_mgr_get(mgr); in a2mp_chan_recv_cb()
626 mgr->ident = hdr->ident; in a2mp_chan_recv_cb()
630 a2mp_command_rej(mgr, skb, hdr); in a2mp_chan_recv_cb()
634 err = a2mp_discover_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
638 err = a2mp_change_notify(mgr, skb, hdr); in a2mp_chan_recv_cb()
642 err = a2mp_getinfo_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
646 err = a2mp_getampassoc_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
650 err = a2mp_createphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
654 err = a2mp_discphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
658 err = a2mp_discover_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
662 err = a2mp_getinfo_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
666 err = a2mp_getampassoc_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
672 err = a2mp_cmd_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
690 a2mp_send(mgr, A2MP_COMMAND_REJ, hdr->ident, sizeof(rej), in a2mp_chan_recv_cb()
698 amp_mgr_put(mgr); in a2mp_chan_recv_cb()
711 struct amp_mgr *mgr = chan->data; in a2mp_chan_state_change_cb() local
713 if (!mgr) in a2mp_chan_state_change_cb()
722 if (mgr) in a2mp_chan_state_change_cb()
723 amp_mgr_put(mgr); in a2mp_chan_state_change_cb()
811 struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr) in amp_mgr_get() argument
813 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); in amp_mgr_get()
815 kref_get(&mgr->kref); in amp_mgr_get()
817 return mgr; in amp_mgr_get()
822 struct amp_mgr *mgr = container_of(kref, struct amp_mgr, kref); in amp_mgr_destroy() local
824 BT_DBG("mgr %p", mgr); in amp_mgr_destroy()
827 list_del(&mgr->list); in amp_mgr_destroy()
830 amp_ctrl_list_flush(mgr); in amp_mgr_destroy()
831 kfree(mgr); in amp_mgr_destroy()
834 int amp_mgr_put(struct amp_mgr *mgr) in amp_mgr_put() argument
836 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); in amp_mgr_put()
838 return kref_put(&mgr->kref, &amp_mgr_destroy); in amp_mgr_put()
843 struct amp_mgr *mgr; in amp_mgr_create() local
846 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in amp_mgr_create()
847 if (!mgr) in amp_mgr_create()
850 BT_DBG("conn %p mgr %p", conn, mgr); in amp_mgr_create()
852 mgr->l2cap_conn = conn; in amp_mgr_create()
856 kfree(mgr); in amp_mgr_create()
860 mgr->a2mp_chan = chan; in amp_mgr_create()
861 chan->data = mgr; in amp_mgr_create()
863 conn->hcon->amp_mgr = mgr; in amp_mgr_create()
865 kref_init(&mgr->kref); in amp_mgr_create()
868 INIT_LIST_HEAD(&mgr->amp_ctrls); in amp_mgr_create()
869 mutex_init(&mgr->amp_ctrls_lock); in amp_mgr_create()
872 list_add(&mgr->list, &amp_mgr_list); in amp_mgr_create()
875 return mgr; in amp_mgr_create()
881 struct amp_mgr *mgr; in a2mp_channel_create() local
886 mgr = amp_mgr_create(conn, false); in a2mp_channel_create()
887 if (!mgr) { in a2mp_channel_create()
892 BT_DBG("mgr: %p chan %p", mgr, mgr->a2mp_chan); in a2mp_channel_create()
894 return mgr->a2mp_chan; in a2mp_channel_create()
899 struct amp_mgr *mgr; in a2mp_send_getinfo_rsp() local
902 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO); in a2mp_send_getinfo_rsp()
903 if (!mgr) in a2mp_send_getinfo_rsp()
906 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getinfo_rsp()
920 a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_getinfo_rsp()
921 amp_mgr_put(mgr); in a2mp_send_getinfo_rsp()
926 struct amp_mgr *mgr; in a2mp_send_getampassoc_rsp() local
931 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC); in a2mp_send_getampassoc_rsp()
932 if (!mgr) in a2mp_send_getampassoc_rsp()
935 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getampassoc_rsp()
940 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
953 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, mgr->ident, len, rsp); in a2mp_send_getampassoc_rsp()
954 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
960 struct amp_mgr *mgr; in a2mp_send_create_phy_link_req() local
966 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC_FINAL); in a2mp_send_create_phy_link_req()
967 if (!mgr) in a2mp_send_create_phy_link_req()
972 BT_DBG("%s mgr %p assoc_len %zu", hdev->name, mgr, len); in a2mp_send_create_phy_link_req()
976 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
980 bredr_chan = mgr->bredr_chan; in a2mp_send_create_phy_link_req()
988 a2mp_send(mgr, A2MP_CREATEPHYSLINK_REQ, __next_ident(mgr), len, req); in a2mp_send_create_phy_link_req()
991 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
997 struct amp_mgr *mgr; in a2mp_send_create_phy_link_rsp() local
1001 mgr = amp_mgr_lookup_by_state(WRITE_REMOTE_AMP_ASSOC); in a2mp_send_create_phy_link_rsp()
1002 if (!mgr) in a2mp_send_create_phy_link_rsp()
1013 BT_DBG("%s mgr %p hs_hcon %p status %u", hdev->name, mgr, hs_hcon, in a2mp_send_create_phy_link_rsp()
1017 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_create_phy_link_rsp()
1018 amp_mgr_put(mgr); in a2mp_send_create_phy_link_rsp()
1024 struct amp_mgr *mgr = conn->hcon->amp_mgr; in a2mp_discover_amp() local
1027 BT_DBG("chan %p conn %p mgr %p", chan, conn, mgr); in a2mp_discover_amp()
1029 if (!mgr) { in a2mp_discover_amp()
1030 mgr = amp_mgr_create(conn, true); in a2mp_discover_amp()
1031 if (!mgr) in a2mp_discover_amp()
1035 mgr->bredr_chan = chan; in a2mp_discover_amp()
1039 a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req); in a2mp_discover_amp()