10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 58082SRamaswamy.Tummala@Sun.COM * Common Development and Distribution License (the "License"). 68082SRamaswamy.Tummala@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12163SRamaswamy.Tummala@Sun.COM * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_IB_IBNEX_IBNEX_H 260Sstevel@tonic-gate #define _SYS_IB_IBNEX_IBNEX_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * ibnex.h 300Sstevel@tonic-gate * This file contains defines and structures used within the IB Nexus 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 370Sstevel@tonic-gate #include <sys/sunndi.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate /* Defines for return codes within the IB nexus driver */ 400Sstevel@tonic-gate typedef enum { 410Sstevel@tonic-gate IBNEX_SUCCESS = 0, 420Sstevel@tonic-gate IBNEX_FAILURE = -1, 430Sstevel@tonic-gate IBNEX_OFFLINE_FAILED = -2, 440Sstevel@tonic-gate IBNEX_BUSY = -3, 450Sstevel@tonic-gate IBNEX_INVALID_NODE = -4 460Sstevel@tonic-gate } ibnex_rval_t; 470Sstevel@tonic-gate 488082SRamaswamy.Tummala@Sun.COM #define IBNEX_IOC_GUID_LEN 33 498082SRamaswamy.Tummala@Sun.COM #define IBNEX_PHCI_GUID_LEN 66 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* IOC device node specific data */ 520Sstevel@tonic-gate typedef struct ibnex_ioc_node_s { 530Sstevel@tonic-gate ib_guid_t iou_guid; /* GUID of the IOU */ 540Sstevel@tonic-gate ib_guid_t ioc_guid; /* GUID of the IOC */ 550Sstevel@tonic-gate char ioc_id_string[IB_DM_IOC_ID_STRING_LEN]; 560Sstevel@tonic-gate uint32_t ioc_ngids; 570Sstevel@tonic-gate /* This field will be non NULL only for diconnected IOCs */ 580Sstevel@tonic-gate ib_dm_ioc_ctrl_profile_t *ioc_profile; 598082SRamaswamy.Tummala@Sun.COM char ioc_guid_str[IBNEX_IOC_GUID_LEN]; 608082SRamaswamy.Tummala@Sun.COM char ioc_phci_guid[IBNEX_PHCI_GUID_LEN]; 610Sstevel@tonic-gate } ibnex_ioc_node_t; 620Sstevel@tonic-gate 630Sstevel@tonic-gate /* DLPI device node specific data */ 640Sstevel@tonic-gate typedef struct ibnex_port_node_s { 650Sstevel@tonic-gate uint8_t port_num; 660Sstevel@tonic-gate int port_commsvc_idx; 670Sstevel@tonic-gate ib_guid_t port_guid; 680Sstevel@tonic-gate ib_guid_t port_hcaguid; 690Sstevel@tonic-gate ib_pkey_t port_pkey; 708082SRamaswamy.Tummala@Sun.COM dev_info_t *port_pdip; 710Sstevel@tonic-gate } ibnex_port_node_t; 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* Pseudo device node specific data */ 740Sstevel@tonic-gate typedef struct ibnex_pseudo_node_s { 750Sstevel@tonic-gate char *pseudo_node_addr; /* node addr of drvr */ 760Sstevel@tonic-gate char *pseudo_unit_addr; /* unit addr of drvr */ 770Sstevel@tonic-gate int pseudo_unit_addr_len; /* unit addr len */ 780Sstevel@tonic-gate char *pseudo_devi_name; /* name of driver */ 791093Shiremath int pseudo_merge_node; /* merge node */ 800Sstevel@tonic-gate } ibnex_pseudo_node_t; 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * Defines for Child device node types. Note that these values are also 840Sstevel@tonic-gate * in use by usr/src/lib/cfgadm_plugins/ib/common/cfga_ib.h. 850Sstevel@tonic-gate * Any changes to these need to be reflected in that file as well. 860Sstevel@tonic-gate */ 870Sstevel@tonic-gate typedef enum { 88*12163SRamaswamy.Tummala@Sun.COM IBNEX_PORT_COMMSVC_NODE = 0, 89*12163SRamaswamy.Tummala@Sun.COM IBNEX_VPPA_COMMSVC_NODE = 1, 90*12163SRamaswamy.Tummala@Sun.COM IBNEX_HCASVC_COMMSVC_NODE = 2, 91*12163SRamaswamy.Tummala@Sun.COM IBNEX_IOC_NODE = 4, 92*12163SRamaswamy.Tummala@Sun.COM IBNEX_PSEUDO_NODE = 8 930Sstevel@tonic-gate } ibnex_node_type_t; 940Sstevel@tonic-gate 95*12163SRamaswamy.Tummala@Sun.COM #define IBNEX_HCA_CHILD_NODE (IBNEX_PORT_COMMSVC_NODE | \ 96*12163SRamaswamy.Tummala@Sun.COM IBNEX_VPPA_COMMSVC_NODE | IBNEX_HCASVC_COMMSVC_NODE) 97*12163SRamaswamy.Tummala@Sun.COM 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* 1000Sstevel@tonic-gate * Defines for Child device node state: 1010Sstevel@tonic-gate * 1020Sstevel@tonic-gate * By default the node is set to CONFIGURED state. 1030Sstevel@tonic-gate * CONFIGURED:---(bus_config/cfgadm configure)---->CONFIGURED 1040Sstevel@tonic-gate * CONFIGURED:----(cfgadm unconfigure:success)--->UNCONFIGURED 1050Sstevel@tonic-gate * CONFIGURED:----(cfgadm unconfigure:fail)--->still CONFIGURED 1060Sstevel@tonic-gate * UNCONFIGURED:----(cfgadm configure:success)--->CONFIGURED 1070Sstevel@tonic-gate * 1080Sstevel@tonic-gate * We maintain two additional states: 1090Sstevel@tonic-gate * CONFIGURING:---(bus_config/cfgadm configure in progress 1100Sstevel@tonic-gate * UNCONFIGURING:--(cfgadm unconfigure in progress) 1110Sstevel@tonic-gate * This is maintained to avoid race conditions between multiple cfgadm 1120Sstevel@tonic-gate * operations. 1130Sstevel@tonic-gate */ 1140Sstevel@tonic-gate typedef enum ibnex_node_state_e { 1150Sstevel@tonic-gate IBNEX_CFGADM_CONFIGURED, /* node is "configured" */ 1160Sstevel@tonic-gate IBNEX_CFGADM_UNCONFIGURED, /* node is "unconfigured" */ 1170Sstevel@tonic-gate IBNEX_CFGADM_CONFIGURING, /* node getting configured */ 1180Sstevel@tonic-gate IBNEX_CFGADM_UNCONFIGURING /* node getting unconfigured */ 1190Sstevel@tonic-gate } ibnex_node_state_t; 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate /* 1220Sstevel@tonic-gate * Defines for reprobe_state: 1230Sstevel@tonic-gate * IBNEX_NODE_REPROBE_NOTIFY_ON_UPDATE 1240Sstevel@tonic-gate * Reprobe and notify if there is a property update 1250Sstevel@tonic-gate * IBNEX_NODE_REPROBE_NOTIFY_ALWAYS 1260Sstevel@tonic-gate * Reprobe and notify always. 1270Sstevel@tonic-gate * IBNEX_NODE_REPROBE_IOC_WAIT 1280Sstevel@tonic-gate * Reprobe for IOC apid waiting 1290Sstevel@tonic-gate * 1300Sstevel@tonic-gate * Device reprobes triggered by ibt_reprobe_dev will result in an DDI 1310Sstevel@tonic-gate * event, even though no prepoerties have changed. 1320Sstevel@tonic-gate */ 1338082SRamaswamy.Tummala@Sun.COM 1348082SRamaswamy.Tummala@Sun.COM /* 1358082SRamaswamy.Tummala@Sun.COM * Defines for node_ap_state: 1368082SRamaswamy.Tummala@Sun.COM * IBNEX_NODE_AP_CONFIGURED 1378082SRamaswamy.Tummala@Sun.COM * this node was not unconfigured by cfgadm. 1388082SRamaswamy.Tummala@Sun.COM * IBNEX_NODE_AP_UNCONFIGURED 1398082SRamaswamy.Tummala@Sun.COM * this node has been unconfigured by cfgadm. 1408082SRamaswamy.Tummala@Sun.COM * IBNEX_NODE_AP_CONFIGURING 1418082SRamaswamy.Tummala@Sun.COM * this node is being configured by cfgadm 1428082SRamaswamy.Tummala@Sun.COM */ 1438082SRamaswamy.Tummala@Sun.COM #define IBNEX_NODE_AP_CONFIGURED 0x0 1448082SRamaswamy.Tummala@Sun.COM #define IBNEX_NODE_AP_UNCONFIGURED 0x1 1458082SRamaswamy.Tummala@Sun.COM #define IBNEX_NODE_AP_CONFIGURING 0x2 1468082SRamaswamy.Tummala@Sun.COM 1470Sstevel@tonic-gate #define IBNEX_NODE_REPROBE_NOTIFY_ON_UPDATE 0x01 1480Sstevel@tonic-gate #define IBNEX_NODE_REPROBE_NOTIFY_ALWAYS 0x02 1490Sstevel@tonic-gate #define IBNEX_NODE_REPROBE_IOC_WAIT 0x04 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* Node specific information, stored as dev_info_t private data */ 1520Sstevel@tonic-gate typedef struct ibnex_node_data_s { 1530Sstevel@tonic-gate dev_info_t *node_dip; 1540Sstevel@tonic-gate union { 1550Sstevel@tonic-gate ibnex_ioc_node_t ioc_node; 1560Sstevel@tonic-gate ibnex_port_node_t port_node; 1570Sstevel@tonic-gate ibnex_pseudo_node_t pseudo_node; 1580Sstevel@tonic-gate } node_data; 1590Sstevel@tonic-gate struct ibnex_node_data_s *node_next; 1600Sstevel@tonic-gate struct ibnex_node_data_s *node_prev; 1610Sstevel@tonic-gate ibnex_node_type_t node_type; 1620Sstevel@tonic-gate ibnex_node_state_t node_state; 1630Sstevel@tonic-gate int node_reprobe_state; /* Node reprobe flag */ 1648082SRamaswamy.Tummala@Sun.COM unsigned int node_ap_state; 1650Sstevel@tonic-gate } ibnex_node_data_t; 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate /* 1680Sstevel@tonic-gate * The fields of IOC and Port node are initialized when the 1690Sstevel@tonic-gate * device node is created. These are read only for the rest 1700Sstevel@tonic-gate * of the IBnexus driver. 1710Sstevel@tonic-gate */ 1720Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_ioc_node_s)) 1730Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_port_node_s)) 1740Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_pseudo_node_s)) 1750Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_node_data_s)) 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate #define IBNEX_VALID_NODE_TYPE(n) \ 1780Sstevel@tonic-gate (((n)->node_type == IBNEX_PORT_COMMSVC_NODE) || \ 1790Sstevel@tonic-gate ((n)->node_type == IBNEX_VPPA_COMMSVC_NODE) || \ 1800Sstevel@tonic-gate ((n)->node_type == IBNEX_HCASVC_COMMSVC_NODE) || \ 1810Sstevel@tonic-gate ((n)->node_type == IBNEX_IOC_NODE) || \ 1820Sstevel@tonic-gate ((n)->node_type == IBNEX_PSEUDO_NODE)) 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate #define IBNEX_COMMSVC_NODE_TYPE(n) \ 1850Sstevel@tonic-gate (((n)->node_type == IBNEX_PORT_COMMSVC_NODE) || \ 1860Sstevel@tonic-gate ((n)->node_type == IBNEX_VPPA_COMMSVC_NODE) || \ 1870Sstevel@tonic-gate ((n)->node_type == IBNEX_HCASVC_COMMSVC_NODE)) 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate /* 1900Sstevel@tonic-gate * Definition for the IB nexus global per-instance structure. 1910Sstevel@tonic-gate * IB nexus supports only one instance. 1920Sstevel@tonic-gate */ 1930Sstevel@tonic-gate typedef struct ibnex_s { 1940Sstevel@tonic-gate dev_info_t *ibnex_dip; 1950Sstevel@tonic-gate kmutex_t ibnex_mutex; 1960Sstevel@tonic-gate int ibnex_num_comm_svcs; 1970Sstevel@tonic-gate char **ibnex_comm_svc_names; 1980Sstevel@tonic-gate int ibnex_nvppa_comm_svcs; 1990Sstevel@tonic-gate char **ibnex_vppa_comm_svc_names; 2000Sstevel@tonic-gate int ibnex_nhcasvc_comm_svcs; 2010Sstevel@tonic-gate char **ibnex_hcasvc_comm_svc_names; 2020Sstevel@tonic-gate ibnex_node_data_t *ibnex_port_node_head; 2030Sstevel@tonic-gate ibnex_node_data_t *ibnex_ioc_node_head; 2040Sstevel@tonic-gate ibnex_node_data_t *ibnex_pseudo_node_head; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate /* 2070Sstevel@tonic-gate * NDI Event handle for -all- ibnexus events 2080Sstevel@tonic-gate * Event Cookie for IB_PROP_UPDATE_EVENT event 2090Sstevel@tonic-gate */ 2100Sstevel@tonic-gate ndi_event_hdl_t ibnex_ndi_event_hdl; 2110Sstevel@tonic-gate ddi_eventcookie_t ibnex_prop_update_evt_cookie; 2120Sstevel@tonic-gate 2130Sstevel@tonic-gate /* Flags & condition variables for reprobe handling */ 2140Sstevel@tonic-gate int ibnex_reprobe_state; 2150Sstevel@tonic-gate kcondvar_t ibnex_reprobe_cv; 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate /* Count of disconnected IOCs still configured */ 2180Sstevel@tonic-gate int ibnex_num_disconnect_iocs; 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate /* Pseudo nodes inited from ibnex_get_snapshot? */ 2210Sstevel@tonic-gate int ibnex_pseudo_inited; 2228695SRajkumar.Sivaprakasam@Sun.COM /* 2238695SRajkumar.Sivaprakasam@Sun.COM * IOC list used by all HCAs. 2248695SRajkumar.Sivaprakasam@Sun.COM */ 2258695SRajkumar.Sivaprakasam@Sun.COM kcondvar_t ibnex_ioc_list_cv; 2268695SRajkumar.Sivaprakasam@Sun.COM uint32_t ibnex_ioc_list_state; 2278082SRamaswamy.Tummala@Sun.COM ibdm_ioc_info_t *ibnex_ioc_list; 228*12163SRamaswamy.Tummala@Sun.COM 229*12163SRamaswamy.Tummala@Sun.COM ddi_taskq_t *ibnex_taskq_id; 2300Sstevel@tonic-gate } ibnex_t; 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate /* 2338695SRajkumar.Sivaprakasam@Sun.COM * States for ibnex_ioc_list_state 2348695SRajkumar.Sivaprakasam@Sun.COM */ 2358695SRajkumar.Sivaprakasam@Sun.COM #define IBNEX_IOC_LIST_READY 0x0 2368695SRajkumar.Sivaprakasam@Sun.COM #define IBNEX_IOC_LIST_RENEW 0x1 2378695SRajkumar.Sivaprakasam@Sun.COM #define IBNEX_IOC_LIST_ACCESS 0x2 2388695SRajkumar.Sivaprakasam@Sun.COM 2398695SRajkumar.Sivaprakasam@Sun.COM /* 2400Sstevel@tonic-gate * States for ibnex_reprobe_state 2410Sstevel@tonic-gate * 0 to REPROBE_ALL_PROGRESS 2420Sstevel@tonic-gate * Reprobe all when no reprobes pending 2430Sstevel@tonic-gate * REPROBE_ALL_PROGRESS to REPROBE_ALL_WAIT 2440Sstevel@tonic-gate * Reprobe all request when another in progress 2450Sstevel@tonic-gate * 0 to REPROBE_IOC_WAIT 2460Sstevel@tonic-gate * Waiting for One or more reprobe_ioc to complete 2470Sstevel@tonic-gate * 2480Sstevel@tonic-gate * Reprobe logic will ensure : 2490Sstevel@tonic-gate * 1. A single reprobe all at any time. 2500Sstevel@tonic-gate * 2. No individual IOC reprobe overlaps with reprobe all. 2510Sstevel@tonic-gate * 3. Reprobe for multiple IOCs can be in parallel 2520Sstevel@tonic-gate * 4. Single reprobe for each IOC. 2530Sstevel@tonic-gate */ 2540Sstevel@tonic-gate #define IBNEX_REPROBE_ALL_PROGRESS 0x01 2550Sstevel@tonic-gate #define IBNEX_REPROBE_ALL_WAIT 0x02 2560Sstevel@tonic-gate #define IBNEX_REPROBE_IOC_WAIT 0x04 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate /* Defines for creating and binding device nodes. */ 2590Sstevel@tonic-gate #define IBNEX_MAX_COMPAT_NAMES 6 2600Sstevel@tonic-gate #define IBNEX_MAX_IBPORT_COMPAT_NAMES 3 2610Sstevel@tonic-gate #define IBNEX_MAX_COMPAT_LEN 48 2620Sstevel@tonic-gate #define IBNEX_MAX_COMPAT_PROP_SZ \ 2630Sstevel@tonic-gate IBNEX_MAX_COMPAT_NAMES * IBNEX_MAX_COMPAT_LEN 2640Sstevel@tonic-gate #define IBNEX_MAX_IBPORT_COMPAT_PROP_SZ \ 2650Sstevel@tonic-gate IBNEX_MAX_IBPORT_COMPAT_NAMES * IBNEX_MAX_COMPAT_LEN 2660Sstevel@tonic-gate #define IBNEX_DEVFS_ENUMERATE 0x1 /* enumerate via devfs(7fs) */ 2670Sstevel@tonic-gate #define IBNEX_CFGADM_ENUMERATE 0x2 /* enumerate via cfgadm */ 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate #define IBNEX_MAX_NODEADDR_SZ 35 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate /* Define for forming the unit address from GUID and class string */ 2720Sstevel@tonic-gate #define IBNEX_FORM_GUID(buf, size, guid) \ 2730Sstevel@tonic-gate (void) snprintf((buf), (size), "%llX", (longlong_t)guid); 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate #define IBNEX_INVALID_PKEY(pkey) \ 2760Sstevel@tonic-gate (((pkey) == IB_PKEY_INVALID_FULL) || \ 2770Sstevel@tonic-gate ((pkey) == IB_PKEY_INVALID_LIMITED)) 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate /* 2800Sstevel@tonic-gate * Defines for the tags of IB DDI events 2810Sstevel@tonic-gate */ 2820Sstevel@tonic-gate typedef enum { 2830Sstevel@tonic-gate IB_EVENT_TAG_PROP_UPDATE = 0 2840Sstevel@tonic-gate } ib_ddi_event_tag_t; 2850Sstevel@tonic-gate 2861093Shiremath /* Definations for IB HW in device tree status */ 2871093Shiremath #define IBNEX_DEVTREE_NOT_CHECKED -1 2881093Shiremath #define IBNEX_HW_NOT_IN_DEVTREE 0 2891093Shiremath #define IBNEX_HW_IN_DEVTREE 1 2901093Shiremath 2910Sstevel@tonic-gate #ifdef __cplusplus 2920Sstevel@tonic-gate } 2930Sstevel@tonic-gate #endif 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate #endif /* _SYS_IB_IBNEX_IBNEX_H */ 296