public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH Bluez 1/2] monitor: define manufacturer company IDs
@ 2026-04-14 11:11 Archie Pusaka
  2026-04-14 11:11 ` [PATCH Bluez 2/2] monitor: Set msft_opcode on read_local_version_rsp Archie Pusaka
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Archie Pusaka @ 2026-04-14 11:11 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz; +Cc: CrosBT Upstreaming, Archie Pusaka

From: Archie Pusaka <apusaka@chromium.org>

Define company IDs to make it more readable.
Also remove an unnecessary if that could cause uninitialized variable
warning.
---

 monitor/packet.c | 51 +++++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index ff28dfbd4..30cab1a2f 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -100,14 +100,21 @@
 
 #define COLOR_PHY_PACKET		COLOR_BLUE
 
-#define UNKNOWN_MANUFACTURER 0xffff
+#define COMPANY_ID_INTEL	0x0002
+#define COMPANY_ID_BROADCOM	0x000F
+#define COMPANY_ID_QUALCOMM	0x001D
+#define COMPANY_ID_MEDIATEK	0x0046
+#define COMPANY_ID_APPLE	0x004C
+#define COMPANY_ID_REALTEK	0x005D
+#define COMPANY_ID_LINUX	0x05F1
+#define COMPANY_ID_UNKNOWN	0xFFFF
 
 static time_t time_offset = ((time_t) -1);
 static int priority_level = BTSNOOP_PRIORITY_DEBUG;
 static unsigned long filter_mask = 0;
 static bool index_filter = false;
 static uint16_t index_current = 0;
-static uint16_t fallback_manufacturer = UNKNOWN_MANUFACTURER;
+static uint16_t fallback_manufacturer = COMPANY_ID_UNKNOWN;
 
 #define CTRL_RAW  0x0000
 #define CTRL_USER 0x0001
@@ -3487,7 +3494,7 @@ static void print_manufacturer_data(const void *data, uint8_t data_len)
 	packet_print_company("Company", company);
 
 	switch (company) {
-	case 76:
+	case COMPANY_ID_APPLE:
 	case 19456:
 		print_manufacturer_apple(data + 2, data_len - 2);
 		break;
@@ -4446,7 +4453,7 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
 			index_list[index].manufacturer = manufacturer;
 
 			switch (manufacturer) {
-			case 2:
+			case COMPANY_ID_INTEL:
 				/*
 				 * Intel controllers that support the
 				 * Microsoft vendor extension are using
@@ -4454,7 +4461,7 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
 				 */
 				index_list[index].msft_opcode = 0xFC1E;
 				break;
-			case 29:
+			case COMPANY_ID_QUALCOMM:
 				/*
 				 * Qualcomm controllers that support the
 				 * Microsoft vendor extensions are using
@@ -4462,7 +4469,7 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
 				 */
 				index_list[index].msft_opcode = 0xFD70;
 				break;
-			case 70:
+			case COMPANY_ID_MEDIATEK:
 				/*
 				 * Mediatek controllers that support the
 				 * Microsoft vendor extensions are using
@@ -4470,7 +4477,7 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
 				 */
 				index_list[index].msft_opcode = 0xFD30;
 				break;
-			case 93:
+			case COMPANY_ID_REALTEK:
 				/*
 				 * Realtek controllers that support the
 				 * Microsoft vendor extensions are using
@@ -4478,7 +4485,7 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
 				 */
 				index_list[index].msft_opcode = 0xFCF0;
 				break;
-			case 1521:
+			case COMPANY_ID_LINUX:
 				/*
 				 * Emulator controllers use Linux Foundation as
 				 * manufacturer and support the
@@ -6528,7 +6535,7 @@ static void read_local_version_rsp(uint16_t index, const void *data,
 	print_manufacturer(rsp->manufacturer);
 
 	switch (manufacturer) {
-	case 15:
+	case COMPANY_ID_BROADCOM:
 		print_manufacturer_broadcom(rsp->lmp_subver, rsp->hci_rev);
 		break;
 	}
@@ -10900,11 +10907,11 @@ static const char *current_vendor_str(uint16_t ocf)
 		return "Microsoft";
 
 	switch (manufacturer) {
-	case 2:
+	case COMPANY_ID_INTEL:
 		return "Intel";
-	case 15:
+	case COMPANY_ID_BROADCOM:
 		return "Broadcom";
-	case 93:
+	case COMPANY_ID_REALTEK:
 		return "Realtek";
 	}
 
@@ -10928,9 +10935,9 @@ static const struct vendor_ocf *current_vendor_ocf(uint16_t ocf)
 		return msft_vendor_ocf();
 
 	switch (manufacturer) {
-	case 2:
+	case COMPANY_ID_INTEL:
 		return intel_vendor_ocf(ocf);
-	case 15:
+	case COMPANY_ID_BROADCOM:
 		return broadcom_vendor_ocf(ocf);
 	}
 
@@ -10952,9 +10959,9 @@ static const struct vendor_evt *current_vendor_evt(const void *data,
 		manufacturer = fallback_manufacturer;
 
 	switch (manufacturer) {
-	case 2:
+	case COMPANY_ID_INTEL:
 		return intel_vendor_evt(data, consumed_size);
-	case 15:
+	case COMPANY_ID_BROADCOM:
 		return broadcom_vendor_evt(evt);
 	}
 
@@ -10971,11 +10978,11 @@ static const char *current_vendor_evt_str(void)
 		manufacturer = fallback_manufacturer;
 
 	switch (manufacturer) {
-	case 2:
+	case COMPANY_ID_INTEL:
 		return "Intel";
-	case 15:
+	case COMPANY_ID_BROADCOM:
 		return "Broadcom";
-	case 93:
+	case COMPANY_ID_REALTEK:
 		return "Realtek";
 	}
 
@@ -11116,7 +11123,7 @@ static void remote_version_complete_evt(struct timeval *tv, uint16_t index,
 	print_manufacturer(evt->manufacturer);
 
 	switch (le16_to_cpu(evt->manufacturer)) {
-	case 15:
+	case COMPANY_ID_BROADCOM:
 		print_manufacturer_broadcom(evt->lmp_subver, 0xffff);
 		break;
 	}
@@ -13808,7 +13815,7 @@ void packet_vendor_diag(struct timeval *tv, uint16_t index,
 					"Vendor Diagnostic", NULL, extra_str);
 
 	switch (manufacturer) {
-	case 15:
+	case COMPANY_ID_BROADCOM:
 		broadcom_lm_diag(data, size);
 		break;
 	default:
@@ -16161,7 +16168,7 @@ static void mgmt_print_system_config_tlv(void *data, void *user_data)
 			value = get_u8(entry->value);
 		else if (entry->length == 2)
 			value = get_le16(entry->value);
-		else if (entry->length == 4)
+		else
 			value = get_le32(entry->value);
 		print_field("%s: %u", desc, value);
 	} else {
-- 
2.54.0.rc1.513.gad8abe7a5a-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH Bluez 2/2] monitor: Set msft_opcode on read_local_version_rsp
  2026-04-14 11:11 [PATCH Bluez 1/2] monitor: define manufacturer company IDs Archie Pusaka
@ 2026-04-14 11:11 ` Archie Pusaka
  2026-04-14 12:24 ` [Bluez,1/2] monitor: define manufacturer company IDs bluez.test.bot
  2026-04-14 21:00 ` [PATCH Bluez 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Archie Pusaka @ 2026-04-14 11:11 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz; +Cc: CrosBT Upstreaming, Archie Pusaka

From: Archie Pusaka <apusaka@chromium.org>

Aside from INDEX_INFO, we can also receive manufacturer company ID
when receiving read_local_version_rsp, so we should also try setting
the msft_opcode there.
---

 monitor/packet.c | 68 +++++++++++++++++-------------------------------
 1 file changed, 24 insertions(+), 44 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index 30cab1a2f..ff0b1cac2 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -4359,6 +4359,24 @@ static int addr2str(const uint8_t *addr, char *str)
 			addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]);
 }
 
