^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _SCSI_SCSI_DBG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _SCSI_SCSI_DBG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) struct scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) struct scsi_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) struct scsi_sense_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) extern void scsi_print_command(struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) extern size_t __scsi_format_command(char *, size_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) const unsigned char *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) extern void scsi_print_sense_hdr(const struct scsi_device *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) const struct scsi_sense_hdr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern void scsi_print_sense(const struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) extern void __scsi_print_sense(const struct scsi_device *, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) const unsigned char *sense_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int sense_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) extern void scsi_print_result(const struct scsi_cmnd *, const char *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #ifdef CONFIG_SCSI_CONSTANTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) extern bool scsi_opcode_sa_name(int, int, const char **, const char **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern const char *scsi_sense_key_string(unsigned char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) const char **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) extern const char *scsi_mlreturn_string(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) extern const char *scsi_hostbyte_string(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern const char *scsi_driverbyte_string(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) scsi_opcode_sa_name(int cmd, int sa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) const char **cdb_name, const char **sa_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *cdb_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) case VARIABLE_LENGTH_CMD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) case MAINTENANCE_IN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) case MAINTENANCE_OUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) case PERSISTENT_RESERVE_IN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) case PERSISTENT_RESERVE_OUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) case SERVICE_ACTION_IN_12:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) case SERVICE_ACTION_OUT_12:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) case SERVICE_ACTION_BIDIRECTIONAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) case SERVICE_ACTION_IN_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) case SERVICE_ACTION_OUT_16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) case EXTENDED_COPY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) case RECEIVE_COPY_RESULTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) *sa_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static inline const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) scsi_sense_key_string(unsigned char key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static inline const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) *fmt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) scsi_mlreturn_string(int result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static inline const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) scsi_hostbyte_string(int result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static inline const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) scsi_driverbyte_string(int result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #endif /* _SCSI_SCSI_DBG_H */