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*8695SRajkumar.Sivaprakasam@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_IB_IBNEX_IBNEX_H 270Sstevel@tonic-gate #define _SYS_IB_IBNEX_IBNEX_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * ibnex.h 310Sstevel@tonic-gate * This file contains defines and structures used within the IB Nexus 320Sstevel@tonic-gate */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #include <sys/sunndi.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate /* Defines for return codes within the IB nexus driver */ 410Sstevel@tonic-gate typedef enum { 420Sstevel@tonic-gate IBNEX_SUCCESS = 0, 430Sstevel@tonic-gate IBNEX_FAILURE = -1, 440Sstevel@tonic-gate IBNEX_OFFLINE_FAILED = -2, 450Sstevel@tonic-gate IBNEX_BUSY = -3, 460Sstevel@tonic-gate IBNEX_INVALID_NODE = -4 470Sstevel@tonic-gate } ibnex_rval_t; 480Sstevel@tonic-gate 498082SRamaswamy.Tummala@Sun.COM #define IBNEX_IOC_GUID_LEN 33 508082SRamaswamy.Tummala@Sun.COM #define IBNEX_PHCI_GUID_LEN 66 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* IOC device node specific data */ 530Sstevel@tonic-gate typedef struct ibnex_ioc_node_s { 540Sstevel@tonic-gate ib_guid_t iou_guid; /* GUID of the IOU */ 550Sstevel@tonic-gate ib_guid_t ioc_guid; /* GUID of the IOC */ 560Sstevel@tonic-gate char ioc_id_string[IB_DM_IOC_ID_STRING_LEN]; 570Sstevel@tonic-gate uint32_t ioc_ngids; 580Sstevel@tonic-gate /* This field will be non NULL only for diconnected IOCs */ 590Sstevel@tonic-gate ib_dm_ioc_ctrl_profile_t *ioc_profile; 608082SRamaswamy.Tummala@Sun.COM char ioc_guid_str[IBNEX_IOC_GUID_LEN]; 618082SRamaswamy.Tummala@Sun.COM char ioc_phci_guid[IBNEX_PHCI_GUID_LEN]; 620Sstevel@tonic-gate } ibnex_ioc_node_t; 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* DLPI device node specific data */ 650Sstevel@tonic-gate typedef struct ibnex_port_node_s { 660Sstevel@tonic-gate uint8_t port_num; 670Sstevel@tonic-gate int port_commsvc_idx; 680Sstevel@tonic-gate ib_guid_t port_guid; 690Sstevel@tonic-gate ib_guid_t port_hcaguid; 700Sstevel@tonic-gate ib_pkey_t port_pkey; 718082SRamaswamy.Tummala@Sun.COM dev_info_t *port_pdip; 720Sstevel@tonic-gate } ibnex_port_node_t; 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* Pseudo device node specific data */ 750Sstevel@tonic-gate typedef struct ibnex_pseudo_node_s { 760Sstevel@tonic-gate char *pseudo_node_addr; /* node addr of drvr */ 770Sstevel@tonic-gate char *pseudo_unit_addr; /* unit addr of drvr */ 780Sstevel@tonic-gate int pseudo_unit_addr_len; /* unit addr len */ 790Sstevel@tonic-gate char *pseudo_devi_name; /* name of driver */ 801093Shiremath int pseudo_merge_node; /* merge node */ 810Sstevel@tonic-gate } ibnex_pseudo_node_t; 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * Defines for Child device node types. Note that these values are also 850Sstevel@tonic-gate * in use by usr/src/lib/cfgadm_plugins/ib/common/cfga_ib.h. 860Sstevel@tonic-gate * Any changes to these need to be reflected in that file as well. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate typedef enum { 890Sstevel@tonic-gate IBNEX_PORT_COMMSVC_NODE, 900Sstevel@tonic-gate IBNEX_VPPA_COMMSVC_NODE, 910Sstevel@tonic-gate IBNEX_HCASVC_COMMSVC_NODE, 920Sstevel@tonic-gate IBNEX_IOC_NODE, 930Sstevel@tonic-gate IBNEX_PSEUDO_NODE 940Sstevel@tonic-gate } ibnex_node_type_t; 950Sstevel@tonic-gate 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* 980Sstevel@tonic-gate * Defines for Child device node state: 990Sstevel@tonic-gate * 1000Sstevel@tonic-gate * By default the node is set to CONFIGURED state. 1010Sstevel@tonic-gate * CONFIGURED:---(bus_config/cfgadm configure)---->CONFIGURED 1020Sstevel@tonic-gate * CONFIGURED:----(cfgadm unconfigure:success)--->UNCONFIGURED 1030Sstevel@tonic-gate * CONFIGURED:----(cfgadm unconfigure:fail)--->still CONFIGURED 1040Sstevel@tonic-gate * UNCONFIGURED:----(cfgadm configure:success)--->CONFIGURED 1050Sstevel@tonic-gate * 1060Sstevel@tonic-gate * We maintain two additional states: 1070Sstevel@tonic-gate * CONFIGURING:---(bus_config/cfgadm configure in progress 1080Sstevel@tonic-gate * UNCONFIGURING:--(cfgadm unconfigure in progress) 1090Sstevel@tonic-gate * This is maintained to avoid race conditions between multiple cfgadm 1100Sstevel@tonic-gate * operations. 1110Sstevel@tonic-gate */ 1120Sstevel@tonic-gate typedef enum ibnex_node_state_e { 1130Sstevel@tonic-gate IBNEX_CFGADM_CONFIGURED, /* node is "configured" */ 1140Sstevel@tonic-gate IBNEX_CFGADM_UNCONFIGURED, /* node is "unconfigured" */ 1150Sstevel@tonic-gate IBNEX_CFGADM_CONFIGURING, /* node getting configured */ 1160Sstevel@tonic-gate IBNEX_CFGADM_UNCONFIGURING /* node getting unconfigured */ 1170Sstevel@tonic-gate } ibnex_node_state_t; 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate /* 1200Sstevel@tonic-gate * Defines for reprobe_state: 1210Sstevel@tonic-gate * IBNEX_NODE_REPROBE_NOTIFY_ON_UPDATE 1220Sstevel@tonic-gate * Reprobe and notify if there is a property update 1230Sstevel@tonic-gate * IBNEX_NODE_REPROBE_NOTIFY_ALWAYS 1240Sstevel@tonic-gate * Reprobe and notify always. 1250Sstevel@tonic-gate * IBNEX_NODE_REPROBE_IOC_WAIT 1260Sstevel@tonic-gate * Reprobe for IOC apid waiting 1270Sstevel@tonic-gate * 1280Sstevel@tonic-gate * Device reprobes triggered by ibt_reprobe_dev will result in an DDI 1290Sstevel@tonic-gate * event, even though no prepoerties have changed. 1300Sstevel@tonic-gate */ 1318082SRamaswamy.Tummala@Sun.COM 1328082SRamaswamy.Tummala@Sun.COM /* 1338082SRamaswamy.Tummala@Sun.COM * Defines for node_ap_state: 1348082SRamaswamy.Tummala@Sun.COM * IBNEX_NODE_AP_CONFIGURED 1358082SRamaswamy.Tummala@Sun.COM * this node was not unconfigured by cfgadm. 1368082SRamaswamy.Tummala@Sun.COM * IBNEX_NODE_AP_UNCONFIGURED 1378082SRamaswamy.Tummala@Sun.COM * this node has been unconfigured by cfgadm. 1388082SRamaswamy.Tummala@Sun.COM * IBNEX_NODE_AP_CONFIGURING 1398082SRamaswamy.Tummala@Sun.COM * this node is being configured by cfgadm 1408082SRamaswamy.Tummala@Sun.COM */ 1418082SRamaswamy.Tummala@Sun.COM #define IBNEX_NODE_AP_CONFIGURED 0x0 1428082SRamaswamy.Tummala@Sun.COM #define IBNEX_NODE_AP_UNCONFIGURED 0x1 1438082SRamaswamy.Tummala@Sun.COM #define IBNEX_NODE_AP_CONFIGURING 0x2 1448082SRamaswamy.Tummala@Sun.COM 1450Sstevel@tonic-gate #define IBNEX_NODE_REPROBE_NOTIFY_ON_UPDATE 0x01 1460Sstevel@tonic-gate #define IBNEX_NODE_REPROBE_NOTIFY_ALWAYS 0x02 1470Sstevel@tonic-gate #define IBNEX_NODE_REPROBE_IOC_WAIT 0x04 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* Node specific information, stored as dev_info_t private data */ 1500Sstevel@tonic-gate typedef struct ibnex_node_data_s { 1510Sstevel@tonic-gate dev_info_t *node_dip; 1520Sstevel@tonic-gate union { 1530Sstevel@tonic-gate ibnex_ioc_node_t ioc_node; 1540Sstevel@tonic-gate ibnex_port_node_t port_node; 1550Sstevel@tonic-gate ibnex_pseudo_node_t pseudo_node; 1560Sstevel@tonic-gate } node_data; 1570Sstevel@tonic-gate struct ibnex_node_data_s *node_next; 1580Sstevel@tonic-gate struct ibnex_node_data_s *node_prev; 1590Sstevel@tonic-gate ibnex_node_type_t node_type; 1600Sstevel@tonic-gate ibnex_node_state_t node_state; 1610Sstevel@tonic-gate int node_reprobe_state; /* Node reprobe flag */ 1628082SRamaswamy.Tummala@Sun.COM unsigned int node_ap_state; 1630Sstevel@tonic-gate } ibnex_node_data_t; 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate /* 1660Sstevel@tonic-gate * The fields of IOC and Port node are initialized when the 1670Sstevel@tonic-gate * device node is created. These are read only for the rest 1680Sstevel@tonic-gate * of the IBnexus driver. 1690Sstevel@tonic-gate */ 1700Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_ioc_node_s)) 1710Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_port_node_s)) 1720Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_pseudo_node_s)) 1730Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_node_data_s)) 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate #define IBNEX_VALID_NODE_TYPE(n) \ 1760Sstevel@tonic-gate (((n)->node_type == IBNEX_PORT_COMMSVC_NODE) || \ 1770Sstevel@tonic-gate ((n)->node_type == IBNEX_VPPA_COMMSVC_NODE) || \ 1780Sstevel@tonic-gate ((n)->node_type == IBNEX_HCASVC_COMMSVC_NODE) || \ 1790Sstevel@tonic-gate ((n)->node_type == IBNEX_IOC_NODE) || \ 1800Sstevel@tonic-gate ((n)->node_type == IBNEX_PSEUDO_NODE)) 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate #define IBNEX_COMMSVC_NODE_TYPE(n) \ 1830Sstevel@tonic-gate (((n)->node_type == IBNEX_PORT_COMMSVC_NODE) || \ 1840Sstevel@tonic-gate ((n)->node_type == IBNEX_VPPA_COMMSVC_NODE) || \ 1850Sstevel@tonic-gate ((n)->node_type == IBNEX_HCASVC_COMMSVC_NODE)) 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * Definition for the IB nexus global per-instance structure. 1890Sstevel@tonic-gate * IB nexus supports only one instance. 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate typedef struct ibnex_s { 1920Sstevel@tonic-gate dev_info_t *ibnex_dip; 1930Sstevel@tonic-gate kmutex_t ibnex_mutex; 1940Sstevel@tonic-gate int ibnex_num_comm_svcs; 1950Sstevel@tonic-gate char **ibnex_comm_svc_names; 1960Sstevel@tonic-gate int ibnex_nvppa_comm_svcs; 1970Sstevel@tonic-gate char **ibnex_vppa_comm_svc_names; 1980Sstevel@tonic-gate int ibnex_nhcasvc_comm_svcs; 1990Sstevel@tonic-gate char **ibnex_hcasvc_comm_svc_names; 2000Sstevel@tonic-gate ibnex_node_data_t *ibnex_port_node_head; 2010Sstevel@tonic-gate ibnex_node_data_t *ibnex_ioc_node_head; 2020Sstevel@tonic-gate ibnex_node_data_t *ibnex_pseudo_node_head; 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate /* 2050Sstevel@tonic-gate * NDI Event handle for -all- ibnexus events 2060Sstevel@tonic-gate * Event Cookie for IB_PROP_UPDATE_EVENT event 2070Sstevel@tonic-gate */ 2080Sstevel@tonic-gate ndi_event_hdl_t ibnex_ndi_event_hdl; 2090Sstevel@tonic-gate ddi_eventcookie_t ibnex_prop_update_evt_cookie; 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate /* Flags & condition variables for reprobe handling */ 2120Sstevel@tonic-gate int ibnex_reprobe_state; 2130Sstevel@tonic-gate kcondvar_t ibnex_reprobe_cv; 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate /* Count of disconnected IOCs still configured */ 2160Sstevel@tonic-gate int ibnex_num_disconnect_iocs; 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate /* Pseudo nodes inited from ibnex_get_snapshot? */ 2190Sstevel@tonic-gate int ibnex_pseudo_inited; 220*8695SRajkumar.Sivaprakasam@Sun.COM /* 221*8695SRajkumar.Sivaprakasam@Sun.COM * IOC list used by all HCAs. 222*8695SRajkumar.Sivaprakasam@Sun.COM */ 223*8695SRajkumar.Sivaprakasam@Sun.COM kcondvar_t ibnex_ioc_list_cv; 224*8695SRajkumar.Sivaprakasam@Sun.COM uint32_t ibnex_ioc_list_state; 2258082SRamaswamy.Tummala@Sun.COM ibdm_ioc_info_t *ibnex_ioc_list; 2260Sstevel@tonic-gate } ibnex_t; 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 229*8695SRajkumar.Sivaprakasam@Sun.COM * States for ibnex_ioc_list_state 230*8695SRajkumar.Sivaprakasam@Sun.COM */ 231*8695SRajkumar.Sivaprakasam@Sun.COM #define IBNEX_IOC_LIST_READY 0x0 232*8695SRajkumar.Sivaprakasam@Sun.COM #define IBNEX_IOC_LIST_RENEW 0x1 233*8695SRajkumar.Sivaprakasam@Sun.COM #define IBNEX_IOC_LIST_ACCESS 0x2 234*8695SRajkumar.Sivaprakasam@Sun.COM 235*8695SRajkumar.Sivaprakasam@Sun.COM /* 2360Sstevel@tonic-gate * States for ibnex_reprobe_state 2370Sstevel@tonic-gate * 0 to REPROBE_ALL_PROGRESS 2380Sstevel@tonic-gate * Reprobe all when no reprobes pending 2390Sstevel@tonic-gate * REPROBE_ALL_PROGRESS to REPROBE_ALL_WAIT 2400Sstevel@tonic-gate * Reprobe all request when another in progress 2410Sstevel@tonic-gate * 0 to REPROBE_IOC_WAIT 2420Sstevel@tonic-gate * Waiting for One or more reprobe_ioc to complete 2430Sstevel@tonic-gate * 2440Sstevel@tonic-gate * Reprobe logic will ensure : 2450Sstevel@tonic-gate * 1. A single reprobe all at any time. 2460Sstevel@tonic-gate * 2. No individual IOC reprobe overlaps with reprobe all. 2470Sstevel@tonic-gate * 3. Reprobe for multiple IOCs can be in parallel 2480Sstevel@tonic-gate * 4. Single reprobe for each IOC. 2490Sstevel@tonic-gate */ 2500Sstevel@tonic-gate #define IBNEX_REPROBE_ALL_PROGRESS 0x01 2510Sstevel@tonic-gate #define IBNEX_REPROBE_ALL_WAIT 0x02 2520Sstevel@tonic-gate #define IBNEX_REPROBE_IOC_WAIT 0x04 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate /* Defines for creating and binding device nodes. */ 2550Sstevel@tonic-gate #define IBNEX_MAX_COMPAT_NAMES 6 2560Sstevel@tonic-gate #define IBNEX_MAX_IBPORT_COMPAT_NAMES 3 2570Sstevel@tonic-gate #define IBNEX_MAX_COMPAT_LEN 48 2580Sstevel@tonic-gate #define IBNEX_MAX_COMPAT_PROP_SZ \ 2590Sstevel@tonic-gate IBNEX_MAX_COMPAT_NAMES * IBNEX_MAX_COMPAT_LEN 2600Sstevel@tonic-gate #define IBNEX_MAX_IBPORT_COMPAT_PROP_SZ \ 2610Sstevel@tonic-gate IBNEX_MAX_IBPORT_COMPAT_NAMES * IBNEX_MAX_COMPAT_LEN 2620Sstevel@tonic-gate #define IBNEX_DEVFS_ENUMERATE 0x1 /* enumerate via devfs(7fs) */ 2630Sstevel@tonic-gate #define IBNEX_CFGADM_ENUMERATE 0x2 /* enumerate via cfgadm */ 2640Sstevel@tonic-gate 2650Sstevel@tonic-gate #define IBNEX_MAX_NODEADDR_SZ 35 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate /* Define for forming the unit address from GUID and class string */ 2680Sstevel@tonic-gate #define IBNEX_FORM_GUID(buf, size, guid) \ 2690Sstevel@tonic-gate (void) snprintf((buf), (size), "%llX", (longlong_t)guid); 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate #define IBNEX_INVALID_PKEY(pkey) \ 2720Sstevel@tonic-gate (((pkey) == IB_PKEY_INVALID_FULL) || \ 2730Sstevel@tonic-gate ((pkey) == IB_PKEY_INVALID_LIMITED)) 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate /* 2760Sstevel@tonic-gate * Defines for the tags of IB DDI events 2770Sstevel@tonic-gate */ 2780Sstevel@tonic-gate typedef enum { 2790Sstevel@tonic-gate IB_EVENT_TAG_PROP_UPDATE = 0 2800Sstevel@tonic-gate } ib_ddi_event_tag_t; 2810Sstevel@tonic-gate 2821093Shiremath /* Definations for IB HW in device tree status */ 2831093Shiremath #define IBNEX_DEVTREE_NOT_CHECKED -1 2841093Shiremath #define IBNEX_HW_NOT_IN_DEVTREE 0 2851093Shiremath #define IBNEX_HW_IN_DEVTREE 1 2861093Shiremath 2870Sstevel@tonic-gate #ifdef __cplusplus 2880Sstevel@tonic-gate } 2890Sstevel@tonic-gate #endif 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate #endif /* _SYS_IB_IBNEX_IBNEX_H */ 292