2 * QLogic FCoE Offload Driver
3 * Copyright (c) 2016-2018 Cavium Inc.
5 * This software is available under the terms of the GNU General Public License
6 * (GPL) Version 2, available from the file COPYING in the main directory of
10 #include <linux/vmalloc.h>
13 qedf_dbg_err(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
24 if (likely(qedf
) && likely(qedf
->pdev
))
25 pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
26 func
, line
, qedf
->host_no
, &vaf
);
28 pr_err("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
34 qedf_dbg_warn(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
45 if (!(qedf_debug
& QEDF_LOG_WARN
))
48 if (likely(qedf
) && likely(qedf
->pdev
))
49 pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
50 func
, line
, qedf
->host_no
, &vaf
);
52 pr_warn("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
59 qedf_dbg_notice(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
70 if (!(qedf_debug
& QEDF_LOG_NOTICE
))
73 if (likely(qedf
) && likely(qedf
->pdev
))
74 pr_notice("[%s]:[%s:%d]:%d: %pV",
75 dev_name(&(qedf
->pdev
->dev
)), func
, line
,
78 pr_notice("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
85 qedf_dbg_info(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
86 u32 level
, const char *fmt
, ...)
96 if (!(qedf_debug
& level
))
99 if (likely(qedf
) && likely(qedf
->pdev
))
100 pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
101 func
, line
, qedf
->host_no
, &vaf
);
103 pr_info("[0000:00:00.0]:[%s:%d]: %pV", func
, line
, &vaf
);
110 qedf_alloc_grc_dump_buf(u8
**buf
, uint32_t len
)
116 memset(*buf
, 0, len
);
121 qedf_free_grc_dump_buf(uint8_t **buf
)
128 qedf_get_grc_dump(struct qed_dev
*cdev
, const struct qed_common_ops
*common
,
129 u8
**buf
, uint32_t *grcsize
)
134 return common
->dbg_all_data(cdev
, *buf
);
138 qedf_uevent_emit(struct Scsi_Host
*shost
, u32 code
, char *msg
)
140 char event_string
[40];
141 char *envp
[] = {event_string
, NULL
};
143 memset(event_string
, 0, sizeof(event_string
));
145 case QEDF_UEVENT_CODE_GRCDUMP
:
147 strscpy(event_string
, msg
, sizeof(event_string
));
149 sprintf(event_string
, "GRCDUMP=%u", shost
->host_no
);
156 kobject_uevent_env(&shost
->shost_gendev
.kobj
, KOBJ_CHANGE
, envp
);
160 qedf_create_sysfs_attr(struct Scsi_Host
*shost
, struct sysfs_bin_attrs
*iter
)
164 for (; iter
->name
; iter
++) {
165 ret
= sysfs_create_bin_file(&shost
->shost_gendev
.kobj
,
168 pr_err("Unable to create sysfs %s attr, err(%d).\n",
175 qedf_remove_sysfs_attr(struct Scsi_Host
*shost
, struct sysfs_bin_attrs
*iter
)
177 for (; iter
->name
; iter
++)
178 sysfs_remove_bin_file(&shost
->shost_gendev
.kobj
, iter
->attr
);