Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright(c) 2009 Intel Corporation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along with |
| 14 | * this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 | * |
| 17 | * Maintained at www.Open-FCoE.org |
| 18 | */ |
| 19 | |
| 20 | #ifndef _FC_LIBFC_H_ |
| 21 | #define _FC_LIBFC_H_ |
| 22 | |
| 23 | #define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */ |
| 24 | #define FC_LPORT_LOGGING 0x02 /* lport layer logging */ |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 25 | #define FC_DISC_LOGGING 0x04 /* discovery layer logging */ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 26 | #define FC_RPORT_LOGGING 0x08 /* rport layer logging */ |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 27 | #define FC_FCP_LOGGING 0x10 /* I/O path logging */ |
| 28 | #define FC_EM_LOGGING 0x20 /* Exchange Manager logging */ |
| 29 | #define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */ |
| 30 | #define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 31 | |
| 32 | extern unsigned int fc_debug_logging; |
| 33 | |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 34 | #define FC_CHECK_LOGGING(LEVEL, CMD) \ |
| 35 | do { \ |
| 36 | if (unlikely(fc_debug_logging & LEVEL)) \ |
| 37 | do { \ |
| 38 | CMD; \ |
| 39 | } while (0); \ |
| 40 | } while (0) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 41 | |
| 42 | #define FC_LIBFC_DBG(fmt, args...) \ |
| 43 | FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \ |
| 44 | printk(KERN_INFO "libfc: " fmt, ##args)) |
| 45 | |
| 46 | #define FC_LPORT_DBG(lport, fmt, args...) \ |
| 47 | FC_CHECK_LOGGING(FC_LPORT_LOGGING, \ |
Chris Leech | ce8b5df | 2010-04-09 14:23:10 -0700 | [diff] [blame] | 48 | printk(KERN_INFO "host%u: lport %6.6x: " fmt, \ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 49 | (lport)->host->host_no, \ |
Robert Love | 7b2787e | 2010-05-07 15:18:41 -0700 | [diff] [blame] | 50 | (lport)->port_id, ##args)) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 51 | |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 52 | #define FC_DISC_DBG(disc, fmt, args...) \ |
| 53 | FC_CHECK_LOGGING(FC_DISC_LOGGING, \ |
| 54 | printk(KERN_INFO "host%u: disc: " fmt, \ |
Joe Eykholt | 0685230 | 2010-07-20 15:19:53 -0700 | [diff] [blame] | 55 | fc_disc_lport(disc)->host->host_no, \ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 56 | ##args)) |
| 57 | |
| 58 | #define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \ |
| 59 | FC_CHECK_LOGGING(FC_RPORT_LOGGING, \ |
Chris Leech | ce8b5df | 2010-04-09 14:23:10 -0700 | [diff] [blame] | 60 | printk(KERN_INFO "host%u: rport %6.6x: " fmt, \ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 61 | (lport)->host->host_no, \ |
| 62 | (port_id), ##args)) |
| 63 | |
| 64 | #define FC_RPORT_DBG(rdata, fmt, args...) \ |
| 65 | FC_RPORT_ID_DBG((rdata)->local_port, (rdata)->ids.port_id, fmt, ##args) |
| 66 | |
| 67 | #define FC_FCP_DBG(pkt, fmt, args...) \ |
| 68 | FC_CHECK_LOGGING(FC_FCP_LOGGING, \ |
Yi Zou | 9b90dc8 | 2010-11-30 16:19:15 -0800 | [diff] [blame] | 69 | { \ |
| 70 | if ((pkt)->seq_ptr) { \ |
| 71 | struct fc_exch *_ep = NULL; \ |
| 72 | _ep = fc_seq_exch((pkt)->seq_ptr); \ |
| 73 | printk(KERN_INFO "host%u: fcp: %6.6x: " \ |
| 74 | "xid %04x-%04x: " fmt, \ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 75 | (pkt)->lp->host->host_no, \ |
Yi Zou | 9b90dc8 | 2010-11-30 16:19:15 -0800 | [diff] [blame] | 76 | (pkt)->rport->port_id, \ |
| 77 | (_ep)->oxid, (_ep)->rxid, ##args); \ |
| 78 | } else { \ |
| 79 | printk(KERN_INFO "host%u: fcp: %6.6x: " fmt, \ |
| 80 | (pkt)->lp->host->host_no, \ |
| 81 | (pkt)->rport->port_id, ##args); \ |
| 82 | } \ |
| 83 | }) |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 84 | |
| 85 | #define FC_EXCH_DBG(exch, fmt, args...) \ |
| 86 | FC_CHECK_LOGGING(FC_EXCH_LOGGING, \ |
| 87 | printk(KERN_INFO "host%u: xid %4x: " fmt, \ |
| 88 | (exch)->lp->host->host_no, \ |
| 89 | exch->xid, ##args)) |
| 90 | |
| 91 | #define FC_SCSI_DBG(lport, fmt, args...) \ |
Robert Love | 3a3b42b | 2009-11-03 11:47:39 -0800 | [diff] [blame] | 92 | FC_CHECK_LOGGING(FC_SCSI_LOGGING, \ |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 93 | printk(KERN_INFO "host%u: scsi: " fmt, \ |
| 94 | (lport)->host->host_no, ##args)) |
| 95 | |
| 96 | /* |
Joe Eykholt | 96ad846 | 2011-01-28 16:04:02 -0800 | [diff] [blame] | 97 | * FC-4 Providers. |
| 98 | */ |
| 99 | extern struct fc4_prov *fc_active_prov[]; /* providers without recv */ |
| 100 | extern struct fc4_prov *fc_passive_prov[]; /* providers with recv */ |
| 101 | extern struct mutex fc_prov_mutex; /* lock over table changes */ |
| 102 | |
| 103 | extern struct fc4_prov fc_rport_t0_prov; /* type 0 provider */ |
| 104 | extern struct fc4_prov fc_lport_els_prov; /* ELS provider */ |
| 105 | extern struct fc4_prov fc_rport_fcp_init; /* FCP initiator provider */ |
| 106 | |
| 107 | /* |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 108 | * Set up direct-data placement for this I/O request |
| 109 | */ |
| 110 | void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid); |
Yi Zou | 6a716a8 | 2011-05-16 16:45:40 -0700 | [diff] [blame] | 111 | void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp); |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 112 | |
| 113 | /* |
| 114 | * Module setup functions |
| 115 | */ |
| 116 | int fc_setup_exch_mgr(void); |
| 117 | void fc_destroy_exch_mgr(void); |
| 118 | int fc_setup_rport(void); |
| 119 | void fc_destroy_rport(void); |
Robert Love | 93e6d5a | 2009-11-03 11:46:03 -0800 | [diff] [blame] | 120 | int fc_setup_fcp(void); |
| 121 | void fc_destroy_fcp(void); |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 122 | |
| 123 | /* |
| 124 | * Internal libfc functions |
| 125 | */ |
| 126 | const char *fc_els_resp_type(struct fc_frame *); |
Joe Eykholt | 70d53b0 | 2011-01-28 16:04:18 -0800 | [diff] [blame] | 127 | extern void fc_fc4_add_lport(struct fc_lport *); |
| 128 | extern void fc_fc4_del_lport(struct fc_lport *); |
Kiran Patil | acc1a92 | 2011-01-28 16:05:22 -0800 | [diff] [blame] | 129 | 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] | 130 | |
Robert Love | 5868287 | 2009-11-03 11:47:28 -0800 | [diff] [blame] | 131 | /* |
| 132 | * Copies a buffer into an sg list |
| 133 | */ |
| 134 | u32 fc_copy_buffer_to_sglist(void *buf, size_t len, |
| 135 | struct scatterlist *sg, |
| 136 | u32 *nents, size_t *offset, |
Cong Wang | 77dfce0 | 2011-11-25 23:14:23 +0800 | [diff] [blame] | 137 | u32 *crc); |
Robert Love | 5868287 | 2009-11-03 11:47:28 -0800 | [diff] [blame] | 138 | |
Robert Love | 8866a5d | 2009-11-03 11:45:58 -0800 | [diff] [blame] | 139 | #endif /* _FC_LIBFC_H_ */ |