Thomas Gleixner | a61127c | 2019-05-29 16:57:49 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright(c) 2009 Intel Corporation. All rights reserved. |
| 4 | * |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 5 | * 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 Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 13 | #define FC_DISC_LOGGING 0x04 /* discovery layer logging */ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 14 | #define FC_RPORT_LOGGING 0x08 /* rport layer logging */ |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 15 | #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 Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 19 | |
| 20 | extern unsigned int fc_debug_logging; |
| 21 | |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 22 | #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 Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 29 | |
| 30 | #define FC_LIBFC_DBG(fmt, args...) \ |
| 31 | FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \ |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 32 | pr_info("libfc: " fmt, ##args)) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 33 | |
| 34 | #define FC_LPORT_DBG(lport, fmt, args...) \ |
| 35 | FC_CHECK_LOGGING(FC_LPORT_LOGGING, \ |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 36 | pr_info("host%u: lport %6.6x: " fmt, \ |
| 37 | (lport)->host->host_no, \ |
| 38 | (lport)->port_id, ##args)) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 39 | |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 40 | #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 Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 45 | |
| 46 | #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \ |
| 47 | FC_CHECK_LOGGING(FC_RPORT_LOGGING, \ |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 48 | pr_info("host%u: rport %6.6x: " fmt, \ |
| 49 | (lport)->host->host_no, \ |
| 50 | (port_id), ##args)) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 51 | |
| 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 Zou | 9b90dc80 | 2010-11-30 16:19:15 -0800 | [diff] [blame] | 57 | { \ |
| 58 | if ((pkt)->seq_ptr) { \ |
| 59 | struct fc_exch *_ep = NULL; \ |
| 60 | _ep = fc_seq_exch((pkt)->seq_ptr); \ |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 61 | pr_info("host%u: fcp: %6.6x: " \ |
Yi Zou | 9b90dc80 | 2010-11-30 16:19:15 -0800 | [diff] [blame] | 62 | "xid %04x-%04x: " fmt, \ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 63 | (pkt)->lp->host->host_no, \ |
Yi Zou | 9b90dc80 | 2010-11-30 16:19:15 -0800 | [diff] [blame] | 64 | (pkt)->rport->port_id, \ |
| 65 | (_ep)->oxid, (_ep)->rxid, ##args); \ |
| 66 | } else { \ |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 67 | pr_info("host%u: fcp: %6.6x: " fmt, \ |
Yi Zou | 9b90dc80 | 2010-11-30 16:19:15 -0800 | [diff] [blame] | 68 | (pkt)->lp->host->host_no, \ |
| 69 | (pkt)->rport->port_id, ##args); \ |
| 70 | } \ |
| 71 | }) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 72 | |
| 73 | #define FC_EXCH_DBG(exch, fmt, args...) \ |
| 74 | FC_CHECK_LOGGING(FC_EXCH_LOGGING, \ |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 75 | pr_info("host%u: xid %4x: " fmt, \ |
| 76 | (exch)->lp->host->host_no, \ |
| 77 | exch->xid, ##args)) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 78 | |
| 79 | #define FC_SCSI_DBG(lport, fmt, args...) \ |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 80 | FC_CHECK_LOGGING(FC_SCSI_LOGGING, \ |
Robert Love | 8e6c536 | 2012-12-04 02:14:53 +0000 | [diff] [blame] | 81 | pr_info("host%u: scsi: " fmt, \ |
| 82 | (lport)->host->host_no, ##args)) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 83 | |
| 84 | /* |
Joe Eykholt | 96ad846 | 2011-01-28 16:04:02 -0800 | [diff] [blame] | 85 | * FC-4 Providers. |
| 86 | */ |
| 87 | extern struct fc4_prov *fc_active_prov[]; /* providers without recv */ |
| 88 | extern struct fc4_prov *fc_passive_prov[]; /* providers with recv */ |
| 89 | extern struct mutex fc_prov_mutex; /* lock over table changes */ |
| 90 | |
| 91 | extern struct fc4_prov fc_rport_t0_prov; /* type 0 provider */ |
| 92 | extern struct fc4_prov fc_lport_els_prov; /* ELS provider */ |
| 93 | extern struct fc4_prov fc_rport_fcp_init; /* FCP initiator provider */ |
| 94 | |
| 95 | /* |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 96 | * Set up direct-data placement for this I/O request |
| 97 | */ |
| 98 | void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid); |
Yi Zou | 6a716a8 | 2011-05-16 16:45:40 -0700 | [diff] [blame] | 99 | void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp); |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 100 | |
| 101 | /* |
| 102 | * Module setup functions |
| 103 | */ |
| 104 | int fc_setup_exch_mgr(void); |
| 105 | void fc_destroy_exch_mgr(void); |
| 106 | int fc_setup_rport(void); |
| 107 | void fc_destroy_rport(void); |
Robert Love | 93e6d5a | 2009-11-03 11:46:03 -0800 | [diff] [blame] | 108 | int fc_setup_fcp(void); |
| 109 | void fc_destroy_fcp(void); |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 110 | |
| 111 | /* |
| 112 | * Internal libfc functions |
| 113 | */ |
| 114 | const char *fc_els_resp_type(struct fc_frame *); |
Joe Eykholt | 70d53b0 | 2011-01-28 16:04:18 -0800 | [diff] [blame] | 115 | extern void fc_fc4_add_lport(struct fc_lport *); |
| 116 | extern void fc_fc4_del_lport(struct fc_lport *); |
Kiran Patil | acc1a92 | 2011-01-28 16:05:22 -0800 | [diff] [blame] | 117 | extern void fc_fc4_conf_lport_params(struct fc_lport *, enum fc_fh_type); |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 118 | |
Robert Love | 5868287 | 2009-11-03 11:47:28 -0800 | [diff] [blame] | 119 | /* |
| 120 | * Copies a buffer into an sg list |
| 121 | */ |
| 122 | u32 fc_copy_buffer_to_sglist(void *buf, size_t len, |
| 123 | struct scatterlist *sg, |
| 124 | u32 *nents, size_t *offset, |
Cong Wang | 77dfce0 | 2011-11-25 23:14:23 +0800 | [diff] [blame] | 125 | u32 *crc); |
Robert Love | 5868287 | 2009-11-03 11:47:28 -0800 | [diff] [blame] | 126 | |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 127 | #endif /* _FC_LIBFC_H_ */ |