1 // SPDX-License-Identifier: GPL-2.0-only
3 * QLogic FCoE Offload Driver
4 * Copyright (c) 2016-2018 Cavium Inc.
7 #include <linux/vmalloc.h>
10 qedf_dbg_err(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
21 if (likely(qedf
) && likely(qedf
->pdev
))
22 pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
23 func
, line
, qedf
->host_no
, &vaf
);
25 pr_err("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
31 qedf_dbg_warn(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
42 if (!(qedf_debug
& QEDF_LOG_WARN
))
45 if (likely(qedf
) && likely(qedf
->pdev
))
46 pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
47 func
, line
, qedf
->host_no
, &vaf
);
49 pr_warn("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
56 qedf_dbg_notice(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
67 if (!(qedf_debug
& QEDF_LOG_NOTICE
))
70 if (likely(qedf
) && likely(qedf
->pdev
))
71 pr_notice("[%s]:[%s:%d]:%d: %pV",
72 dev_name(&(qedf
->pdev
->dev
)), func
, line
,
75 pr_notice("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
82 qedf_dbg_info(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
83 u32 level
, const char *fmt
, ...)
93 if (!(qedf_debug
& level
))
96 if (likely(qedf
) && likely(qedf
->pdev
))
97 pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
98 func
, line
, qedf
->host_no
, &vaf
);
100 pr_info("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
107 qedf_alloc_grc_dump_buf(u8
**buf
, uint32_t len
)
113 memset(*buf
, 0, len
);
118 qedf_free_grc_dump_buf(uint8_t **buf
)
125 qedf_get_grc_dump(struct qed_dev
*cdev
, const struct qed_common_ops
*common
,
126 u8
**buf
, uint32_t *grcsize
)
131 return common
->dbg_all_data(cdev
, *buf
);
135 qedf_uevent_emit(struct Scsi_Host
*shost
, u32 code
, char *msg
)
137 char event_string
[40];
138 char *envp
[] = {event_string
, NULL
};
140 memset(event_string
, 0, sizeof(event_string
));
142 case QEDF_UEVENT_CODE_GRCDUMP
:
144 strscpy(event_string
, msg
, sizeof(event_string
));
146 sprintf(event_string
, "GRCDUMP=%u", shost
->host_no
);
153 kobject_uevent_env(&shost
->shost_gendev
.kobj
, KOBJ_CHANGE
, envp
);
157 qedf_create_sysfs_attr(struct Scsi_Host
*shost
, struct sysfs_bin_attrs
*iter
)
161 for (; iter
->name
; iter
++) {
162 ret
= sysfs_create_bin_file(&shost
->shost_gendev
.kobj
,
165 pr_err("Unable to create sysfs %s attr, err(%d).\n",
172 qedf_remove_sysfs_attr(struct Scsi_Host
*shost
, struct sysfs_bin_attrs
*iter
)
174 for (; iter
->name
; iter
++)
175 sysfs_remove_bin_file(&shost
->shost_gendev
.kobj
, iter
->attr
);