]> Git Repo - esp-hosted.git/commitdiff
[BT Host driver] Update hcidev stats
authorMangesh Malusare <[email protected]>
Mon, 4 May 2020 14:44:06 +0000 (20:14 +0530)
committerMangesh Malusare <[email protected]>
Tue, 5 May 2020 07:02:00 +0000 (12:32 +0530)
Signed-off-by: Mangesh Malusare <[email protected]>
host_driver/esp32/esp_bt.c
host_driver/esp32/esp_bt_api.h
host_driver/esp32/main.c

index 19a2e473bf97fd6dec5c704c2ce85b6d795af5ed..9c408e8a0ade0583db59c2af0c427472a79a0a1c 100644 (file)
 #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;
@@ -56,6 +86,7 @@ static int esp_bt_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
                if(!new_skb) {
                        printk(KERN_ERR "%s: Failed to allocate SKB", __func__);
                        dev_kfree_skb(skb);
+                       hdev->stat.err_tx++;
                        return -ENOMEM;
                }
 
@@ -79,6 +110,12 @@ static int esp_bt_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 /*     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;
index bb7bcfe6ca9add3c8f5d9ae1d61524fa18bcf647..495713aa844f24d482f4e2d93b2d6217be915d5d 100644 (file)
@@ -24,5 +24,7 @@
 
 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
index 7ab4fed862cdf22bafcbae42ac65070452ca5ea1..4da94cf73ae4c2d3eef6b0ddfad7fd922a2aacc3 100644 (file)
@@ -31,6 +31,7 @@
 #ifdef CONFIG_SUPPORT_ESP_SERIAL
 #include "esp_serial.h"
 #endif
+#include "esp_bt_api.h"
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Amey Inamdar <[email protected]>");
@@ -329,7 +330,12 @@ static void process_rx_packet(struct sk_buff *skb)
                        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);
+                       }
                }
        }
 }
This page took 0.032238 seconds and 4 git commands to generate.