Lines Matching full:ndev
122 static void nci_hci_reset_pipes_per_host(struct nci_dev *ndev, u8 host) in nci_hci_reset_pipes_per_host() argument
127 if (ndev->hci_dev->pipes[i].host == host) { in nci_hci_reset_pipes_per_host()
128 ndev->hci_dev->pipes[i].gate = NCI_HCI_INVALID_GATE; in nci_hci_reset_pipes_per_host()
129 ndev->hci_dev->pipes[i].host = NCI_HCI_INVALID_HOST; in nci_hci_reset_pipes_per_host()
142 static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe, in nci_hci_send_data() argument
151 conn_info = ndev->hci_dev->conn_info; in nci_hci_send_data()
156 skb = nci_skb_alloc(ndev, conn_info->max_pkt_payload_len + in nci_hci_send_data()
179 r = nci_send_data(ndev, conn_info->conn_id, skb); in nci_hci_send_data()
186 skb = nci_skb_alloc(ndev, in nci_hci_send_data()
199 static void nci_hci_send_data_req(struct nci_dev *ndev, const void *opt) in nci_hci_send_data_req() argument
203 nci_hci_send_data(ndev, data->pipe, data->cmd, in nci_hci_send_data_req()
207 int nci_hci_send_event(struct nci_dev *ndev, u8 gate, u8 event, in nci_hci_send_event() argument
210 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_send_event()
215 return nci_hci_send_data(ndev, pipe, in nci_hci_send_event()
221 int nci_hci_send_cmd(struct nci_dev *ndev, u8 gate, u8 cmd, in nci_hci_send_cmd() argument
229 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_send_cmd()
234 conn_info = ndev->hci_dev->conn_info; in nci_hci_send_cmd()
244 r = nci_request(ndev, nci_hci_send_data_req, &data, in nci_hci_send_cmd()
260 int nci_hci_clear_all_pipes(struct nci_dev *ndev) in nci_hci_clear_all_pipes() argument
264 r = nci_hci_send_cmd(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_clear_all_pipes()
269 nci_hci_reset_pipes(ndev->hci_dev); in nci_hci_clear_all_pipes()
274 static void nci_hci_event_received(struct nci_dev *ndev, u8 pipe, in nci_hci_event_received() argument
277 if (ndev->ops->hci_event_received) in nci_hci_event_received()
278 ndev->ops->hci_event_received(ndev, pipe, event, skb); in nci_hci_event_received()
281 static void nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe, in nci_hci_cmd_received() argument
284 u8 gate = ndev->hci_dev->pipes[pipe].gate; in nci_hci_cmd_received()
312 ndev->hci_dev->gate2pipe[dest_gate] = new_pipe; in nci_hci_cmd_received()
313 ndev->hci_dev->pipes[new_pipe].gate = dest_gate; in nci_hci_cmd_received()
314 ndev->hci_dev->pipes[new_pipe].host = in nci_hci_cmd_received()
335 ndev->hci_dev->pipes[delete_info->pipe].gate = in nci_hci_cmd_received()
337 ndev->hci_dev->pipes[delete_info->pipe].host = in nci_hci_cmd_received()
348 nci_hci_reset_pipes_per_host(ndev, cleared_info->host); in nci_hci_cmd_received()
355 if (ndev->ops->hci_cmd_received) in nci_hci_cmd_received()
356 ndev->ops->hci_cmd_received(ndev, pipe, cmd, skb); in nci_hci_cmd_received()
359 nci_hci_send_data(ndev, pipe, status, NULL, 0); in nci_hci_cmd_received()
364 static void nci_hci_resp_received(struct nci_dev *ndev, u8 pipe, in nci_hci_resp_received() argument
369 conn_info = ndev->hci_dev->conn_info; in nci_hci_resp_received()
376 nci_req_complete(ndev, NCI_STATUS_OK); in nci_hci_resp_received()
382 static void nci_hci_hcp_message_rx(struct nci_dev *ndev, u8 pipe, in nci_hci_hcp_message_rx() argument
387 nci_hci_resp_received(ndev, pipe, skb); in nci_hci_hcp_message_rx()
390 nci_hci_cmd_received(ndev, pipe, instruction, skb); in nci_hci_hcp_message_rx()
393 nci_hci_event_received(ndev, pipe, instruction, skb); in nci_hci_hcp_message_rx()
402 nci_req_complete(ndev, NCI_STATUS_OK); in nci_hci_hcp_message_rx()
422 nci_hci_hcp_message_rx(hdev->ndev, pipe, in nci_hci_msg_rx_work()
430 struct nci_dev *ndev = (struct nci_dev *)context; in nci_hci_data_received_cb() local
438 nci_req_complete(ndev, err); in nci_hci_data_received_cb()
444 skb_queue_tail(&ndev->hci_dev->rx_hcp_frags, skb); in nci_hci_data_received_cb()
449 if (skb_queue_len(&ndev->hci_dev->rx_hcp_frags)) { in nci_hci_data_received_cb()
451 skb_queue_tail(&ndev->hci_dev->rx_hcp_frags, skb); in nci_hci_data_received_cb()
454 skb_queue_walk(&ndev->hci_dev->rx_hcp_frags, frag_skb) { in nci_hci_data_received_cb()
462 nci_req_complete(ndev, -ENOMEM); in nci_hci_data_received_cb()
468 skb_queue_walk(&ndev->hci_dev->rx_hcp_frags, frag_skb) { in nci_hci_data_received_cb()
475 skb_queue_purge(&ndev->hci_dev->rx_hcp_frags); in nci_hci_data_received_cb()
490 nci_hci_hcp_message_rx(ndev, pipe, type, in nci_hci_data_received_cb()
493 skb_queue_tail(&ndev->hci_dev->msg_rx_queue, hcp_skb); in nci_hci_data_received_cb()
494 schedule_work(&ndev->hci_dev->msg_rx_work); in nci_hci_data_received_cb()
498 int nci_hci_open_pipe(struct nci_dev *ndev, u8 pipe) in nci_hci_open_pipe() argument
503 conn_info = ndev->hci_dev->conn_info; in nci_hci_open_pipe()
514 return nci_request(ndev, nci_hci_send_data_req, &data, in nci_hci_open_pipe()
519 static u8 nci_hci_create_pipe(struct nci_dev *ndev, u8 dest_host, in nci_hci_create_pipe() argument
533 *result = nci_hci_send_cmd(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_create_pipe()
548 static int nci_hci_delete_pipe(struct nci_dev *ndev, u8 pipe) in nci_hci_delete_pipe() argument
550 return nci_hci_send_cmd(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_delete_pipe()
554 int nci_hci_set_param(struct nci_dev *ndev, u8 gate, u8 idx, in nci_hci_set_param() argument
562 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_set_param()
569 conn_info = ndev->hci_dev->conn_info; in nci_hci_set_param()
587 r = nci_request(ndev, nci_hci_send_data_req, &data, in nci_hci_set_param()
601 int nci_hci_get_param(struct nci_dev *ndev, u8 gate, u8 idx, in nci_hci_get_param() argument
608 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_get_param()
615 conn_info = ndev->hci_dev->conn_info; in nci_hci_get_param()
626 r = nci_request(ndev, nci_hci_send_data_req, &data, in nci_hci_get_param()
643 int nci_hci_connect_gate(struct nci_dev *ndev, in nci_hci_connect_gate() argument
652 if (ndev->hci_dev->gate2pipe[dest_gate] != NCI_HCI_INVALID_PIPE) in nci_hci_connect_gate()
666 pipe = nci_hci_create_pipe(ndev, dest_host, dest_gate, &r); in nci_hci_connect_gate()
674 r = nci_hci_open_pipe(ndev, pipe); in nci_hci_connect_gate()
677 if (nci_hci_delete_pipe(ndev, pipe) < 0) { in nci_hci_connect_gate()
686 ndev->hci_dev->pipes[pipe].gate = dest_gate; in nci_hci_connect_gate()
687 ndev->hci_dev->pipes[pipe].host = dest_host; in nci_hci_connect_gate()
688 ndev->hci_dev->gate2pipe[dest_gate] = pipe; in nci_hci_connect_gate()
694 static int nci_hci_dev_connect_gates(struct nci_dev *ndev, in nci_hci_dev_connect_gates() argument
701 r = nci_hci_connect_gate(ndev, gates->dest_host, in nci_hci_dev_connect_gates()
711 int nci_hci_dev_session_init(struct nci_dev *ndev) in nci_hci_dev_session_init() argument
717 ndev->hci_dev->count_pipes = 0; in nci_hci_dev_session_init()
718 ndev->hci_dev->expected_pipes = 0; in nci_hci_dev_session_init()
720 conn_info = ndev->hci_dev->conn_info; in nci_hci_dev_session_init()
725 conn_info->data_exchange_cb_context = ndev; in nci_hci_dev_session_init()
727 nci_hci_reset_pipes(ndev->hci_dev); in nci_hci_dev_session_init()
729 if (ndev->hci_dev->init_data.gates[0].gate != NCI_HCI_ADMIN_GATE) in nci_hci_dev_session_init()
732 r = nci_hci_connect_gate(ndev, in nci_hci_dev_session_init()
733 ndev->hci_dev->init_data.gates[0].dest_host, in nci_hci_dev_session_init()
734 ndev->hci_dev->init_data.gates[0].gate, in nci_hci_dev_session_init()
735 ndev->hci_dev->init_data.gates[0].pipe); in nci_hci_dev_session_init()
739 r = nci_hci_get_param(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_dev_session_init()
745 skb->len == strlen(ndev->hci_dev->init_data.session_id) && in nci_hci_dev_session_init()
746 !memcmp(ndev->hci_dev->init_data.session_id, skb->data, skb->len) && in nci_hci_dev_session_init()
747 ndev->ops->hci_load_session) { in nci_hci_dev_session_init()
749 r = ndev->ops->hci_load_session(ndev); in nci_hci_dev_session_init()
751 r = nci_hci_clear_all_pipes(ndev); in nci_hci_dev_session_init()
755 r = nci_hci_dev_connect_gates(ndev, in nci_hci_dev_session_init()
756 ndev->hci_dev->init_data.gate_count, in nci_hci_dev_session_init()
757 ndev->hci_dev->init_data.gates); in nci_hci_dev_session_init()
761 r = nci_hci_set_param(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_dev_session_init()
763 ndev->hci_dev->init_data.session_id, in nci_hci_dev_session_init()
764 strlen(ndev->hci_dev->init_data.session_id)); in nci_hci_dev_session_init()
774 struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev) in nci_hci_allocate() argument
785 hdev->ndev = ndev; in nci_hci_allocate()
790 void nci_hci_deallocate(struct nci_dev *ndev) in nci_hci_deallocate() argument
792 kfree(ndev->hci_dev); in nci_hci_deallocate()