2 * QLogic FCoE Offload Driver
3 * Copyright (c) 2016 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
,
20 memset(nfunc
, 0, sizeof(nfunc
));
21 memcpy(nfunc
, func
, sizeof(nfunc
) - 1);
28 if (likely(qedf
) && likely(qedf
->pdev
))
29 pr_err("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
30 nfunc
, line
, qedf
->host_no
, &vaf
);
32 pr_err("[0000:00:00.0]:[%s:%d]: %pV", nfunc
, line
, &vaf
);
38 qedf_dbg_warn(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
45 memset(nfunc
, 0, sizeof(nfunc
));
46 memcpy(nfunc
, func
, sizeof(nfunc
) - 1);
53 if (!(qedf_debug
& QEDF_LOG_WARN
))
56 if (likely(qedf
) && likely(qedf
->pdev
))
57 pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
58 nfunc
, line
, qedf
->host_no
, &vaf
);
60 pr_warn("[0000:00:00.0]:[%s:%d]: %pV", nfunc
, line
, &vaf
);
67 qedf_dbg_notice(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
74 memset(nfunc
, 0, sizeof(nfunc
));
75 memcpy(nfunc
, func
, sizeof(nfunc
) - 1);
82 if (!(qedf_debug
& QEDF_LOG_NOTICE
))
85 if (likely(qedf
) && likely(qedf
->pdev
))
86 pr_notice("[%s]:[%s:%d]:%d: %pV",
87 dev_name(&(qedf
->pdev
->dev
)), nfunc
, line
,
90 pr_notice("[0000:00:00.0]:[%s:%d]: %pV", nfunc
, line
, &vaf
);
97 qedf_dbg_info(struct qedf_dbg_ctx
*qedf
, const char *func
, u32 line
,
98 u32 level
, const char *fmt
, ...)
101 struct va_format vaf
;
104 memset(nfunc
, 0, sizeof(nfunc
));
105 memcpy(nfunc
, func
, sizeof(nfunc
) - 1);
112 if (!(qedf_debug
& level
))
115 if (likely(qedf
) && likely(qedf
->pdev
))
116 pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&(qedf
->pdev
->dev
)),
117 nfunc
, line
, qedf
->host_no
, &vaf
);
119 pr_info("[0000:00:00.0]:[%s:%d]: %pV", nfunc
, line
, &vaf
);
126 qedf_alloc_grc_dump_buf(u8
**buf
, uint32_t len
)
132 memset(*buf
, 0, len
);
137 qedf_free_grc_dump_buf(uint8_t **buf
)
144 qedf_get_grc_dump(struct qed_dev
*cdev
, const struct qed_common_ops
*common
,
145 u8
**buf
, uint32_t *grcsize
)
150 return common
->dbg_grc(cdev
, *buf
, grcsize
);
154 qedf_uevent_emit(struct Scsi_Host
*shost
, u32 code
, char *msg
)
156 char event_string
[40];
157 char *envp
[] = {event_string
, NULL
};
159 memset(event_string
, 0, sizeof(event_string
));
161 case QEDF_UEVENT_CODE_GRCDUMP
:
163 strncpy(event_string
, msg
, strlen(msg
));
165 sprintf(event_string
, "GRCDUMP=%u", shost
->host_no
);
172 kobject_uevent_env(&shost
->shost_gendev
.kobj
, KOBJ_CHANGE
, envp
);
176 qedf_create_sysfs_attr(struct Scsi_Host
*shost
, struct sysfs_bin_attrs
*iter
)
180 for (; iter
->name
; iter
++) {
181 ret
= sysfs_create_bin_file(&shost
->shost_gendev
.kobj
,
184 pr_err("Unable to create sysfs %s attr, err(%d).\n",
191 qedf_remove_sysfs_attr(struct Scsi_Host
*shost
, struct sysfs_bin_attrs
*iter
)
193 for (; iter
->name
; iter
++)
194 sysfs_remove_bin_file(&shost
->shost_gendev
.kobj
, iter
->attr
);