2021-12-09 06:48:24

by Sai Teja Aluvala

[permalink] [raw]
Subject: [PATCH v2] Bluetooth: btqca: sequential validation

This change will have sequential validation support
& patch config command is added

Signed-off-by: Sai Teja Aluvala <[email protected]>
---
drivers/bluetooth/btqca.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
drivers/bluetooth/btqca.h | 2 ++
2 files changed, 52 insertions(+)

diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c
index be04d74..633a24c 100644
--- a/drivers/bluetooth/btqca.c
+++ b/drivers/bluetooth/btqca.c
@@ -141,6 +141,53 @@ static int qca_read_fw_build_info(struct hci_dev *hdev)
return err;
}

+static int qca_send_patch_config_cmd(struct hci_dev *hdev)
+{
+ struct sk_buff *skb;
+ int err = 0;
+ u8 cmd[] = {EDL_PATCH_CONFIG_CMD, 0x01, 0, 0, 0};
+ u8 rlen = 0x02;
+ struct edl_event_hdr *edl;
+ u8 rtype = EDL_PATCH_CONFIG_CMD;
+
+ bt_dev_dbg(hdev, "QCA Patch config");
+
+ skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, sizeof(cmd),
+ cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
+ if (IS_ERR(skb)) {
+ err = PTR_ERR(skb);
+ bt_dev_err(hdev, "Sending QCA Patch config failed (%d)", err);
+ return err;
+ }
+
+ if (skb->len != rlen) {
+ bt_dev_err(hdev, "QCA Patch config cmd size mismatch len %d", skb->len);
+ err = -EILSEQ;
+ goto out;
+ }
+
+ edl = (struct edl_event_hdr *)(skb->data);
+ if (!edl) {
+ bt_dev_err(hdev, "QCA Patch config with no header");
+ err = -EILSEQ;
+ goto out;
+ }
+
+ if (edl->cresp != EDL_PATCH_CONFIG_RES_EVT || edl->rtype != rtype) {
+ bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
+ edl->rtype);
+ err = -EIO;
+ goto out;
+ }
+
+out:
+ kfree(skb);
+ if (err)
+ bt_dev_err(hdev, "QCA Patch config cmd failed (%d)", err);
+
+ return err;
+}
+
static int qca_send_reset(struct hci_dev *hdev)
{
struct sk_buff *skb;
@@ -551,6 +598,9 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
*/
rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f);

+ if (soc_type == QCA_WCN6750)
+ qca_send_patch_config_cmd(hdev);
+
/* Download rampatch file */
config.type = TLV_TYPE_PATCH;
if (qca_is_wcn399x(soc_type)) {
diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h
index 30afa77..61e9a50 100644
--- a/drivers/bluetooth/btqca.h
+++ b/drivers/bluetooth/btqca.h
@@ -13,6 +13,7 @@
#define EDL_PATCH_TLV_REQ_CMD (0x1E)
#define EDL_GET_BUILD_INFO_CMD (0x20)
#define EDL_NVM_ACCESS_SET_REQ_CMD (0x01)
+#define EDL_PATCH_CONFIG_CMD (0x28)
#define MAX_SIZE_PER_TLV_SEGMENT (243)
#define QCA_PRE_SHUTDOWN_CMD (0xFC08)
#define QCA_DISABLE_LOGGING (0xFC17)
@@ -24,6 +25,7 @@
#define EDL_CMD_EXE_STATUS_EVT (0x00)
#define EDL_SET_BAUDRATE_RSP_EVT (0x92)
#define EDL_NVM_ACCESS_CODE_EVT (0x0B)
+#define EDL_PATCH_CONFIG_RES_EVT (0x00)
#define QCA_DISABLE_LOGGING_SUB_OP (0x14)

#define EDL_TAG_ID_HCI (17)
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc.



2021-12-09 10:45:27

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2] Bluetooth: btqca: sequential validation

Hi Sai,

