Lines Matching defs:mgr
42 static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)
44 struct l2cap_chan *chan = mgr->a2mp_chan;
66 static u8 __next_ident(struct amp_mgr *mgr)
68 if (++mgr->ident == 0)
69 mgr->ident = 1;
71 return mgr->ident;
76 struct amp_mgr *mgr;
79 list_for_each_entry(mgr, &_mgr_list, list) {
80 if (test_and_clear_bit(state, &mgr->state)) {
81 amp_mgr_get(mgr);
83 return mgr;
92 static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl)
115 static int a2mp_command_rej(struct amp_mgr *mgr, struct sk_buff *skb,
130 static int a2mp_discover_req(struct amp_mgr *mgr, struct sk_buff *skb,
180 __a2mp_add_cl(mgr, rsp->cl);
184 a2mp_send(mgr, A2MP_DISCOVER_RSP, hdr->ident, len, rsp);
190 static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
233 a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr),
243 struct l2cap_conn *conn = mgr->l2cap_conn;
270 static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb,
294 static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
316 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp),
322 set_bit(READ_LOC_AMP_INFO, &mgr->state);
337 static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
352 ctrl = amp_ctrl_add(mgr, rsp->id);
359 a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req),
366 static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb,
395 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp),
401 amp_read_loc_assoc(hdev, mgr);
411 static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
433 ctrl = amp_ctrl_lookup(mgr, rsp->id);
456 hcon = phylink_add(hdev, mgr, rsp->id, true);
462 mgr->bredr_chan->remote_amp_id = rsp->id;
464 amp_create_phylink(hdev, mgr, hcon);
472 static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
497 ctrl = amp_ctrl_lookup(mgr, rsp.remote_id);
499 ctrl = amp_ctrl_add(mgr, rsp.remote_id);
527 hcon = phylink_add(hdev, mgr, req->local_id, false);
529 amp_accept_phylink(hdev, mgr, hcon);
543 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident,
546 set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state);
547 mgr->ident = hdr->ident;
554 static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
580 &mgr->l2cap_conn->hcon->dst);
593 a2mp_send(mgr, A2MP_DISCONNPHYSLINK_RSP, hdr->ident, sizeof(rsp), &rsp);
599 static inline int a2mp_cmd_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
612 struct amp_mgr *mgr = chan->data;
615 amp_mgr_get(mgr);
632 mgr->ident = hdr->ident;
636 a2mp_command_rej(mgr, skb, hdr);
640 err = a2mp_discover_req(mgr, skb, hdr);
644 err = a2mp_change_notify(mgr, skb, hdr);
648 err = a2mp_getinfo_req(mgr, skb, hdr);
652 err = a2mp_getampassoc_req(mgr, skb, hdr);
656 err = a2mp_createphyslink_req(mgr, skb, hdr);
660 err = a2mp_discphyslink_req(mgr, skb, hdr);
664 err = a2mp_discover_rsp(mgr, skb, hdr);
668 err = a2mp_getinfo_rsp(mgr, skb, hdr);
672 err = a2mp_getampassoc_rsp(mgr, skb, hdr);
678 err = a2mp_cmd_rsp(mgr, skb, hdr);
698 a2mp_send(mgr, A2MP_COMMAND_REJ, hdr->ident, sizeof(rej),
706 amp_mgr_put(mgr);
719 struct amp_mgr *mgr = chan->data;
721 if (!mgr)
730 if (mgr)
731 amp_mgr_put(mgr);
819 struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr)
821 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref));
823 kref_get(&mgr->kref);
825 return mgr;
830 struct amp_mgr *mgr = container_of(kref, struct amp_mgr, kref);
832 BT_DBG("mgr %p", mgr);
835 list_del(&mgr->list);
838 amp_ctrl_list_flush(mgr);
839 kfree(mgr);
842 int amp_mgr_put(struct amp_mgr *mgr)
844 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref));
846 return kref_put(&mgr->kref, &_mgr_destroy);
851 struct amp_mgr *mgr;
854 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
855 if (!mgr)
858 BT_DBG("conn %p mgr %p", conn, mgr);
860 mgr->l2cap_conn = conn;
864 kfree(mgr);
868 mgr->a2mp_chan = chan;
869 chan->data = mgr;
871 conn->hcon->amp_mgr = mgr;
873 kref_init(&mgr->kref);
876 INIT_LIST_HEAD(&mgr->amp_ctrls);
877 mutex_init(&mgr->amp_ctrls_lock);
880 list_add(&mgr->list, &_mgr_list);
883 return mgr;
889 struct amp_mgr *mgr;
894 mgr = amp_mgr_create(conn, false);
895 if (!mgr) {
900 BT_DBG("mgr: %p chan %p", mgr, mgr->a2mp_chan);
902 return mgr->a2mp_chan;
907 struct amp_mgr *mgr;
910 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO);
911 if (!mgr)
914 BT_DBG("%s mgr %p", hdev->name, mgr);
930 a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp);
931 amp_mgr_put(mgr);
936 struct amp_mgr *mgr;
941 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC);
942 if (!mgr)
945 BT_DBG("%s mgr %p", hdev->name, mgr);
950 amp_mgr_put(mgr);
963 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, mgr->ident, len, rsp);
964 amp_mgr_put(mgr);
970 struct amp_mgr *mgr;
976 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC_FINAL);
977 if (!mgr)
982 BT_DBG("%s mgr %p assoc_len %zu", hdev->name, mgr, len);
986 amp_mgr_put(mgr);
990 bredr_chan = mgr->bredr_chan;
998 a2mp_send(mgr, A2MP_CREATEPHYSLINK_REQ, __next_ident(mgr), len, req);
1001 amp_mgr_put(mgr);
1007 struct amp_mgr *mgr;
1011 mgr = amp_mgr_lookup_by_state(WRITE_REMOTE_AMP_ASSOC);
1012 if (!mgr)
1025 BT_DBG("%s mgr %p hs_hcon %p status %u", hdev->name, mgr, hs_hcon,
1029 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, mgr->ident, sizeof(rsp), &rsp);
1030 amp_mgr_put(mgr);
1036 struct amp_mgr *mgr = conn->hcon->amp_mgr;
1039 BT_DBG("chan %p conn %p mgr %p", chan, conn, mgr);
1041 if (!mgr) {
1042 mgr = amp_mgr_create(conn, true);
1043 if (!mgr)
1047 mgr->bredr_chan = chan;
1053 a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req);