Lines Matching +full:- +full:eproto

1 // SPDX-License-Identifier: GPL-2.0-only
50 u8 header; /* type -cmd,evt,rsp- + instruction */
102 return -EOPNOTSUPP; in nci_hci_result_to_errno()
104 return -ETIME; in nci_hci_result_to_errno()
106 return -1; in nci_hci_result_to_errno()
116 hdev->pipes[i].gate = NCI_HCI_INVALID_GATE; in nci_hci_reset_pipes()
117 hdev->pipes[i].host = NCI_HCI_INVALID_HOST; in nci_hci_reset_pipes()
119 memset(hdev->gate2pipe, NCI_HCI_INVALID_PIPE, sizeof(hdev->gate2pipe)); in nci_hci_reset_pipes()
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()
151 conn_info = ndev->hci_dev->conn_info; in nci_hci_send_data()
153 return -EPROTO; in nci_hci_send_data()
156 skb = nci_skb_alloc(ndev, conn_info->max_pkt_payload_len + in nci_hci_send_data()
159 return -ENOMEM; in nci_hci_send_data()
166 if (i + conn_info->max_pkt_payload_len - in nci_hci_send_data()
167 (skb->len + 1) >= data_len) { in nci_hci_send_data()
169 len = data_len - i; in nci_hci_send_data()
171 len = conn_info->max_pkt_payload_len - skb->len - 1; in nci_hci_send_data()
179 r = nci_send_data(ndev, conn_info->conn_id, skb); in nci_hci_send_data()
187 conn_info->max_pkt_payload_len + in nci_hci_send_data()
190 return -ENOMEM; in nci_hci_send_data()
203 nci_hci_send_data(ndev, data->pipe, data->cmd, in nci_hci_send_data_req()
204 data->data, data->data_len); in nci_hci_send_data_req()
210 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_send_event()
213 return -EADDRNOTAVAIL; in nci_hci_send_event()
229 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_send_cmd()
232 return -EADDRNOTAVAIL; in nci_hci_send_cmd()
234 conn_info = ndev->hci_dev->conn_info; in nci_hci_send_cmd()
236 return -EPROTO; in nci_hci_send_cmd()
238 data.conn_id = conn_info->conn_id; in nci_hci_send_cmd()
247 message = (struct nci_hcp_message *)conn_info->rx_skb->data; in nci_hci_send_cmd()
249 NCI_HCP_MSG_GET_CMD(message->header)); in nci_hci_send_cmd()
250 skb_pull(conn_info->rx_skb, NCI_HCI_HCP_MESSAGE_HEADER_LEN); in nci_hci_send_cmd()
253 *skb = conn_info->rx_skb; in nci_hci_send_cmd()
269 nci_hci_reset_pipes(ndev->hci_dev); in nci_hci_clear_all_pipes()
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()
284 u8 gate = ndev->hci_dev->pipes[pipe].gate; in nci_hci_cmd_received()
295 if (skb->len != 5) { in nci_hci_cmd_received()
299 create_info = (struct nci_hci_create_pipe_resp *)skb->data; in nci_hci_cmd_received()
300 dest_gate = create_info->dest_gate; in nci_hci_cmd_received()
301 new_pipe = create_info->pipe; in nci_hci_cmd_received()
308 * the description for skb->data[3] is destination gate id 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()
315 create_info->src_host; in nci_hci_cmd_received()
325 if (skb->len != 1) { in nci_hci_cmd_received()
329 delete_info = (struct nci_hci_delete_pipe_noti *)skb->data; in nci_hci_cmd_received()
330 if (delete_info->pipe >= NCI_HCI_MAX_PIPES) { 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()
341 if (skb->len != 1) { in nci_hci_cmd_received()
347 (struct nci_hci_all_pipe_cleared_noti *)skb->data; 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()
369 conn_info = ndev->hci_dev->conn_info; in nci_hci_resp_received()
373 conn_info->rx_skb = skb; in nci_hci_resp_received()
413 for (; (skb = skb_dequeue(&hdev->msg_rx_queue)); kcov_remote_stop()) { in nci_hci_msg_rx_work()
415 pipe = NCI_HCP_MSG_GET_PIPE(skb->data[0]); in nci_hci_msg_rx_work()
417 message = (struct nci_hcp_message *)skb->data; in nci_hci_msg_rx_work()
418 type = NCI_HCP_MSG_GET_TYPE(message->header); in nci_hci_msg_rx_work()
419 instruction = NCI_HCP_MSG_GET_CMD(message->header); in nci_hci_msg_rx_work()
422 nci_hci_hcp_message_rx(hdev->ndev, pipe, in nci_hci_msg_rx_work()
442 packet = (struct nci_hcp_packet *)skb->data; in nci_hci_data_received_cb()
443 if ((packet->header & ~NCI_HCI_FRAGMENT) == 0) { in nci_hci_data_received_cb()
444 skb_queue_tail(&ndev->hci_dev->rx_hcp_frags, skb); in nci_hci_data_received_cb()
448 /* it's the last fragment. Does it need re-aggregation? */ in nci_hci_data_received_cb()
449 if (skb_queue_len(&ndev->hci_dev->rx_hcp_frags)) { in nci_hci_data_received_cb()
450 pipe = NCI_HCP_MSG_GET_PIPE(packet->header); 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()
455 msg_len += (frag_skb->len - 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()
469 msg_len = frag_skb->len - NCI_HCI_HCP_PACKET_HEADER_LEN; in nci_hci_data_received_cb()
471 frag_skb->data + NCI_HCI_HCP_PACKET_HEADER_LEN, in nci_hci_data_received_cb()
475 skb_queue_purge(&ndev->hci_dev->rx_hcp_frags); in nci_hci_data_received_cb()
477 packet->header &= NCI_HCI_FRAGMENT; in nci_hci_data_received_cb()
485 packet = (struct nci_hcp_packet *)hcp_skb->data; in nci_hci_data_received_cb()
486 type = NCI_HCP_MSG_GET_TYPE(packet->message.header); in nci_hci_data_received_cb()
488 pipe = NCI_HCP_MSG_GET_PIPE(packet->header); 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()
503 conn_info = ndev->hci_dev->conn_info; in nci_hci_open_pipe()
505 return -EPROTO; in nci_hci_open_pipe()
507 data.conn_id = conn_info->conn_id; in nci_hci_open_pipe()
539 resp = (struct nci_hci_create_pipe_resp *)skb->data; in nci_hci_create_pipe()
540 pipe = resp->pipe; in nci_hci_create_pipe()
564 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_set_param()
569 return -EADDRNOTAVAIL; in nci_hci_set_param()
571 conn_info = ndev->hci_dev->conn_info; in nci_hci_set_param()
573 return -EPROTO; in nci_hci_set_param()
577 return -ENOMEM; in nci_hci_set_param()
582 data.conn_id = conn_info->conn_id; in nci_hci_set_param()
592 message = (struct nci_hcp_message *)conn_info->rx_skb->data; in nci_hci_set_param()
594 NCI_HCP_MSG_GET_CMD(message->header)); in nci_hci_set_param()
595 skb_pull(conn_info->rx_skb, NCI_HCI_HCP_MESSAGE_HEADER_LEN); in nci_hci_set_param()
610 u8 pipe = ndev->hci_dev->gate2pipe[gate]; in nci_hci_get_param()
615 return -EADDRNOTAVAIL; in nci_hci_get_param()
617 conn_info = ndev->hci_dev->conn_info; in nci_hci_get_param()
619 return -EPROTO; in nci_hci_get_param()
621 data.conn_id = conn_info->conn_id; in nci_hci_get_param()
632 message = (struct nci_hcp_message *)conn_info->rx_skb->data; in nci_hci_get_param()
634 NCI_HCP_MSG_GET_CMD(message->header)); in nci_hci_get_param()
635 skb_pull(conn_info->rx_skb, NCI_HCI_HCP_MESSAGE_HEADER_LEN); in nci_hci_get_param()
638 *skb = conn_info->rx_skb; in nci_hci_get_param()
654 if (ndev->hci_dev->gate2pipe[dest_gate] != NCI_HCI_INVALID_PIPE) in nci_hci_connect_gate()
655 return -EADDRINUSE; in nci_hci_connect_gate()
681 * -> inconsistent state in nci_hci_connect_gate()
688 ndev->hci_dev->pipes[pipe].gate = dest_gate; in nci_hci_connect_gate()
689 ndev->hci_dev->pipes[pipe].host = dest_host; in nci_hci_connect_gate()
690 ndev->hci_dev->gate2pipe[dest_gate] = pipe; in nci_hci_connect_gate()
702 while (gate_count--) { in nci_hci_dev_connect_gates()
703 r = nci_hci_connect_gate(ndev, gates->dest_host, in nci_hci_dev_connect_gates()
704 gates->gate, gates->pipe); in nci_hci_dev_connect_gates()
719 ndev->hci_dev->count_pipes = 0; in nci_hci_dev_session_init()
720 ndev->hci_dev->expected_pipes = 0; in nci_hci_dev_session_init()
722 conn_info = ndev->hci_dev->conn_info; in nci_hci_dev_session_init()
724 return -EPROTO; in nci_hci_dev_session_init()
726 conn_info->data_exchange_cb = nci_hci_data_received_cb; in nci_hci_dev_session_init()
727 conn_info->data_exchange_cb_context = ndev; in nci_hci_dev_session_init()
729 nci_hci_reset_pipes(ndev->hci_dev); in nci_hci_dev_session_init()
731 if (ndev->hci_dev->init_data.gates[0].gate != NCI_HCI_ADMIN_GATE) in nci_hci_dev_session_init()
732 return -EPROTO; in nci_hci_dev_session_init()
735 ndev->hci_dev->init_data.gates[0].dest_host, in nci_hci_dev_session_init()
736 ndev->hci_dev->init_data.gates[0].gate, in nci_hci_dev_session_init()
737 ndev->hci_dev->init_data.gates[0].pipe); in nci_hci_dev_session_init()
746 if (skb->len && in nci_hci_dev_session_init()
747 skb->len == strlen(ndev->hci_dev->init_data.session_id) && in nci_hci_dev_session_init()
748 !memcmp(ndev->hci_dev->init_data.session_id, skb->data, skb->len) && in nci_hci_dev_session_init()
749 ndev->ops->hci_load_session) { in nci_hci_dev_session_init()
750 /* Restore gate<->pipe table from some proprietary location. */ in nci_hci_dev_session_init()
751 r = ndev->ops->hci_load_session(ndev); in nci_hci_dev_session_init()
758 ndev->hci_dev->init_data.gate_count, in nci_hci_dev_session_init()
759 ndev->hci_dev->init_data.gates); in nci_hci_dev_session_init()
765 ndev->hci_dev->init_data.session_id, in nci_hci_dev_session_init()
766 strlen(ndev->hci_dev->init_data.session_id)); in nci_hci_dev_session_init()
784 skb_queue_head_init(&hdev->rx_hcp_frags); in nci_hci_allocate()
785 INIT_WORK(&hdev->msg_rx_work, nci_hci_msg_rx_work); in nci_hci_allocate()
786 skb_queue_head_init(&hdev->msg_rx_queue); in nci_hci_allocate()
787 hdev->ndev = ndev; in nci_hci_allocate()
794 kfree(ndev->hci_dev); in nci_hci_deallocate()