1 /*- 2 * Copyright (c) 2017 Broadcom. All rights reserved. 3 * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef __OCS_CAM_H__ 33 #define __OCS_CAM_H__ 34 35 #include <cam/cam.h> 36 #include <cam/cam_sim.h> 37 #include <cam/cam_ccb.h> 38 #include <cam/cam_periph.h> 39 #include <cam/cam_xpt_sim.h> 40 41 #include <cam/scsi/scsi_message.h> 42 43 #define ccb_ocs_ptr spriv_ptr0 44 #define ccb_io_ptr spriv_ptr1 45 46 typedef STAILQ_HEAD(ocs_hdr_list_s, ccb_hdr) ocs_hdr_list_t; 47 48 typedef struct ocs_tgt_resource_s { 49 ocs_hdr_list_t atio; 50 ocs_hdr_list_t inot; 51 uint8_t enabled; 52 53 lun_id_t lun; 54 } ocs_tgt_resource_t; 55 56 /* Common SCSI Domain structure declarations */ 57 58 typedef struct { 59 } ocs_scsi_tgt_domain_t; 60 61 typedef struct { 62 } ocs_scsi_ini_domain_t; 63 64 /* Common SCSI SLI port structure declarations */ 65 66 typedef struct { 67 } ocs_scsi_tgt_sport_t; 68 69 typedef struct { 70 } ocs_scsi_ini_sport_t; 71 72 /* Common IO structure declarations */ 73 74 typedef enum { 75 OCS_CAM_IO_FREE, /* IO unused (SIM) */ 76 OCS_CAM_IO_COMMAND, /* ATIO returned to BE (CTL) */ 77 OCS_CAM_IO_DATA, /* data phase (SIM) */ 78 OCS_CAM_IO_DATA_DONE, /* CTIO returned to BE (CTL) */ 79 OCS_CAM_IO_RESP, /* send response (SIM) */ 80 OCS_CAM_IO_MAX 81 } ocs_cam_io_state_t; 82 83 typedef struct { 84 bus_dmamap_t dmap; 85 uint64_t lun; /* target_lun */ 86 void *app; /** application specific pointer */ 87 ocs_cam_io_state_t state; 88 bool sendresp; 89 uint32_t flags; 90 #define OCS_CAM_IO_F_DMAPPED BIT(0) /* associated buffer bus_dmamap'd */ 91 #define OCS_CAM_IO_F_ABORT_RECV BIT(1) /* received ABORT TASK */ 92 #define OCS_CAM_IO_F_ABORT_DEV BIT(2) /* abort WQE pending */ 93 #define OCS_CAM_IO_F_ABORT_TMF BIT(3) /* TMF response sent */ 94 #define OCS_CAM_IO_F_ABORT_NOTIFY BIT(4) /* XPT_NOTIFY sent to CTL */ 95 #define OCS_CAM_IO_F_ABORT_CAM BIT(5) /* received ABORT or CTIO from CAM */ 96 } ocs_scsi_tgt_io_t; 97 98 typedef struct { 99 } ocs_scsi_ini_io_t; 100 101 struct ocs_lun_crn { 102 uint64_t lun; /* target_lun */ 103 uint8_t crnseed; /* next command reference number */ 104 }; 105 106 /* Common NODE structure declarations */ 107 typedef struct { 108 struct ocs_lun_crn *lun_crn[OCS_MAX_LUN]; 109 } ocs_scsi_ini_node_t; 110 111 typedef struct { 112 uint32_t busy_sent; 113 } ocs_scsi_tgt_node_t; 114 115 extern int32_t ocs_cam_attach(ocs_t *ocs); 116 extern int32_t ocs_cam_detach(ocs_t *ocs); 117 118 #endif /* __OCS_CAM_H__ */ 119