mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-28 18:10:32 +00:00

The firmware log buffer is enabled during probe and freed during remove. Early versions of firmware do not support sending logs. Once the mailbox is up driver will enable logging when supported firmware versions are detected. Logging is disabled before the mailbox is freed. Signed-off-by: Lee Trager <lee@trager.us> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250702192207.697368-6-lee@trager.us Signed-off-by: Jakub Kicinski <kuba@kernel.org>
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
|
|
|
|
#ifndef _FBNIC_FW_LOG_H_
|
|
#define _FBNIC_FW_LOG_H_
|
|
|
|
#include <linux/spinlock.h>
|
|
#include <linux/types.h>
|
|
|
|
/* A 512K log buffer was chosen fairly arbitrarily */
|
|
#define FBNIC_FW_LOG_SIZE (512 * 1024) /* bytes */
|
|
|
|
/* Firmware log output is prepended with log index followed by a timestamp.
|
|
* The timestamp is similar to Zephyr's format DD:HH:MM:SS.MMM
|
|
*/
|
|
#define FBNIC_FW_LOG_FMT "[%5lld] [%02ld:%02ld:%02ld:%02ld.%03ld] %s\n"
|
|
|
|
struct fbnic_dev;
|
|
|
|
struct fbnic_fw_log_entry {
|
|
struct list_head list;
|
|
u64 index;
|
|
u32 timestamp;
|
|
u16 len;
|
|
char msg[] __counted_by(len);
|
|
};
|
|
|
|
struct fbnic_fw_log {
|
|
void *data_start;
|
|
void *data_end;
|
|
size_t size;
|
|
struct list_head entries;
|
|
/* Spin lock for accessing or modifying entries */
|
|
spinlock_t lock;
|
|
};
|
|
|
|
#define fbnic_fw_log_ready(_fbd) (!!(_fbd)->fw_log.data_start)
|
|
|
|
void fbnic_fw_log_enable(struct fbnic_dev *fbd, bool send_hist);
|
|
void fbnic_fw_log_disable(struct fbnic_dev *fbd);
|
|
int fbnic_fw_log_init(struct fbnic_dev *fbd);
|
|
void fbnic_fw_log_free(struct fbnic_dev *fbd);
|
|
int fbnic_fw_log_write(struct fbnic_dev *fbd, u64 index, u32 timestamp,
|
|
char *msg);
|
|
#endif /* _FBNIC_FW_LOG_H_ */
|