1*936b7af6Sjw149990 /* 2*936b7af6Sjw149990 * CDDL HEADER START 3*936b7af6Sjw149990 * 4*936b7af6Sjw149990 * The contents of this file are subject to the terms of the 5*936b7af6Sjw149990 * Common Development and Distribution License (the "License"). 6*936b7af6Sjw149990 * You may not use this file except in compliance with the License. 7*936b7af6Sjw149990 * 8*936b7af6Sjw149990 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*936b7af6Sjw149990 * or http://www.opensolaris.org/os/licensing. 10*936b7af6Sjw149990 * See the License for the specific language governing permissions 11*936b7af6Sjw149990 * and limitations under the License. 12*936b7af6Sjw149990 * 13*936b7af6Sjw149990 * When distributing Covered Code, include this CDDL HEADER in each 14*936b7af6Sjw149990 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*936b7af6Sjw149990 * If applicable, add the following below this CDDL HEADER, with the 16*936b7af6Sjw149990 * fields enclosed by brackets "[]" replaced with your own identifying 17*936b7af6Sjw149990 * information: Portions Copyright [yyyy] [name of copyright owner] 18*936b7af6Sjw149990 * 19*936b7af6Sjw149990 * CDDL HEADER END 20*936b7af6Sjw149990 */ 21*936b7af6Sjw149990 22*936b7af6Sjw149990 /* 23*936b7af6Sjw149990 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*936b7af6Sjw149990 * Use is subject to license terms. 25*936b7af6Sjw149990 */ 26*936b7af6Sjw149990 27*936b7af6Sjw149990 #pragma ident "%Z%%M% %I% %E% SMI" 28*936b7af6Sjw149990 29*936b7af6Sjw149990 #include <devfsadm.h> 30*936b7af6Sjw149990 #include <strings.h> 31*936b7af6Sjw149990 #include <stdlib.h> 32*936b7af6Sjw149990 #include <limits.h> 33*936b7af6Sjw149990 #include <bsm/devalloc.h> 34*936b7af6Sjw149990 35*936b7af6Sjw149990 #define SMP_LINK_RE "^smp/expd[0-9]+$" 36*936b7af6Sjw149990 #define SMP_CLASS "sas" 37*936b7af6Sjw149990 #define SMP_DRV_NAME "smp" 38*936b7af6Sjw149990 39*936b7af6Sjw149990 static int smp_callback(di_minor_t minor, di_node_t node); 40*936b7af6Sjw149990 41*936b7af6Sjw149990 static devfsadm_create_t smp_create_cbt[] = { 42*936b7af6Sjw149990 { SMP_CLASS, "ddi_sas_smp", SMP_DRV_NAME, 43*936b7af6Sjw149990 TYPE_EXACT | DRV_EXACT, ILEVEL_0, smp_callback 44*936b7af6Sjw149990 } 45*936b7af6Sjw149990 }; 46*936b7af6Sjw149990 47*936b7af6Sjw149990 DEVFSADM_CREATE_INIT_V0(smp_create_cbt); 48*936b7af6Sjw149990 49*936b7af6Sjw149990 /* 50*936b7af6Sjw149990 * HOT auto cleanup of smp links not desired. 51*936b7af6Sjw149990 */ 52*936b7af6Sjw149990 static devfsadm_remove_t smp_remove_cbt[] = { 53*936b7af6Sjw149990 { SMP_CLASS, SMP_LINK_RE, RM_PRE, 54*936b7af6Sjw149990 ILEVEL_0, devfsadm_rm_all 55*936b7af6Sjw149990 } 56*936b7af6Sjw149990 }; 57*936b7af6Sjw149990 58*936b7af6Sjw149990 DEVFSADM_REMOVE_INIT_V0(smp_remove_cbt); 59*936b7af6Sjw149990 60*936b7af6Sjw149990 /* 61*936b7af6Sjw149990 * Create link for expander devices as form 62*936b7af6Sjw149990 * dev/smp/expd0 -> ../../devices/pci@0,0/.../smp@w5001636000005aff:smp 63*936b7af6Sjw149990 */ 64*936b7af6Sjw149990 static int 65*936b7af6Sjw149990 smp_callback(di_minor_t minor, di_node_t node) 66*936b7af6Sjw149990 { 67*936b7af6Sjw149990 char l_path[PATH_MAX + 1]; 68*936b7af6Sjw149990 char *buf; 69*936b7af6Sjw149990 char *mn; 70*936b7af6Sjw149990 char *devfspath; 71*936b7af6Sjw149990 devfsadm_enumerate_t rules[1] = {"smp/expd([0-9]+)", 1, MATCH_ADDR}; 72*936b7af6Sjw149990 73*936b7af6Sjw149990 mn = di_minor_name(minor); 74*936b7af6Sjw149990 75*936b7af6Sjw149990 devfspath = di_devfs_path(node); 76*936b7af6Sjw149990 77*936b7af6Sjw149990 (void) strcpy(l_path, devfspath); 78*936b7af6Sjw149990 (void) strcat(l_path, ":"); 79*936b7af6Sjw149990 (void) strcat(l_path, mn); 80*936b7af6Sjw149990 81*936b7af6Sjw149990 di_devfs_path_free(devfspath); 82*936b7af6Sjw149990 83*936b7af6Sjw149990 if (devfsadm_enumerate_int(l_path, 0, &buf, rules, 1)) { 84*936b7af6Sjw149990 return (DEVFSADM_CONTINUE); 85*936b7af6Sjw149990 } 86*936b7af6Sjw149990 87*936b7af6Sjw149990 (void) strcpy(l_path, "smp/expd"); 88*936b7af6Sjw149990 (void) strcat(l_path, buf); 89*936b7af6Sjw149990 free(buf); 90*936b7af6Sjw149990 91*936b7af6Sjw149990 (void) devfsadm_mklink(l_path, node, minor, 0); 92*936b7af6Sjw149990 93*936b7af6Sjw149990 return (DEVFSADM_CONTINUE); 94*936b7af6Sjw149990 } 95