Lines Matching refs:mgr
48 static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) in a2mp_send() argument
50 struct l2cap_chan *chan = mgr->a2mp_chan; in a2mp_send()
72 static u8 __next_ident(struct amp_mgr *mgr) in __next_ident() argument
74 if (++mgr->ident == 0) in __next_ident()
75 mgr->ident = 1; in __next_ident()
77 return mgr->ident; in __next_ident()
82 struct amp_mgr *mgr; in amp_mgr_lookup_by_state() local
85 list_for_each_entry(mgr, &_mgr_list, list) { in amp_mgr_lookup_by_state()
86 if (test_and_clear_bit(state, &mgr->state)) { in amp_mgr_lookup_by_state()
87 amp_mgr_get(mgr); in amp_mgr_lookup_by_state()
89 return mgr; in amp_mgr_lookup_by_state()
98 static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl) in __a2mp_add_cl() argument
121 static int a2mp_command_rej(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_command_rej() argument
136 static int a2mp_discover_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_req() argument
186 __a2mp_add_cl(mgr, rsp->cl); in a2mp_discover_req()
190 a2mp_send(mgr, A2MP_DISCOVER_RSP, hdr->ident, len, rsp); in a2mp_discover_req()
196 static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_rsp() argument
236 a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr), in a2mp_discover_rsp()
246 struct l2cap_conn *conn = mgr->l2cap_conn; in a2mp_discover_rsp()
273 static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_change_notify() argument
289 static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_req() argument
307 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), in a2mp_getinfo_req()
313 set_bit(READ_LOC_AMP_INFO, &mgr->state); in a2mp_getinfo_req()
324 static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_rsp() argument
339 ctrl = amp_ctrl_add(mgr, rsp->id); in a2mp_getinfo_rsp()
344 a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req), in a2mp_getinfo_rsp()
351 static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_req() argument
378 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp), in a2mp_getampassoc_req()
384 amp_read_loc_assoc(hdev, mgr); in a2mp_getampassoc_req()
394 static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_rsp() argument
416 ctrl = amp_ctrl_lookup(mgr, rsp->id); in a2mp_getampassoc_rsp()
439 hcon = phylink_add(hdev, mgr, rsp->id, true); in a2mp_getampassoc_rsp()
445 mgr->bredr_chan->remote_amp_id = rsp->id; in a2mp_getampassoc_rsp()
447 amp_create_phylink(hdev, mgr, hcon); in a2mp_getampassoc_rsp()
455 static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_createphyslink_req() argument
479 ctrl = amp_ctrl_lookup(mgr, rsp.remote_id); in a2mp_createphyslink_req()
481 ctrl = amp_ctrl_add(mgr, rsp.remote_id); in a2mp_createphyslink_req()
508 hcon = phylink_add(hdev, mgr, req->local_id, false); in a2mp_createphyslink_req()
510 amp_accept_phylink(hdev, mgr, hcon); in a2mp_createphyslink_req()
524 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident, in a2mp_createphyslink_req()
527 set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state); in a2mp_createphyslink_req()
528 mgr->ident = hdr->ident; in a2mp_createphyslink_req()
535 static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discphyslink_req() argument
559 &mgr->l2cap_conn->hcon->dst); in a2mp_discphyslink_req()
572 a2mp_send(mgr, A2MP_DISCONNPHYSLINK_RSP, hdr->ident, sizeof(rsp), &rsp); in a2mp_discphyslink_req()
578 static inline int a2mp_cmd_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_cmd_rsp() argument
591 struct amp_mgr *mgr = chan->data; in a2mp_chan_recv_cb() local
594 amp_mgr_get(mgr); in a2mp_chan_recv_cb()
611 mgr->ident = hdr->ident; in a2mp_chan_recv_cb()
615 a2mp_command_rej(mgr, skb, hdr); in a2mp_chan_recv_cb()
619 err = a2mp_discover_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
623 err = a2mp_change_notify(mgr, skb, hdr); in a2mp_chan_recv_cb()
627 err = a2mp_getinfo_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
631 err = a2mp_getampassoc_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
635 err = a2mp_createphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
639 err = a2mp_discphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
643 err = a2mp_discover_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
647 err = a2mp_getinfo_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
651 err = a2mp_getampassoc_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
657 err = a2mp_cmd_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
675 a2mp_send(mgr, A2MP_COMMAND_REJ, hdr->ident, sizeof(rej), in a2mp_chan_recv_cb()
683 amp_mgr_put(mgr); in a2mp_chan_recv_cb()
696 struct amp_mgr *mgr = chan->data; in a2mp_chan_state_change_cb() local
698 if (!mgr) in a2mp_chan_state_change_cb()
707 if (mgr) in a2mp_chan_state_change_cb()
708 amp_mgr_put(mgr); in a2mp_chan_state_change_cb()
796 struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr) in amp_mgr_get() argument
798 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); in amp_mgr_get()
800 kref_get(&mgr->kref); in amp_mgr_get()
802 return mgr; in amp_mgr_get()
807 struct amp_mgr *mgr = container_of(kref, struct amp_mgr, kref); in amp_mgr_destroy() local
809 BT_DBG("mgr %p", mgr); in amp_mgr_destroy()
812 list_del(&mgr->list); in amp_mgr_destroy()
815 amp_ctrl_list_flush(mgr); in amp_mgr_destroy()
816 kfree(mgr); in amp_mgr_destroy()
819 int amp_mgr_put(struct amp_mgr *mgr) in amp_mgr_put() argument
821 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); in amp_mgr_put()
823 return kref_put(&mgr->kref, &_mgr_destroy); in amp_mgr_put()
828 struct amp_mgr *mgr; in amp_mgr_create() local
831 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in amp_mgr_create()
832 if (!mgr) in amp_mgr_create()
835 BT_DBG("conn %p mgr %p", conn, mgr); in amp_mgr_create()
837 mgr->l2cap_conn = conn; in amp_mgr_create()
841 kfree(mgr); in amp_mgr_create()
845 mgr->a2mp_chan = chan; in amp_mgr_create()
846 chan->data = mgr; in amp_mgr_create()
848 conn->hcon->amp_mgr = mgr; in amp_mgr_create()
850 kref_init(&mgr->kref); in amp_mgr_create()
853 INIT_LIST_HEAD(&mgr->amp_ctrls); in amp_mgr_create()
854 mutex_init(&mgr->amp_ctrls_lock); in amp_mgr_create()
857 list_add(&mgr->list, &_mgr_list); in amp_mgr_create()
860 return mgr; in amp_mgr_create()
866 struct amp_mgr *mgr; in a2mp_channel_create() local
871 mgr = amp_mgr_create(conn, false); in a2mp_channel_create()
872 if (!mgr) { in a2mp_channel_create()
877 BT_DBG("mgr: %p chan %p", mgr, mgr->a2mp_chan); in a2mp_channel_create()
879 return mgr->a2mp_chan; in a2mp_channel_create()
884 struct amp_mgr *mgr; in a2mp_send_getinfo_rsp() local
887 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO); in a2mp_send_getinfo_rsp()
888 if (!mgr) in a2mp_send_getinfo_rsp()
891 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getinfo_rsp()
905 a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_getinfo_rsp()
906 amp_mgr_put(mgr); in a2mp_send_getinfo_rsp()
911 struct amp_mgr *mgr; in a2mp_send_getampassoc_rsp() local
916 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC); in a2mp_send_getampassoc_rsp()
917 if (!mgr) in a2mp_send_getampassoc_rsp()
920 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getampassoc_rsp()
925 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
938 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, mgr->ident, len, rsp); in a2mp_send_getampassoc_rsp()
939 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
945 struct amp_mgr *mgr; in a2mp_send_create_phy_link_req() local
951 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC_FINAL); in a2mp_send_create_phy_link_req()
952 if (!mgr) in a2mp_send_create_phy_link_req()
957 BT_DBG("%s mgr %p assoc_len %zu", hdev->name, mgr, len); in a2mp_send_create_phy_link_req()
961 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
965 bredr_chan = mgr->bredr_chan; in a2mp_send_create_phy_link_req()
973 a2mp_send(mgr, A2MP_CREATEPHYSLINK_REQ, __next_ident(mgr), len, req); in a2mp_send_create_phy_link_req()
976 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
982 struct amp_mgr *mgr; in a2mp_send_create_phy_link_rsp() local
986 mgr = amp_mgr_lookup_by_state(WRITE_REMOTE_AMP_ASSOC); in a2mp_send_create_phy_link_rsp()
987 if (!mgr) in a2mp_send_create_phy_link_rsp()
998 BT_DBG("%s mgr %p hs_hcon %p status %u", hdev->name, mgr, hs_hcon, in a2mp_send_create_phy_link_rsp()
1002 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_create_phy_link_rsp()
1003 amp_mgr_put(mgr); in a2mp_send_create_phy_link_rsp()
1009 struct amp_mgr *mgr = conn->hcon->amp_mgr; in a2mp_discover_amp() local
1012 BT_DBG("chan %p conn %p mgr %p", chan, conn, mgr); in a2mp_discover_amp()
1014 if (!mgr) { in a2mp_discover_amp()
1015 mgr = amp_mgr_create(conn, true); in a2mp_discover_amp()
1016 if (!mgr) in a2mp_discover_amp()
1020 mgr->bredr_chan = chan; in a2mp_discover_amp()
1024 a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req); in a2mp_discover_amp()