/* Recv data */ static int ath_recv(struct hci_uart *hu, void *data, int count) { struct ath_struct *ath = hu->priv; unsigned int type; BT_DBG(""); if (hci_recv_stream_fragment(hu->hdev, data, count) < 0) BT_ERR("Frame Reassembly Failed"); if (count & test_bit(BT_SLEEPCMD, &flags)) { struct sk_buff *skb = hu->hdev->reassembly[0]; if (!skb) { struct { char type; } *pkt; /* Start of the frame */ pkt = data; type = pkt->type; } else type = bt_cb(skb)->pkt_type; if (type == HCI_EVENT_PKT) { clear_bit(BT_SLEEPCMD, &flags); BT_INFO("cur_sleep:%d\n", ath->cur_sleep); if (ath->cur_sleep == 1) set_bit(BT_SLEEPENABLE, &flags); else clear_bit(BT_SLEEPENABLE, &flags); } if (test_bit(BT_SLEEPENABLE, &flags)) modify_timer_task(); } return count; }
/* Recv data */ static int ath_recv(struct hci_uart *hu, void *data, int count) { if (hci_recv_stream_fragment(hu->hdev, data, count) < 0) BT_ERR("Frame Reassembly Failed"); return count; }
/* Recv data */ static int h4_recv(struct hci_uart *hu, void *data, int count) { int ret; ret = hci_recv_stream_fragment(hu->hdev, data, count); if (ret < 0) { BT_ERR("Frame Reassembly Failed"); return ret; } return count; }
/* Recv data */ static int h4_recv(struct hci_uart *hu, void *data, int count) { int ret; if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) return -EUNATCH; ret = hci_recv_stream_fragment(hu->hdev, data, count); if (ret < 0) { BT_ERR("Frame Reassembly Failed"); return ret; } return count; }
/* Recv data */ static int h4_recv(struct hci_uart *hu, void *data, int count) { if(mt6622_hack == 0) { int ret; ret = hci_recv_stream_fragment(hu->hdev, data, count); if (ret < 0) { BT_ERR("Frame Reassembly Failed"); return ret; } return count; } else { struct h4_struct *h4 = hu->priv; register char *ptr; struct hci_event_hdr *eh; struct hci_acl_hdr *ah; struct hci_sco_hdr *sh; register int len, type, dlen; int iDiscard = 0; int while_count = 0; BT_DBG("hu %p count %d rx_state %ld rx_count %ld", hu, count, h4->rx_state, h4->rx_count); ptr = data; while (count) { while_count ++; if(while_count > 5000){ BT_ERR("h4_recv while_count %d\n", while_count); } if (h4->rx_count) { len = min_t(unsigned int, h4->rx_count, count); memcpy(skb_put(h4->rx_skb, len), ptr, len); h4->rx_count -= len; count -= len; ptr += len; if (h4->rx_count) continue; switch (h4->rx_state) { case H4_W4_DATA: iDiscard = 0; /* default not to drop packet */ if(HCI_EVENT_PKT == bt_cb(h4->rx_skb)->pkt_type){ unsigned short usOpCode = 0; eh = hci_event_hdr(h4->rx_skb); switch(eh->evt){ case HCI_EV_CMD_COMPLETE: usOpCode = (((unsigned short)(h4->rx_skb->data[4])) << 8) | ((unsigned short)(h4->rx_skb->data[3])); if(usOpCode == 0xFCC0){ iDiscard = 1; clear_bit(1, &h4->ulMagic); /* allow TX to run */ BT_DBG("recv event 0x%04x\n", (int)usOpCode); /* flag is cleared. we may resume TX. or later? */ hci_uart_tx_wakeup(hu); } if(usOpCode == 0xFCC1){ BT_DBG("recv host awake command event 0x%04x\n", (int)usOpCode); //mt_bt_enable_irq(); } break; } } if(!iDiscard){ hci_recv_frame(h4->rx_skb); } else{ kfree_skb(h4->rx_skb); } h4->rx_state = H4_W4_PACKET_TYPE; h4->rx_skb = NULL; continue; case H4_W4_EVENT_HDR: eh = hci_event_hdr(h4->rx_skb); BT_DBG("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen); h4_check_data_len(h4, eh->plen); continue; case H4_W4_ACL_HDR: ah = hci_acl_hdr(h4->rx_skb); dlen = __le16_to_cpu(ah->dlen); BT_DBG("ACL header: dlen %d", dlen); h4_check_data_len(h4, dlen); continue; case H4_W4_SCO_HDR: sh = hci_sco_hdr(h4->rx_skb); BT_DBG("SCO header: dlen %d", sh->dlen); h4_check_data_len(h4, sh->dlen); continue; } } /* H4_W4_PACKET_TYPE */ switch (*ptr) { case HCI_EVENT_PKT: BT_DBG("Event packet"); h4->rx_state = H4_W4_EVENT_HDR; h4->rx_count = HCI_EVENT_HDR_SIZE; type = HCI_EVENT_PKT; break; case HCI_ACLDATA_PKT: BT_DBG("ACL packet"); h4->rx_state = H4_W4_ACL_HDR; h4->rx_count = HCI_ACL_HDR_SIZE; type = HCI_ACLDATA_PKT; break; case HCI_SCODATA_PKT: BT_DBG("SCO packet"); h4->rx_state = H4_W4_SCO_HDR; h4->rx_count = HCI_SCO_HDR_SIZE; type = HCI_SCODATA_PKT; break; default: BT_ERR("Unknown HCI packet type %2.2x", (__u8)*ptr); hu->hdev->stat.err_rx++; ptr++; count--; continue; }; ptr++; count--; /* Allocate packet */ h4->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); if (!h4->rx_skb) { BT_ERR("Can't allocate mem for new packet"); h4->rx_state = H4_W4_PACKET_TYPE; h4->rx_count = 0; return 0; } h4->rx_skb->dev = (void *) hu->hdev; bt_cb(h4->rx_skb)->pkt_type = type; } return count; }