diff mbox series

[v1] monitor/intel: Add decode support for vendor command 0xfc2a

Message ID 20240316010327.944183-1-kiran.k@intel.com (mailing list archive)
State New, archived
Headers show
Series [v1] monitor/intel: Add decode support for vendor command 0xfc2a | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #80: < HCI Command: Intel Read Connection Info by bd address (0x3f|0x002a) plen 7 WARNING:LONG_LINE: line length of 86 exceeds 80 columns #156: FILE: monitor/intel.c:590: + str = "Connection is detached but handle is not yet released"; WARNING:LONG_LINE: line length of 84 exceeds 80 columns #159: FILE: monitor/intel.c:593: + str = "Connection is used for outgoing remote name request"; WARNING:LONG_LINE: line length of 91 exceeds 80 columns #162: FILE: monitor/intel.c:596: + str = "Connection is prepared but handle is not yet sent to host"; WARNING:LONG_LINE: line length of 89 exceeds 80 columns #165: FILE: monitor/intel.c:599: + str = "Connection request is pending to the host on this handle"; /github/workspace/src/src/13594138.patch total: 0 errors, 5 warnings, 118 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/13594138.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.
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS

Commit Message

K, Kiran March 16, 2024, 1:03 a.m. UTC
0xfc2a command is used to read the connection information by bdaddress.

btmon output:

< HCI Command: Intel Read Connection Info by bd address (0x3f|0x002a) plen 7
        Device Address Type: Random Device Address (0x01)
        Address: CF:AC:A6:79:3C:AF (OUI CF-AC-A6)
        af 3c 79 a6 ac cf
> HCI Event: Command Complete (0x0e) plen 9
      Intel Read Connection Info by bd address (0x3f|0x002a) ncmd 1
        Status: Success (0x00)
        Number of handles: 0x01
        Handle: 3585
        State: Connection is established on this handle (0x06)
        Type: Handle belongs to LE link (0x04)
---
 monitor/intel.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)
diff mbox series

Patch

diff --git a/monitor/intel.c b/monitor/intel.c
index aa05a803bf8e..d50f70779459 100644
--- a/monitor/intel.c
+++ b/monitor/intel.c
@@ -534,6 +534,109 @@  static void manufacturer_mode_cmd(uint16_t index, const void *data,
 	print_field("Reset behavior: %s (0x%2.2x)", str, reset);
 }
 
+static void read_connection_info_cmd(uint16_t index, const void *data,
+				     uint8_t size)
+{
+	uint8_t addr_type;
+	const char *str;
+
+	addr_type = get_u8(data);
+
+	switch (addr_type) {
+	case 0x00:
+		str = "Public Device Address";
+		break;
+	case 0x01:
+		str = "Random Device Address";
+		break;
+	default:
+		str = "Unknown Device Address";
+		break;
+	}
+	print_field("Device Address Type: %s (0x%2.2x)", str, addr_type);
+	packet_print_addr("Address", data + 1, 0x00);
+	packet_hexdump(data + 1, 6);
+
+}
+
+static void read_connection_info_rsp(uint16_t index, const void *data,
+				     uint8_t size)
+{
+	uint8_t status = get_u8(data);
+	uint8_t hndls;
+	const uint8_t *p;
+	const char *str;
+	uint8_t i;
+
+	print_status(status);
+
+	if (status)
+		return;
+	size--;
+
+	hndls = get_u8(data + 1);
+	print_field("Number of handles: 0x%2.2x", hndls);
+	size--;
+
+	for (i = 0, p = data + 2; size > 0 && i < hndls;
+			size -= 4, i++, p = p + 4) {
+		uint16_t handle = get_le16(p);
+		uint8_t state = get_u8(p + 2);
+		uint8_t type = get_u8(p + 3);
+
+		print_field("Handle: %u", handle);
+		switch (state) {
+		case 1:
+			str = "Connection is detached but handle is not yet released";
+			break;
+		case 2:
+			str = "Connection is used for outgoing remote name request";
+			break;
+		case 4:
+			str = "Connection is prepared  but handle is not yet sent to host";
+			break;
+		case 5:
+			str = "Connection request is pending to the host on this handle";
+			break;
+		case 6:
+			str = "Connection is established on this handle";
+			break;
+		case 7:
+			str = "Connection is in Hold mode";
+			break;
+		case 8:
+			str = "Connection in Sniff mode";
+			break;
+		default:
+			str = "Unknown state";
+			break;
+		}
+
+		print_field("State: %s (0x%2.2x)", str, state);
+		switch (type) {
+		case 0:
+			str = "Handle belongs to SCO link";
+			break;
+		case 1:
+			str = "Handle belongs to ACL link";
+			break;
+		case 2:
+			str = "Handle belongs to eSCO link";
+			break;
+		case 4:
+			str  = "Handle belongs to LE link";
+			break;
+		case 255:
+			str = "Handle doesn't have an associated link";
+			break;
+		default:
+			str = "Unknown link";
+			break;
+		}
+		print_field("Type: %s (0x%2.2x)", str, type);
+	}
+}
+
 static void write_bd_data_cmd(uint16_t index, const void *data, uint8_t size)
 {
 	uint8_t features[8];
@@ -763,6 +866,9 @@  static const struct vendor_ocf vendor_ocf_table[] = {
 	{ 0x012, "Read Link RSSI" },
 	{ 0x022, "Get Exception Info" },
 	{ 0x024, "Clear Exception Info" },
+	{ 0x02a, "Read Connection Info by bd address",
+			read_connection_info_cmd, 7, true,
+			read_connection_info_rsp, 1, false },
 	{ 0x02f, "Write BD Data",
 			write_bd_data_cmd, 6, false },
 	{ 0x030, "Read BD Data",