+static int get_msft_opcode(uint16_t manufacturer) {
+	switch (manufacturer) {
+	case COMPANY_ID_INTEL:
+		return 0xFC1E;
+	case COMPANY_ID_QUALCOMM:
+		return 0xFD70;
+	case COMPANY_ID_MEDIATEK:
+		return 0xFD30;
+	case COMPANY_ID_REALTEK:
+		return 0xFCF0;
+	case COMPANY_ID_LINUX:
+		return 0xFC1E;
+	default:
+		return BT_HCI_CMD_NOP;
+	}
+
+}
+
 void packet_monitor(struct timeval *tv, struct ucred *cred,
 					uint16_t index, uint16_t opcode,
 					const void *data, uint16_t size)
@@ -4451,50 +4469,8 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
 		if (index < MAX_INDEX) {
 			memcpy(index_list[index].bdaddr, ii->bdaddr, 6);
 			index_list[index].manufacturer = manufacturer;
-
-			switch (manufacturer) {
-			case COMPANY_ID_INTEL:
-				/*
-				 * Intel controllers that support the
-				 * Microsoft vendor extension are using
-				 * 0xFC1E for VsMsftOpCode.
-				 */
-				index_list[index].msft_opcode = 0xFC1E;
-				break;
-			case COMPANY_ID_QUALCOMM:
-				/*
-				 * Qualcomm controllers that support the
-				 * Microsoft vendor extensions are using
-				 * 0xFD70 for VsMsftOpCode.
-				 */
-				index_list[index].msft_opcode = 0xFD70;
-				break;
-			case COMPANY_ID_MEDIATEK:
-				/*
-				 * Mediatek controllers that support the
-				 * Microsoft vendor extensions are using
-				 * 0xFD30 for VsMsftOpCode.
-				 */
-				index_list[index].msft_opcode = 0xFD30;
-				break;
-			case COMPANY_ID_REALTEK:
-				/*
-				 * Realtek controllers that support the
-				 * Microsoft vendor extensions are using
-				 * 0xFCF0 for VsMsftOpCode.
-				 */
-				index_list[index].msft_opcode = 0xFCF0;
-				break;
-			case COMPANY_ID_LINUX:
-				/*
-				 * Emulator controllers use Linux Foundation as
-				 * manufacturer and support the
-				 * Microsoft vendor extensions using
-				 * 0xFC1E for VsMsftOpCode.
-				 */
-				index_list[index].msft_opcode = 0xFC1E;
-				break;
-			}
+			index_list[index].msft_opcode =
+				get_msft_opcode(manufacturer);
 		}
 
 		addr2str(ii->bdaddr, str);
