fc_libfc.h 3.7 KB

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