monitor: Fix not printing latency information with -r
Luiz Augusto von Dentz
maintainerPATCH 1/2 monitor: Fix not printing latency information with -r
From: Luiz Augusto von Dentz <[email protected]>
When reading a log from file hci_devba may not work, also store link information so assign_handle can use use the parent (ACL) destination.
--- monitor/packet.c | 40 +++++++++++++++++++++++++++++++++++++--- monitor/packet.h | 1 + 2 files changed, 38 insertions(+), 3 deletions(-)
monitor/packet.c +37 -3
@@ -174,6 +174,18 @@ static uint16_t get_format(uint32_t cookie)static struct packet_conn_data conn_list[MAX_CONN ]; +static struct packet_conn_data *lookup_parent (uint16_t handle) +{ +int i; + +for (i =0 ; i <MAX_CONN ; i++) { +if (conn_list[i].link == handle) +return &conn_list[i]; + } + +return NULL ; +} +static void assign_handle (uint16_t index,uint16_t handle,uint8_t type,uint8_t *dst,uint8_t dst_type) {
@@ -181,15 +193,27 @@ static void assign_handle(uint16_t index, uint16_t handle, uint8_t type,for (i =0 ; i <MAX_CONN ; i++) {if (conn_list[i].handle ==0x0000 ) { -if (hci_devba (index, (bdaddr_t *)conn_list[i].src) <0 ) -return ; +hci_devba (index, (bdaddr_t *)conn_list[i].src); conn_list[i].index = index; conn_list[i].handle = handle; conn_list[i].type = type; -if (!dst) +if (!dst) { +struct packet_conn_data *p; + +/* If destination is not set attempt to use the +* parent one if that exists. +*/ + p =lookup_parent (handle); +if (p) { +memcpy (conn_list[i].dst, p->dst, +sizeof (conn_list[i].dst)); + conn_list[i].dst_type = p->dst_type; + } +break ; + }memcpy (conn_list[i].dst, dst,sizeof (conn_list[i].dst)); conn_list[i].dst_type = dst_type;
@@ -8725,9 +8749,14 @@ static void le_set_cig_params_rsp(uint16_t index, const void *data,static void print_cis (const void *data,int i) {const struct bt_hci_cis *cis = data; +struct packet_conn_data *conn;print_field ("CIS Handle: %d" , cis->cis_handle);print_field ("ACL Handle: %d" , cis->acl_handle); + + conn =packet_get_conn_data (cis->acl_handle); +if (conn) + conn->link = cis->cis_handle; }static void le_create_cis_cmd (uint16_t index,const void *data,uint8_t size)
@@ -11643,11 +11672,16 @@ static void le_req_cis_evt(struct timeval *tv, uint16_t index, const void *data, uint8_t size) {const struct bt_hci_evt_le_cis_req *evt = data; +struct packet_conn_data *conn;print_field ("ACL Handle: %d" ,le16_to_cpu (evt->acl_handle));print_field ("CIS Handle: %d" ,le16_to_cpu (evt->cis_handle));print_field ("CIG ID: 0x%2.2x" , evt->cig_id);print_field ("CIS ID: 0x%2.2x" , evt->cis_id); + + conn =packet_get_conn_data (evt->acl_handle); +if (conn) + conn->link = evt->cis_handle; }static void print_bis_handle (const void *data,int i)
monitor/packet.h +1 -0
@@ -42,6 +42,7 @@ struct packet_conn_data {uint16_t index;uint8_t src[6 ];uint16_t handle; +uint16_t link;uint8_t type;uint8_t dst[6 ];uint8_t dst_type;
Signature · 1 line
2.41.0
Luiz Augusto von Dentz
maintainerPATCH 2/2 monitor: Detect LE-ACL connections
From: Luiz Augusto von Dentz <[email protected]>
This enables LE-ACL connections to be detected by processing its events otherwise they would be assumed to be BR-ACL. Also make sure that LE-ISO address is set based on its ACL link.
--- monitor/analyze.c | 88 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 4 deletions(-)
monitor/analyze.c +84 -4
@@ -71,6 +71,7 @@ struct hci_stats {struct hci_conn {uint16_t handle; +uint16_t link;uint8_t type;uint8_t bdaddr[6 ];bool setup_seen;
@@ -290,6 +291,20 @@ static struct hci_conn *conn_lookup(struct hci_dev *dev, uint16_t handle) UINT_TO_PTR(handle)); } +static bool link_match_handle (const void *a,const void *b) +{ +const struct hci_conn *conn = a; +uint16_t handle =PTR_TO_UINT (b); + +return (conn->link == handle && !conn->terminated); +} + +static struct hci_conn *link_lookup (struct hci_dev *dev,uint16_t handle) +{ +return queue_find (dev->conn_list, link_match_handle, +UINT_TO_PTR (handle)); +} +static struct hci_conn *conn_lookup_type (struct hci_dev *dev,uint16_t handle,uint8_t type) {
@@ -297,7 +312,7 @@ static struct hci_conn *conn_lookup_type(struct hci_dev *dev, uint16_t handle, conn =queue_find (dev->conn_list, conn_match_handle,UINT_TO_PTR (handle)); -if (!conn || conn->type != type) { +if (!conn || (type && conn->type != type)) { conn =conn_alloc (dev, handle, type);queue_push_tail (dev->conn_list, conn); }
@@ -542,6 +557,42 @@ static void plot_add(struct queue *queue, struct timeval *latency,queue_push_tail (queue, plot); } +static void evt_le_conn_complete (struct hci_dev *dev,struct timeval *tv, +struct iovec *iov) +{ +const struct bt_hci_evt_le_conn_complete *evt; +struct hci_conn *conn; + + evt =util_iov_pull_mem (iov,sizeof (*evt)); +if (!evt || evt->status) +return ; + + conn =conn_lookup_type (dev,le16_to_cpu (evt->handle),CONN_LE_ACL ); +if (!conn) +return ; + +memcpy (conn->bdaddr, evt->peer_addr,6 ); + conn->setup_seen = true; +} + +static void evt_le_enh_conn_complete (struct hci_dev *dev,struct timeval *tv, +struct iovec *iov) +{ +const struct bt_hci_evt_le_enhanced_conn_complete *evt; +struct hci_conn *conn; + + evt =util_iov_pull_mem (iov,sizeof (*evt)); +if (!evt || evt->status) +return ; + + conn =conn_lookup_type (dev,le16_to_cpu (evt->handle),CONN_LE_ACL ); +if (!conn) +return ; + +memcpy (conn->bdaddr, evt->peer_addr,6 ); + conn->setup_seen = true; +} +static void evt_num_completed_packets (struct hci_dev *dev,struct timeval *tv,const void *data,uint16_t size) {
@@ -612,7 +663,7 @@ static void evt_le_cis_established(struct hci_dev *dev, struct timeval *tv, struct iovec *iov) {const struct bt_hci_evt_le_cis_established *evt; -struct hci_conn *conn; +struct hci_conn *conn, *link; evt =util_iov_pull_mem (iov,sizeof (*evt));if (!evt || evt->status)
@@ -624,6 +675,27 @@ static void evt_le_cis_established(struct hci_dev *dev, struct timeval *tv,return ; conn->setup_seen = true; + + link =link_lookup (dev, conn->handle); +if (link) +memcpy (conn->bdaddr, link->bdaddr,6 ); +} + +static void evt_le_cis_req (struct hci_dev *dev,struct timeval *tv, +struct iovec *iov) +{ +const struct bt_hci_evt_le_cis_req *evt; +struct hci_conn *conn; + + evt =util_iov_pull_mem (iov,sizeof (*evt)); +if (!evt) +return ; + + conn =conn_lookup (dev,le16_to_cpu (evt->acl_handle)); +if (!conn) +return ; + + conn->link =le16_to_cpu (evt->cis_handle); } static void evt_le_big_complete(struct hci_dev *dev, struct timeval *tv,
@@ -685,9 +757,18 @@ static void evt_le_meta_event(struct hci_dev *dev, struct timeval *tv,return ;switch (subevt) { +case BT_HCI_EVT_LE_CONN_COMPLETE : +evt_le_conn_complete (dev, tv, &iov); +break ; +case BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE : +evt_le_enh_conn_complete (dev, tv, &iov); +break ;case BT_HCI_EVT_LE_CIS_ESTABLISHED :evt_le_cis_established (dev, tv, &iov);break ; +case BT_HCI_EVT_LE_CIS_REQ : +evt_le_cis_req (dev, tv, &iov); +break ;case BT_HCI_EVT_LE_BIG_COMPLETE :evt_le_big_complete (dev, tv, &iov);break ;
@@ -811,8 +892,7 @@ static void acl_pkt(struct timeval *tv, uint16_t index, bool out, dev->num_hci++; dev->num_acl++; - conn =conn_lookup_type (dev,le16_to_cpu (hdr->handle) &0x0fff , -CONN_BR_ACL ); + conn =conn_lookup_type (dev,le16_to_cpu (hdr->handle) &0x0fff ,0x00 );if (!conn)return ;
Signature · 1 line
2.41.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=776802
---Test result---
Test Summary:
CheckPatch FAIL 1.15 seconds GitLint PASS 0.50 seconds BuildEll PASS 32.17 seconds BluezMake PASS 999.21 seconds MakeCheck PASS 13.26 seconds MakeDistcheck PASS 186.01 seconds CheckValgrind PASS 304.34 seconds CheckSmatch WARNING 405.71 seconds bluezmakeextell PASS 123.19 seconds IncrementalBuild PASS 1632.94 seconds ScanBuild PASS 1243.22 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,1/2] monitor: Fix not printing latency information with -r WARNING:REPEATED_WORD: Possible repeated word: 'use'
#83:
information so assign_handle can use use the parent (ACL) destination.
/github/workspace/src/src/13355745.patch total: 0 errors, 1 warnings, 85 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13355745.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:monitor/packet.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/packet.c:1856:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3606:52: warning: array of flexible structuresmonitor/bt.h:3594:40: warning: array of flexible structures
---
Regards,
Linux Bluetooth
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Wed, 16 Aug 2023 15:31:46 -0700 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
When reading a log from file
hci_devbamay not work, also store link information soassign_handlecan use use the parent (ACL) destination.--- monitor/packet.c | 40 +++++++++++++++++++++++++++++++++++++--- monitor/packet.h | 1 + 2 files changed, 38 insertions(+), 3 deletions(-)
Here is the summary with links:
- [BlueZ,1/2] monitor: Fix not printing latency information with -r
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=31941ff3977c - [BlueZ,2/2] monitor: Detect LE-ACL connections https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=aed756136b7f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html