@@ -6530,6 +6506,10 @@ static void read_local_version_rsp(uint16_t index, const void *data,
 		}
 
 		index_list[index_current].manufacturer = manufacturer;
+		if (index_list[index_current].msft_opcode == BT_HCI_CMD_NOP) {
+			index_list[index_current].msft_opcode =
+				get_msft_opcode(manufacturer);
+		}
 	}
 
 	print_manufacturer(rsp->manufacturer);
-- 
2.54.0.rc1.513.gad8abe7a5a-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [Bluez,1/2] monitor: define manufacturer company IDs
  2026-04-14 11:11 [PATCH Bluez 1/2] monitor: define manufacturer company IDs Archie Pusaka
  2026-04-14 11:11 ` [PATCH Bluez 2/2] monitor: Set msft_opcode on read_local_version_rsp Archie Pusaka
@ 2026-04-14 12:24 ` bluez.test.bot
  2026-04-14 21:00 ` [PATCH Bluez 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-04-14 12:24 UTC (permalink / raw)
  To: linux-bluetooth, apusaka

[-- Attachment #1: Type: text/plain, Size: 2687 bytes --]

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=1081093

---Test result---

Test Summary:
CheckPatch                    FAIL      1.22 seconds
GitLint                       PASS      0.54 seconds
BuildEll                      PASS      17.61 seconds
BluezMake                     PASS      603.42 seconds
MakeCheck                     PASS      18.55 seconds
MakeDistcheck                 PASS      220.26 seconds
CheckValgrind                 PASS      273.63 seconds
CheckSmatch                   WARNING   305.22 seconds
bluezmakeextell               PASS      166.13 seconds
IncrementalBuild              FAIL      0.25 seconds
ScanBuild                     PASS      902.35 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[Bluez,2/2] monitor: Set msft_opcode on read_local_version_rsp
ERROR:OPEN_BRACE: open brace '{' following function definitions go on the next line
#108: FILE: monitor/packet.c:4362:
+static int get_msft_opcode(uint16_t manufacturer) {

/github/workspace/src/patch/14524190.patch total: 1 errors, 0 warnings, 86 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/patch/14524190.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:2000:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3866:52: warning: array of flexible structuresmonitor/bt.h:3854:40: warning: array of flexible structuresmonitor/packet.c:2000:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3866:52: warning: array of flexible structuresmonitor/bt.h:3854:40: warning: array of flexible structures
##############################
Test: IncrementalBuild - FAIL
Desc: Incremental build with the patches in the series
Output:

fatal: previous rebase directory .git/rebase-apply still exists but mbox given.


https://github.com/bluez/bluez/pull/2031

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH Bluez 1/2] monitor: define manufacturer company IDs
  2026-04-14 11:11 [PATCH Bluez 1/2] monitor: define manufacturer company IDs Archie Pusaka
  2026-04-14 11:11 ` [PATCH Bluez 2/2] monitor: Set msft_opcode on read_local_version_rsp Archie Pusaka
  2026-04-14 12:24 ` [Bluez,1/2] monitor: define manufacturer company IDs bluez.test.bot
@ 2026-04-14 21:00 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2026-04-14 21:00 UTC (permalink / raw)
  To: Archie Pusaka
  Cc: linux-bluetooth, luiz.dentz, chromeos-bluetooth-upstreaming,
	apusaka

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 14 Apr 2026 19:11:10 +0800 you wrote:
> From: Archie Pusaka <apusaka@chromium.org>
> 
> Define company IDs to make it more readable.
> Also remove an unnecessary if that could cause uninitialized variable
> warning.
> ---
> 
> [...]

Here is the summary with links:
  - [Bluez,1/2] monitor: define manufacturer company IDs
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=babc5699226b
  - [Bluez,2/2] monitor: Set msft_opcode on read_local_version_rsp
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=510623fb53b5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-14 21:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 11:11 [PATCH Bluez 1/2] monitor: define manufacturer company IDs Archie Pusaka
2026-04-14 11:11 ` [PATCH Bluez 2/2] monitor: Set msft_opcode on read_local_version_rsp Archie Pusaka
2026-04-14 12:24 ` [Bluez,1/2] monitor: define manufacturer company IDs bluez.test.bot
2026-04-14 21:00 ` [PATCH Bluez 1/2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox