fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Message printing flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Debug levels
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_INIT_INSTANCES 8 /* # of instances for soft_state_init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Definitions for command retries */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MAX_CMD_RETRIES 5 /* Max retries in case of failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_RETRY_INTERVAL 3 /* Retry interval in seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_RETRY_TICKER 1 /* Retry thread execution interval */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MAX_JOB_RETRIES 3 /* Max retries in case of job failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcsm_job - Job structure to issue commands using command thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int job_port_instance; /* port driver instance */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*job_comp)(opaque_t, struct fcsm_job *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* completion func */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opaque_t job_comp_arg; /* Arg for completion func */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t job_priv_flags; /* fcsm private flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcsm_t - FCSM Structure for per port information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm *sm_next; /* for global linked list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_state; /* San Mgmt State information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_flags; /* San Mgmt Flags (see below) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_ulp_port_info_t sm_port_info; /* FCA Port Information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcsm_job_t *sm_job_head; /* port's job queue head */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcsm_job_t *sm_job_tail; /* port's job queue tail */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm_cmd *sm_retry_head; /* cmd retry queue head */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm_cmd *sm_retry_tail; /* cmd retry queue tail */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t sm_job_cv; /* cv for job processing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_dev_count; /* # of devices discovered */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_cache_t *sm_cmd_cache; /* per port fc packet cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mgmt Server Login Params */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sm_flags in the per port FCSM Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Command flags for Job structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Command codes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Private flags for command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Command DMA Flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_INIT_CMD(cmd, job, tran_flags, tran_type, max_retries, func) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd)->cmd_fc_packet.pkt_tran_flags = (tran_flags); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd)->cmd_fc_packet.pkt_tran_type = (tran_type); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Macros to address endian issues
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang * local variable "fcsm" must exist before using these
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang#define FCSM_REP_RD(handle, hostaddr, devaddr, cnt) \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) { \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang#define FCSM_REP_WR(handle, hostaddr, devaddr, cnt) \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL Definitions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* aiu_payload can be up to 'm' bytes (arbitrary length) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO_ADAPTER_LIST (FCSMIO_SUB_CMD + 0x02)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO_FIND_ADAPTER (FCSMIO_SUB_CMD + 0x03)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Management Server - Fabric Configuration Server Commands */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GTIN 0x0100 /* Get Topology Information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIEL 0x0101 /* Get Interconnect Element List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIET 0x0111 /* Get Interconnect Element Type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GDID 0x0112 /* Get Domain Identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GMID 0x0113 /* Get Management Identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIELN 0x0115 /* Get Interconnect Element Logical Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GMAL 0x0116 /* Get Management Address List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIEIL 0x0117 /* Get Interconnect Element Information List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPPN 0x0122 /* Get Physical Port Number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GAPNL 0x0124 /* Get Attached Port Name List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GATIN 0x0128 /* Get Attached Topology Information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPLNL 0x0191 /* Get Platform Node Name List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPLML 0x0193 /* Get Platform Management Address List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GNPL 0x01a1 /* Get Platform Name - Node Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPNL 0x01a2 /* Get Platform Name List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GNID 0x01b1 /* Get Node Identification Data - Node Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RIELN 0x0215 /* Register Interconnect Element Logical Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RPLN 0x0291 /* Register Platform Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RPLT 0x0292 /* Register Platform Type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RPLM 0x0293 /* Register Platform Management Address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_DPL 0x0380 /* Deregister Platform */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_DPLN 0x0391 /* Deregister Platform Node Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_DPLML 0x0393 /* Deregister Platform Management Addr List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Driver entry point functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_attach(dev_info_t *, ddi_attach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_detach(dev_info_t *, ddi_detach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_open(dev_t *, int, int, cred_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC Transport functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_port_attach(opaque_t, fc_ulp_port_info_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_port_detach(opaque_t, fc_ulp_port_info_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_port_ioctl(opaque_t, opaque_t, dev_t, int, intptr_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_statec_cb(opaque_t, opaque_t, uint32_t, uint32_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_els_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_data_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Internal functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_handle_port_attach(fc_ulp_port_info_t *, uint32_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_handle_port_resume(opaque_t, fc_ulp_port_info_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_handle_port_detach(fc_ulp_port_info_t *, fcsm_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_offline_timeout(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_fciocmd(intptr_t, int, cred_t *, fcio_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_fcio_copyout(fcio_t *, intptr_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_job_cache_constructor(void *, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_job_cache_destructor(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_init_job(fcsm_job_t *, int, uint32_t, uint32_t, opaque_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opaque_t, void (*comp)(opaque_t, fcsm_job_t *, int),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_enque_job(fcsm_t *, fcsm_job_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_cmd_cache_constructor(void *, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_cmd_cache_destructor(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic fcsm_cmd_t *fcsm_alloc_cmd(fcsm_t *, uint32_t, uint32_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_retry_job(fcsm_t *fcsm, fcsm_job_t *job);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_ct_init(fcsm_t *, fcsm_cmd_t *, fc_ct_aiu_t *, size_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_login_and_process_job(fcsm_t *, fcsm_job_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_login_ms_comp(opaque_t, fcsm_job_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_els_init(fcsm_cmd_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_xlogi_init(fcsm_t *, fcsm_cmd_t *, uint32_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_job_login_mgmt_server(fcsm_job_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_ct_passthru_comp(opaque_t, fcsm_job_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_enque_cmd(fcsm_t *, fcsm_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_retry_timeout(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_force_port_detach_all(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Utility functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_disp_devlist(fcsm_t *, fc_portmap_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *, const char *, ...);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _FCSM_H */