> This change will have sequential validation support
> & patch config command is added
>
> Signed-off-by: Sai Teja Aluvala <[email protected]>
> ---
> drivers/bluetooth/btqca.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
> drivers/bluetooth/btqca.h | 2 ++
> 2 files changed, 52 insertions(+)
>
> diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c
> index be04d74..633a24c 100644
> --- a/drivers/bluetooth/btqca.c
> +++ b/drivers/bluetooth/btqca.c
> @@ -141,6 +141,53 @@ static int qca_read_fw_build_info(struct hci_dev *hdev)
> return err;
> }
>
> +static int qca_send_patch_config_cmd(struct hci_dev *hdev)
> +{
> + struct sk_buff *skb;
> + int err = 0;
> + u8 cmd[] = {EDL_PATCH_CONFIG_CMD, 0x01, 0, 0, 0};

is there are reason not to address review comments?

const u8 cmd[] = { EDL_PATCH_CONFIG_CMD, 0x01, 0, 0, 0 };

> + u8 rlen = 0x02;
> + struct edl_event_hdr *edl;
> + u8 rtype = EDL_PATCH_CONFIG_CMD;

I missed these two and must have assumed there are used somewhere, rlen and rtype are a waste to be declared.

> +
> + bt_dev_dbg(hdev, "QCA Patch config");
> +
> + skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, sizeof(cmd),
> + cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
> + if (IS_ERR(skb)) {
> + err = PTR_ERR(skb);
> + bt_dev_err(hdev, "Sending QCA Patch config failed (%d)", err);
> + return err;
> + }
> +
> + if (skb->len != rlen) {

if (skb->len != 2) {

> + bt_dev_err(hdev, "QCA Patch config cmd size mismatch len %d", skb->len);
> + err = -EILSEQ;
> + goto out;
> + }
> +
> + edl = (struct edl_event_hdr *)(skb->data);
> + if (!edl) {
> + bt_dev_err(hdev, "QCA Patch config with no header");
> + err = -EILSEQ;
> + goto out;
> + }
> +
> + if (edl->cresp != EDL_PATCH_CONFIG_RES_EVT || edl->rtype != rtype) {

edl->rtype != EDL_PATCH_CONFIG_CMD) {

> + bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
> + edl->rtype);
> + err = -EIO;
> + goto out;
> + }
> +
> +out:
> + kfree(skb);
> + if (err)
> + bt_dev_err(hdev, "QCA Patch config cmd failed (%d)", err);
> +
> + return err;
> +}
> +

Regards

Marcel


2021-12-15 11:28:23

by Sai Teja Aluvala

[permalink] [raw]
Subject: RE: [PATCH v2] Bluetooth: btqca: sequential validation



-----Original Message-----
From: Marcel Holtmann <[email protected]>
Sent: Thursday, December 9, 2021 4:15 PM
To: Sai Teja Aluvala (Temp) (QUIC) <[email protected]>
Cc: Johan Hedberg <[email protected]>; Matthias Kaehlcke <[email protected]>; Linux Kernel Mailing List <[email protected]>; linux-bluetooth <[email protected]>; Hemant Gupta (QUIC) <[email protected]>; MSM <[email protected]>; quic_bgodavar <[email protected]>; Rocky Liao <[email protected]>; [email protected]; Abhishek Pandit-Subedi <[email protected]>; Miao-chen Chou <[email protected]>; PANICKER HARISH (Temp) (QUIC) <[email protected]>
Subject: Re: [PATCH v2] Bluetooth: btqca: sequential validation

Hi Sai,

> This change will have sequential validation support & patch config
> command is added
>
> Signed-off-by: Sai Teja Aluvala <[email protected]>
> ---
> drivers/bluetooth/btqca.c | 50
> +++++++++++++++++++++++++++++++++++++++++++++++
> drivers/bluetooth/btqca.h | 2 ++
> 2 files changed, 52 insertions(+)
>
> diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c
> index be04d74..633a24c 100644
> --- a/drivers/bluetooth/btqca.c
> +++ b/drivers/bluetooth/btqca.c
> @@ -141,6 +141,53 @@ static int qca_read_fw_build_info(struct hci_dev *hdev)
> return err;
> }
>
> +static int qca_send_patch_config_cmd(struct hci_dev *hdev) {
> + struct sk_buff *skb;
> + int err = 0;
> + u8 cmd[] = {EDL_PATCH_CONFIG_CMD, 0x01, 0, 0, 0};

is there are reason not to address review comments?
[Sai] : I will address in next patch

const u8 cmd[] = { EDL_PATCH_CONFIG_CMD, 0x01, 0, 0, 0 };

> + u8 rlen = 0x02;
> + struct edl_event_hdr *edl;
> + u8 rtype = EDL_PATCH_CONFIG_CMD;

I missed these two and must have assumed there are used somewhere, rlen and rtype are a waste to be declared.
[Sai] : I will delete rlen in next patch.

> +
> + bt_dev_dbg(hdev, "QCA Patch config");
> +
> + skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, sizeof(cmd),
> + cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
> + if (IS_ERR(skb)) {
> + err = PTR_ERR(skb);
> + bt_dev_err(hdev, "Sending QCA Patch config failed (%d)", err);
> + return err;
> + }
> +
> + if (skb->len != rlen) {

if (skb->len != 2) {

> + bt_dev_err(hdev, "QCA Patch config cmd size mismatch len %d", skb->len);
> + err = -EILSEQ;
> + goto out;
> + }
> +
> + edl = (struct edl_event_hdr *)(skb->data);
> + if (!edl) {
> + bt_dev_err(hdev, "QCA Patch config with no header");
> + err = -EILSEQ;
> + goto out;
> + }
> +
> + if (edl->cresp != EDL_PATCH_CONFIG_RES_EVT || edl->rtype != rtype) {

edl->rtype != EDL_PATCH_CONFIG_CMD) {

[Sai] : I will update in next patch.


> + bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
> + edl->rtype);
> + err = -EIO;
> + goto out;
> + }
> +
> +out:
> + kfree(skb);
> + if (err)
> + bt_dev_err(hdev, "QCA Patch config cmd failed (%d)", err);
> +
> + return err;
> +}
> +

Regards

Marcel