diff options
| author | Ramaswamy Tummala <Ramaswamy.Tummala@Sun.COM> | 2010-04-14 10:26:18 -0700 |
|---|---|---|
| committer | Ramaswamy Tummala <Ramaswamy.Tummala@Sun.COM> | 2010-04-14 10:26:18 -0700 |
| commit | 1cfa752f4e24c34133009b0f6c139127a5c461de (patch) | |
| tree | 6ffe378521988d12eb5fb895e53549460bf2a47c /usr/src/cmd/ibd_upgrade | |
| parent | 97689f66b4d49d8e41fb47ce04dd38217fba0acb (diff) | |
| download | illumos-joyent-1cfa752f4e24c34133009b0f6c139127a5c461de.tar.gz | |
PSARC 2010/085 IPoIB Administration Enhancement
6837574 IPoIB Administration Enhancement - PSARC 2010/085
6864899 IB datalink names need to be consistent between cluster controllers
6855737 cfgadm status for ibd attachment points gets to inconsistent state
6883212 ibd: add Brussels framework support
6927048 IBD driver should be hardened to handle late HCA port initialization issue
6827237 Fix warlock errors in ibnex
--HG--
rename : usr/src/uts/common/io/ib/clients/ibd/ibd.conf => usr/src/uts/common/io/ib/clients/ibd/ibp.conf
rename : usr/src/uts/intel/ibd/Makefile => usr/src/uts/intel/ibp/Makefile
rename : usr/src/uts/sparc/ibd/Makefile => usr/src/uts/sparc/ibp/Makefile
Diffstat (limited to 'usr/src/cmd/ibd_upgrade')
| -rw-r--r-- | usr/src/cmd/ibd_upgrade/Makefile | 61 | ||||
| -rw-r--r-- | usr/src/cmd/ibd_upgrade/ibd-post-upgrade | 47 | ||||
| -rw-r--r-- | usr/src/cmd/ibd_upgrade/ibd-post-upgrade.xml | 92 | ||||
| -rw-r--r-- | usr/src/cmd/ibd_upgrade/ibd_delete_link.c | 151 | ||||
| -rw-r--r-- | usr/src/cmd/ibd_upgrade/ibd_upgrade.sh | 159 |
5 files changed, 510 insertions, 0 deletions
diff --git a/usr/src/cmd/ibd_upgrade/Makefile b/usr/src/cmd/ibd_upgrade/Makefile new file mode 100644 index 0000000000..2bffb56658 --- /dev/null +++ b/usr/src/cmd/ibd_upgrade/Makefile @@ -0,0 +1,61 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# or http://www.opensolaris.org/os/licensing. +# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. +# + +MANIFEST = ibd-post-upgrade.xml +SVCMETHOD = ibd-post-upgrade + +include ../Makefile.cmd + +SHFILES = ibd_upgrade +IBD_DELETE_LINK = ibd_delete_link +OBJS = $(IBD_DELETE_LINK).o +SRCS = $(OBJS:%.o=%.c) + +CLOBBERFILES = $(SHFILES) $(IBD_DELETE_LINK) $(OBJS) + +ROOTMANIFESTDIR = $(ROOTSVCNETWORK) +LDLIBS += -ldladm + +.KEEP_STATE: + +all: $(IBD_DELETE_LINK) $(SHFILES) + +install: all \ + $(ROOTSBIN)/$(IBD_DELETE_LINK) \ + $(ROOTMANIFEST) \ + $(ROOTSVCMETHOD) \ + $(ROOTSBIN)/ibd_upgrade + +check: $(CHKMANIFEST) + $(CSTYLE) -pP $(SRCS) + +clean: + +lint: lint_SRCS + +include ../Makefile.targ + +$(ROOTSBIN)/%: % + $(INS.file) + diff --git a/usr/src/cmd/ibd_upgrade/ibd-post-upgrade b/usr/src/cmd/ibd_upgrade/ibd-post-upgrade new file mode 100644 index 0000000000..a486d68cd6 --- /dev/null +++ b/usr/src/cmd/ibd_upgrade/ibd-post-upgrade @@ -0,0 +1,47 @@ +#!/sbin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# or http://www.opensolaris.org/os/licensing. +# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. +# + +. /lib/svc/share/smf_include.sh + +# +# Actual work of ibd upgrade is done in network/physical service. +# Here we mearly set the property to indicate that the ibd upgrade has been +# done. Setting of the property can not be done in network/physical service +# because the file system is read-only at that point. +# +if smf_is_globalzone; then + NETPHYS=svc:/network/physical:default + PROP=ibd/ibd_upgraded + + upgrade_done=`/bin/svcprop -c -p $PROP $NETPHYS 2> /dev/null` + + if [ "$upgrade_done" != "true" ]; then + /usr/sbin/svccfg -s $NETPHYS addpg ibd system 2> /dev/null + /usr/sbin/svccfg -s $NETPHYS setprop $PROP = boolean: true + fi +fi + +/usr/sbin/svcadm disable $SMF_FMRI +exit $SMF_EXIT_OK diff --git a/usr/src/cmd/ibd_upgrade/ibd-post-upgrade.xml b/usr/src/cmd/ibd_upgrade/ibd-post-upgrade.xml new file mode 100644 index 0000000000..2540d6de14 --- /dev/null +++ b/usr/src/cmd/ibd_upgrade/ibd-post-upgrade.xml @@ -0,0 +1,92 @@ +<?xml version="1.0"?> +<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> +<!-- + Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + + CDDL HEADER START + + The contents of this file are subject to the terms of the + Common Development and Distribution License (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 + or http://www.opensolaris.org/os/licensing. + 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 + + NOTE: This service manifest is not editable; its contents will + be overwritten by package or patch operations, including + operating system upgrade. Make customizations in a different + file. +--> + +<service_bundle type='manifest' name='SUNWipoib:ibd-post-upgrade'> + +<service + name='network/ibd-post-upgrade' + type='service' + version='1'> + + <create_default_instance enabled='true' /> + + <single_instance /> + + <dependency + name='network-physical' + type='service' + grouping='require_all' + restart_on='none'> + <service_fmri value='svc:/network/physical' /> + </dependency> + + <dependency + name='filesystem-minimal' + type='service' + grouping='require_all' + restart_on='none'> + <service_fmri value='svc:/system/filesystem/minimal' /> + </dependency> + + <exec_method + type='method' + name='start' + exec='/lib/svc/method/ibd-post-upgrade' + timeout_seconds='0' /> + + <exec_method + type='method' + name='stop' + exec=':true' + timeout_seconds='0' /> + + <property_group name='startd' type='framework'> + <propval name='duration' type='astring' value='transient' /> + </property_group> + + <stability value='Unstable' /> + + <template> + <common_name> + <loctext xml:lang='C'> + ibd upgrade + </loctext> + </common_name> + + <documentation> + <manpage + title='ibp' + section='7D' + manpath='/usr/share/man' /> + </documentation> + </template> +</service> + +</service_bundle> diff --git a/usr/src/cmd/ibd_upgrade/ibd_delete_link.c b/usr/src/cmd/ibd_upgrade/ibd_delete_link.c new file mode 100644 index 0000000000..b9d10a56cd --- /dev/null +++ b/usr/src/cmd/ibd_upgrade/ibd_delete_link.c @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 + * or http://www.opensolaris.org/os/licensing. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include <stdio.h> +#include <door.h> +#include <errno.h> +#include <strings.h> +#include <sys/mman.h> +#include <libdladm.h> +#include <libdlib.h> +#include <libdllink.h> + +extern dladm_status_t dladm_door_fd(dladm_handle_t, int *); + +static dladm_status_t +ibd_dladm_door_call(dladm_handle_t handle, void *arg, size_t asize, void *rbuf, + size_t rsize) +{ + door_arg_t darg; + int door_fd; + dladm_status_t status = DLADM_STATUS_OK; + + darg.data_ptr = arg; + darg.data_size = asize; + darg.desc_ptr = NULL; + darg.desc_num = 0; + darg.rbuf = rbuf; + darg.rsize = rsize; + + /* The door descriptor is opened if it isn't already */ + if ((status = dladm_door_fd(handle, &door_fd)) != DLADM_STATUS_OK) + return (status); + + if (door_call(door_fd, &darg) == -1) + return (DLADM_STATUS_FAILED); + + if (darg.rbuf != rbuf) { + /* + * The size of the input rbuf is not big enough so that + * the door allocate the rbuf itself. In this case, simply + * think something wrong with the door call. + */ + (void) munmap(darg.rbuf, darg.rsize); + return (DLADM_STATUS_TOOSMALL); + } + + if (darg.rsize != rsize) + return (DLADM_STATUS_FAILED); + + if ((((dlmgmt_retval_t *)rbuf)->lr_err) == 0) + return (DLADM_STATUS_OK); + else + return (DLADM_STATUS_FAILED); +} + +static int +ibd_delete_link(dladm_handle_t dlh, char *link) +{ + dlmgmt_door_getlinkid_t getlinkid; + dlmgmt_getlinkid_retval_t retval; + datalink_id_t linkid; + dladm_status_t status; + char errmsg[DLADM_STRSIZE]; + + getlinkid.ld_cmd = DLMGMT_CMD_GETLINKID; + (void) strlcpy(getlinkid.ld_link, link, MAXLINKNAMELEN); + + if ((status = ibd_dladm_door_call(dlh, &getlinkid, sizeof (getlinkid), + &retval, sizeof (retval))) != DLADM_STATUS_OK) { + (void) fprintf(stderr, + "dladm_door_call failed: %s; linkname = %s\n", + dladm_status2str(status, errmsg), link); + return (status); + } + + if (retval.lr_class != DATALINK_CLASS_PHYS) { + (void) fprintf(stderr, + "Not a physical link: linkname = %s, class = 0x%x\n", + link, (uint_t)retval.lr_class); + return (status); + } + + linkid = retval.lr_linkid; + + if ((status = dladm_remove_conf(dlh, linkid)) != DLADM_STATUS_OK) { + (void) fprintf(stderr, "dladm_remove_conf failed: %s\n", + dladm_status2str(status, errmsg)); + return (status); + } + + if ((status = dladm_destroy_datalink_id(dlh, linkid, + DLADM_OPT_ACTIVE | DLADM_OPT_PERSIST)) != DLADM_STATUS_OK) { + (void) fprintf(stderr, "dladm_destroy_datalink_id failed: %s\n", + dladm_status2str(status, errmsg)); + } + + return (status); +} + +int +main(int argc, char *argv[]) +{ + dladm_handle_t dlh; + int i; + dladm_status_t status; + char errmsg[DLADM_STRSIZE]; + + if (argc < 2) { + (void) fprintf(stderr, + "Usage: ibd_delete_link linkname ...\n"); + return (2); + } + + if ((status = dladm_open(&dlh)) != DLADM_STATUS_OK) { + (void) fprintf(stderr, "Failed to open dladm handle: %s\n", + dladm_status2str(status, errmsg)); + return (1); + } + + for (i = 1; i < argc; i++) { + if (ibd_delete_link(dlh, argv[i]) != DLADM_STATUS_OK) { + dladm_close(dlh); + return (1); + } + } + + dladm_close(dlh); + return (0); +} diff --git a/usr/src/cmd/ibd_upgrade/ibd_upgrade.sh b/usr/src/cmd/ibd_upgrade/ibd_upgrade.sh new file mode 100644 index 0000000000..23be8cdc02 --- /dev/null +++ b/usr/src/cmd/ibd_upgrade/ibd_upgrade.sh @@ -0,0 +1,159 @@ +#!/sbin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# or http://www.opensolaris.org/os/licensing. +# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. +# +# + +PATH=/sbin:/bin +ORIGIFS="${IFS}" +USAGE="Usage: ibd_upgrade [-v]" +DRVCONF=/kernel/drv/ibp.conf.old + +# +# split device path into path components +# +split_path_components() +{ + hca_path= + node_name= + port= + pkey= + service= + partition_name= + + hca_path="/dev/`dirname $device_path`" + bname=`basename $device_path` + IFS=":" + set -- $bname + node_at_addr=$1 + partition_name=$2 + IFS="@" + set -- $node_at_addr + node_name=$1 + IFS="," + set -- $2 + port=$1 + pkey=0x$2 + service=$3 + + IFS="${ORIGIFS}" +} + +do_cmd() +{ + if [ $verbose -eq 1 ]; then + echo "$1" + fi + $1 +} + +process_rc_mode() +{ + device=$1 + + # + # Get the instance number of ibd + # Device name format would be ibd#, + # + IFS="d" + set -- ${device} + IFS="${ORIGIFS}" + + if [ "$1" != "ib" ]; then + return + fi + + inst=$2 + + IFS="," + set -- ${enable_rc} + IFS="${ORIGIFS}" + + if [ ${inst} -lt $# ]; then + (( inst = $inst + 1 )) + eval "linkmode=\$${inst}" + else + linkmode=0 + fi + + if [ "$linkmode" = "0" ]; then + do_cmd "dladm set-linkprop -p linkmode=ud ${device}" + fi +} + +verbose=0 +while getopts v c +do + case $c in + v) verbose=1;; + \?) echo "$USAGE" 1>&2 + exit 2;; + esac +done + +enable_rc= +if [ -f ${DRVCONF} ]; then + enable_rc=`egrep "^[ ]*enable_rc[ ]*=" ${DRVCONF} | sed -e "s/[ ]*//g" -e "s/enable_rc=//" -e "s/;$//" 2>/dev/null` +fi + +# +# Loop through all ibd devices based on the old model (i.e., one ibd instance +# per partition; consequently device names have non zero pkey) +# and create data links with the same names as in the old model under the +# new model. +# +ls -l /dev/ibd* 2> /dev/null \ + | while read x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 device_path +do + split_path_components + + if [ "$node_name" != "ibport" -o "$service" != "ipib" \ + -o "$pkey" = "0x0" -o "$pkey" = "0x" ]; then + continue + fi + + # verify that the hca path exists + cd $hca_path 2> /dev/null + if [ $? -ne 0 ]; then + continue + fi + + fn=`echo ibport@${port},0,ipib:ibp*[0-9]` + if [ -c "$fn" ]; then + IFS=":" + set -- $fn + IFS="${ORIGIFS}" + + do_cmd "dladm delete-phys $partition_name" 2>/dev/null + if [ $? -ne 0 ]; then + do_cmd "ibd_delete_link $partition_name" + fi + do_cmd "dladm create-part -f -l $2 -P $pkey $partition_name" + + if [ "$enable_rc" != "" ]; then + process_rc_mode $partition_name + fi + fi +done + +exit 0 |
