]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/ocs_fc/ocs_cam.h
[ath] replace the hard-coded magic values in if_athioctl.h with constant defines
[FreeBSD/FreeBSD.git] / sys / dev / ocs_fc / ocs_cam.h
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  * $FreeBSD$
32  */
33
34 #ifndef __OCS_CAM_H__
35 #define __OCS_CAM_H__
36
37 #include <cam/cam.h>
38 #include <cam/cam_sim.h>
39 #include <cam/cam_ccb.h>
40 #include <cam/cam_periph.h>
41 #include <cam/cam_xpt_sim.h>
42
43 #include <cam/scsi/scsi_message.h>
44
45 #define ccb_ocs_ptr     spriv_ptr0
46 #define ccb_io_ptr      spriv_ptr1
47
48 typedef STAILQ_HEAD(ocs_hdr_list_s, ccb_hdr) ocs_hdr_list_t;
49
50 typedef struct ocs_tgt_resource_s {
51         ocs_hdr_list_t  atio;
52         ocs_hdr_list_t  inot;
53         uint8_t         enabled;
54
55         lun_id_t        lun;
56 } ocs_tgt_resource_t;
57
58 /* Common SCSI Domain structure declarations */
59
60 typedef struct {
61 } ocs_scsi_tgt_domain_t;
62
63 typedef struct {
64 } ocs_scsi_ini_domain_t;
65
66 /* Common SCSI SLI port structure declarations */
67
68 typedef struct {
69 } ocs_scsi_tgt_sport_t;
70
71 typedef struct {
72 } ocs_scsi_ini_sport_t;
73
74 /* Common IO structure declarations */
75
76 typedef enum {
77         OCS_CAM_IO_FREE,        /* IO unused            (SIM) */
78         OCS_CAM_IO_COMMAND,     /* ATIO returned to BE  (CTL) */
79         OCS_CAM_IO_DATA,        /* data phase           (SIM) */
80         OCS_CAM_IO_DATA_DONE,   /* CTIO returned to BE  (CTL) */
81         OCS_CAM_IO_RESP,        /* send response        (SIM) */
82         OCS_CAM_IO_MAX
83 } ocs_cam_io_state_t;
84
85 typedef struct {
86         bus_dmamap_t    dmap;
87         uint64_t lun;           /* target_lun */
88         void            *app;   /** application specific pointer */
89         ocs_cam_io_state_t state;
90         bool            sendresp;
91         uint32_t        flags;
92 #define OCS_CAM_IO_F_DMAPPED            BIT(0)  /* associated buffer bus_dmamap'd */
93 #define OCS_CAM_IO_F_ABORT_RECV         BIT(1)  /* received ABORT TASK */
94 #define OCS_CAM_IO_F_ABORT_DEV          BIT(2)  /* abort WQE pending */
95 #define OCS_CAM_IO_F_ABORT_TMF          BIT(3)  /* TMF response sent */
96 #define OCS_CAM_IO_F_ABORT_NOTIFY       BIT(4)  /* XPT_NOTIFY sent to CTL */
97 #define OCS_CAM_IO_F_ABORT_CAM          BIT(5)  /* received ABORT or CTIO from CAM */
98 } ocs_scsi_tgt_io_t;
99
100 typedef struct {
101 } ocs_scsi_ini_io_t;
102
103 struct ocs_lun_crn {
104         uint64_t lun;                   /* target_lun */
105         uint8_t crnseed;                /* next command reference number */
106 };
107
108 /* Common NODE structure declarations */
109 typedef struct {
110         struct ocs_lun_crn *lun_crn[OCS_MAX_LUN];
111 } ocs_scsi_ini_node_t;
112
113 typedef struct {
114         uint32_t        busy_sent;
115 } ocs_scsi_tgt_node_t;
116
117 extern int32_t ocs_cam_attach(ocs_t *ocs);
118 extern int32_t ocs_cam_detach(ocs_t *ocs);
119
120 #endif /* __OCS_CAM_H__ */