forked from ecdufcdrvr/bcmufctdrvr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathocs_common.h
411 lines (354 loc) · 15.7 KB
/
ocs_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
/*
* BSD LICENSE
*
* Copyright (c) 2011-2018 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* Contains declarations shared between the alex layer and HAL/SLI4
*/
#if !defined(__OCS_COMMON_H__)
#define __OCS_COMMON_H__
#include "ocs_common_shared.h"
#include "ocs_sm.h"
#include "spv.h"
typedef enum {OCS_XPORT_FC, OCS_XPORT_ISCSI} ocs_xport_e;
#define OCS_SERVICE_PARMS_LENGTH 0x74
#define OCS_DISPLAY_NAME_LENGTH 32
#define OCS_DISPLAY_BUS_INFO_LENGTH 16
#define OCS_WWN_LENGTH 32
typedef struct ocs_hal_s ocs_hal_t;
typedef struct ocs_domain_s ocs_domain_t;
typedef struct ocs_sli_port_s ocs_sli_port_t;
typedef struct ocs_sli_port_s ocs_sport_t;
typedef struct ocs_remote_node_s ocs_remote_node_t;
typedef struct ocs_remote_node_group_s ocs_remote_node_group_t;
typedef struct ocs_node_s ocs_node_t;
typedef struct ocs_io_s ocs_io_t;
typedef struct ocs_xport_s ocs_xport_t;
typedef struct ocs_node_cb_s ocs_node_cb_t;
typedef struct ocs_ns_s ocs_ns_t;
/* Node group data structure */
typedef struct ocs_node_group_dir_s ocs_node_group_dir_t;
#include "ocs_scsi_ini.h"
#include "ocs_scsi_tgt.h"
/*--------------------------------------------------
* Shared HAL/SLI objects
*
* Several objects used by the HAL/SLI layers are communal; part of the
* object is for the sole use of the lower layers, but implementations
* are free to add their own fields if desired.
*/
/**
* @brief Description of discovered Fabric Domain
*
* @note Not all fields are valid for all mediums (FC/ethernet).
*/
typedef struct ocs_domain_record_s {
uint32_t index; /**< FCF table index (used in REG_FCFI) */
uint32_t priority; /**< FCF reported priority */
uint8_t address[6]; /**< Switch MAC/FC address */
uint8_t wwn[8]; /**< Switch WWN */
union {
uint8_t vlan[512]; /**< bitmap of valid VLAN IDs */
uint8_t loop[128]; /**< FC-AL position map */
} map;
uint32_t speed; /**< link speed */
uint32_t fc_id; /**< our ports fc_id */
uint32_t is_fc:1, /**< Connection medium is native FC */
is_ethernet:1, /**< Connection medium is ethernet (FCoE) */
is_loop:1, /**< Topology is FC-AL */
is_nport:1, /**< Topology is N-PORT */
:28;
} ocs_domain_record_t;
/**
* @brief Node group directory entry
*/
struct ocs_node_group_dir_s {
uint32_t instance_index; /*<< instance index */
ocs_sport_t *sport; /*<< pointer to sport */
uint8_t service_params[OCS_SERVICE_PARMS_LENGTH]; /**< Login parameters */
ocs_list_link_t link; /**< linked list link */
ocs_list_t node_group_list; /**< linked list of node groups */
uint32_t node_group_list_count; /**< current number of elements on the node group list */
uint32_t next_idx; /*<< index of the next node group in list */
};
typedef enum {
OCS_SPORT_TOPOLOGY_UNKNOWN=0,
OCS_SPORT_TOPOLOGY_FABRIC,
OCS_SPORT_TOPOLOGY_P2P,
OCS_SPORT_TOPOLOGY_LOOP,
} ocs_sport_topology_e;
/**
* @brief SLI Port object
*
* The SLI Port object represents the connection between the driver and the
* FC/FCoE domain. In some topologies / hardware, it is possible to have
* multiple connections to the domain via different WWN. Each would require
* a separate SLI port object.
*/
struct ocs_sli_port_s {
ocs_t *ocs; /**< pointer to ocs */
uint32_t tgt_id; /**< target id */
uint32_t index; /**< ??? */
uint32_t instance_index;
char display_name[OCS_DISPLAY_NAME_LENGTH]; /**< sport display name */
ocs_domain_t *domain; /**< current fabric domain */
uint32_t is_vport:1; /**< this SPORT is a virtual port */
uint64_t wwpn; /**< WWPN from HAL (host endian) */
uint64_t wwnn; /**< WWNN from HAL (host endian) */
ocs_list_t node_list; /**< list of nodes */
ocs_scsi_ini_sport_t ini_sport; /**< initiator backend private sport data */
ocs_scsi_tgt_sport_t tgt_sport; /**< target backend private sport data */
void *tgt_data; /**< target backend private pointer */
void *ini_data; /**< initiator backend private pointer */
ocs_mgmt_functions_t *mgmt_functions;
/*
* Members private to HAL/SLI
*/
ocs_sm_ctx_t ctx; /**< state machine context */
ocs_hal_t *hal; /**< pointer to HAL */
uint32_t indicator; /**< VPI */
uint32_t fc_id; /**< FC address */
ocs_dma_t dma; /**< memory for Service Parameters */
uint8_t wwnn_str[OCS_WWN_LENGTH]; /**< WWN (ASCII) */
uint64_t sli_wwpn; /**< WWPN (wire endian) */
uint64_t sli_wwnn; /**< WWNN (wire endian) */
uint32_t sm_free_req_pending:1; /**< Free request received while waiting for attach response */
/*
* Implementation specific fields allowed here
*/
ocs_sm_ctx_t sm; /**< sport context state machine */
sparse_vector_t lookup; /**< fc_id to node lookup object */
ocs_list_link_t link;
uint32_t enable_ini:1, /**< SCSI initiator enabled for this node */
enable_tgt:1, /**< SCSI target enabled for this node */
enable_rscn:1, /**< This SPORT will be expecting RSCN */
shutting_down:1, /**< sport in process of shutting down */
p2p_winner:1; /**< TRUE if we're the point-to-point winner */
ocs_sport_topology_e topology; /**< topology: fabric/p2p/unknown */
uint8_t service_params[OCS_SERVICE_PARMS_LENGTH]; /**< Login parameters */
uint32_t p2p_remote_port_id; /**< Remote node's port id for p2p */
uint32_t p2p_port_id; /**< our port's id */
/* List of remote node group directory entries (used by high login mode) */
ocs_lock_t node_group_lock;
uint32_t node_group_dir_next_instance; /**< HLM next node group directory instance value */
uint32_t node_group_next_instance; /**< HLM next node group instance value */
ocs_list_t node_group_dir_list;
};
/**
* @brief Fibre Channel domain object
*
* This object is a container for the various SLI components needed
* to connect to the domain of a FC or FCoE switch
*/
struct ocs_domain_s {
ocs_t *ocs; /**< pointer back to ocs */
uint32_t instance_index; /**< unique instance index value */
char display_name[OCS_DISPLAY_NAME_LENGTH]; /**< Node display name */
ocs_list_t sport_list; /**< linked list of SLI ports */
ocs_scsi_ini_domain_t ini_domain; /**< initiator backend private domain data */
ocs_scsi_tgt_domain_t tgt_domain; /**< target backend private domain data */
ocs_mgmt_functions_t *mgmt_functions;
/* Declarations private to HAL/SLI */
ocs_hal_t *hal; /**< pointer to HAL */
ocs_sm_ctx_t sm; /**< state machine context */
uint32_t fcf; /**< FC Forwarder table index */
uint32_t fcf_indicator; /**< FCFI */
uint32_t vlan_id; /**< VLAN tag for this domain */
uint32_t indicator; /**< VFI */
ocs_dma_t dma; /**< memory for Service Parameters */
uint32_t req_rediscover_fcf:1; /**< TRUE if fcf rediscover is needed (in response
* to Vlink Clear async event */
/* Declarations private to FC transport */
uint64_t fcf_wwn; /**< WWN for FCF/switch */
ocs_list_link_t link;
ocs_sm_ctx_t drvsm; /**< driver domain sm context */
ocs_rlock_t drvsm_lock; /**< driver domain sm lock */
uint32_t attached:1, /**< set true after attach completes */
is_fc:1, /**< is FC */
is_loop:1, /**< is loop topology */
is_nlport:1, /**< is public loop */
domain_found_pending:1, /**< A domain found is pending, drec is updated */
req_domain_free:1, /**< True if domain object should be free'd */
req_accept_frames:1; /**< set in domain state machine to enable frames */
ocs_domain_record_t pending_drec; /**< Pending drec if a domain found is pending */
uint8_t service_params[OCS_SERVICE_PARMS_LENGTH]; /**< any sports service parameters */
uint8_t flogi_service_params[OCS_SERVICE_PARMS_LENGTH]; /**< Fabric/P2p service parameters from FLOGI */
uint8_t femul_enable; /**< TRUE if Fabric Emulation mode is enabled */
#if defined(ENABLE_FABRIC_EMULATION)
uint8_t femul_vports_started; /**< TRUE if fabric vports are started */
ocs_atomic_t femul_count; /**< count of fabric emulation nodes in the process of being created */
uint16_t femul_oxid; /**< ox_id for FLOGI response */
uint64_t femul_port_name;/**< used to populate nameserver db */
#endif
/* Declarations shared with back-ends */
sparse_vector_t lookup; /**< d_id to node lookup object */
ocs_lock_t lookup_lock;
ocs_sli_port_t *sport; /**< Pointer to first (physical) SLI port (also at the head of sport_list) */
uint32_t sport_instance_count; /**< count of sport instances */
/* Fabric Emulation */
ocs_bitmap_t *portid_pool;
ocs_ns_t *ocs_ns; /*>> Directory(Name) services data */
};
/**
* @brief Remote Node object
*
* This object represents a connection between the SLI port and another
* Nx_Port on the fabric. Note this can be either a well known port such
* as a F_Port (i.e. ff:ff:fe) or another N_Port.
*/
struct ocs_remote_node_s {
/*
* Members private to HAL/SLI
*/
uint32_t indicator; /**< RPI */
uint32_t index;
uint32_t fc_id; /**< FC address */
uint32_t attached:1, /**< true if attached */
node_group:1, /**< true if in node group */
free_group:1; /**< true if the node group should be free'd */
ocs_sli_port_t *sport; /**< associated SLI port */
/*
* Implementation specific fields allowed here
*/
void *node; /**< associated node */
};
struct ocs_remote_node_group_s {
/*
* Members private to HAL/SLI
*/
uint32_t indicator; /**< RPI */
uint32_t index;
/*
* Implementation specific fields allowed here
*/
uint32_t instance_index; /*<< instance index */
ocs_node_group_dir_t *node_group_dir; /*<< pointer to the node group directory */
ocs_list_link_t link; /*<< linked list link */
};
typedef enum {
OCS_NODE_SHUTDOWN_DEFAULT = 0,
OCS_NODE_SHUTDOWN_EXPLICIT_LOGO,
OCS_NODE_SHUTDOWN_IMPLICIT_LOGO,
} ocs_node_shutd_rsn_e;
typedef enum {
OCS_NODE_SEND_LS_ACC_NONE = 0,
OCS_NODE_SEND_LS_ACC_PLOGI,
OCS_NODE_SEND_LS_ACC_PRLI,
} ocs_node_send_ls_acc_e;
/**
* @brief FC Node object
*
*/
struct ocs_node_s {
ocs_t *ocs; /**< pointer back to ocs structure */
uint32_t instance_index; /**< unique instance index value */
char display_name[2 * OCS_DISPLAY_NAME_LENGTH]; /**< Node display name */
ocs_sport_t *sport;
uint32_t hold_frames:1; /**< hold incoming frames if true */
ocs_rlock_t lock; /**< node wide lock */
ocs_lock_t active_ios_lock; /**< active SCSI and XPORT I/O's for this node */
ocs_list_t active_ios; /**< active I/O's for this node */
uint32_t max_wr_xfer_size; /**< Max write IO size per phase for the transport */
ocs_scsi_ini_node_t ini_node; /**< backend initiator private node data */
ocs_scsi_tgt_node_t tgt_node; /**< backend target private node data */
ocs_mgmt_functions_t *mgmt_functions;
/* Declarations private to HAL/SLI */
ocs_remote_node_t rnode; /**< Remote node */
/* Declarations private to FC transport */
ocs_sm_ctx_t sm; /**< state machine context */
uint32_t evtdepth; /**< current event posting nesting depth */
uint32_t req_free:1, /**< this node is to be free'd */
attached:1, /**< node is attached (REGLOGIN complete) */
fcp_enabled:1, /**< node is enabled to handle FCP */
rscn_pending:1, /**< for name server node RSCN is pending */
send_plogi:1, /**< if initiator, send PLOGI at node initialization */
send_plogi_acc:1,/**< send PLOGI accept, upon completion of node attach */
io_alloc_enabled:1; /**< TRUE if ocs_scsi_io_alloc() and ocs_els_io_alloc() are enabled */
ocs_node_send_ls_acc_e send_ls_acc; /**< type of LS acc to send */
ocs_io_t *ls_acc_io; /**< SCSI IO for LS acc */
uint32_t ls_acc_oxid; /**< OX_ID for pending accept */
uint32_t ls_acc_did; /**< D_ID for pending accept */
ocs_node_shutd_rsn_e shutdown_reason;/**< reason for node shutdown */
ocs_dma_t sparm_dma_buf; /**< service parameters buffer */
uint8_t service_params[OCS_SERVICE_PARMS_LENGTH]; /**< plogi/acc frame from remote device */
ocs_lock_t pend_frames_lock; /**< lock for inbound pending frames list */
ocs_list_t pend_frames; /**< inbound pending frames list */
uint32_t pend_frames_processed; /**< count of frames processed in hold frames interval */
uint32_t ox_id_in_use; /**< used to verify one at a time us of ox_id */
uint32_t els_retries_remaining; /**< for ELS, number of retries remaining */
uint32_t els_req_cnt; /**< number of outstanding ELS requests */
uint32_t els_cmpl_cnt; /**< number of outstanding ELS completions */
uint32_t abort_cnt; /**< Abort counter for debugging purpose */
char current_state_name[OCS_DISPLAY_NAME_LENGTH]; /**< current node state */
char prev_state_name[OCS_DISPLAY_NAME_LENGTH]; /**< previous node state */
ocs_sm_event_t current_evt; /**< current event */
ocs_sm_event_t prev_evt; /**< current event */
uint32_t targ:1, /**< node is target capable */
init:1, /**< node is init capable */
nvme_init:1, /**< node is NVME tgt capable */
nvme_tgt:1, /**< node is NVME tgt capable */
refound:1; /**< Handle node refound case when node is being deleted */
uint32_t nvme_prli_service_params;
ocs_list_t els_io_pend_list; /**< list of pending (not yet processed) ELS IOs */
ocs_list_t els_io_active_list; /**< list of active (processed) ELS IOs */
ocs_sm_function_t nodedb_state; /**< Node debugging, saved state */
ocs_timer_t gidft_delay_timer; /**< GIDFT delay timer */
time_t time_last_gidft_msec; /**< Start time of last target RSCN GIDFT */
/* WWN */
char wwnn[OCS_WWN_LENGTH]; /**< remote port WWN (uses iSCSI naming) */
char wwpn[OCS_WWN_LENGTH]; /**< remote port WWN (uses iSCSI naming) */
/* Statistics */
uint32_t chained_io_count; /**< count of IOs with chained SGL's */
ocs_list_link_t link; /**< node list link */
ocs_remote_node_group_t *node_group; /**< pointer to node group (if HLM enabled) */
};
/**
* @brief Virtual port specification
*
* Collection of the information required to restore a virtual port across
* link events
*/
typedef struct ocs_vport_spec_s ocs_vport_spec_t;
struct ocs_vport_spec_s {
uint32_t domain_instance; /*>> instance index of this domain for the sport */
uint64_t wwnn; /*>> node name */
uint64_t wwpn; /*>> port name */
uint32_t fc_id; /*>> port id */
uint32_t enable_tgt:1, /*>> port is a target */
enable_ini:1, /*>> port is an initiator */
enable_nvme_tgt:1; /**< NVME target functionality */
ocs_list_link_t link; /*>> link */
void *tgt_data; /**< target backend pointer */
void *ini_data; /**< initiator backend pointer */
ocs_sport_t *sport; /**< Used to match record after attaching for update */
};
#endif // __OCS_COMMON_H__