#include "esp_bt_api.h"
#include "esp_api.h"
+void esp_hci_update_tx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len)
+{
+ if (hdev) {
+ if (pkt_type == HCI_COMMAND_PKT) {
+ hdev->stat.cmd_tx++;
+ } else if (pkt_type == HCI_ACLDATA_PKT) {
+ hdev->stat.acl_tx++;
+ } else if (pkt_type == HCI_SCODATA_PKT) {
+ hdev->stat.sco_tx++;
+ }
+
+ hdev->stat.byte_tx += len;
+ }
+}
+
+void esp_hci_update_rx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len)
+{
+ if (hdev) {
+ if (pkt_type == HCI_EVENT_PKT) {
+ hdev->stat.evt_rx++;
+ } else if (pkt_type == HCI_ACLDATA_PKT) {
+ hdev->stat.acl_rx++;
+ } else if (pkt_type == HCI_SCODATA_PKT) {
+ hdev->stat.sco_rx++;
+ }
+
+ hdev->stat.byte_rx += len;
+ }
+}
+
static int esp_bt_open(struct hci_dev *hdev)
{
return 0;
if(!new_skb) {
printk(KERN_ERR "%s: Failed to allocate SKB", __func__);
dev_kfree_skb(skb);
+ hdev->stat.err_tx++;
return -ENOMEM;
}
/* print_hex_dump_bytes("Tx:", DUMP_PREFIX_NONE, skb->data, skb->len);*/
ret = esp32_send_packet(adapter, skb->data, skb->len);
+ if (ret) {
+ hdev->stat.err_tx++;
+ } else {
+ esp_hci_update_tx_counter(hdev, hdr->hci_pkt_type, skb->len);
+ }
+
dev_kfree_skb(skb);
return 0;
int esp_init_bt(struct esp_adapter *adapter);
int esp_deinit_bt(struct esp_adapter *adapter);
+void esp_hci_update_tx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len);
+void esp_hci_update_rx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len);
#endif
#ifdef CONFIG_SUPPORT_ESP_SERIAL
#include "esp_serial.h"
#endif
+#include "esp_bt_api.h"
MODULE_LICENSE("GPL");
type = skb->data;
hci_skb_pkt_type(skb) = *type;
skb_pull(skb, 1);
- hci_recv_frame(hdev, skb);
+
+ if (hci_recv_frame(hdev, skb)) {
+ hdev->stat.err_rx++;
+ } else {
+ esp_hci_update_rx_counter(hdev, *type, skb->len);
+ }
}
}
}