s1394.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_1394_S1394_H
#define _SYS_1394_S1394_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* s1394.h
* Contains all of the structures used (internally) by the 1394
* Software Framework
*/
#include <sys/dditypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/* SelfID buffer size */
#define S1394_SELFID_BUF_SIZE 8192
/* Maximum number of allocated commands per target */
#define MAX_NUMBER_ALLOC_CMDS 256
/* Maximum number of lock retries */
#define MAX_NUMBER_OF_LOCK_RETRIES 256
#define S1394_INITIAL_STATES 2
/* Invalid entry in the Speed Map */
#define SPEED_MAP_INVALID 0xFF
/* Invalid node num */
#define S1394_INVALID_NODE_NUM 0x3F
/* Node state */
#define S1394_NODE_OFFLINE 1
#define S1394_NODE_ONLINE 2
/* Where are commands inserted onto the pending Q? */
#define S1394_PENDING_Q_FRONT 1
#define S1394_PENDING_Q_REAR 2
/* Number of self-initiated bus resets until HAL fails */
#define NUM_BR_FAIL 5
/* Reasons for Self-Initiated Bus Reset */
#define NON_CRITICAL 0
#define CRITICAL 1
/* Bus Mgr (IRM) defines */
#define ROOT_HOLDOFF (1 << 0)
/* Root Node has no parents */
#define NO_PARENT -1
/* Maximum number of Hops between Nodes on the Bus */
#define MAX_HOPS 23
/* Invalid lo and hi addresses used in s1394_init_addr_space() */
#define ADDR_LO_INVALID 0x0000000000000001
#define ADDR_HI_INVALID 0x0000000000000000
/* Time to delay after CYCLE_TOO_LONG before enabling cycle master */
/* Size of directory stack used during config rom scan */
#define S1394_DIR_STACK_SIZE 16
/*
* P1394a (Draft 2.x) proposes to disallow a
* Config ROM "generation" to be repeated within
* a 60 second window.
* Because of that, this value should not be set
* to any value smaller than 5 seconds without
* another method in place to ensure that this
* "generation" reuse can not happen.
*/
/*
* Time delay (in ms) from Config ROM update to
* software-initiated bus reset.
*/
#define S1394_ROOT_TEXT_LEAF_SZ 36
#define S1394_ROOT_TEXT_LEAF_QUAD_SZ 9
#define S1394_ROOT_TEXT_KEY 0x81
#define S1394_NODE_UNIQUE_ID_SZ 12
#define S1394_NODE_UNIQUE_ID_QUAD_SZ 3
#define S1394_NODE_UNIQUE_ID_KEY 0x8D
#define S1394_UNIT_DIR_SZ 56
#define S1394_UNIT_DIR_QUAD_SZ 14
#define S1394_UNIT_DIR_KEY 0xD1
/* The Organizationally Unique Identifier for Sun Microsystems, Inc. */
#define S1394_SUNW_OUI 0x080020
/* Number of retries in reading the Config ROM */
#define CFGROM_READ_RETRIES 5
/* Delay time between reads of the Config ROM */
/* Error message for serious HBA hardware shutdowns */
#define HALT_ERROR_MESSAGE "%s%d: Unexpected Error: Shutting down HBA -" \
" Hardware disabled until next reboot"
/* Command Transaction Type */
#define S1394_CMD_READ 0
#define S1394_CMD_WRITE 1
#define S1394_CMD_LOCK 2
/* Channel allocations */
#define S1394_CHANNEL_ALLOC_HI 1
#define S1394_CHANNEL_ALLOC_LO 0
/* Maximum number of bus resets allowed in isoch rsrc alloc */
#define S1394_ISOCH_ALLOC_RETRIES 5
#define ADDR_RESERVED 1
/* Flags used by the used tree (red-black tree) */
#define BLACK 0
#define RED 1
#define LEFT 0
#define RIGHT 1
/* Isoch Bandwidth Allocation Units conversion */
#define ISOCH_SPEED_FACTOR_S100 16
#define ISOCH_SPEED_FACTOR_S200 8
#define ISOCH_SPEED_FACTOR_S400 4
/* TNF probes */
#define S1394_TNF_SL "1394 s1394 "
#define S1394_TNF_SL_ERROR "1394 s1394 error "
#define S1394_TNF_SL_STACK "1394 s1394 stacktrace "
#define S1394_TNF_SL_ARREQ_STACK "1394 s1394 arreq stacktrace "
#define S1394_TNF_SL_ARREQ_ERROR "1394 s1394 arreq error "
#define S1394_TNF_SL_ATREQ_STACK "1394 s1394 atreq stacktrace "
#define S1394_TNF_SL_ATREQ_ERROR "1394 s1394 atreq error "
#define S1394_TNF_SL_ATRESP_STACK "1394 s1394 atresp stacktrace "
#define S1394_TNF_SL_ATRESP_ERROR "1394 s1394 atresp error "
#define S1394_TNF_SL_ATREQ_ATRESP_STACK "1394 s1394 atreq atresp stacktrace "
#define S1394_TNF_SL_ATREQ_ATRESP_ERROR "1394 s1394 atreq atresp error "
#define S1394_TNF_SL_BR_STACK "1394 s1394 bus_reset stacktrace "
#define S1394_TNF_SL_BR_ERROR "1394 s1394 bus_reset error "
#define S1394_TNF_SL_IOCTL_STACK "1394 s1394 ioctl stacktrace "
#define S1394_TNF_SL_HOTPLUG_STACK "1394 s1394 hotplug stacktrace "
#define S1394_TNF_SL_HOTPLUG_ERROR "1394 s1394 hotplug error "
#define S1394_TNF_SL_NX1394_STACK "1394 s1394 nx1394 stacktrace "
#define S1394_TNF_SL_CSR_ERROR "1394 s1394 csr error "
#define S1394_TNF_SL_CSR_STACK "1394 s1394 csr stacktrace "
#define S1394_TNF_SL_BR_CSR_STACK "1394 s1394 bus_reset csr stacktrace "
#define S1394_TNF_SL_CFGROM_ERROR "1394 s1394 cfgrom error "
#define S1394_TNF_SL_CFGROM_STACK "1394 s1394 cfgrom stacktrace "
#define S1394_TNF_SL_ISOCH_ERROR "1394 s1394 isoch error "
#define S1394_TNF_SL_ISOCH_STACK "1394 s1394 isoch stacktrace "
#define S1394_TNF_SL_NEXUS_ERROR "1394 s1394 nexus error "
#define S1394_TNF_SL_NEXUS_STACK "1394 s1394 nexus stacktrace "
#define S1394_TNF_SL_FA_STACK "1394 s1394 FA stacktrace "
#define S1394_TNF_SL_FA_ERROR "1394 s1394 FA error "
#define S1394_TNF_SL_FCP_STACK "1394 s1394 FCP stacktrace "
#define S1394_TNF_SL_FCP_ERROR "1394 s1394 FCP error "
#define S1394_TNF_SL_CMP_STACK "1394 s1394 CMP stacktrace "
#define S1394_TNF_SL_CMP_ERROR "1394 s1394 CMP error "
/* s1394_hal_state_t */
typedef enum {
/* s1394_isoch_cec_type_t */
typedef enum {
S1394_SINGLE = 1,
/* s1394_isoch_cec_state_t */
typedef enum {
ISOCH_CEC_FREE = (1 << 0),
/* s1394_status_t */
typedef enum {
S1394_NOSTATUS = (1 << 0),
/* s1394_free_cfgrom_t */
typedef enum {
typedef struct s1394_node_s s1394_node_t;
typedef struct s1394_target_s s1394_target_t;
typedef struct s1394_hal_s s1394_hal_t;
typedef struct s1394_addr_space_blk_s s1394_addr_space_blk_t;
typedef struct s1394_config_rom_s s1394_config_rom_t;
typedef struct s1394_kstat_s s1394_kstat_t;
typedef struct s1394_isoch_cec_s s1394_isoch_cec_t;
typedef struct s1394_isoch_cec_member_s s1394_isoch_cec_member_t;
/* cfgrom_dir_t */
typedef struct {
} cfgrom_dir_t;
/* s1394_selfid_pkt_t */
typedef struct s1394_selfid_pkt_s {
/* s1394_node_t */
struct s1394_node_s {
/* All fields above can be zero'd while initing the topology tree */
/* fields dir_stack through expected_dir_quad constitute dir stack */
char dir_stack_top;
};
/* defines used during enumeration */
/* defines for link_active */
#define CLEAR_LINK_ACTIVE(n) ((n)->link_active = 0)
#define LINK_ACTIVE(n) \
/* defines for state */
#define S1394_NODE_CONSUMING_PWR 0x00000001
#define S1394_NODE_ACTIVE 0x00000010
#define S1394_NODE_BUS_PWR_CONSUMER(n) \
/* defines for cfgrom_state */
#define S1394_VALID_MASK \
#define CFGROM_VALID(n) \
/* macros for cfgrom_state */
#define CFGROM_NEW_ALLOC(n) \
#define CFGROM_BIB_READ(n) \
#define CLEAR_CFGROM_ALL_READ(n) ((n)->cfgrom_state &= \
#define CFGROM_ALL_READ(n) \
#define SET_CFGROM_BLK_READ_OK(n) \
((n)->cfgrom_state |= S1394_CFGROM_BLK_READ_OK)
#define CLEAR_CFGROM_BLK_READ_OK(n) \
((n)->cfgrom_state &= ~S1394_CFGROM_BLK_READ_OK)
#define CFGROM_BLK_READ_OK(n) \
#define SET_CFGROM_GEN_CHANGED(n) \
((n)->cfgrom_state |= S1394_CFGROM_GEN_CHANGED)
#define CLEAR_CFGROM_GEN_CHANGED(n) \
((n)->cfgrom_state &= ~S1394_CFGROM_GEN_CHANGED)
#define CFGROM_GEN_CHANGED(n) \
#define CFGROM_PARSED(n) \
#define SET_CFGROM_DIR_STACK_OFF(n) \
((n)->cfgrom_state |= S1394_CFGROM_DIR_STACK_OFF)
#define CLEAR_CFGROM_DIR_STACK_OFF(n) \
((n)->cfgrom_state &= ~S1394_CFGROM_DIR_STACK_OFF)
#define CFGROM_DIR_STACK_OFF(n) \
#define SET_CFGROM_SIZE_IS_CRCSIZE(n) \
((n)->cfgrom_state |= S1394_CFGROM_SIZE_IS_CRCSIZE)
#define CLEAR_CFGROM_SIZE_IS_CRCSIZE(n) \
((n)->cfgrom_state &= ~S1394_CFGROM_SIZE_IS_CRCSIZE)
#define CFGROM_SIZE_IS_CRCSIZE(n) \
/* defines for bus_enum_flags */
#define S1394_NODE_VISITED 0x00000001
#define S1394_NODE_MATCHED 0x00000010
#define NODE_VISITED(n) \
#define NODE_MATCHED(n) \
#define NODE_IDENTIFIED(n) \
/*
* s1394_fa_type_t - FA types, used as index into target_fa and hal_fa
*/
typedef enum {
S1394_FA_TYPE_FCP_CTL, /* FCP controller */
S1394_FA_TYPE_FCP_TGT, /* FCP target */
S1394_FA_TYPE_CMP_OMPR, /* CMP oMPR */
S1394_FA_TYPE_CMP_IMPR, /* CMP iMPR */
S1394_FA_NTYPES, /* should remain the last field */
/*
* s1394_fa_descr_t - FA type descriptor
*/
typedef struct s1394_fa_descr_s {
/*
* s1394_fcp_target_t - per-target data required for FCP support
*/
typedef struct s1394_fcp_target_s {
/*
* s1394_cmp_target_t - per-target data required for CMP support
*/
typedef struct s1394_cmp_target_s {
/*
* s1394_fa_target_t - per-target data required for fixed address support
*/
typedef struct s1394_fa_target_s {
/* type-specific data */
union {
} fat_u;
/* s1394_target_t - fields protected by the HAL's target_list_rwlock */
struct s1394_target_s {
int target_version;
/* Pointers to the node and HAL on which the target exists */
/* target_list is a copy of target_list pointer in the node */
/* The max_payload sizes - max and current conditions */
/* Number of asynch command target has allocated */
/*
* Are physical AR requests allowed from this target's node?
* This field keeps track of the number of allocated blocks
* of physical memory the target has.
*/
/* FCP controller and target */
};
/*
* s1394_fa_hal_t - per-hal data required for fixed address support
*/
typedef struct s1394_fa_hal_s {
/*
* each hal keeps a list of registered fixed address clients
*/
/*
* s1394_cmp_hal_t - per-hal data required for fixed address support
*/
typedef struct s1394_cmp_hal_s {
/* oMPR */
/* iMPR */
/* s1394_hal_t */
struct s1394_hal_s {
/* Target list */
/* halinfo structure given at attach time */
/* Bus reset thread */
/* kstats - kernel statistics for the Services Layer */
/* CSR STATE register bits (DREQ and ABDICATE) */
int initiated_br_reason;
/* IRM and Bus Manager */
int IRM_node;
int bus_mgr_node;
/* 1394 Bus stats */
int gap_count;
int optimum_gap_count;
/* Local Config ROM */
/* Cycle Master - CYCLE_TOO_LONG timer */
/* Incoming (AR) request and 1394 address space */
/* Outgoing (AT) request queues */
/* SelfID buffers */
void *selfid_buf0;
void *selfid_buf1;
int current_buffer;
/* Topology trees and local bus stats */
/* TOPOLOGY_MAP backing store buffer */
/* Speed Map */
/* Stack, Queue, and Node Number list */
void *hal_stack[IEEE1394_MAX_NODES];
int hal_stack_depth;
void *hal_queue[IEEE1394_MAX_NODES];
int hal_queue_front;
int hal_queue_back;
/* Isoch CEC list */
struct kmem_cache *hal_kmem_cachep;
/* FCP controllers and targets */
/* CMP support */
};
/* defines for br_thread_ev_type */
/*
* FCP command and response address space
*/
#define IEC61883_FCP_BASE_ADDR 0xFFFFF0000B00
#define IEC61883_FCP_CMD_SIZE 0x200
#define IEC61883_FCP_RESP_SIZE 0x200
/* CMP master plugs */
#define IEC61883_CMP_OMPR_ADDR 0xFFFFF0000900
#define IEC61883_CMP_IMPR_ADDR 0xFFFFF0000980
#define IEC61883_CMP_OMPR_INIT_VAL 0xBFFFFF00
#define IEC61883_CMP_IMPR_INIT_VAL 0x80FFFF00
#define IEC61883_CMP_OMPR_LOCK_MASK 0x3FFFFF00
#define IEC61883_CMP_IMPR_LOCK_MASK 0x00FFFF00
/* s1394_addr_space_blk_t */
struct s1394_addr_space_blk_s {
/* Pointers and coloring for Red-Black tree */
/* Addr Blk info - callbacks, permissions, backing store, etc. */
void *addr_arg;
};
/* s1394_config_rom_t */
struct s1394_config_rom_s {
};
/* s1394_kstat_t */
struct s1394_kstat_s {
/* Asynch Receive (AR) requests */
/* Failure responses to AR requests (sent) */
/* Asynch Transmit (AT) requests */
/* Failure responses to AT requests (received) */
/* Allocate & free requests */
/* Bus reset and miscellaneous */
};
/* s1394_isoch_cec_t */
struct s1394_isoch_cec_s {
/* Isoch CEC member list */
/* Properties given in t1394_alloc_isoch_cec() */
/* Current state of Isoch CEC */
};
/* s1394_isoch_cec_member_t */
struct s1394_isoch_cec_member_s {
/* Events for Isoch CEC member - given in t1394_join_isoch_cec() */
};
/* cmd1394_fa_cmd_priv_t - per-command data for fixed address support */
typedef struct s1394_fa_cmd_priv_s {
void (*completion_callback)();
/* s1394_cmd_priv_t */
typedef struct s1394_cmd_priv_s {
/* Services Layer private structure for asynch commands */
int lock_req_step;
int temp_num_retries;
/*
* Commands can be extended to support additional functionality.
* The only extension at this time is FA (currently used only for FCP).
* The downside here is that every command should carry FA overhead
* even if the target doesn't use FA. However, alternative approaches
* would require separate allocation of FA overhead per command, which
* complicates the code and fragments the memory -- seems not worth it
* given that FA overhead is just a few bytes and there's a limit of
* 256 commands per target.
*/
int cmd_ext_type;
union {
} cmd_ext;
#define S1394_GET_CMD_PRIV(cmd) \
/* command extension types */
enum {
S1394_CMD_EXT_FA = 1
};
#define S1394_IS_CMD_FCP(s_priv) \
/* s1394_state_t */
typedef struct s1394_state_s {
/* HAL list */
/* Service Layer Global State Pointer */
extern s1394_state_t *s1394_statep;
/* 1394 Services Layer Internals - 1394 Address Space Routines */
/* 1394 Services Layer Internals - Asynchronous Communications Routines */
int status);
int status);
cmd1394_cmd_t *cmd);
cmd1394_cmd_t *cmd);
/* 1394 Services Layer Internals - Bus Reset Routines */
int s1394_gap_count_optimize(int diameter);
/* 1394 Services Layer Internals - CSR and Config ROM Routines */
int *status);
void s1394_update_config_rom_callback(void *arg);
/* In s1394_dev_disc.c */
/* 1394 Services Layer Driver - Hotplug Routines */
/* fixed address support */
/* FCP */
/* CMP */
/* 1394 Services Layer Internals - Isochronous Communication Routines */
/* 1394 Services Layer Internals - Miscellaneous Routines */
dev_info_t *tdip);
void s1394_cycle_too_long_callback(void *arg);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_1394_S1394_H */