2024-04-12 16:28:52

by quic_zijuhu

[permalink] [raw]
Subject: [PATCH BlueZ v1] tools/btattach: Add support for more QCA soc types

Tool btattach currently only supports QCA default soc type
QCA_ROME, this change adds support for all other QCA soc types
by adding a option to specify soc type.
---
tools/btattach.c | 29 ++++++++++++++++++++++++-----
tools/btattach.rst | 2 ++
tools/hciattach.h | 2 ++
3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/tools/btattach.c b/tools/btattach.c
index 4ce1be78d69c..024b0c7a289c 100644
--- a/tools/btattach.c
+++ b/tools/btattach.c
@@ -97,7 +97,8 @@ static void local_version_callback(const void *data, uint8_t size,
}

static int attach_proto(const char *path, unsigned int proto,
- unsigned int speed, bool flowctl, unsigned int flags)
+ unsigned int speed, bool flowctl, unsigned int flags,
+ unsigned long soc_type)
{
int fd, dev_id;

@@ -111,6 +112,16 @@ static int attach_proto(const char *path, unsigned int proto,
return -1;
}

+ if ((proto == HCI_UART_QCA) && (soc_type > 0)) {
+ if (ioctl(fd, HCIUARTSETPROTODATA, soc_type) < 0) {
+ fprintf(stderr,
+ "Failed to set soc_type(%lu) for protocol qca\n",
+ soc_type);
+ close(fd);
+ return -1;
+ }
+ }
+
if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
perror("Failed to set protocol");
close(fd);
@@ -181,6 +192,7 @@ static void usage(void)
"\t-A, --amp <device> Attach AMP controller\n"
"\t-P, --protocol <proto> Specify protocol type\n"
"\t-S, --speed <baudrate> Specify which baudrate to use\n"
+ "\t-T, --type <soc_type> Specify soc_type for protocol qca\n"
"\t-N, --noflowctl Disable flow control\n"
"\t-h, --help Show help options\n");
}
@@ -190,6 +202,7 @@ static const struct option main_options[] = {
{ "amp", required_argument, NULL, 'A' },
{ "protocol", required_argument, NULL, 'P' },
{ "speed", required_argument, NULL, 'S' },
+ { "type", required_argument, NULL, 'T' },
{ "noflowctl",no_argument, NULL, 'N' },
{ "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
@@ -221,12 +234,13 @@ int main(int argc, char *argv[])
bool flowctl = true, raw_device = false;
int exit_status, count = 0, proto_id = HCI_UART_H4;
unsigned int speed = B115200;
+ unsigned long soc_type = 0;

for (;;) {
int opt;

- opt = getopt_long(argc, argv, "B:A:P:S:NRvh",
- main_options, NULL);
+ opt = getopt_long(argc, argv, "B:A:P:S:T:NRvh",
+ main_options, NULL);
if (opt < 0)
break;

@@ -237,6 +251,9 @@ int main(int argc, char *argv[])
case 'A':
amp_path = optarg;
break;
+ case 'T':
+ soc_type = strtoul(optarg, NULL, 0);
+ break;
case 'P':
proto = optarg;
break;
@@ -298,7 +315,8 @@ int main(int argc, char *argv[])
if (raw_device)
flags = (1 << HCI_UART_RAW_DEVICE);

- fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags);
+ fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags,
+ soc_type);
if (fd >= 0) {
mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
count++;
@@ -317,7 +335,8 @@ int main(int argc, char *argv[])
if (raw_device)
flags = (1 << HCI_UART_RAW_DEVICE);

- fd = attach_proto(amp_path, proto_id, speed, flowctl, flags);
+ fd = attach_proto(amp_path, proto_id, speed, flowctl, flags,
+ soc_type);
if (fd >= 0) {
mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
count++;
diff --git a/tools/btattach.rst b/tools/btattach.rst
index 787d5c49e3bb..4aad3b915641 100644
--- a/tools/btattach.rst
+++ b/tools/btattach.rst
@@ -62,6 +62,8 @@ OPTIONS

-S baudrate, --speed baudrate Specify wich baudrate to use

+-T soc_type, --type soc_type Specify soc_type for protocol qca
+
-N, --noflowctl Disable flow control

-v, --version Show version
diff --git a/tools/hciattach.h b/tools/hciattach.h
index dfa4c1e7abe7..998a2a9a8460 100644
--- a/tools/hciattach.h
+++ b/tools/hciattach.h
@@ -19,6 +19,8 @@
#define HCIUARTGETDEVICE _IOR('U', 202, int)
#define HCIUARTSETFLAGS _IOW('U', 203, int)
#define HCIUARTGETFLAGS _IOR('U', 204, int)
+#define HCIUARTSETPROTODATA _IOW('U', 205, unsigned long)
+

#define HCI_UART_H4 0
#define HCI_UART_BCSP 1
--
2.7.4



2024-04-12 18:02:55

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ,v1] tools/btattach: Add support for more QCA soc types

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

---Test result---

Test Summary:
CheckPatch PASS 0.47 seconds
GitLint PASS 0.31 seconds
BuildEll PASS 24.16 seconds
BluezMake PASS 1661.75 seconds
MakeCheck PASS 13.36 seconds
MakeDistcheck PASS 177.85 seconds
CheckValgrind PASS 248.58 seconds
CheckSmatch PASS 355.23 seconds
bluezmakeextell PASS 120.37 seconds
IncrementalBuild PASS 1459.70 seconds
ScanBuild PASS 1035.21 seconds



---
Regards,
Linux Bluetooth

2024-04-12 20:11:03

by Wren Turkal

[permalink] [raw]
Subject: Re: [PATCH BlueZ v1] tools/btattach: Add support for more QCA soc types

On 4/12/24 9:26 AM, Zijun Hu wrote:
> Tool btattach currently only supports QCA default soc type
> QCA_ROME, this change adds support for all other QCA soc types
> by adding a option to specify soc type.
> ---
> tools/btattach.c | 29 ++++++++++++++++++++++++-----
> tools/btattach.rst | 2 ++
> tools/hciattach.h | 2 ++
> 3 files changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/tools/btattach.c b/tools/btattach.c
> index 4ce1be78d69c..024b0c7a289c 100644
> --- a/tools/btattach.c
> +++ b/tools/btattach.c
> @@ -97,7 +97,8 @@ static void local_version_callback(const void *data, uint8_t size,
> }
>
> static int attach_proto(const char *path, unsigned int proto,
> - unsigned int speed, bool flowctl, unsigned int flags)
> + unsigned int speed, bool flowctl, unsigned int flags,
> + unsigned long soc_type)
> {
> int fd, dev_id;
>
> @@ -111,6 +112,16 @@ static int attach_proto(const char *path, unsigned int proto,
> return -1;
> }
>
> + if ((proto == HCI_UART_QCA) && (soc_type > 0)) {
> + if (ioctl(fd, HCIUARTSETPROTODATA, soc_type) < 0) {
> + fprintf(stderr,
> + "Failed to set soc_type(%lu) for protocol qca\n",
> + soc_type);
> + close(fd);
> + return -1;
> + }
> + }
> +
> if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
> perror("Failed to set protocol");
> close(fd);
> @@ -181,6 +192,7 @@ static void usage(void)
> "\t-A, --amp <device> Attach AMP controller\n"
> "\t-P, --protocol <proto> Specify protocol type\n"
> "\t-S, --speed <baudrate> Specify which baudrate to use\n"
> + "\t-T, --type <soc_type> Specify soc_type for protocol qca\n"
> "\t-N, --noflowctl Disable flow control\n"
> "\t-h, --help Show help options\n");
> }
> @@ -190,6 +202,7 @@ static const struct option main_options[] = {
> { "amp", required_argument, NULL, 'A' },
> { "protocol", required_argument, NULL, 'P' },
> { "speed", required_argument, NULL, 'S' },
> + { "type", required_argument, NULL, 'T' },

I am guessing this means that there is no way to determine the soc from
the kernel without the assist of the IOCTL? I also see this is a
required parm. Is this not something that can use something like a
devicetree for discovery so that the type of soc can be a property of
the system instead of being manually specified?

> { "noflowctl",no_argument, NULL, 'N' },
> { "version", no_argument, NULL, 'v' },
> { "help", no_argument, NULL, 'h' },
> @@ -221,12 +234,13 @@ int main(int argc, char *argv[])
> bool flowctl = true, raw_device = false;
> int exit_status, count = 0, proto_id = HCI_UART_H4;
> unsigned int speed = B115200;
> + unsigned long soc_type = 0;
>
> for (;;) {
> int opt;
>
> - opt = getopt_long(argc, argv, "B:A:P:S:NRvh",
> - main_options, NULL);
> + opt = getopt_long(argc, argv, "B:A:P:S:T:NRvh",
> + main_options, NULL);
> if (opt < 0)
> break;
>
> @@ -237,6 +251,9 @@ int main(int argc, char *argv[])
> case 'A':
> amp_path = optarg;
> break;
> + case 'T':
> + soc_type = strtoul(optarg, NULL, 0);
> + break;
> case 'P':
> proto = optarg;
> break;
> @@ -298,7 +315,8 @@ int main(int argc, char *argv[])
> if (raw_device)
> flags = (1 << HCI_UART_RAW_DEVICE);
>
> - fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags);
> + fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags,
> + soc_type);
> if (fd >= 0) {
> mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
> count++;
> @@ -317,7 +335,8 @@ int main(int argc, char *argv[])
> if (raw_device)
> flags = (1 << HCI_UART_RAW_DEVICE);
>
> - fd = attach_proto(amp_path, proto_id, speed, flowctl, flags);
> + fd = attach_proto(amp_path, proto_id, speed, flowctl, flags,
> + soc_type);
> if (fd >= 0) {
> mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
> count++;
> diff --git a/tools/btattach.rst b/tools/btattach.rst
> index 787d5c49e3bb..4aad3b915641 100644
> --- a/tools/btattach.rst
> +++ b/tools/btattach.rst
> @@ -62,6 +62,8 @@ OPTIONS
>
> -S baudrate, --speed baudrate Specify wich baudrate to use
>
> +-T soc_type, --type soc_type Specify soc_type for protocol qca
> +
> -N, --noflowctl Disable flow control
>
> -v, --version Show version
> diff --git a/tools/hciattach.h b/tools/hciattach.h
> index dfa4c1e7abe7..998a2a9a8460 100644
> --- a/tools/hciattach.h
> +++ b/tools/hciattach.h
> @@ -19,6 +19,8 @@
> #define HCIUARTGETDEVICE _IOR('U', 202, int)
> #define HCIUARTSETFLAGS _IOW('U', 203, int)
> #define HCIUARTGETFLAGS _IOR('U', 204, int)
> +#define HCIUARTSETPROTODATA _IOW('U', 205, unsigned long)
> +
>
> #define HCI_UART_H4 0
> #define HCI_UART_BCSP 1

--
You're more amazing than you think!

2024-04-13 02:44:32

by quic_zijuhu

[permalink] [raw]
Subject: Re: [PATCH BlueZ v1] tools/btattach: Add support for more QCA soc types

On 4/13/2024 4:10 AM, Wren Turkal wrote:
> On 4/12/24 9:26 AM, Zijun Hu wrote:
>> Tool btattach currently only supports QCA default soc type
>> QCA_ROME, this change adds support for all other QCA soc types
>> by adding a option to specify soc type.
>> ---
>>   tools/btattach.c   | 29 ++++++++++++++++++++++++-----
>>   tools/btattach.rst |  2 ++
>>   tools/hciattach.h  |  2 ++
>>   3 files changed, 28 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/btattach.c b/tools/btattach.c
>> index 4ce1be78d69c..024b0c7a289c 100644
>> --- a/tools/btattach.c
>> +++ b/tools/btattach.c
>> @@ -97,7 +97,8 @@ static void local_version_callback(const void *data, uint8_t size,
>>   }
>>     static int attach_proto(const char *path, unsigned int proto,
>> -            unsigned int speed, bool flowctl, unsigned int flags)
>> +            unsigned int speed, bool flowctl, unsigned int flags,
>> +            unsigned long soc_type)
>>   {
>>       int fd, dev_id;
>>   @@ -111,6 +112,16 @@ static int attach_proto(const char *path, unsigned int proto,
>>           return -1;
>>       }
>>   +    if ((proto == HCI_UART_QCA) && (soc_type > 0)) {
>> +        if (ioctl(fd, HCIUARTSETPROTODATA, soc_type) < 0) {
>> +            fprintf(stderr,
>> +                "Failed to set soc_type(%lu) for protocol qca\n",
>> +                soc_type);
>> +            close(fd);
>> +            return -1;
>> +        }
>> +    }
>> +
>>       if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
>>           perror("Failed to set protocol");
>>           close(fd);
>> @@ -181,6 +192,7 @@ static void usage(void)
>>           "\t-A, --amp <device>     Attach AMP controller\n"
>>           "\t-P, --protocol <proto> Specify protocol type\n"
>>           "\t-S, --speed <baudrate> Specify which baudrate to use\n"
>> +        "\t-T, --type <soc_type>  Specify soc_type for protocol qca\n"
>>           "\t-N, --noflowctl        Disable flow control\n"
>>           "\t-h, --help             Show help options\n");
>>   }
>> @@ -190,6 +202,7 @@ static const struct option main_options[] = {
>>       { "amp",      required_argument, NULL, 'A' },
>>       { "protocol", required_argument, NULL, 'P' },
>>       { "speed",    required_argument, NULL, 'S' },
>> +    { "type",     required_argument, NULL, 'T' },
>
> I am guessing this means that there is no way to determine the soc from the kernel without the assist of the IOCTL? I also see this is a required parm. Is this not something that can use something like a devicetree for discovery so that the type of soc can be a property of the system instead of being manually specified?
>
yes for tool btattch scenario. tool btattch is mainly used before the final board configuration phase(change DT|APCI to enabel BT), so it can't get such soc type info from board configuration.
for tool btattach, it doesn't need to touch any system configuration and is mainly used for variant evaluation tests before the final product implementation phase

let me take below process to explain its usage scenario.
Customer often buys a BT module from a vendor for BT evaluation, the BT module have BT chip embedded and are externally powered, the module also has a BT UART converted mini usb port,
they connects the BT module to generic ubntu PC by a USB cable, then they run tool btattach at the machine to enable BT and perform variants BT tests, when the evaluation results is expected,
they maybe buy the embedded chip and integrated into there target product's PCB, then change and compile DT to enable BT formally.

thanks
>>       { "noflowctl",no_argument,       NULL, 'N' },
>>       { "version",  no_argument,       NULL, 'v' },
>>       { "help",     no_argument,       NULL, 'h' },
>> @@ -221,12 +234,13 @@ int main(int argc, char *argv[])
>>       bool flowctl = true, raw_device = false;
>>       int exit_status, count = 0, proto_id = HCI_UART_H4;
>>       unsigned int speed = B115200;
>> +    unsigned long soc_type = 0;
>>         for (;;) {
>>           int opt;
>>   -        opt = getopt_long(argc, argv, "B:A:P:S:NRvh",
>> -                        main_options, NULL);
>> +        opt = getopt_long(argc, argv, "B:A:P:S:T:NRvh",
>> +                  main_options, NULL);
>>           if (opt < 0)
>>               break;
>>   @@ -237,6 +251,9 @@ int main(int argc, char *argv[])
>>           case 'A':
>>               amp_path = optarg;
>>               break;
>> +        case 'T':
>> +            soc_type = strtoul(optarg, NULL, 0);
>> +            break;
>>           case 'P':
>>               proto = optarg;
>>               break;
>> @@ -298,7 +315,8 @@ int main(int argc, char *argv[])
>>           if (raw_device)
>>               flags = (1 << HCI_UART_RAW_DEVICE);
>>   -        fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags);
>> +        fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags,
>> +                  soc_type);
>>           if (fd >= 0) {
>>               mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
>>               count++;
>> @@ -317,7 +335,8 @@ int main(int argc, char *argv[])
>>           if (raw_device)
>>               flags = (1 << HCI_UART_RAW_DEVICE);
>>   -        fd = attach_proto(amp_path, proto_id, speed, flowctl, flags);
>> +        fd = attach_proto(amp_path, proto_id, speed, flowctl, flags,
>> +                  soc_type);
>>           if (fd >= 0) {
>>               mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
>>               count++;
>> diff --git a/tools/btattach.rst b/tools/btattach.rst
>> index 787d5c49e3bb..4aad3b915641 100644
>> --- a/tools/btattach.rst
>> +++ b/tools/btattach.rst
>> @@ -62,6 +62,8 @@ OPTIONS
>>     -S baudrate, --speed baudrate       Specify wich baudrate to use
>>   +-T soc_type, --type soc_type        Specify soc_type for protocol qca
>> +
>>   -N, --noflowctl            Disable flow control
>>     -v, --version              Show version
>> diff --git a/tools/hciattach.h b/tools/hciattach.h
>> index dfa4c1e7abe7..998a2a9a8460 100644
>> --- a/tools/hciattach.h
>> +++ b/tools/hciattach.h
>> @@ -19,6 +19,8 @@
>>   #define HCIUARTGETDEVICE    _IOR('U', 202, int)
>>   #define HCIUARTSETFLAGS        _IOW('U', 203, int)
>>   #define HCIUARTGETFLAGS        _IOR('U', 204, int)
>> +#define HCIUARTSETPROTODATA    _IOW('U', 205, unsigned long)
>> +
>>     #define HCI_UART_H4    0
>>   #define HCI_UART_BCSP    1
>


2024-04-13 03:12:42

by Wren Turkal

[permalink] [raw]
Subject: Re: [PATCH BlueZ v1] tools/btattach: Add support for more QCA soc types

On 4/12/24 7:44 PM, quic_zijuhu wrote:
> On 4/13/2024 4:10 AM, Wren Turkal wrote:
>> On 4/12/24 9:26 AM, Zijun Hu wrote:
>>> Tool btattach currently only supports QCA default soc type
>>> QCA_ROME, this change adds support for all other QCA soc types
>>> by adding a option to specify soc type.
>>> ---
>>>   tools/btattach.c   | 29 ++++++++++++++++++++++++-----
>>>   tools/btattach.rst |  2 ++
>>>   tools/hciattach.h  |  2 ++
>>>   3 files changed, 28 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/tools/btattach.c b/tools/btattach.c
>>> index 4ce1be78d69c..024b0c7a289c 100644
>>> --- a/tools/btattach.c
>>> +++ b/tools/btattach.c
>>> @@ -97,7 +97,8 @@ static void local_version_callback(const void *data, uint8_t size,
>>>   }
>>>     static int attach_proto(const char *path, unsigned int proto,
>>> -            unsigned int speed, bool flowctl, unsigned int flags)
>>> +            unsigned int speed, bool flowctl, unsigned int flags,
>>> +            unsigned long soc_type)
>>>   {
>>>       int fd, dev_id;
>>>   @@ -111,6 +112,16 @@ static int attach_proto(const char *path, unsigned int proto,
>>>           return -1;
>>>       }
>>>   +    if ((proto == HCI_UART_QCA) && (soc_type > 0)) {
>>> +        if (ioctl(fd, HCIUARTSETPROTODATA, soc_type) < 0) {
>>> +            fprintf(stderr,
>>> +                "Failed to set soc_type(%lu) for protocol qca\n",
>>> +                soc_type);
>>> +            close(fd);
>>> +            return -1;
>>> +        }
>>> +    }
>>> +
>>>       if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
>>>           perror("Failed to set protocol");
>>>           close(fd);
>>> @@ -181,6 +192,7 @@ static void usage(void)
>>>           "\t-A, --amp <device>     Attach AMP controller\n"
>>>           "\t-P, --protocol <proto> Specify protocol type\n"
>>>           "\t-S, --speed <baudrate> Specify which baudrate to use\n"
>>> +        "\t-T, --type <soc_type>  Specify soc_type for protocol qca\n"
>>>           "\t-N, --noflowctl        Disable flow control\n"
>>>           "\t-h, --help             Show help options\n");
>>>   }
>>> @@ -190,6 +202,7 @@ static const struct option main_options[] = {
>>>       { "amp",      required_argument, NULL, 'A' },
>>>       { "protocol", required_argument, NULL, 'P' },
>>>       { "speed",    required_argument, NULL, 'S' },
>>> +    { "type",     required_argument, NULL, 'T' },
>>
>> I am guessing this means that there is no way to determine the soc from the kernel without the assist of the IOCTL? I also see this is a required parm. Is this not something that can use something like a devicetree for discovery so that the type of soc can be a property of the system instead of being manually specified?
>>
> yes for tool btattch scenario. tool btattch is mainly used before the final board configuration phase(change DT|APCI to enabel BT), so it can't get such soc type info from board configuration.
> for tool btattach, it doesn't need to touch any system configuration and is mainly used for variant evaluation tests before the final product implementation phase
>
> let me take below process to explain its usage scenario.
> Customer often buys a BT module from a vendor for BT evaluation, the BT module have BT chip embedded and are externally powered, the module also has a BT UART converted mini usb port,
> they connects the BT module to generic ubntu PC by a USB cable, then they run tool btattach at the machine to enable BT and perform variants BT tests, when the evaluation results is expected,
> they maybe buy the embedded chip and integrated into there target product's PCB, then change and compile DT to enable BT formally.
Thanks for the explanation for a total newb. This is really cool to
learn about. Really appreciate your taking the time to help me out.

> thanks
>>>       { "noflowctl",no_argument,       NULL, 'N' },
>>>       { "version",  no_argument,       NULL, 'v' },
>>>       { "help",     no_argument,       NULL, 'h' },
>>> @@ -221,12 +234,13 @@ int main(int argc, char *argv[])
>>>       bool flowctl = true, raw_device = false;
>>>       int exit_status, count = 0, proto_id = HCI_UART_H4;
>>>       unsigned int speed = B115200;
>>> +    unsigned long soc_type = 0;
>>>         for (;;) {
>>>           int opt;
>>>   -        opt = getopt_long(argc, argv, "B:A:P:S:NRvh",
>>> -                        main_options, NULL);
>>> +        opt = getopt_long(argc, argv, "B:A:P:S:T:NRvh",
>>> +                  main_options, NULL);
>>>           if (opt < 0)
>>>               break;
>>>   @@ -237,6 +251,9 @@ int main(int argc, char *argv[])
>>>           case 'A':
>>>               amp_path = optarg;
>>>               break;
>>> +        case 'T':
>>> +            soc_type = strtoul(optarg, NULL, 0);
>>> +            break;
>>>           case 'P':
>>>               proto = optarg;
>>>               break;
>>> @@ -298,7 +315,8 @@ int main(int argc, char *argv[])
>>>           if (raw_device)
>>>               flags = (1 << HCI_UART_RAW_DEVICE);
>>>   -        fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags);
>>> +        fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags,
>>> +                  soc_type);
>>>           if (fd >= 0) {
>>>               mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
>>>               count++;
>>> @@ -317,7 +335,8 @@ int main(int argc, char *argv[])
>>>           if (raw_device)
>>>               flags = (1 << HCI_UART_RAW_DEVICE);
>>>   -        fd = attach_proto(amp_path, proto_id, speed, flowctl, flags);
>>> +        fd = attach_proto(amp_path, proto_id, speed, flowctl, flags,
>>> +                  soc_type);
>>>           if (fd >= 0) {
>>>               mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
>>>               count++;
>>> diff --git a/tools/btattach.rst b/tools/btattach.rst
>>> index 787d5c49e3bb..4aad3b915641 100644
>>> --- a/tools/btattach.rst
>>> +++ b/tools/btattach.rst
>>> @@ -62,6 +62,8 @@ OPTIONS
>>>     -S baudrate, --speed baudrate       Specify wich baudrate to use
>>>   +-T soc_type, --type soc_type        Specify soc_type for protocol qca
>>> +
>>>   -N, --noflowctl            Disable flow control
>>>     -v, --version              Show version
>>> diff --git a/tools/hciattach.h b/tools/hciattach.h
>>> index dfa4c1e7abe7..998a2a9a8460 100644
>>> --- a/tools/hciattach.h
>>> +++ b/tools/hciattach.h
>>> @@ -19,6 +19,8 @@
>>>   #define HCIUARTGETDEVICE    _IOR('U', 202, int)
>>>   #define HCIUARTSETFLAGS        _IOW('U', 203, int)
>>>   #define HCIUARTGETFLAGS        _IOR('U', 204, int)
>>> +#define HCIUARTSETPROTODATA    _IOW('U', 205, unsigned long)
>>> +
>>>     #define HCI_UART_H4    0
>>>   #define HCI_UART_BCSP    1
>>
>

--
You're more amazing than you think!

2024-04-18 03:39:36

by quic_zijuhu

[permalink] [raw]
Subject: [PATCH BlueZ v2] tools/btattach: Add support for more QCA soc types

Tool btattach currently only supports QCA default soc type
QCA_ROME, this change adds support for all other QCA soc types
by adding a option to specify soc type.
---
V1->V2: rename variable names

tools/btattach.c | 29 ++++++++++++++++++++++++-----
tools/btattach.rst | 2 ++
tools/hciattach.h | 2 ++
3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/tools/btattach.c b/tools/btattach.c
index 4ce1be78d69c..08c648f44248 100644
--- a/tools/btattach.c
+++ b/tools/btattach.c
@@ -97,7 +97,8 @@ static void local_version_callback(const void *data, uint8_t size,
}

static int attach_proto(const char *path, unsigned int proto,
- unsigned int speed, bool flowctl, unsigned int flags)
+ unsigned int speed, bool flowctl, unsigned int flags,
+ unsigned long proto_data)
{
int fd, dev_id;

@@ -111,6 +112,16 @@ static int attach_proto(const char *path, unsigned int proto,
return -1;
}

+ if ((proto == HCI_UART_QCA) && (proto_data > 0)) {
+ if (ioctl(fd, HCIUARTSETPROTODATA, proto_data) < 0) {
+ fprintf(stderr,
+ "Failed to set proto_data(%lu) for protocol qca\n",
+ proto_data);
+ close(fd);
+ return -1;
+ }
+ }
+
if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) {
perror("Failed to set protocol");
close(fd);
@@ -181,6 +192,7 @@ static void usage(void)
"\t-A, --amp <device> Attach AMP controller\n"
"\t-P, --protocol <proto> Specify protocol type\n"
"\t-S, --speed <baudrate> Specify which baudrate to use\n"
+ "\t-T, --type <soc_type> Specify soc type for protocol qca\n"
"\t-N, --noflowctl Disable flow control\n"
"\t-h, --help Show help options\n");
}
@@ -190,6 +202,7 @@ static const struct option main_options[] = {
{ "amp", required_argument, NULL, 'A' },
{ "protocol", required_argument, NULL, 'P' },
{ "speed", required_argument, NULL, 'S' },
+ { "type", required_argument, NULL, 'T' },
{ "noflowctl",no_argument, NULL, 'N' },
{ "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
@@ -221,12 +234,13 @@ int main(int argc, char *argv[])
bool flowctl = true, raw_device = false;
int exit_status, count = 0, proto_id = HCI_UART_H4;
unsigned int speed = B115200;
+ unsigned long soc_type = 0;

for (;;) {
int opt;

- opt = getopt_long(argc, argv, "B:A:P:S:NRvh",
- main_options, NULL);
+ opt = getopt_long(argc, argv, "B:A:P:S:T:NRvh",
+ main_options, NULL);
if (opt < 0)
break;

@@ -237,6 +251,9 @@ int main(int argc, char *argv[])
case 'A':
amp_path = optarg;
break;
+ case 'T':
+ soc_type = strtoul(optarg, NULL, 0);
+ break;
case 'P':
proto = optarg;
break;
@@ -298,7 +315,8 @@ int main(int argc, char *argv[])
if (raw_device)
flags = (1 << HCI_UART_RAW_DEVICE);

- fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags);
+ fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags,
+ soc_type);
if (fd >= 0) {
mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
count++;
@@ -317,7 +335,8 @@ int main(int argc, char *argv[])
if (raw_device)
flags = (1 << HCI_UART_RAW_DEVICE);

- fd = attach_proto(amp_path, proto_id, speed, flowctl, flags);
+ fd = attach_proto(amp_path, proto_id, speed, flowctl, flags,
+ soc_type);
if (fd >= 0) {
mainloop_add_fd(fd, 0, uart_callback, NULL, NULL);
count++;
diff --git a/tools/btattach.rst b/tools/btattach.rst
index 787d5c49e3bb..8f554a38181f 100644
--- a/tools/btattach.rst
+++ b/tools/btattach.rst
@@ -62,6 +62,8 @@ OPTIONS

-S baudrate, --speed baudrate Specify wich baudrate to use

+-T soc_type, --type soc_type Specify soc type for protocol qca
+
-N, --noflowctl Disable flow control

-v, --version Show version
diff --git a/tools/hciattach.h b/tools/hciattach.h
index dfa4c1e7abe7..998a2a9a8460 100644
--- a/tools/hciattach.h
+++ b/tools/hciattach.h
@@ -19,6 +19,8 @@
#define HCIUARTGETDEVICE _IOR('U', 202, int)
#define HCIUARTSETFLAGS _IOW('U', 203, int)
#define HCIUARTGETFLAGS _IOR('U', 204, int)
+#define HCIUARTSETPROTODATA _IOW('U', 205, unsigned long)
+

#define HCI_UART_H4 0
#define HCI_UART_BCSP 1
--
2.7.4


2024-04-18 05:40:10

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ,v2] tools/btattach: Add support for more QCA soc types

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

---Test result---

Test Summary:
CheckPatch PASS 0.46 seconds
GitLint PASS 0.31 seconds
BuildEll PASS 24.35 seconds
BluezMake PASS 1651.99 seconds
MakeCheck PASS 13.44 seconds
MakeDistcheck PASS 176.71 seconds
CheckValgrind PASS 246.94 seconds
CheckSmatch PASS 348.94 seconds
bluezmakeextell PASS 119.09 seconds
IncrementalBuild PASS 1406.00 seconds
ScanBuild PASS 1020.09 seconds



---
Regards,
Linux Bluetooth