2019-06-01 15:08:54 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2017-02-15 21:28:23 +07:00
|
|
|
/*
|
|
|
|
* QLogic FCoE Offload Driver
|
2018-04-25 20:09:04 +07:00
|
|
|
* Copyright (c) 2016-2018 Cavium Inc.
|
2017-02-15 21:28:23 +07:00
|
|
|
*/
|
|
|
|
#include "qedf_dbg.h"
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
|
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
struct va_format vaf;
|
|
|
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
|
|
|
|
vaf.fmt = fmt;
|
|
|
|
vaf.va = &va;
|
|
|
|
|
|
|
|
if (likely(qedf) && likely(qedf->pdev))
|
|
|
|
pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
|
2019-04-12 16:48:29 +07:00
|
|
|
func, line, qedf->host_no, &vaf);
|
2017-02-15 21:28:23 +07:00
|
|
|
else
|
2019-04-12 16:48:29 +07:00
|
|
|
pr_err("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
|
2017-02-15 21:28:23 +07:00
|
|
|
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
|
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
struct va_format vaf;
|
|
|
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
|
|
|
|
vaf.fmt = fmt;
|
|
|
|
vaf.va = &va;
|
|
|
|
|
|
|
|
if (!(qedf_debug & QEDF_LOG_WARN))
|
|
|
|
goto ret;
|
|
|
|
|
|
|
|
if (likely(qedf) && likely(qedf->pdev))
|
|
|
|
pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
|
2019-04-12 16:48:29 +07:00
|
|
|
func, line, qedf->host_no, &vaf);
|
2017-02-15 21:28:23 +07:00
|
|
|
else
|
2019-04-12 16:48:29 +07:00
|
|
|
pr_warn("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
|
2017-02-15 21:28:23 +07:00
|
|
|
|
|
|
|
ret:
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
|
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
struct va_format vaf;
|
|
|
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
|
|
|
|
vaf.fmt = fmt;
|
|
|
|
vaf.va = &va;
|
|
|
|
|
|
|
|
if (!(qedf_debug & QEDF_LOG_NOTICE))
|
|
|
|
goto ret;
|
|
|
|
|
|
|
|
if (likely(qedf) && likely(qedf->pdev))
|
|
|
|
pr_notice("[%s]:[%s:%d]:%d: %pV",
|
2019-04-12 16:48:29 +07:00
|
|
|
dev_name(&(qedf->pdev->dev)), func, line,
|
2017-02-15 21:28:23 +07:00
|
|
|
qedf->host_no, &vaf);
|
|
|
|
else
|
2019-04-12 16:48:29 +07:00
|
|
|
pr_notice("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
|
2017-02-15 21:28:23 +07:00
|
|
|
|
|
|
|
ret:
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
|
|
|
|
u32 level, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
struct va_format vaf;
|
|
|
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
|
|
|
|
vaf.fmt = fmt;
|
|
|
|
vaf.va = &va;
|
|
|
|
|
|
|
|
if (!(qedf_debug & level))
|
|
|
|
goto ret;
|
|
|
|
|
|
|
|
if (likely(qedf) && likely(qedf->pdev))
|
|
|
|
pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf->pdev->dev)),
|
2019-04-12 16:48:29 +07:00
|
|
|
func, line, qedf->host_no, &vaf);
|
2017-02-15 21:28:23 +07:00
|
|
|
else
|
2019-04-12 16:48:29 +07:00
|
|
|
pr_info("[0000:00:00.0]:[%s:%d]: %pV", func, line, &vaf);
|
2017-02-15 21:28:23 +07:00
|
|
|
|
|
|
|
ret:
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qedf_alloc_grc_dump_buf(u8 **buf, uint32_t len)
|
|
|
|
{
|
|
|
|
*buf = vmalloc(len);
|
|
|
|
if (!(*buf))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memset(*buf, 0, len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qedf_free_grc_dump_buf(uint8_t **buf)
|
|
|
|
{
|
|
|
|
vfree(*buf);
|
|
|
|
*buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qedf_get_grc_dump(struct qed_dev *cdev, const struct qed_common_ops *common,
|
|
|
|
u8 **buf, uint32_t *grcsize)
|
|
|
|
{
|
|
|
|
if (!*buf)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-04-25 20:08:58 +07:00
|
|
|
return common->dbg_all_data(cdev, *buf);
|
2017-02-15 21:28:23 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qedf_uevent_emit(struct Scsi_Host *shost, u32 code, char *msg)
|
|
|
|
{
|
|
|
|
char event_string[40];
|
|
|
|
char *envp[] = {event_string, NULL};
|
|
|
|
|
|
|
|
memset(event_string, 0, sizeof(event_string));
|
|
|
|
switch (code) {
|
|
|
|
case QEDF_UEVENT_CODE_GRCDUMP:
|
|
|
|
if (msg)
|
2018-02-02 20:12:20 +07:00
|
|
|
strscpy(event_string, msg, sizeof(event_string));
|
2017-02-15 21:28:23 +07:00
|
|
|
else
|
|
|
|
sprintf(event_string, "GRCDUMP=%u", shost->host_no);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
kobject_uevent_env(&shost->shost_gendev.kobj, KOBJ_CHANGE, envp);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qedf_create_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
for (; iter->name; iter++) {
|
|
|
|
ret = sysfs_create_bin_file(&shost->shost_gendev.kobj,
|
|
|
|
iter->attr);
|
|
|
|
if (ret)
|
|
|
|
pr_err("Unable to create sysfs %s attr, err(%d).\n",
|
|
|
|
iter->name, ret);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qedf_remove_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter)
|
|
|
|
{
|
|
|
|
for (; iter->name; iter++)
|
|
|
|
sysfs_remove_bin_file(&shost->shost_gendev.kobj, iter->attr);
|
|
|
|
}
|