17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*00a3eaf3SRamaswamy Tummala * Common Development and Distribution License (the "License"). 6*00a3eaf3SRamaswamy Tummala * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*00a3eaf3SRamaswamy Tummala * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _CFGA_IB_H 277c478bd9Sstevel@tonic-gate #define _CFGA_IB_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <stdlib.h> 347c478bd9Sstevel@tonic-gate #include <strings.h> 357c478bd9Sstevel@tonic-gate #include <fcntl.h> 367c478bd9Sstevel@tonic-gate #include <ctype.h> 377c478bd9Sstevel@tonic-gate #include <unistd.h> 387c478bd9Sstevel@tonic-gate #include <libintl.h> 397c478bd9Sstevel@tonic-gate #include <sys/types32.h> 407c478bd9Sstevel@tonic-gate #include <sys/varargs.h> 417c478bd9Sstevel@tonic-gate #include <sys/ib/ibnex/ibnex_devctl.h> 427c478bd9Sstevel@tonic-gate #include <libdevinfo.h> 437c478bd9Sstevel@tonic-gate #include <libdevice.h> 447c478bd9Sstevel@tonic-gate #include <librcm.h> 457c478bd9Sstevel@tonic-gate #include <synch.h> 467c478bd9Sstevel@tonic-gate #include <thread.h> 477c478bd9Sstevel@tonic-gate #include <assert.h> 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define CFGA_PLUGIN_LIB 507c478bd9Sstevel@tonic-gate #include <config_admin.h> 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Debug stuff. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate #ifdef DEBUG 577c478bd9Sstevel@tonic-gate #define DPRINTF printf 587c478bd9Sstevel@tonic-gate #else 597c478bd9Sstevel@tonic-gate #define DPRINTF 0 && 607c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* for walking links */ 647c478bd9Sstevel@tonic-gate typedef struct walk_link { 657c478bd9Sstevel@tonic-gate char *path; 667c478bd9Sstevel@tonic-gate char len; 677c478bd9Sstevel@tonic-gate char **linkpp; 687c478bd9Sstevel@tonic-gate } walk_link_t; 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * Stuff carried over for the routines borrowed from cfgadm/SCSI. 737c478bd9Sstevel@tonic-gate */ 747c478bd9Sstevel@tonic-gate #define MATCH_MINOR_NAME 1 757c478bd9Sstevel@tonic-gate #define S_FREE(x) (((x) != NULL) ? (free(x), (x) = NULL) : (void *)0) 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* Return/error codes */ 787c478bd9Sstevel@tonic-gate typedef enum { 797c478bd9Sstevel@tonic-gate ICFGA_ERR = -2, 807c478bd9Sstevel@tonic-gate ICFGA_LIB_ERR, 817c478bd9Sstevel@tonic-gate ICFGA_OK, 827c478bd9Sstevel@tonic-gate ICFGA_BUSY, 837c478bd9Sstevel@tonic-gate ICFGA_NO_REC 847c478bd9Sstevel@tonic-gate } icfga_ret_t; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* Error Messages */ 887c478bd9Sstevel@tonic-gate typedef struct { 897c478bd9Sstevel@tonic-gate int intl; /* Flag: if 1, internationalize */ 907c478bd9Sstevel@tonic-gate cfga_err_t cfga_err; /* Error code for libcfgadm */ 917c478bd9Sstevel@tonic-gate const char *msgstr; 927c478bd9Sstevel@tonic-gate } msgcvt_t; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* "intl" defines */ 957c478bd9Sstevel@tonic-gate #define NO_CVT 0 967c478bd9Sstevel@tonic-gate #define CVT 1 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #define MSG_TBL_SZ(table) (sizeof ((table)) / sizeof (msgcvt_t)) 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* Error message ids (and indices into ib_error_msgs) "cfga_err values " */ 1027c478bd9Sstevel@tonic-gate typedef enum { 1037c478bd9Sstevel@tonic-gate CFGA_IB_OK = 0, /* Plugin Related Errors */ 1047c478bd9Sstevel@tonic-gate CFGA_IB_UNKNOWN, 1057c478bd9Sstevel@tonic-gate CFGA_IB_INTERNAL_ERR, 1067c478bd9Sstevel@tonic-gate CFGA_IB_INVAL_ARG_ERR, 1077c478bd9Sstevel@tonic-gate CFGA_IB_OPTIONS_ERR, 1087c478bd9Sstevel@tonic-gate CFGA_IB_AP_ERR, 1097c478bd9Sstevel@tonic-gate CFGA_IB_DEVCTL_ERR, 1107c478bd9Sstevel@tonic-gate CFGA_IB_NOT_CONNECTED, 1117c478bd9Sstevel@tonic-gate CFGA_IB_NOT_CONFIGURED, 1127c478bd9Sstevel@tonic-gate CFGA_IB_ALREADY_CONNECTED, 1137c478bd9Sstevel@tonic-gate CFGA_IB_ALREADY_CONFIGURED, 1147c478bd9Sstevel@tonic-gate CFGA_IB_CONFIG_OP_ERR, 1157c478bd9Sstevel@tonic-gate CFGA_IB_UNCONFIG_OP_ERR, 1167c478bd9Sstevel@tonic-gate CFGA_IB_OPEN_ERR, 1177c478bd9Sstevel@tonic-gate CFGA_IB_IOCTL_ERR, 1187c478bd9Sstevel@tonic-gate CFGA_IB_BUSY_ERR, 1197c478bd9Sstevel@tonic-gate CFGA_IB_ALLOC_FAIL, 1207c478bd9Sstevel@tonic-gate CFGA_IB_OPNOTSUPP, 1217c478bd9Sstevel@tonic-gate CFGA_IB_INVAL_APID_ERR, 1227c478bd9Sstevel@tonic-gate CFGA_IB_DEVLINK_ERR, 1237c478bd9Sstevel@tonic-gate CFGA_IB_PRIV_ERR, 1247c478bd9Sstevel@tonic-gate CFGA_IB_NVLIST_ERR, 1257c478bd9Sstevel@tonic-gate CFGA_IB_HCA_LIST_ERR, 1267c478bd9Sstevel@tonic-gate CFGA_IB_HCA_UNCONFIG_ERR, 1277c478bd9Sstevel@tonic-gate CFGA_IB_UPD_PKEY_TBLS_ERR, 1287c478bd9Sstevel@tonic-gate CFGA_IB_CONFIG_FILE_ERR, 1297c478bd9Sstevel@tonic-gate CFGA_IB_LOCK_FILE_ERR, 1307c478bd9Sstevel@tonic-gate CFGA_IB_UNLOCK_FILE_ERR, 1317c478bd9Sstevel@tonic-gate CFGA_IB_COMM_INVAL_ERR, 1327c478bd9Sstevel@tonic-gate CFGA_IB_SVC_INVAL_ERR, 1337c478bd9Sstevel@tonic-gate CFGA_IB_SVC_LEN_ERR, 1347c478bd9Sstevel@tonic-gate CFGA_IB_SVC_EXISTS_ERR, 1357c478bd9Sstevel@tonic-gate CFGA_IB_SVC_NO_EXIST_ERR, 1367c478bd9Sstevel@tonic-gate CFGA_IB_UCFG_CLNTS_ERR, 1377c478bd9Sstevel@tonic-gate CFGA_IB_INVALID_OP_ERR, 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate CFGA_IB_RCM_HANDLE_ERR, /* Plugin's RCM Related Errors */ 1407c478bd9Sstevel@tonic-gate CFGA_IB_RCM_ONLINE_ERR, 1417c478bd9Sstevel@tonic-gate CFGA_IB_RCM_OFFLINE_ERR 1427c478bd9Sstevel@tonic-gate } cfga_ib_ret_t; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Given an error msg index, look up the associated string, and 1477c478bd9Sstevel@tonic-gate * convert it to the current locale if required. 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate #define ERR_STR(msg_idx) \ 1507c478bd9Sstevel@tonic-gate (ib_get_msg((msg_idx), ib_error_msgs, MSG_TBL_SZ(ib_error_msgs))) 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* Defines for "usage" */ 1537c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_HEADER 1 /* Header only */ 1547c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_CONFIG 2 /* -c usage help */ 1557c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_LIST 3 /* -x list_clients usage help */ 1567c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_UPD_PKEY 4 /* -x update_pkey_tbls usage help */ 1577c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_CONF_FILE1 5 /* -x [add_service|delete_service] */ 1587c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_CONF_FILE2 6 /* -x list_services help */ 1597c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_UPD_IOC_CONF \ 1607c478bd9Sstevel@tonic-gate 7 /* -x update_ioc_config help */ 1617c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_UNCFG_CLNTS \ 1627c478bd9Sstevel@tonic-gate 8 /* -x unconfig_clients usage help */ 1637c478bd9Sstevel@tonic-gate #define CFGA_IB_HELP_UNKNOWN 9 /* unknown help */ 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate #define IB_RETRY_DEVPATH 12 /* devicepath show up: retry count */ 1667c478bd9Sstevel@tonic-gate #define IB_MAX_DEVPATH_DELAY 6 /* sleep for 6 seconds */ 1677c478bd9Sstevel@tonic-gate #define IB_NUM_NVPAIRS 6 /* for "info", "ap_id" etc. */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate /* Misc text strings */ 1707c478bd9Sstevel@tonic-gate #define CFGA_DEV_DIR "/dev/cfg" 1717c478bd9Sstevel@tonic-gate #define IB_STATIC_APID "/dev/cfg/ib" 1727c478bd9Sstevel@tonic-gate #define MINOR_SEP ":" 1737c478bd9Sstevel@tonic-gate #define IB_APID "apid" 1747c478bd9Sstevel@tonic-gate #define IB_CFGADM_DEFAULT_AP_TYPE "unknown" 1757c478bd9Sstevel@tonic-gate #define IB_PORT_TYPE "IB-PORT" 1767c478bd9Sstevel@tonic-gate #define IB_FABRIC_INFO "InfiniBand Fabric" 1777c478bd9Sstevel@tonic-gate #define IB_HCA_TYPE "IB-HCA" 1787c478bd9Sstevel@tonic-gate #define IB_IOC_TYPE "IB-IOC" 1797c478bd9Sstevel@tonic-gate #define IB_VPPA_TYPE "IB-VPPA" 1807c478bd9Sstevel@tonic-gate #define IB_HCASVC_TYPE "IB-HCA_SVC" 1817c478bd9Sstevel@tonic-gate #define IB_PSEUDO_TYPE "IB-PSEUDO" 1827c478bd9Sstevel@tonic-gate #define IB_FABRIC_TYPE "IB-Fabric" 1837c478bd9Sstevel@tonic-gate #define IB_FABRIC_APID_STR "ib:fabric" 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate /* -x commands */ 1867c478bd9Sstevel@tonic-gate #define IB_LIST_HCA_CLIENTS "list_clients" /* list HCA's */ 1877c478bd9Sstevel@tonic-gate /* clients */ 1887c478bd9Sstevel@tonic-gate #define IB_UNCONFIG_HCA_CLIENTS "unconfig_clients" /* unconfig */ 1897c478bd9Sstevel@tonic-gate /* HCA's */ 1907c478bd9Sstevel@tonic-gate /* clients */ 1917c478bd9Sstevel@tonic-gate #define IB_UPDATE_PKEY_TBLS "update_pkey_tbls" /* re-read */ 1927c478bd9Sstevel@tonic-gate /* P_Keys */ 1937c478bd9Sstevel@tonic-gate #define IB_ADD_SERVICE "add_service" /* add svc */ 1947c478bd9Sstevel@tonic-gate #define IB_DELETE_SERVICE "delete_service" /* delete svc */ 1957c478bd9Sstevel@tonic-gate #define IB_LIST_SERVICES "list_services" /* list svcs */ 1967c478bd9Sstevel@tonic-gate #define IB_UPDATE_IOC_CONF "update_ioc_config" /* update IOC */ 1977c478bd9Sstevel@tonic-gate /* config */ 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate /* for confirm operation */ 2007c478bd9Sstevel@tonic-gate #define IB_CONFIRM1 \ 2017c478bd9Sstevel@tonic-gate "This operation will suspend activity on the IB device\nContinue" 2027c478bd9Sstevel@tonic-gate #define IB_CONFIRM3 \ 2037c478bd9Sstevel@tonic-gate "This operation will unconfigure IB clients of this HCA\nContinue" 2047c478bd9Sstevel@tonic-gate #define IB_CONFIRM4 \ 2057c478bd9Sstevel@tonic-gate "This operation will update P_Key tables for all ports of all HCAs" 2067c478bd9Sstevel@tonic-gate #define IB_CONFIRM5 \ 2077c478bd9Sstevel@tonic-gate "This operation can update properties of IOC devices." 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * Export "node_type"s from ibnex_node_type_t (see ibnex.h) to 2117c478bd9Sstevel@tonic-gate * cfgadm in user land. NOTE: If ibnex_node_type_t changes in 2127c478bd9Sstevel@tonic-gate * ibnex.h; do not forget to update these values here as well. 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate #define IBNEX_PORT_NODE_TYPE 0 2157c478bd9Sstevel@tonic-gate #define IBNEX_VPPA_NODE_TYPE 1 2167c478bd9Sstevel@tonic-gate #define IBNEX_HCASVC_NODE_TYPE 2 2177c478bd9Sstevel@tonic-gate #define IBNEX_IOC_NODE_TYPE 3 2187c478bd9Sstevel@tonic-gate #define IBNEX_PSEUDO_NODE_TYPE 4 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate /* for ib.conf file support */ 2217c478bd9Sstevel@tonic-gate #define IBCONF_ADD_ENTRY 1 2227c478bd9Sstevel@tonic-gate #define IBCONF_DELETE_ENTRY 2 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2257c478bd9Sstevel@tonic-gate } 2267c478bd9Sstevel@tonic-gate #endif 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate #endif /* _CFGA_IB_H */ 229