Bluetooth: coredump: Expose header size and end marker to drivers

To separate the coredump header and data far more easily, give a
vendor driver the option to pad its header to a fixed size, by
moving the header size limit and ending marker to coredump.h:

 - HCI_DEVCD_HDR_SIZE_MAX: the max header size
 - HCI_DEVCD_HDR_END_MARKER: the header-ending marker

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Zijun Hu
2026-08-01 23:31:38 -07:00
committed by Luiz Augusto von Dentz
parent d39667cb04
commit 8824e13fb5
2 changed files with 9 additions and 5 deletions

View File

@@ -8,6 +8,13 @@
#define DEVCOREDUMP_TIMEOUT msecs_to_jiffies(10000) /* 10 sec */
/*
* Max header size, shared by both the devcoredump core and
* the dmp_hdr() registered by driver via hci_devcd_register()
*/
#define HCI_DEVCD_HDR_SIZE_MAX 512
#define HCI_DEVCD_HDR_END_MARKER "--- Start dump ---\n"
typedef void (*coredump_t)(struct hci_dev *hdev);
typedef void (*dmp_hdr_t)(struct hci_dev *hdev, struct sk_buff *skb);
typedef void (*notify_change_t)(struct hci_dev *hdev, int state);

View File

@@ -34,8 +34,6 @@ struct hci_devcoredump_skb_pattern {
hci_dmp_cb(skb)->pkt_type, \
hci_devcd_state_name(hdev->dump.state))
#define MAX_DEVCOREDUMP_HDR_SIZE 512 /* bytes */
static int hci_devcd_update_hdr_state(char *buf, size_t size, int state)
{
int len = 0;
@@ -63,7 +61,6 @@ static int hci_devcd_update_state(struct hci_dev *hdev, int state)
static int hci_devcd_mkheader(struct hci_dev *hdev, struct sk_buff *skb)
{
char dump_start[] = "--- Start dump ---\n";
char hdr[80];
int hdr_len;
@@ -74,7 +71,7 @@ static int hci_devcd_mkheader(struct hci_dev *hdev, struct sk_buff *skb)
if (hdev->dump.dmp_hdr)
hdev->dump.dmp_hdr(hdev, skb);
skb_put_data(skb, dump_start, strlen(dump_start));
skb_put_data(skb, HCI_DEVCD_HDR_END_MARKER, strlen(HCI_DEVCD_HDR_END_MARKER));
return skb->len;
}
@@ -154,7 +151,7 @@ static int hci_devcd_prepare(struct hci_dev *hdev, u32 dump_size)
int dump_hdr_size;
int err = 0;
skb = alloc_skb(MAX_DEVCOREDUMP_HDR_SIZE, GFP_ATOMIC);
skb = alloc_skb(HCI_DEVCD_HDR_SIZE_MAX, GFP_ATOMIC);
if (!skb)
return -ENOMEM;