blob: 685e3bdd033a5455665679b2de2e326a2a8b134c [file] [log] [blame]
Thomas Gleixnera61127c2019-05-29 16:57:49 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Robert Love8866a5d2009-11-03 11:45:58 -08002/*
3 * Copyright(c) 2009 Intel Corporation. All rights reserved.
4 *
Robert Love8866a5d2009-11-03 11:45:58 -08005 * Maintained at www.Open-FCoE.org
6 */
7
8#ifndef _FC_LIBFC_H_
9#define _FC_LIBFC_H_
10
11#define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */
12#define FC_LPORT_LOGGING 0x02 /* lport layer logging */
Robert Love3a3b42b2009-11-03 11:47:39 -080013#define FC_DISC_LOGGING 0x04 /* discovery layer logging */
Robert Love8866a5d2009-11-03 11:45:58 -080014#define FC_RPORT_LOGGING 0x08 /* rport layer logging */
Robert Love3a3b42b2009-11-03 11:47:39 -080015#define FC_FCP_LOGGING 0x10 /* I/O path logging */
16#define FC_EM_LOGGING 0x20 /* Exchange Manager logging */
17#define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */
18#define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */
Robert Love8866a5d2009-11-03 11:45:58 -080019
20extern unsigned int fc_debug_logging;
21
Robert Love3a3b42b2009-11-03 11:47:39 -080022#define FC_CHECK_LOGGING(LEVEL, CMD) \
23 do { \
24 if (unlikely(fc_debug_logging & LEVEL)) \
25 do { \
26 CMD; \
27 } while (0); \
28 } while (0)
Robert Love8866a5d2009-11-03 11:45:58 -080029
30#define FC_LIBFC_DBG(fmt, args...) \
31 FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \
Robert Love8e6c5362012-12-04 02:14:53 +000032 pr_info("libfc: " fmt, ##args))
Robert Love8866a5d2009-11-03 11:45:58 -080033
34#define FC_LPORT_DBG(lport, fmt, args...) \
35 FC_CHECK_LOGGING(FC_LPORT_LOGGING, \
Robert Love8e6c5362012-12-04 02:14:53 +000036 pr_info("host%u: lport %6.6x: " fmt, \
37 (lport)->host->host_no, \
38 (lport)->port_id, ##args))
Robert Love8866a5d2009-11-03 11:45:58 -080039
Robert Love8e6c5362012-12-04 02:14:53 +000040#define FC_DISC_DBG(disc, fmt, args...) \
41 FC_CHECK_LOGGING(FC_DISC_LOGGING, \
42 pr_info("host%u: disc: " fmt, \
43 fc_disc_lport(disc)->host->host_no, \
44 ##args))
Robert Love8866a5d2009-11-03 11:45:58 -080045
46#define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \
47 FC_CHECK_LOGGING(FC_RPORT_LOGGING, \
Robert Love8e6c5362012-12-04 02:14:53 +000048 pr_info("host%u: rport %6.6x: " fmt, \
49 (lport)->host->host_no, \
50 (port_id), ##args))
Robert Love8866a5d2009-11-03 11:45:58 -080051
52#define FC_RPORT_DBG(rdata, fmt, args...) \
53 FC_RPORT_ID_DBG((rdata)->local_port, (rdata)->ids.port_id, fmt, ##args)
54
55#define FC_FCP_DBG(pkt, fmt, args...) \
56 FC_CHECK_LOGGING(FC_FCP_LOGGING, \
Yi Zou9b90dc802010-11-30 16:19:15 -080057 { \
58 if ((pkt)->seq_ptr) { \
59 struct fc_exch *_ep = NULL; \
60 _ep = fc_seq_exch((pkt)->seq_ptr); \
Robert Love8e6c5362012-12-04 02:14:53 +000061 pr_info("host%u: fcp: %6.6x: " \
Yi Zou9b90dc802010-11-30 16:19:15 -080062 "xid %04x-%04x: " fmt, \
Robert Love8866a5d2009-11-03 11:45:58 -080063 (pkt)->lp->host->host_no, \
Yi Zou9b90dc802010-11-30 16:19:15 -080064 (pkt)->rport->port_id, \
65 (_ep)->oxid, (_ep)->rxid, ##args); \
66 } else { \
Robert Love8e6c5362012-12-04 02:14:53 +000067 pr_info("host%u: fcp: %6.6x: " fmt, \
Yi Zou9b90dc802010-11-30 16:19:15 -080068 (pkt)->lp->host->host_no, \
69 (pkt)->rport->port_id, ##args); \
70 } \
71 })
Robert Love8866a5d2009-11-03 11:45:58 -080072
73#define FC_EXCH_DBG(exch, fmt, args...) \
74 FC_CHECK_LOGGING(FC_EXCH_LOGGING, \
Robert Love8e6c5362012-12-04 02:14:53 +000075 pr_info("host%u: xid %4x: " fmt, \
76 (exch)->lp->host->host_no, \
77 exch->xid, ##args))
Robert Love8866a5d2009-11-03 11:45:58 -080078
79#define FC_SCSI_DBG(lport, fmt, args...) \
Robert Love3a3b42b2009-11-03 11:47:39 -080080 FC_CHECK_LOGGING(FC_SCSI_LOGGING, \
Robert Love8e6c5362012-12-04 02:14:53 +000081 pr_info("host%u: scsi: " fmt, \
82 (lport)->host->host_no, ##args))
Robert Love8866a5d2009-11-03 11:45:58 -080083
84/*
Joe Eykholt96ad8462011-01-28 16:04:02 -080085 * FC-4 Providers.
86 */
87extern struct fc4_prov *fc_active_prov[]; /* providers without recv */
88extern struct fc4_prov *fc_passive_prov[]; /* providers with recv */
89extern struct mutex fc_prov_mutex; /* lock over table changes */
90
91extern struct fc4_prov fc_rport_t0_prov; /* type 0 provider */
92extern struct fc4_prov fc_lport_els_prov; /* ELS provider */
93extern struct fc4_prov fc_rport_fcp_init; /* FCP initiator provider */
94
95/*
Robert Love8866a5d2009-11-03 11:45:58 -080096 * Set up direct-data placement for this I/O request
97 */
98void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid);
Yi Zou6a716a82011-05-16 16:45:40 -070099void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp);
Robert Love8866a5d2009-11-03 11:45:58 -0800100
101/*
102 * Module setup functions
103 */
104int fc_setup_exch_mgr(void);
105void fc_destroy_exch_mgr(void);
106int fc_setup_rport(void);
107void fc_destroy_rport(void);
Robert Love93e6d5a2009-11-03 11:46:03 -0800108int fc_setup_fcp(void);
109void fc_destroy_fcp(void);
Robert Love8866a5d2009-11-03 11:45:58 -0800110
111/*
112 * Internal libfc functions
113 */
114const char *fc_els_resp_type(struct fc_frame *);
Joe Eykholt70d53b02011-01-28 16:04:18 -0800115extern void fc_fc4_add_lport(struct fc_lport *);
116extern void fc_fc4_del_lport(struct fc_lport *);
Kiran Patilacc1a922011-01-28 16:05:22 -0800117extern void fc_fc4_conf_lport_params(struct fc_lport *, enum fc_fh_type);
Robert Love8866a5d2009-11-03 11:45:58 -0800118
Robert Love58682872009-11-03 11:47:28 -0800119/*
120 * Copies a buffer into an sg list
121 */
122u32 fc_copy_buffer_to_sglist(void *buf, size_t len,
123 struct scatterlist *sg,
124 u32 *nents, size_t *offset,
Cong Wang77dfce02011-11-25 23:14:23 +0800125 u32 *crc);
Robert Love58682872009-11-03 11:47:28 -0800126
Robert Love8866a5d2009-11-03 11:45:58 -0800127#endif /* _FC_LIBFC_H_ */