Lines Matching refs:mgr
42 static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) in a2mp_send() argument
44 struct l2cap_chan *chan = mgr->a2mp_chan; in a2mp_send()
66 static u8 __next_ident(struct amp_mgr *mgr) in __next_ident() argument
68 if (++mgr->ident == 0) in __next_ident()
69 mgr->ident = 1; in __next_ident()
71 return mgr->ident; in __next_ident()
76 struct amp_mgr *mgr; in amp_mgr_lookup_by_state() local
79 list_for_each_entry(mgr, &_mgr_list, list) { in amp_mgr_lookup_by_state()
80 if (test_and_clear_bit(state, &mgr->state)) { in amp_mgr_lookup_by_state()
81 amp_mgr_get(mgr); in amp_mgr_lookup_by_state()
83 return mgr; in amp_mgr_lookup_by_state()
92 static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl) in __a2mp_add_cl() argument
115 static int a2mp_command_rej(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_command_rej() argument
130 static int a2mp_discover_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_req() argument
180 __a2mp_add_cl(mgr, rsp->cl); in a2mp_discover_req()
184 a2mp_send(mgr, A2MP_DISCOVER_RSP, hdr->ident, len, rsp); in a2mp_discover_req()
190 static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_rsp() argument
230 a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr), in a2mp_discover_rsp()
240 struct l2cap_conn *conn = mgr->l2cap_conn; in a2mp_discover_rsp()
267 static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_change_notify() argument
291 static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_req() argument
311 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), in a2mp_getinfo_req()
317 set_bit(READ_LOC_AMP_INFO, &mgr->state); in a2mp_getinfo_req()
332 static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_rsp() argument
347 ctrl = amp_ctrl_add(mgr, rsp->id); in a2mp_getinfo_rsp()
352 a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req), in a2mp_getinfo_rsp()
359 static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_req() argument
386 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp), in a2mp_getampassoc_req()
392 amp_read_loc_assoc(hdev, mgr); in a2mp_getampassoc_req()
402 static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_rsp() argument
424 ctrl = amp_ctrl_lookup(mgr, rsp->id); in a2mp_getampassoc_rsp()
447 hcon = phylink_add(hdev, mgr, rsp->id, true); in a2mp_getampassoc_rsp()
453 mgr->bredr_chan->remote_amp_id = rsp->id; in a2mp_getampassoc_rsp()
455 amp_create_phylink(hdev, mgr, hcon); in a2mp_getampassoc_rsp()
463 static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_createphyslink_req() argument
487 ctrl = amp_ctrl_lookup(mgr, rsp.remote_id); in a2mp_createphyslink_req()
489 ctrl = amp_ctrl_add(mgr, rsp.remote_id); in a2mp_createphyslink_req()
516 hcon = phylink_add(hdev, mgr, req->local_id, false); in a2mp_createphyslink_req()
518 amp_accept_phylink(hdev, mgr, hcon); in a2mp_createphyslink_req()
532 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident, in a2mp_createphyslink_req()
535 set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state); in a2mp_createphyslink_req()
536 mgr->ident = hdr->ident; in a2mp_createphyslink_req()
543 static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discphyslink_req() argument
567 &mgr->l2cap_conn->hcon->dst); in a2mp_discphyslink_req()
580 a2mp_send(mgr, A2MP_DISCONNPHYSLINK_RSP, hdr->ident, sizeof(rsp), &rsp); in a2mp_discphyslink_req()
586 static inline int a2mp_cmd_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_cmd_rsp() argument
599 struct amp_mgr *mgr = chan->data; in a2mp_chan_recv_cb() local
602 amp_mgr_get(mgr); in a2mp_chan_recv_cb()
619 mgr->ident = hdr->ident; in a2mp_chan_recv_cb()
623 a2mp_command_rej(mgr, skb, hdr); in a2mp_chan_recv_cb()
627 err = a2mp_discover_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
631 err = a2mp_change_notify(mgr, skb, hdr); in a2mp_chan_recv_cb()
635 err = a2mp_getinfo_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
639 err = a2mp_getampassoc_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
643 err = a2mp_createphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
647 err = a2mp_discphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
651 err = a2mp_discover_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
655 err = a2mp_getinfo_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
659 err = a2mp_getampassoc_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
665 err = a2mp_cmd_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
683 a2mp_send(mgr, A2MP_COMMAND_REJ, hdr->ident, sizeof(rej), in a2mp_chan_recv_cb()
691 amp_mgr_put(mgr); in a2mp_chan_recv_cb()
704 struct amp_mgr *mgr = chan->data; in a2mp_chan_state_change_cb() local
706 if (!mgr) in a2mp_chan_state_change_cb()
715 if (mgr) in a2mp_chan_state_change_cb()
716 amp_mgr_put(mgr); in a2mp_chan_state_change_cb()
804 struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr) in amp_mgr_get() argument
806 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref)); in amp_mgr_get()
808 kref_get(&mgr->kref); in amp_mgr_get()
810 return mgr; in amp_mgr_get()
815 struct amp_mgr *mgr = container_of(kref, struct amp_mgr, kref); in amp_mgr_destroy() local
817 BT_DBG("mgr %p", mgr); in amp_mgr_destroy()
820 list_del(&mgr->list); in amp_mgr_destroy()
823 amp_ctrl_list_flush(mgr); in amp_mgr_destroy()
824 kfree(mgr); in amp_mgr_destroy()
827 int amp_mgr_put(struct amp_mgr *mgr) in amp_mgr_put() argument
829 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref)); in amp_mgr_put()
831 return kref_put(&mgr->kref, &_mgr_destroy); in amp_mgr_put()
836 struct amp_mgr *mgr; in amp_mgr_create() local
839 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in amp_mgr_create()
840 if (!mgr) in amp_mgr_create()
843 BT_DBG("conn %p mgr %p", conn, mgr); in amp_mgr_create()
845 mgr->l2cap_conn = conn; in amp_mgr_create()
849 kfree(mgr); in amp_mgr_create()
853 mgr->a2mp_chan = chan; in amp_mgr_create()
854 chan->data = mgr; in amp_mgr_create()
856 conn->hcon->amp_mgr = mgr; in amp_mgr_create()
858 kref_init(&mgr->kref); in amp_mgr_create()
861 INIT_LIST_HEAD(&mgr->amp_ctrls); in amp_mgr_create()
862 mutex_init(&mgr->amp_ctrls_lock); in amp_mgr_create()
865 list_add(&mgr->list, &_mgr_list); in amp_mgr_create()
868 return mgr; in amp_mgr_create()
874 struct amp_mgr *mgr; in a2mp_channel_create() local
879 mgr = amp_mgr_create(conn, false); in a2mp_channel_create()
880 if (!mgr) { in a2mp_channel_create()
885 BT_DBG("mgr: %p chan %p", mgr, mgr->a2mp_chan); in a2mp_channel_create()
887 return mgr->a2mp_chan; in a2mp_channel_create()
892 struct amp_mgr *mgr; in a2mp_send_getinfo_rsp() local
895 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO); in a2mp_send_getinfo_rsp()
896 if (!mgr) in a2mp_send_getinfo_rsp()
899 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getinfo_rsp()
913 a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_getinfo_rsp()
914 amp_mgr_put(mgr); in a2mp_send_getinfo_rsp()
919 struct amp_mgr *mgr; in a2mp_send_getampassoc_rsp() local
924 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC); in a2mp_send_getampassoc_rsp()
925 if (!mgr) in a2mp_send_getampassoc_rsp()
928 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getampassoc_rsp()
933 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
946 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, mgr->ident, len, rsp); in a2mp_send_getampassoc_rsp()
947 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
953 struct amp_mgr *mgr; in a2mp_send_create_phy_link_req() local
959 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC_FINAL); in a2mp_send_create_phy_link_req()
960 if (!mgr) in a2mp_send_create_phy_link_req()
965 BT_DBG("%s mgr %p assoc_len %zu", hdev->name, mgr, len); in a2mp_send_create_phy_link_req()
969 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
973 bredr_chan = mgr->bredr_chan; in a2mp_send_create_phy_link_req()
981 a2mp_send(mgr, A2MP_CREATEPHYSLINK_REQ, __next_ident(mgr), len, req); in a2mp_send_create_phy_link_req()
984 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
990 struct amp_mgr *mgr; in a2mp_send_create_phy_link_rsp() local
994 mgr = amp_mgr_lookup_by_state(WRITE_REMOTE_AMP_ASSOC); in a2mp_send_create_phy_link_rsp()
995 if (!mgr) in a2mp_send_create_phy_link_rsp()
1006 BT_DBG("%s mgr %p hs_hcon %p status %u", hdev->name, mgr, hs_hcon, in a2mp_send_create_phy_link_rsp()
1010 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_create_phy_link_rsp()
1011 amp_mgr_put(mgr); in a2mp_send_create_phy_link_rsp()
1017 struct amp_mgr *mgr = conn->hcon->amp_mgr; in a2mp_discover_amp() local
1020 BT_DBG("chan %p conn %p mgr %p", chan, conn, mgr); in a2mp_discover_amp()
1022 if (!mgr) { in a2mp_discover_amp()
1023 mgr = amp_mgr_create(conn, true); in a2mp_discover_amp()
1024 if (!mgr) in a2mp_discover_amp()
1028 mgr->bredr_chan = chan; in a2mp_discover_amp()
1032 a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req); in a2mp_discover_amp()