^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright(c) 2009 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Maintained at www.Open-FCoE.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _FC_LIBFC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _FC_LIBFC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define FC_LPORT_LOGGING 0x02 /* lport layer logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define FC_DISC_LOGGING 0x04 /* discovery layer logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define FC_RPORT_LOGGING 0x08 /* rport layer logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define FC_FCP_LOGGING 0x10 /* I/O path logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define FC_EM_LOGGING 0x20 /* Exchange Manager logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) extern unsigned int fc_debug_logging;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define FC_CHECK_LOGGING(LEVEL, CMD) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) if (unlikely(fc_debug_logging & LEVEL)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) CMD; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) } while (0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define FC_LIBFC_DBG(fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) pr_info("libfc: " fmt, ##args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define FC_LPORT_DBG(lport, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) FC_CHECK_LOGGING(FC_LPORT_LOGGING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) pr_info("host%u: lport %6.6x: " fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) (lport)->host->host_no, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) (lport)->port_id, ##args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define FC_DISC_DBG(disc, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) FC_CHECK_LOGGING(FC_DISC_LOGGING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) pr_info("host%u: disc: " fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) fc_disc_lport(disc)->host->host_no, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ##args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) FC_CHECK_LOGGING(FC_RPORT_LOGGING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) pr_info("host%u: rport %6.6x: " fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) (lport)->host->host_no, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) (port_id), ##args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define FC_RPORT_DBG(rdata, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) FC_RPORT_ID_DBG((rdata)->local_port, (rdata)->ids.port_id, fmt, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define FC_FCP_DBG(pkt, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) FC_CHECK_LOGGING(FC_FCP_LOGGING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if ((pkt)->seq_ptr) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct fc_exch *_ep = NULL; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) _ep = fc_seq_exch((pkt)->seq_ptr); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) pr_info("host%u: fcp: %6.6x: " \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) "xid %04x-%04x: " fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) (pkt)->lp->host->host_no, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) (pkt)->rport->port_id, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) (_ep)->oxid, (_ep)->rxid, ##args); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) } else { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) pr_info("host%u: fcp: %6.6x: " fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) (pkt)->lp->host->host_no, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) (pkt)->rport->port_id, ##args); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) } \
^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) #define FC_EXCH_DBG(exch, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) FC_CHECK_LOGGING(FC_EXCH_LOGGING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) pr_info("host%u: xid %4x: " fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) (exch)->lp->host->host_no, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) exch->xid, ##args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define FC_SCSI_DBG(lport, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) FC_CHECK_LOGGING(FC_SCSI_LOGGING, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) pr_info("host%u: scsi: " fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) (lport)->host->host_no, ##args))
^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) * FC-4 Providers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) extern struct fc4_prov *fc_active_prov[]; /* providers without recv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) extern struct fc4_prov *fc_passive_prov[]; /* providers with recv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern struct mutex fc_prov_mutex; /* lock over table changes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) extern struct fc4_prov fc_rport_t0_prov; /* type 0 provider */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) extern struct fc4_prov fc_lport_els_prov; /* ELS provider */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) extern struct fc4_prov fc_rport_fcp_init; /* FCP initiator provider */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * Set up direct-data placement for this I/O request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * Module setup functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int fc_setup_exch_mgr(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) void fc_destroy_exch_mgr(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int fc_setup_rport(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) void fc_destroy_rport(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int fc_setup_fcp(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) void fc_destroy_fcp(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * Internal libfc functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) const char *fc_els_resp_type(struct fc_frame *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) extern void fc_fc4_add_lport(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) extern void fc_fc4_del_lport(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) extern void fc_fc4_conf_lport_params(struct fc_lport *, enum fc_fh_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * Copies a buffer into an sg list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u32 fc_copy_buffer_to_sglist(void *buf, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct scatterlist *sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) u32 *nents, size_t *offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) u32 *crc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #endif /* _FC_LIBFC_H_ */