Lines Matching refs:ndev
133 static void nci_hci_reset_pipes_per_host(struct nci_dev *ndev, u8 host) in nci_hci_reset_pipes_per_host() argument
138 if (ndev->hci_dev->pipes[i].host == host) { in nci_hci_reset_pipes_per_host()
139 ndev->hci_dev->pipes[i].gate = NCI_HCI_INVALID_GATE; in nci_hci_reset_pipes_per_host()
140 ndev->hci_dev->pipes[i].host = NCI_HCI_INVALID_HOST; in nci_hci_reset_pipes_per_host()
153 static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe, in nci_hci_send_data() argument
162 conn_info = ndev->hci_dev->conn_info; in nci_hci_send_data()
167 skb = nci_skb_alloc(ndev, conn_info->max_pkt_payload_len + in nci_hci_send_data()
192 r = nci_send_data(ndev, conn_info->conn_id, skb); in nci_hci_send_data()
199 skb = nci_skb_alloc(ndev, in nci_hci_send_data()
212 static void nci_hci_send_data_req(struct nci_dev *ndev, unsigned long opt) in nci_hci_send_data_req() argument
216 nci_hci_send_data(ndev, data->pipe, data->cmd, in nci_hci_send_data_req()
220 int nci_hci_send_event(struct nci_dev *ndev, u8 gate, u8 event, in nci_hci_send_event() argument
223 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_send_event()
228 return nci_hci_send_data(ndev, pipe, in nci_hci_send_event()
234 int nci_hci_send_cmd(struct nci_dev *ndev, u8 gate, u8 cmd, in nci_hci_send_cmd() argument
242 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_send_cmd()
247 conn_info = ndev->hci_dev->conn_info; in nci_hci_send_cmd()
257 r = nci_request(ndev, nci_hci_send_data_req, (unsigned long)&data, in nci_hci_send_cmd()
273 int nci_hci_clear_all_pipes(struct nci_dev *ndev) in nci_hci_clear_all_pipes() argument
277 r = nci_hci_send_cmd(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_clear_all_pipes()
282 nci_hci_reset_pipes(ndev->hci_dev); in nci_hci_clear_all_pipes()
287 static void nci_hci_event_received(struct nci_dev *ndev, u8 pipe, in nci_hci_event_received() argument
290 if (ndev->ops->hci_event_received) in nci_hci_event_received()
291 ndev->ops->hci_event_received(ndev, pipe, event, skb); in nci_hci_event_received()
294 static void nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe, in nci_hci_cmd_received() argument
297 u8 gate = ndev->hci_dev->pipes[pipe].gate; in nci_hci_cmd_received()
321 ndev->hci_dev->gate2pipe[dest_gate] = new_pipe; in nci_hci_cmd_received()
322 ndev->hci_dev->pipes[new_pipe].gate = dest_gate; in nci_hci_cmd_received()
323 ndev->hci_dev->pipes[new_pipe].host = in nci_hci_cmd_received()
340 ndev->hci_dev->pipes[delete_info->pipe].gate = in nci_hci_cmd_received()
342 ndev->hci_dev->pipes[delete_info->pipe].host = in nci_hci_cmd_received()
353 nci_hci_reset_pipes_per_host(ndev, cleared_info->host); in nci_hci_cmd_received()
360 if (ndev->ops->hci_cmd_received) in nci_hci_cmd_received()
361 ndev->ops->hci_cmd_received(ndev, pipe, cmd, skb); in nci_hci_cmd_received()
364 nci_hci_send_data(ndev, pipe, status, NULL, 0); in nci_hci_cmd_received()
369 static void nci_hci_resp_received(struct nci_dev *ndev, u8 pipe, in nci_hci_resp_received() argument
375 conn_info = ndev->hci_dev->conn_info; in nci_hci_resp_received()
384 nci_req_complete(ndev, NCI_STATUS_OK); in nci_hci_resp_received()
390 static void nci_hci_hcp_message_rx(struct nci_dev *ndev, u8 pipe, in nci_hci_hcp_message_rx() argument
395 nci_hci_resp_received(ndev, pipe, instruction, skb); in nci_hci_hcp_message_rx()
398 nci_hci_cmd_received(ndev, pipe, instruction, skb); in nci_hci_hcp_message_rx()
401 nci_hci_event_received(ndev, pipe, instruction, skb); in nci_hci_hcp_message_rx()
410 nci_req_complete(ndev, NCI_STATUS_OK); in nci_hci_hcp_message_rx()
429 nci_hci_hcp_message_rx(hdev->ndev, pipe, in nci_hci_msg_rx_work()
437 struct nci_dev *ndev = (struct nci_dev *)context; in nci_hci_data_received_cb() local
447 nci_req_complete(ndev, err); in nci_hci_data_received_cb()
453 skb_queue_tail(&ndev->hci_dev->rx_hcp_frags, skb); in nci_hci_data_received_cb()
458 if (skb_queue_len(&ndev->hci_dev->rx_hcp_frags)) { in nci_hci_data_received_cb()
460 skb_queue_tail(&ndev->hci_dev->rx_hcp_frags, skb); in nci_hci_data_received_cb()
463 skb_queue_walk(&ndev->hci_dev->rx_hcp_frags, frag_skb) { in nci_hci_data_received_cb()
471 nci_req_complete(ndev, -ENOMEM); in nci_hci_data_received_cb()
477 skb_queue_walk(&ndev->hci_dev->rx_hcp_frags, frag_skb) { in nci_hci_data_received_cb()
483 skb_queue_purge(&ndev->hci_dev->rx_hcp_frags); in nci_hci_data_received_cb()
498 nci_hci_hcp_message_rx(ndev, pipe, type, in nci_hci_data_received_cb()
501 skb_queue_tail(&ndev->hci_dev->msg_rx_queue, hcp_skb); in nci_hci_data_received_cb()
502 schedule_work(&ndev->hci_dev->msg_rx_work); in nci_hci_data_received_cb()
506 int nci_hci_open_pipe(struct nci_dev *ndev, u8 pipe) in nci_hci_open_pipe() argument
511 conn_info = ndev->hci_dev->conn_info; in nci_hci_open_pipe()
522 return nci_request(ndev, nci_hci_send_data_req, in nci_hci_open_pipe()
528 static u8 nci_hci_create_pipe(struct nci_dev *ndev, u8 dest_host, in nci_hci_create_pipe() argument
542 *result = nci_hci_send_cmd(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_create_pipe()
557 static int nci_hci_delete_pipe(struct nci_dev *ndev, u8 pipe) in nci_hci_delete_pipe() argument
561 return nci_hci_send_cmd(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_delete_pipe()
565 int nci_hci_set_param(struct nci_dev *ndev, u8 gate, u8 idx, in nci_hci_set_param() argument
573 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_set_param()
580 conn_info = ndev->hci_dev->conn_info; in nci_hci_set_param()
598 r = nci_request(ndev, nci_hci_send_data_req, in nci_hci_set_param()
613 int nci_hci_get_param(struct nci_dev *ndev, u8 gate, u8 idx, in nci_hci_get_param() argument
620 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_get_param()
627 conn_info = ndev->hci_dev->conn_info; in nci_hci_get_param()
638 r = nci_request(ndev, nci_hci_send_data_req, (unsigned long)&data, in nci_hci_get_param()
655 int nci_hci_connect_gate(struct nci_dev *ndev, in nci_hci_connect_gate() argument
664 if (ndev->hci_dev->gate2pipe[dest_gate] != NCI_HCI_INVALID_PIPE) in nci_hci_connect_gate()
678 pipe = nci_hci_create_pipe(ndev, dest_host, dest_gate, &r); in nci_hci_connect_gate()
686 r = nci_hci_open_pipe(ndev, pipe); in nci_hci_connect_gate()
689 if (nci_hci_delete_pipe(ndev, pipe) < 0) { in nci_hci_connect_gate()
698 ndev->hci_dev->pipes[pipe].gate = dest_gate; in nci_hci_connect_gate()
699 ndev->hci_dev->pipes[pipe].host = dest_host; in nci_hci_connect_gate()
700 ndev->hci_dev->gate2pipe[dest_gate] = pipe; in nci_hci_connect_gate()
706 static int nci_hci_dev_connect_gates(struct nci_dev *ndev, in nci_hci_dev_connect_gates() argument
713 r = nci_hci_connect_gate(ndev, gates->dest_host, in nci_hci_dev_connect_gates()
723 int nci_hci_dev_session_init(struct nci_dev *ndev) in nci_hci_dev_session_init() argument
729 ndev->hci_dev->count_pipes = 0; in nci_hci_dev_session_init()
730 ndev->hci_dev->expected_pipes = 0; in nci_hci_dev_session_init()
732 conn_info = ndev->hci_dev->conn_info; in nci_hci_dev_session_init()
737 conn_info->data_exchange_cb_context = ndev; in nci_hci_dev_session_init()
739 nci_hci_reset_pipes(ndev->hci_dev); in nci_hci_dev_session_init()
741 if (ndev->hci_dev->init_data.gates[0].gate != NCI_HCI_ADMIN_GATE) in nci_hci_dev_session_init()
744 r = nci_hci_connect_gate(ndev, in nci_hci_dev_session_init()
745 ndev->hci_dev->init_data.gates[0].dest_host, in nci_hci_dev_session_init()
746 ndev->hci_dev->init_data.gates[0].gate, in nci_hci_dev_session_init()
747 ndev->hci_dev->init_data.gates[0].pipe); in nci_hci_dev_session_init()
751 r = nci_hci_get_param(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_dev_session_init()
757 skb->len == strlen(ndev->hci_dev->init_data.session_id) && in nci_hci_dev_session_init()
758 !memcmp(ndev->hci_dev->init_data.session_id, skb->data, skb->len) && in nci_hci_dev_session_init()
759 ndev->ops->hci_load_session) { in nci_hci_dev_session_init()
761 r = ndev->ops->hci_load_session(ndev); in nci_hci_dev_session_init()
763 r = nci_hci_clear_all_pipes(ndev); in nci_hci_dev_session_init()
767 r = nci_hci_dev_connect_gates(ndev, in nci_hci_dev_session_init()
768 ndev->hci_dev->init_data.gate_count, in nci_hci_dev_session_init()
769 ndev->hci_dev->init_data.gates); in nci_hci_dev_session_init()
773 r = nci_hci_set_param(ndev, NCI_HCI_ADMIN_GATE, in nci_hci_dev_session_init()
775 ndev->hci_dev->init_data.session_id, in nci_hci_dev_session_init()
776 strlen(ndev->hci_dev->init_data.session_id)); in nci_hci_dev_session_init()
786 struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev) in nci_hci_allocate() argument
797 hdev->ndev = ndev; in nci_hci_allocate()