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