fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
a1837c6df940f4a4992df53cc52935596ced1b89srivijitha dugganapalli * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
33f5ff17089e3a43e6e730bf80384c233123dbd9Milan Jurik * Copyright 2012 Milan Jurik. All rights reserved.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define SBD_PATH "/devices/pseudo/stmf_sbd@0:admin"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/* various initial allocation values */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define MAX_SBD_PROPS MAXPATHLEN + MAX_SERIAL_SIZE + MAX_LU_ALIAS_SIZE
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/* set default persistence here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int groupIoctl(int fd, int cmd, stmfGroupName *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int groupMemberIoctl(int fd, int cmd, stmfGroupName *, stmfDevid *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int guidCompare(const void *, const void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int addViewEntryIoctl(int fd, stmfGuid *, stmfViewEntry *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int loadHostGroups(int fd, stmfGroupList *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int loadTargetGroups(int fd, stmfGroupList *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int setStmfState(int fd, stmf_state_desc_t *, int);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int setProviderData(int fd, char *, nvlist_t *, int, uint64_t *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int createDiskLu(diskResource *, stmfGuid *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int getDiskProp(luResourceImpl *, uint32_t, char *, size_t *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int getDiskAllProps(stmfGuid *luGuid, luResource *hdl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int loadDiskPropsFromDriver(luResourceImpl *, sbd_lu_props_t *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int persistDiskGuid(stmfGuid *, char *, boolean_t);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int setDiskProp(luResourceImpl *, uint32_t, const char *);
7beff157537d14493d525a42d33f0621b0b26217John Fortestatic int getDiskGlobalProp(uint32_t prop, char *propVal, size_t *propLen);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int checkHexUpper(char *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int strToShift(const char *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int modifyDiskLu(diskResource *, stmfGuid *, const char *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int modifyDiskLuProp(stmfGuid *, const char *, uint32_t, const char *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int iLoadGroupFromPs(stmfGroupList **, int);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int groupMemberListIoctl(stmfGroupName *, stmfGroupProperties **, int);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int getProviderData(char *, nvlist_t **, int, uint64_t *);
7beff157537d14493d525a42d33f0621b0b26217John Fortestatic int setDiskGlobalProp(uint32_t, const char *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int viewEntryCompare(const void *, const void *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic pthread_mutex_t persistenceTypeLock = PTHREAD_MUTEX_INITIALIZER;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/* when B_TRUE, no need to access SMF anymore. Just use iPersistType */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open for stmf module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag - open flag (OPEN_STMF, OPEN_EXCL_STMF)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd - pointer to integer. On success, contains the stmf file descriptor
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*fd = open(STMF_PATH, O_NDELAY | O_RDONLY | flag)) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_DEBUG, "openStmf:open failure:%s:errno(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open for sbd module
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * flag - open flag (OPEN_SBD, OPEN_EXCL_SBD)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * fd - pointer to integer. On success, contains the stmf file descriptor
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((*fd = open(SBD_PATH, O_NDELAY | O_RDONLY | flag)) != -1) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto syslog(LOG_DEBUG, "openSbd:open failure:%s:errno(%d)",
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Open for pppt module
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * flag - open flag (OPEN_PPPT, OPEN_EXCL_PPPT)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * fd - pointer to integer. On success, contains the stmf file descriptor
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte if ((*fd = open(PPPT_PATH, O_RDONLY | flag)) != -1) {
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte syslog(LOG_DEBUG, "openPppt:open failure:%s:errno(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initializeConfig
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This routine should be called before any ioctl requiring initialization
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which is basically everything except stmfGetState(), setStmfState() and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfLoadConfig().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if we've already initialized or in the process, return success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (state.configState == STMF_CONFIG_STATE_INIT_DONE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "initializeConfig:stmfLoadConfig:error(%d)", ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (state.configState != STMF_CONFIG_STATE_INIT_DONE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_DEBUG, "initializeConfig:state.configState(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupIoctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: issue ioctl for create/delete on group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd - valid STMF ioctl group cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - groupName to create or delete
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegroupIoctl(int fd, int cmd, stmfGroupName *groupName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(groupName, &iGroupName.name, strlen((char *)groupName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iGroupName.name_size = strlen((char *)groupName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to create the host group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&iGroupName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "groupIoctl:error(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * groupMemberIoctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: issue ioctl for add/remove member on group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd - valid STMF ioctl group member cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - groupName to add to or remove from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devid - group member to add or remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegroupMemberIoctl(int fd, int cmd, stmfGroupName *groupName, stmfDevid *devid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(groupName, &stmfGroupData.group.name, strlen((char *)groupName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfGroupData.group.name_size = strlen((char *)groupName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfGroupData.ident[IDENT_LENGTH_BYTE] = devid->identLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&(devid->ident), &stmfGroupData.ident[IDENT_LENGTH_BYTE + 1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to add to the host group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf_size = sizeof (stmfGroupData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&stmfGroupData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "groupMemberIoctl:error"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * qsort function
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * sort on veIndex
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfViewEntry *v1 = (stmfViewEntry *)p1, *v2 = (stmfViewEntry *)p2;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * guidCompare
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * qsort function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sort on guid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfGuid *g1 = (stmfGuid *)p1, *g2 = (stmfGuid *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sizeof (stmfGuid); i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfAddToHostGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Adds an initiator to an existing host group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hostGroupName - name of an existing host group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hostName - name of initiator to add
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfAddToHostGroup(stmfGroupName *hostGroupName, stmfDevid *hostName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strnlen((char *)hostGroupName, sizeof (stmfGroupName))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == sizeof (stmfGroupName)) || hostName == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupMemberIoctl(fd, STMF_IOCTL_ADD_HG_ENTRY, hostGroupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = psAddHostGroupMember((char *)hostGroupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)hostName->ident);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfAddToHostGroup:psAddHostGroupMember:error(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfAddToTargetGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Adds a local port to an existing target group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targetGroupName - name of an existing target group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targetName - name of target to add
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfAddToTargetGroup(stmfGroupName *targetGroupName, stmfDevid *targetName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strnlen((char *)targetGroupName, sizeof (stmfGroupName))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == sizeof (stmfGroupName)) || targetName == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupMemberIoctl(fd, STMF_IOCTL_ADD_TG_ENTRY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetGroupName, targetName)) != STMF_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = psAddTargetGroupMember((char *)targetGroupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)targetName->ident);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfAddToTargetGroup:psAddTargetGroupMember:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * addViewEntryIoctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Issues ioctl to add a view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu - Logical Unit identifier to which the view entry is added
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntry - view entry to add
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * init - When set to B_TRUE, we are in the init state, i.e. don't call open
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteaddViewEntryIoctl(int fd, stmfGuid *lu, stmfViewEntry *viewEntry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * don't set ve_ndx or ve_ndx_valid as ve_ndx_valid should be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * false on input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlViewEntry.ve_lu_number_valid = viewEntry->luNbrValid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlViewEntry.ve_all_hosts = viewEntry->allHosts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlViewEntry.ve_all_targets = viewEntry->allTargets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(viewEntry->hostGroup, &ioctlViewEntry.ve_host_group.name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(viewEntry->luNbr, &ioctlViewEntry.ve_lu_nbr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(lu, &ioctlViewEntry.ve_guid, sizeof (stmfGuid));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to add to the view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf_size = sizeof (ioctlViewEntry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&ioctlViewEntry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf_size = sizeof (ioctlViewEntry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)&ioctlViewEntry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_ADD_VIEW_ENTRY, &stmfIoctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "addViewEntryIoctl"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ":error(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy lu nbr back to caller's view entry on success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&ioctlViewEntry.ve_lu_nbr, viewEntry->luNbr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfAddViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Adds a view entry to a logical unit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu - guid of the logical unit to which the view entry is added
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntry - view entry structure to add
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfAddViewEntry(stmfGuid *lu, stmfViewEntry *viewEntry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize and set internal view entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(viewEntry->hostGroup, iViewEntry.hostGroup,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(viewEntry->targetGroup, iViewEntry.targetGroup,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set users return view entry index valid flag to false
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in case of failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to ensure service exists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First add the view entry to the driver
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the add to driver was successful, add it to the persistent
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfAddViewEntry:psAddViewEntry:error(%d)", ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set caller's view entry on success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte viewEntry->veIndexValid = iViewEntry.veIndexValid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfClearProviderData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: delete all provider data for specified provider
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - name of provider for which data should be deleted
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfClearProviderData(char *providerName, int providerType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(ppi.ppi_name, providerName, sizeof (ppi.ppi_name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf_size = sizeof (stmf_ppioctl_data_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&ppi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_CLEAR_PP_DATA, &stmfIoctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfClearProviderData:ioctl error(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = psClearProviderData(providerName, providerType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfClearProviderData:psClearProviderData"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfCreateHostGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Create a new initiator group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hostGroupName - name of host group to create
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strnlen((char *)hostGroupName, sizeof (stmfGroupName))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == sizeof (stmfGroupName))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to ensure service exists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupIoctl(fd, STMF_IOCTL_CREATE_HOST_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfCreateHostGroup:psCreateHostGroup:error(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfCreateLu
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Create a logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - handle to logical unit resource created via stmfCreateLuResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * luGuid - If non-NULL, on success, contains the guid of the created logical
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = createDiskLu((diskResource *)luPropsHdl->resource,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfCreateLuResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Create resource handle for a logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * dType - Type of logical unit resource to create
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Can be: STMF_DISK
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - pointer to luResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfCreateLuResource(uint16_t dType, luResource *hdl)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Creates a disk logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * disk - pointer to diskResource structure that represents the properties
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * for the disk logical unit to be created.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetocreateDiskLu(diskResource *disk, stmfGuid *createdGuid)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for sbd
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* data file name must be specified */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * 8 is the size of the buffer set aside for
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * concatenation of variable length fields
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sizeof (sbd_create_and_reg_lu_t) + sluBufSize - 8);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdLu->slu_struct_size = sizeof (sbd_create_and_reg_lu_t) +
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->luMetaFileName, &(sbdLu->slu_buf[bufOffset]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->luDataFileName, &(sbdLu->slu_buf[bufOffset]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* currently, serial # is not passed null terminated to the driver */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->serialNum, &(sbdLu->slu_buf[bufOffset]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->luAlias, &(sbdLu->slu_buf[bufOffset]),
2f624233c43c1f4fe0d930648d6ece6fffe7aa49Nattuvetty Bhavyan bcopy(disk->luMgmtUrl, &(sbdLu->slu_buf[bufOffset]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->luGuid, sbdLu->slu_guid, sizeof (disk->luGuid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->vid, sbdLu->slu_vid, sizeof (disk->vid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->pid, sbdLu->slu_pid, sizeof (disk->pid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->rev, sbdLu->slu_rev, sizeof (disk->rev));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_ibuf = (uint64_t)(unsigned long)sbdLu;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_obuf = (uint64_t)(unsigned long)sbdLu;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ioctlRet = ioctl(fd, SBD_IOCTL_CREATE_AND_REGISTER_LU, &sbdIoctl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "createDiskLu:ioctl "
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * on success, copy the resulting guid into the caller's guid if not
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(sbdLu->slu_guid, guid.guid, sizeof (sbdLu->slu_guid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = addGuidToDiskStore(&guid, disk->luMetaFileName);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = addGuidToDiskStore(&guid, disk->luDataFileName);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfImportLu
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Import a previously created logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * dType - Type of logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Can be: STMF_DISK
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * luGuid - If non-NULL, on success, contains the guid of the imported logical
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * fname - A file name where the metadata resides
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfImportLu(uint16_t dType, char *fname, stmfGuid *luGuid)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * importDiskLu
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * filename - filename to import
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * createdGuid - if not NULL, on success contains the imported guid
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for sbd
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * 8 is the size of the buffer set aside for
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * concatenation of variable length fields
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Accept either a data file or meta data file.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * sbd will do the right thing here either way.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * i.e. if it's a data file, it assumes that the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * meta data is shared with the data.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) strncpy(sbdLu->ilu_meta_fname, fname, metaFileNameLen);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdLu->ilu_struct_size = sizeof (sbd_import_lu_t) + iluBufSize - 8;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_ibuf = (uint64_t)(unsigned long)sbdLu;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_obuf = (uint64_t)(unsigned long)sbdLu;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ioctlRet = ioctl(fd, SBD_IOCTL_IMPORT_LU, &sbdIoctl);
a1837c6df940f4a4992df53cc52935596ced1b89srivijitha dugganapalli if (createdGuid && sbdIoctl.stmf_error ==
a1837c6df940f4a4992df53cc52935596ced1b89srivijitha dugganapalli bcopy(sbdLu->ilu_ret_guid, createdGuid->guid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "importDiskLu:ioctl "
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * on success, copy the resulting guid into the caller's guid if not
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * NULL and add it to the persistent store for sbd
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Translate sbd driver error
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Creates a logical unit resource of type STMF_DISK.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * No defaults should be set here as all defaults are derived from the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * driver's default settings.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfDeleteLu
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Delete a logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - handle to logical unit resource created via stmfCreateLuResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * luGuid - If non-NULL, on success, contains the guid of the created logical
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check logical unit provider name to call correct dtype function */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = stmfGetLogicalUnitProperties(luGuid, &luProps))
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else if (luProps.status == STMF_LOGICAL_UNIT_UNREGISTERED) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for sbd
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(luGuid, deleteLu.dlu_guid, sizeof (deleteLu.dlu_guid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_ibuf = (uint64_t)(unsigned long)&deleteLu;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ioctlRet = ioctl(fd, SBD_IOCTL_DELETE_LU, &sbdIoctl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "deleteDiskLu:ioctl error(%d) (%d) (%d)",
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * stmfLuStandby
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Purpose: Sets access state to standby
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * luGuid - guid of registered logical unit
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte /* Check logical unit provider name to call correct dtype function */
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte if ((ret = stmfGetLogicalUnitProperties(luGuid, &luProps))
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte } else if (luProps.status == STMF_LOGICAL_UNIT_UNREGISTERED) {
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Open control node for sbd
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte bcopy(luGuid, &sbdLu.stlu_guid, sizeof (stmfGuid));
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte sbdIoctl.stmf_ibuf_size = sizeof (sbd_set_lu_standby_t);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte sbdIoctl.stmf_ibuf = (uint64_t)(unsigned long)&sbdLu;
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte ioctlRet = ioctl(fd, SBD_IOCTL_SET_LU_STANDBY, &sbdIoctl);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte "setDiskStandby:ioctl "
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfModifyLu
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Modify properties of a logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * luGuid - guid of registered logical unit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * prop - property to modify
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * propVal - property value to set
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfModifyLu(stmfGuid *luGuid, uint32_t prop, const char *propVal)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check logical unit provider name to call correct dtype function */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = stmfGetLogicalUnitProperties(luGuid, &luProps))
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = modifyDiskLuProp(luGuid, NULL, prop, propVal);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else if (luProps.status == STMF_LOGICAL_UNIT_UNREGISTERED) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfModifyLuByFname
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Modify a device by filename. Device does not need to be registered.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * dType - type of device to modify
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * fname - filename or meta filename
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * prop - valid property identifier
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * propVal - property value
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfModifyLuByFname(uint16_t dType, const char *fname, uint32_t prop,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto const char *propVal)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = modifyDiskLuProp(NULL, fname, prop, propVal);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetomodifyDiskLuProp(stmfGuid *luGuid, const char *fname, uint32_t prop,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto const char *propVal)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = modifyDiskLu((diskResource *)luPropsHdl->resource, luGuid, fname);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetomodifyDiskLu(diskResource *disk, stmfGuid *luGuid, const char *fname)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for sbd
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * 8 is the size of the buffer set aside for
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * concatenation of variable length fields
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sizeof (sbd_modify_lu_t) + mluBufSize - 8 + fnameSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdLu->mlu_struct_size = sizeof (sbd_modify_lu_t) +
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(disk->luAlias, &(sbdLu->mlu_buf[bufOffset]),
2f624233c43c1f4fe0d930648d6ece6fffe7aa49Nattuvetty Bhavyan bcopy(disk->luMgmtUrl, &(sbdLu->mlu_buf[bufOffset]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(luGuid, sbdLu->mlu_input_guid, sizeof (stmfGuid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(fname, &(sbdLu->mlu_buf[bufOffset]), fnameSize + 1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_ibuf = (uint64_t)(unsigned long)sbdLu;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ioctlRet = ioctl(fd, SBD_IOCTL_MODIFY_LU, &sbdIoctl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "modifyDiskLu:ioctl "
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * removeGuidFromDiskStore
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: delete a logical unit from the sbd provider data
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * addGuidToDiskStore
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: add a logical unit to the sbd provider data
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * persistDiskGuid
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Persist or unpersist a guid for the sbd provider data
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetopersistDiskGuid(stmfGuid *guid, char *filename, boolean_t persist)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* if we're persisting a guid, there must be a filename */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* guid is stored in lowercase ascii hex */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) snprintf(guidAsciiBuf, sizeof (guidAsciiBuf),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "%02x%02x%02x%02x%02x%02x",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto guid->guid[0], guid->guid[1], guid->guid[2], guid->guid[3],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto guid->guid[4], guid->guid[5], guid->guid[6], guid->guid[7],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto guid->guid[8], guid->guid[9], guid->guid[10], guid->guid[11],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto guid->guid[12], guid->guid[13], guid->guid[14], guid->guid[15]);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret != 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "unpersistGuid:nvlist_alloc(%d)",
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * if we're persisting the data, it's
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * an error. Otherwise, just return
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = nvlist_add_string(nvl, guidAsciiBuf, filename);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret == 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* get/set failed, try again */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else if (stmfRet ==
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* update failed, try again */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "unpersistGuid:error nvlist_add/remove(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfGetLuProp
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Get current value for a resource property
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - luResource from a previous call to stmfCreateLuResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * resourceProp - a valid resource property type
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * propVal - void pointer to a pointer of the value to be retrieved
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfGetLuProp(luResource hdl, uint32_t prop, char *propVal, size_t *propLen)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (hdl == NULL || propLen == NULL || propVal == NULL) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = getDiskProp(luPropsHdl, prop, propVal, propLen);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfGetLuResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Get a logical unit resource handle for a given logical unit.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - pointer to luResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfGetLuResource(stmfGuid *luGuid, luResource *hdl)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check logical unit provider name to call correct dtype function */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = stmfGetLogicalUnitProperties(luGuid, &luProps))
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else if (luProps.status == STMF_LOGICAL_UNIT_UNREGISTERED) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * getDiskAllProps
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: load all disk properties from sbd driver
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * luGuid - guid of disk device for which properties are to be retrieved
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - allocated luResource into which properties are to be copied
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int sbdPropsSize = sizeof (*sbdProps) + MAX_SBD_PROPS;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for sbd
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(luGuid, sbdProps->slp_guid, sizeof (sbdProps->slp_guid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_ibuf = (uint64_t)(unsigned long)sbdProps;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdIoctl.stmf_obuf = (uint64_t)(unsigned long)sbdProps;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ioctlRet = ioctl(fd, SBD_IOCTL_GET_LU_PROPS, &sbdIoctl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "getDiskAllProps:ioctl error(%d) (%d) (%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = loadDiskPropsFromDriver((luResourceImpl *)*hdl, sbdProps);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * loadDiskPropsFromDriver
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Retrieve all disk type properties from sbd driver
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - Allocated luResourceImpl
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * sbdProps - sbd_lu_props_t structure returned from sbd driver
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoloadDiskPropsFromDriver(luResourceImpl *hdl, sbd_lu_props_t *sbdProps)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* copy guid */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(sbdProps->slp_guid, diskLu->luGuid, sizeof (sbdProps->slp_guid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (sbdProps->slp_separate_meta && sbdProps->slp_meta_fname_valid) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (char *)&(sbdProps->slp_buf[sbdProps->slp_meta_fname_off]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (char *)&(sbdProps->slp_buf[sbdProps->slp_data_fname_off]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(&(sbdProps->slp_buf[sbdProps->slp_serial_off]),
2f624233c43c1f4fe0d930648d6ece6fffe7aa49Nattuvetty Bhavyan (char *)&(sbdProps->slp_buf[sbdProps->slp_mgmt_url_off]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (char *)&(sbdProps->slp_buf[sbdProps->slp_alias_off]),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else { /* set alias to data filename if not set */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(sbdProps->slp_vid, diskLu->vid, sizeof (diskLu->vid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(sbdProps->slp_pid, diskLu->pid, sizeof (diskLu->pid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(sbdProps->slp_rev, diskLu->rev, sizeof (diskLu->rev));
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte diskLu->accessState = sbdProps->slp_access_state;
7beff157537d14493d525a42d33f0621b0b26217John Forte * stmfGetGlobalLuProp
7beff157537d14493d525a42d33f0621b0b26217John Forte * Purpose: get a global property for a device type
7beff157537d14493d525a42d33f0621b0b26217John FortestmfGetGlobalLuProp(uint16_t dType, uint32_t prop, char *propVal,
7beff157537d14493d525a42d33f0621b0b26217John Forte * getDiskGlobalProp
7beff157537d14493d525a42d33f0621b0b26217John Forte * Purpose: get global property from sbd driver
7beff157537d14493d525a42d33f0621b0b26217John FortegetDiskGlobalProp(uint32_t prop, char *propVal, size_t *propLen)
7beff157537d14493d525a42d33f0621b0b26217John Forte int sbdPropsSize = sizeof (*sbdProps) + MAX_SBD_PROPS;
7beff157537d14493d525a42d33f0621b0b26217John Forte * Open control node for sbd
7beff157537d14493d525a42d33f0621b0b26217John Forte if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
7beff157537d14493d525a42d33f0621b0b26217John Forte sbdIoctl.stmf_obuf = (uint64_t)(unsigned long)sbdProps;
7beff157537d14493d525a42d33f0621b0b26217John Forte ioctlRet = ioctl(fd, SBD_IOCTL_GET_GLOBAL_LU, &sbdIoctl);
7beff157537d14493d525a42d33f0621b0b26217John Forte "getDiskGlobalProp:ioctl error(%d)"
7beff157537d14493d525a42d33f0621b0b26217John Forte * stmfSetGlobalLuProp
7beff157537d14493d525a42d33f0621b0b26217John Forte * Purpose: set a global property for a device type
7beff157537d14493d525a42d33f0621b0b26217John FortestmfSetGlobalLuProp(uint16_t dType, uint32_t prop, const char *propVal)
7beff157537d14493d525a42d33f0621b0b26217John Forte * setDiskGlobalProp
7beff157537d14493d525a42d33f0621b0b26217John Forte * Purpose: set properties for resource of type disk
7beff157537d14493d525a42d33f0621b0b26217John Forte * resourceProp - valid resource identifier
7beff157537d14493d525a42d33f0621b0b26217John Forte * propVal - valid resource value
7beff157537d14493d525a42d33f0621b0b26217John FortesetDiskGlobalProp(uint32_t resourceProp, const char *propVal)
7beff157537d14493d525a42d33f0621b0b26217John Forte * Open control node for sbd
7beff157537d14493d525a42d33f0621b0b26217John Forte if ((ret = openSbd(OPEN_SBD, &fd)) != STMF_STATUS_SUCCESS)
7beff157537d14493d525a42d33f0621b0b26217John Forte sbdGlobalPropsSize += sizeof (sbd_global_props_t) - 8 +
7beff157537d14493d525a42d33f0621b0b26217John Forte * 8 is the size of the buffer set aside for
7beff157537d14493d525a42d33f0621b0b26217John Forte * concatenation of variable length fields
7beff157537d14493d525a42d33f0621b0b26217John Forte sbdGlobalProps = (sbd_global_props_t *)calloc(1, sbdGlobalPropsSize);
7beff157537d14493d525a42d33f0621b0b26217John Forte sbdGlobalProps->mlu_struct_size = sbdGlobalPropsSize;
7beff157537d14493d525a42d33f0621b0b26217John Forte sbdIoctl.stmf_ibuf_size = sbdGlobalProps->mlu_struct_size;
7beff157537d14493d525a42d33f0621b0b26217John Forte sbdIoctl.stmf_ibuf = (uint64_t)(unsigned long)sbdGlobalProps;
7beff157537d14493d525a42d33f0621b0b26217John Forte ioctlRet = ioctl(fd, SBD_IOCTL_SET_GLOBAL_LU, &sbdIoctl);
7beff157537d14493d525a42d33f0621b0b26217John Forte "modifyDiskLu:ioctl "
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfSetLuProp
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: set a property on an luResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - allocated luResource
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * prop - property identifier
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * propVal - property value to be set
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfSetLuProp(luResource hdl, uint32_t prop, const char *propVal)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * getDiskProp
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: retrieve a given property from a logical unit resource of type disk
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - allocated luResourceImpl
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * prop - property identifier
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * propVal - pointer to character to contain the retrieved property value
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * propLen - On input this is the length of propVal. On failure, it contains the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * number of bytes required for propVal
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetogetDiskProp(luResourceImpl *hdl, uint32_t prop, char *propVal, size_t *propLen)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte } else if (diskLu->accessState == SBD_LU_TRANSITION_TO_ACTIVE) {
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte } else if (diskLu->accessState == SBD_LU_STANDBY) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((reqLen = strlcpy(propVal, diskLu->luDataFileName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((reqLen = strlcpy(propVal, diskLu->luMetaFileName,
2f624233c43c1f4fe0d930648d6ece6fffe7aa49Nattuvetty Bhavyan if ((reqLen = strlcpy(propVal, diskLu->luMgmtUrl,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "%02X%02X%02X%02X",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(diskLu->vid, propVal, sizeof (diskLu->vid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(diskLu->pid, propVal, sizeof (diskLu->pid));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (diskLu->writebackCacheDisableValid == B_FALSE) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * setDiskProp
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: set properties for resource of type disk
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hdl - allocated luResourceImpl
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * resourceProp - valid resource identifier
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * propVal - valid resource value
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetosetDiskProp(luResourceImpl *hdl, uint32_t resourceProp, const char *propVal)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((strlcpy(ouiProp, propVal, sizeof (ouiProp))) >=
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((strlcpy(guidProp, propVal, sizeof (guidProp))) >=
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) strncpy(diskLu->serialNum, propVal, propSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((niceStrToNum(propVal, &diskLu->luSize) != 0)) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Given a numeric suffix, convert the value into a number of bits that the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * resulting value must be shifted.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Code lifted from libzfs_util.c
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (10*i);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Convert a string of the form '100G' into a real number. Used when setting
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * the size of a logical unit.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Code lifted from libzfs_util.c
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check to see if this looks like a number. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((value[0] < '0' || value[0] > '9') && value[0] != '.') {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Rely on stroull() to process the numeric portion. */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Check for ERANGE, which indicates that the value is too large to fit
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * in a 64-bit value.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If we have a decimal value, then do the computation with floating
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * point arithmetic. Otherwise, use standard arithmetic.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check for overflow */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (shift >= 64 || (*num << shift) >> shift != *num) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (-1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfCreateTargetGroup
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Create a local port group
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * targetGroupName - name of local port group to create
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfCreateTargetGroup(stmfGroupName *targetGroupName)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (strnlen((char *)targetGroupName, sizeof (stmfGroupName))
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto == sizeof (stmfGroupName))) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check to ensure service exists */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* call init */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Add the group to the driver
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = groupIoctl(fd, STMF_IOCTL_CREATE_TARGET_GROUP,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If the add to the driver was successful, add it to the persistent
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = psCreateTargetGroup((char *)targetGroupName);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "stmfCreateTargetGroup:psCreateTargetGroup"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfDeleteHostGroup
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Delete an initiator or local port group
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hostGroupName - group to delete
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check to ensure service exists */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* call init */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Remove the group from the driver
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = groupIoctl(fd, STMF_IOCTL_REMOVE_HOST_GROUP,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If the remove from the driver was successful, remove it from the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * persistent store.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "stmfDeleteHostGroup:psDeleteHostGroup:error(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfDeleteTargetGroup
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Delete an initiator or local port group
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * targetGroupName - group to delete
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfDeleteTargetGroup(stmfGroupName *targetGroupName)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Check to ensure service exists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Remove the group from the driver
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = groupIoctl(fd, STMF_IOCTL_REMOVE_TARGET_GROUP,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If the remove from the driver was successful, remove it from the
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * persistent store.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = psDeleteTargetGroup((char *)targetGroupName);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "stmfDeleteTargetGroup:psDeleteTargetGroup"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfDevidFromIscsiName
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: convert an iSCSI name to an stmf devid
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * iscsiName - unicode nul terminated utf-8 encoded iSCSI name
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * devid - on success, contains the converted iscsi name
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfDevidFromIscsiName(char *iscsiName, stmfDevid *devid)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Validate size of target */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((devid->identLength = strlen(iscsiName)) > MAX_ISCSI_NAME ||
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((strncmp(iscsiName, EUI, strlen(EUI)) != 0) &&
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* copy UTF-8 bytes to ident */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(iscsiName, devid->ident, devid->identLength);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfDevidFromWwn
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: convert a WWN to an stmf devid
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * wwn - 8-byte wwn identifier
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * devid - on success, contains the converted wwn
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Copy eui prefix */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Convert to ASCII uppercase hexadecimal string */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) snprintf((char *)&devid->ident[strlen(WWN)],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sizeof (devid->ident), "%02X%02X%02X%02X%02X%02X%02X%02X",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto wwn[0], wwn[1], wwn[2], wwn[3], wwn[4], wwn[5], wwn[6], wwn[7]);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto devid->identLength = strlen((char *)devid->ident);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfFreeMemory
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Free memory allocated by this library
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * memory - previously allocated pointer of memory managed by library
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * get host group, target group list from stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * groupType - HOST_GROUP, TARGET_GROUP
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetogroupListIoctl(stmfGroupList **groupList, int groupType)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* framework group list */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* call init */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Allocate ioctl input buffer
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto groupListSize = groupListSize * (sizeof (stmf_group_name_t));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto iGroupList = (stmf_group_name_t *)calloc(1, groupListSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Issue ioctl to get the group list
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)iGroupList;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "groupListIoctl:ioctl errno(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Check whether input buffer was large enough
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfIoctl.stmf_obuf_max_nentries > ALLOC_GROUP) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto groupListSize = stmfIoctl.stmf_obuf_max_nentries *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)iGroupList;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "groupListIoctl:ioctl errno(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* allocate and copy to caller's buffer */
4f2997b292e45181ce3a682d44c3c14a815d97fdsrivijitha dugganapalli *groupList = (stmfGroupList *)calloc(1, sizeof (stmfGroupList) +
4f2997b292e45181ce3a682d44c3c14a815d97fdsrivijitha dugganapalli sizeof (stmfGroupName) * stmfIoctl.stmf_obuf_nentries);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < stmfIoctl.stmf_obuf_nentries; i++) {
2f624233c43c1f4fe0d930648d6ece6fffe7aa49Nattuvetty Bhavyan bcopy(iGroupList[i].name, (*groupList)->name[i],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * get host group members, target group members from stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * groupProps - allocated on success
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * groupType - HOST_GROUP, TARGET_GROUP
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetogroupMemberListIoctl(stmfGroupName *groupName, stmfGroupProperties **groupProps,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* framework group list */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* call init */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(groupName, &iGroupName.name, strlen((char *)groupName));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Allocate ioctl input buffer
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto groupListSize = groupListSize * (sizeof (stmf_ge_ident_t));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto iGroupMembers = (stmf_ge_ident_t *)calloc(1, groupListSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Issue ioctl to get the group list
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&iGroupName;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_ibuf_size = sizeof (stmf_group_name_t);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)iGroupMembers;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "groupListIoctl:ioctl errno(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Check whether input buffer was large enough
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfIoctl.stmf_obuf_max_nentries > ALLOC_GRP_MEMBER) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto groupListSize = stmfIoctl.stmf_obuf_max_nentries *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto iGroupMembers = realloc(iGroupMembers, groupListSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&iGroupName;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_ibuf_size = sizeof (stmf_group_name_t);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)iGroupMembers;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "groupListIoctl:ioctl errno(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* allocate and copy to caller's buffer */
4f2997b292e45181ce3a682d44c3c14a815d97fdsrivijitha dugganapalli sizeof (stmfDevid) * stmfIoctl.stmf_obuf_nentries);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (*groupProps)->cnt = stmfIoctl.stmf_obuf_nentries;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < stmfIoctl.stmf_obuf_nentries; i++) {
2f624233c43c1f4fe0d930648d6ece6fffe7aa49Nattuvetty Bhavyan bcopy(iGroupMembers[i].ident, (*groupProps)->name[i].ident,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: access persistent config data for host groups and target groups
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoiLoadGroupFromPs(stmfGroupList **groupList, int type)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "stmfGetHostGroupList:psGetHostGroupList:error(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfGetHostGroupList
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Retrieves the list of initiator group oids
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * hostGroupList - pointer to pointer to hostGroupList structure
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * on success, this contains the host group list.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfGetHostGroupList(stmfGroupList **hostGroupList)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: access persistent config data for host groups and target groups
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = psGetHostGroupMemberList((char *)groupName, groupProp);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = psGetTargetGroupMemberList((char *)groupName, groupProp);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "iLoadGroupMembersFromPs:psGetHostGroupList:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetHostGroupMembers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves the group properties for a host group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of group for which to retrieve host group members.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupProp - pointer to pointer to stmfGroupProperties structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on success, this contains the list of group members.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = groupMemberListIoctl(groupName, groupProp, HOST_GROUP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetProviderData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Get provider data list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - name of provider for which to retrieve the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nvl - pointer to nvlist_t pointer which will contain the nvlist data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * retrieved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerType - type of provider for which to retrieve data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_LU_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PORT_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetProviderData(char *providerName, nvlist_t **nvl, int providerType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (stmfGetProviderDataProt(providerName, nvl, providerType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetProviderDataProt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Get provider data list with token
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - name of provider for which to retrieve the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nvl - pointer to nvlist_t pointer which will contain the nvlist data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * retrieved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerType - type of provider for which to retrieve data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_LU_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PORT_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setToken - Returns the stale data token
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetProviderDataProt(char *providerName, nvlist_t **nvl, int providerType,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* call init */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (getProviderData(providerName, nvl, providerType, setToken));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetProviderDataList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Get the list of providers currently persisting data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerList - pointer to pointer to an stmfProviderList structure allocated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by the caller. Will contain the list of providers on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetProviderDataList(stmfProviderList **providerList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetProviderDataList:psGetProviderDataList"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetSessionList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves the session list for a target (devid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devid - devid of target for which to retrieve session information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sessionList - pointer to pointer to stmfSessionList structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on success, this contains the list of initiator sessions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetSessionList(stmfDevid *devid, stmfSessionList **sessionList)
562610838fe0b8fdbe99a91a1dc13e77da2b6546Charles Ting slist_scsi_session_t *fSessionList, *fSessionListP = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate ioctl input buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fSessionListSize = fSessionListSize * (sizeof (slist_scsi_session_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fSessionList = (slist_scsi_session_t *)calloc(1, fSessionListSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&(devid->ident), &ident[IDENT_LENGTH_BYTE + 1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to get the session list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&ident;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fSessionList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetSessionList:ioctl errno(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check whether input buffer was large enough
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfIoctl.stmf_obuf_max_nentries > ALLOC_SESSION) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fSessionListSize = stmfIoctl.stmf_obuf_max_nentries *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fSessionList = realloc(fSessionList, fSessionListSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fSessionList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetSessionList:ioctl "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate caller's buffer with the final size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *sessionList = (stmfSessionList *)calloc(1, sizeof (stmfSessionList) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf_max_nentries * sizeof (stmfSession));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*sessionList)->cnt = stmfIoctl.stmf_obuf_max_nentries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy session info to caller's buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*sessionList)->session[i].initiator.identLength =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&(fSessionList->initiator[IDENT_LENGTH_BYTE + 1]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetTargetGroupList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves the list of target groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targetGroupList - pointer to a pointer to an stmfGroupList structure. On
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * success, it contains the list of target groups.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetTargetGroupList(stmfGroupList **targetGroupList)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = groupListIoctl(targetGroupList, TARGET_GROUP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetTargetGroupMembers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves the group members for a target group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of target group for which to retrieve members.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupProp - pointer to pointer to stmfGroupProperties structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on success, this contains the list of group members.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetTargetGroupMembers(stmfGroupName *groupName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = groupMemberListIoctl(groupName, groupProp, TARGET_GROUP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetTargetList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves the list of target ports
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targetList - pointer to a pointer to an stmfDevidList structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On success, it contains the list of local ports (target).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* framework target port list */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto slist_target_port_t *fTargetList, *fTargetListP = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate ioctl input buffer
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto fTargetListSize = ALLOC_TARGET_PORT * sizeof (slist_target_port_t);
3e7352aecf183df6c5f819be775df62aadcdfd08John Forte (slist_target_port_t *)calloc(1, fTargetListSize);
3e7352aecf183df6c5f819be775df62aadcdfd08John Forte * Issue ioctl to retrieve target list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fTargetList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_TARGET_PORT_LIST, &stmfIoctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check whether input buffer was large enough
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfIoctl.stmf_obuf_max_nentries > ALLOC_TARGET_PORT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fTargetListSize = stmfIoctl.stmf_obuf_max_nentries *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fTargetList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_TARGET_PORT_LIST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetTargetList:ioctl errno(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf_max_nentries * sizeof (stmfDevid) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*targetList)->cnt = stmfIoctl.stmf_obuf_max_nentries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < stmfIoctl.stmf_obuf_max_nentries; i++, fTargetList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&fTargetList->target[IDENT_LENGTH_BYTE + 1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetTargetProperties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves the properties for a logical unit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devid - devid of the target for which to retrieve properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targetProps - pointer to an stmfTargetProperties structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On success, it contains the target properties for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the specified devid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetTargetProperties(stmfDevid *devid, stmfTargetProperties *targetProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProperties.tgt_id[IDENT_LENGTH_BYTE] = devid->identLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&(devid->ident), &targetProperties.tgt_id[IDENT_LENGTH_BYTE + 1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to add to the host group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf_size = sizeof (targetProperties.tgt_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&targetProperties.tgt_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)&targetProperties;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf_size = sizeof (targetProperties);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_GET_TARGET_PORT_PROPERTIES,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetTargetProperties:ioctl errno(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(targetProperties.tgt_provider_name, targetProps->providerName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetProperties.tgt_state == STMF_STATE_ONLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (targetProperties.tgt_state == STMF_STATE_OFFLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (targetProperties.tgt_state == STMF_STATE_ONLINING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (targetProperties.tgt_state == STMF_STATE_OFFLINING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps->status = STMF_TARGET_PORT_OFFLINING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(targetProperties.tgt_alias, targetProps->alias,
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte scsiDevid = (scsi_devid_desc_t *)&targetProperties.tgt_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetLogicalUnitList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves list of logical unit Object IDs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * luList - pointer to a pointer to a stmfGuidList structure. On success,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it contains the list of logical unit guids.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate ioctl input buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fLuListSize = fLuListSize * (sizeof (slist_lu_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to get the LU list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fLuList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetLogicalUnitList:ioctl errno(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check whether input buffer was large enough
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfIoctl.stmf_obuf_max_nentries > ALLOC_LU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fLuList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetLogicalUnitList:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate caller's buffer with the final size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *luList = (stmfGuidList *)calloc(1, sizeof (stmfGuidList) +
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* copy to caller's buffer */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < listCnt; i++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(&fLuList[i].lu_guid, (*luList)->guid[i].guid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * sort the list. This gives a consistent view across gets
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto qsort((void *)&((*luList)->guid[0]), (*luList)->cnt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free internal buffers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetLogicalUnitProperties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Retrieves the properties for a logical unit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu - guid of the logical unit for which to retrieve properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfLuProps - pointer to an stmfLogicalUnitProperties structure. On success,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it contains the logical unit properties for the specified guid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfGetLogicalUnitProperties(stmfGuid *lu, stmfLogicalUnitProperties *luProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(luProps, sizeof (stmfLogicalUnitProperties));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to add to the host group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)lu;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)&fLuProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfGetLogicalUnit:ioctl errno(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(fLuProps.lu_provider_name, luProps->providerName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fLuProps.lu_state == STMF_STATE_OFFLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fLuProps.lu_state == STMF_STATE_ONLINING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fLuProps.lu_state == STMF_STATE_OFFLINING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(fLuProps.lu_alias, luProps->alias, sizeof (luProps->alias));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfGetState
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: retrieve the current state of the stmf module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * state - pointer to stmfState structure allocated by the caller
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On success, contains the state of stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * stmfGetViewEntryList
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: Retrieves the list of view entries for the specified
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * logical unit.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * lu - the guid of the logical unit for which to retrieve the view entry list
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * viewEntryList - a pointer to a pointer to a stmfViewEntryList structure. On
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * success, contains the list of view entries.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* call init */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Allocate ioctl input buffer
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto fVeListSize = fVeListSize * (sizeof (stmf_view_op_entry_t));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto fVeList = (stmf_view_op_entry_t *)calloc(1, fVeListSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Issue ioctl to get the LU list
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)lu;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fVeList;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "stmfGetViewEntryList:ioctl errno(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Check whether input buffer was large enough
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfIoctl.stmf_obuf_max_nentries > ALLOC_VE) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto fVeList = (stmf_view_op_entry_t *)calloc(1, fVeListSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)fVeList;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "stmfGetLogicalUnitList:"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * allocate caller's buffer with the final size
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sizeof (stmfViewEntryList) + listCnt * sizeof (stmfViewEntry));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* copy to caller's buffer */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < listCnt; i++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (*viewEntryList)->ve[i].veIndex = fVeList[i].ve_ndx;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto bcopy(fVeList[i].ve_lu_nbr, (*viewEntryList)->ve[i].luNbr,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * sort the list. This gives a consistent view across gets
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto qsort((void *)&((*viewEntryList)->ve[0]), (*viewEntryList)->cnt,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * free internal buffers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * loadHostGroups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose - issues the ioctl to load the host groups into stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd - file descriptor for the control node of stmf.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupList - populated host group list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupIoctl(fd, STMF_IOCTL_CREATE_HOST_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(groupList->name[i]))) != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = iLoadGroupMembersFromPs(&(groupList->name[i]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupMemberIoctl(fd, STMF_IOCTL_ADD_HG_ENTRY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * loadTargetGroups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose - issues the ioctl to load the target groups into stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd - file descriptor for the control node of stmf.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupList - populated target group list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteloadTargetGroups(int fd, stmfGroupList *groupList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupIoctl(fd, STMF_IOCTL_CREATE_TARGET_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(groupList->name[i]))) != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = iLoadGroupMembersFromPs(&(groupList->name[i]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupMemberIoctl(fd, STMF_IOCTL_ADD_TG_ENTRY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Load the configuration data from the store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First load the host groups and target groups, then the view entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and finally the provider data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd - file descriptor of control node for stmf.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* load host groups */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* load target groups */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the guid list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We have the guid list, now get the corresponding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * view entries for each guid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = psGetViewEntryList(&guidList->guid[i], &viewEntryList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the list of providers that have data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte providerType = providerList->provider[i].providerType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = psGetProviderData(providerList->provider[i].name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call setProviderData */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setProviderData(fd, providerList->provider[i].name, nvl,
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * stmfGetAluaState
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Purpose - Get the alua state
450396635f70344c58b6b1e4db38cf17ff34445cJohn FortestmfGetAluaState(boolean_t *enabled, uint32_t *node)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Open control node for stmf
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Issue ioctl to get the stmf state
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)&alua_state;
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_GET_ALUA_STATE, &stmfIoctl);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * stmfSetAluaState
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Purpose - set the alua state to enabled/disabled
450396635f70344c58b6b1e4db38cf17ff34445cJohn FortestmfSetAluaState(boolean_t enabled, uint32_t node)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte if ((enabled != B_TRUE && enabled != B_FALSE) || (node > 1)) {
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Open control node for stmf
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Issue ioctl to get the stmf state
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&alua_state;
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_SET_ALUA_STATE, &stmfIoctl);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte stmfRet = stmfGetLuResource(&luList->guid[i], &hdl);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_ACCESS_STATE, propVal,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfLoadConfig
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose - load the configuration data from smf into stmf
640428ae0ffb68033a9bf38dcc271e17d13933cbSue Gleeson * Configuration not stored persistently; nothing to
640428ae0ffb68033a9bf38dcc271e17d13933cbSue Gleeson * initialize so do not set to STMF_CONFIG_INIT.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfStateSet.config_state = STMF_CONFIG_INIT_DONE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to ensure service exists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (state.operationalState != STMF_SERVICE_STATE_OFFLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_EXCL_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &stmfStateSet, STMF_SERVICE_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load the persistent configuration data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfStateSet.config_state = STMF_CONFIG_INIT_DONE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &stmfStateSet, STMF_SERVICE_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getStmfState
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfState - pointer to stmf_state_desc_t structure. Will contain the state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information of the stmf service on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to get the stmf state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf_size = sizeof (stmf_state_desc_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)stmfState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf_size = sizeof (stmf_state_desc_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)stmfState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_GET_STMF_STATE, &stmfIoctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setStmfState
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfState - pointer to caller set state structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * objectType - one of:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LOGICAL_UNIT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TARGET_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_SERVICE_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesetStmfState(int fd, stmf_state_desc_t *stmfState, int objectType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to set the stmf state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf_size = sizeof (stmf_state_desc_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)stmfState;
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapallistmfSetStmfProp(uint8_t propType, char *propVal)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli case STMF_DEFAULT_TARGET_PORT_STATE:
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli ret = psSetStmfProp(propType, propVal);
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "stmfSetStmfProp:psSetStmfProp:error(%d)",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapallistmfGetStmfProp(uint8_t propType, char *propVal, size_t *propLen)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (propVal == NULL || propLen == NULL) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli case STMF_DEFAULT_TARGET_PORT_STATE:
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli ret = psGetStmfProp(propType, prop);
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if ((reqLen = strlcpy(propVal, prop, *propLen)) >= *propLen) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "stmfGetStmfProp:psGetStmfProp:error(%d)",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapallisetStmfProp(stmf_set_props_t *stmf_set_props)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if ((ret = psGetStmfProp(STMF_DEFAULT_LU_STATE, propVal)) ==
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (strncmp(propVal, "offline", strlen(propVal)) == 0) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmf_set_props->default_lu_state_value =
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmf_set_props->default_lu_state_value =
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "DefaultLuState:psSetStmfProp:error(%d)", ret);
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if ((ret = psGetStmfProp(STMF_DEFAULT_TARGET_PORT_STATE, propVal)) ==
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (strncmp(propVal, "offline", strlen(propVal)) == 0) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmf_set_props->default_target_state_value =
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmf_set_props->default_target_state_value =
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "DefaultTargetPortState:psSetStmfProp:error(%d)", ret);
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmf_set_props_t *stmf_set_props = NULL;
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmf_set_props = (stmf_set_props_t *)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli calloc(1, (sizeof (stmf_set_props_t)));
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli /* Loading the default property values from smf */
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if ((ret = setStmfProp(stmf_set_props)) != STMF_STATUS_SUCCESS)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmfIoctl.stmf_version = STMF_VERSION_1;
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli stmfIoctl.stmf_ibuf_size = sizeof (stmf_set_props_t);
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli (uint64_t)(unsigned long)stmf_set_props;
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli ioctlRet = ioctl(fd, STMF_IOCTL_SET_STMF_PROPS,
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "setDefaultStmfState:"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli /* open control node for stmf */
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if ((ret = openStmf(OPEN_EXCL_STMF, &fd))
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "stmfLoadStmfProps:Failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfOnline
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Online stmf service
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (state.operationalState == STMF_SERVICE_STATE_ONLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to make call to setStmfState()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_EXCL_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &iState, STMF_SERVICE_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfOffline
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Offline stmf service
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (state.operationalState == STMF_SERVICE_STATE_OFFLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to make call to setStmfState()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_EXCL_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &iState, STMF_SERVICE_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfOfflineTarget
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Change state of target to offline
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devid - devid of the target to offline
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetState.ident[IDENT_LENGTH_BYTE] = devid->identLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&(devid->ident), &targetState.ident[IDENT_LENGTH_BYTE + 1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to make call to setStmfState()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_EXCL_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &targetState, TARGET_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfOfflineLogicalUnit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Change state of logical unit to offline
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu - guid of the logical unit to offline
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to make call to setStmfState()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_EXCL_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &luState, LOGICAL_UNIT_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfOnlineTarget
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Change state of target to online
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devid - devid of the target to online
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetState.ident[IDENT_LENGTH_BYTE] = devid->identLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&(devid->ident), &targetState.ident[IDENT_LENGTH_BYTE + 1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to make call to setStmfState()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_EXCL_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &targetState, TARGET_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfOnlineLogicalUnit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Change state of logical unit to online
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu - guid of the logical unit to online
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to make call to setStmfState()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_EXCL_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = setStmfState(fd, &luState, LOGICAL_UNIT_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfRemoveFromHostGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Removes an initiator from an initiator group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hostGroupName - name of an initiator group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hostName - name of host group member to remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfRemoveFromHostGroup(stmfGroupName *hostGroupName, stmfDevid *hostName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strnlen((char *)hostGroupName, sizeof (stmfGroupName))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == sizeof (stmfGroupName)) || hostName == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupMemberIoctl(fd, STMF_IOCTL_REMOVE_HG_ENTRY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hostGroupName, hostName)) != STMF_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = psRemoveHostGroupMember((char *)hostGroupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)hostName->ident);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfRemoveFromHostGroup"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfRemoveFromTargetGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Removes a local port from a local port group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targetGroupName - name of a target group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * targetName - name of target to remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfRemoveFromTargetGroup(stmfGroupName *targetGroupName, stmfDevid *targetName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strnlen((char *)targetGroupName, sizeof (stmfGroupName))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == sizeof (stmfGroupName)) || targetName == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = groupMemberIoctl(fd, STMF_IOCTL_REMOVE_TG_ENTRY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetGroupName, targetName)) != STMF_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = psRemoveTargetGroupMember((char *)targetGroupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)targetName->ident);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfRemoveFromTargetGroup"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfRemoveViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Removes a view entry from a logical unit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu - guid of lu for which view entry is being removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntryIndex - index of view entry to remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfRemoveViewEntry(stmfGuid *lu, uint32_t viewEntryIndex)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(lu, &ioctlViewEntry.ve_guid, sizeof (stmfGuid));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue ioctl to add to the view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf_size = sizeof (ioctlViewEntry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&ioctlViewEntry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_REMOVE_VIEW_ENTRY, &stmfIoctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfRemoveViewEntry:ioctl errno(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfRemoveViewEntry" "psRemoveViewEntry:error(%d)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfSetProviderData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: set the provider data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - unique name of provider
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nvl - nvlist to set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerType - type of provider for which to set data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_LU_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PORT_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfSetProviderData(char *providerName, nvlist_t *nvl, int providerType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (stmfSetProviderDataProt(providerName, nvl, providerType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfSetProviderDataProt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: set the provider data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - unique name of provider
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nvl - nvlist to set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerType - type of provider for which to set data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_LU_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PORT_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setToken - Stale data token returned in the stmfGetProviderDataProt()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * call or NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortestmfSetProviderDataProt(char *providerName, nvlist_t *nvl, int providerType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open control node for stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = setProviderData(fd, providerName, nvl, providerType, setToken);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setting driver provider data successful. Now persist it */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = psSetProviderData(providerName, nvl, providerType, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "stmfSetProviderData"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * getProviderData
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: set the provider data from stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * providerName - unique name of provider
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * nvl - nvlist to load/retrieve
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * providerType - logical unit or port provider
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * setToken - returned stale data token
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetogetProviderData(char *providerName, nvlist_t **nvl, int providerType,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Open control node for stmf
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* set provider name and provider type */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* allocate memory for ioctl */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ppi_out = (stmf_ppioctl_data_t *)calloc(1, nvlistSize +
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* set the size of the ioctl data to allocated buffer */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_ibuf_size = sizeof (stmf_ppioctl_data_t);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&ppi;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf_size = sizeof (stmf_ppioctl_data_t) +
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)ppi_out;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ioctlRet = ioctl(fd, STMF_IOCTL_GET_PP_DATA, &stmfIoctl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "getProviderData:ioctl"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "unable to retrieve "
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "getProviderData:ioctl errno(%d)",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } while (retry && stmfIoctl.stmf_error == STMF_IOCERR_INSUFFICIENT_BUF);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((ret = nvlist_unpack((char *)ppi_out->ppi_data,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* caller has asked for new token */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setProviderData
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Purpose: set the provider data in stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - unique name of provider
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nvl - nvlist to set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerType - logical unit or port provider
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * setToken - stale data token to check if not NULL
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetosetProviderData(int fd, char *providerName, nvlist_t *nvl, int providerType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get size of encoded nvlist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_size(nvl, &nvlistEncodedSize, NV_ENCODE_XDR) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate memory for ioctl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ppi = (stmf_ppioctl_data_t *)calloc(1, nvlistEncodedSize +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_pack(nvl, &allocatedNvBuffer, &nvlistEncodedSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set provider name and provider type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(ppi->ppi_name, providerName, sizeof (ppi->ppi_name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the size of the ioctl data to packed data size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Subtracting 8 from the size as that is the size of the last member
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the structure where the packed data resides
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)ppi;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)&outToken;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioctlRet = ioctl(fd, STMF_IOCTL_LOAD_PP_DATA, &stmfIoctl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* caller has asked for new token */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * set the persistence method in the library only or library and service
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfSetPersistMethod(uint8_t persistType, boolean_t serviceSet)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) pthread_mutex_unlock(&persistenceTypeLock);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Is this for this library open or in SMF */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Set to old value */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) pthread_mutex_unlock(&persistenceTypeLock);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Only returns internal state for persist. If unset, goes to ps. If that
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * fails, returns default setting
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* set to default */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) pthread_mutex_unlock(&persistenceTypeLock);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Returns either library state or persistent config state depending on
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * serviceState
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostmfGetPersistMethod(uint8_t *persistType, boolean_t serviceState)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) pthread_mutex_unlock(&persistenceTypeLock);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * stmfPostProxyMsg
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Purpose: Post a message to the proxy port provider
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * buf - buffer containing message to post
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * buflen - buffer length
450396635f70344c58b6b1e4db38cf17ff34445cJohn FortestmfPostProxyMsg(int hdl, void *buf, uint32_t buflen)
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Issue ioctl to post the message
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte ppptIoctl.pppt_buf = (uint64_t)(unsigned long)buf;
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * stmfInitProxyDoor
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Purpose: Install door in proxy
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * hdl - pointer to returned handle
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * fd - door from door_create()
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Open control node for pppt
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte if ((ret = openPppt(OPEN_PPPT, &fd)) != STMF_STATUS_SUCCESS) {
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte * Issue ioctl to install the door
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte ioctlRet = ioctl(fd, PPPT_INSTALL_DOOR, &ppptIoctl);
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte /* return driver fd to caller */
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * validateLunNumIoctl
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * Purpose: Issues ioctl to check and get available lun# in view entry
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * viewEntry - view entry to use
63ed874a56e20df7e4ec98ba42582352d87386c5tim szetovalidateLunNumIoctl(int fd, stmfViewEntry *viewEntry)
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * don't set ve_ndx or ve_ndx_valid as ve_ndx_valid should be
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * false on input
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto ioctlViewEntry.ve_lu_number_valid = viewEntry->luNbrValid;
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto ioctlViewEntry.ve_all_hosts = viewEntry->allHosts;
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto ioctlViewEntry.ve_all_targets = viewEntry->allTargets;
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto bcopy(viewEntry->hostGroup, &ioctlViewEntry.ve_host_group.name,
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto /* Validating the lun number */
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto bcopy(viewEntry->luNbr, &ioctlViewEntry.ve_lu_nbr,
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * Issue ioctl to validate lun# in the view entry
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto stmfIoctl.stmf_ibuf_size = sizeof (ioctlViewEntry);
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto stmfIoctl.stmf_ibuf = (uint64_t)(unsigned long)&ioctlViewEntry;
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto stmfIoctl.stmf_obuf_size = sizeof (ioctlViewEntry);
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto stmfIoctl.stmf_obuf = (uint64_t)(unsigned long)&ioctlViewEntry;
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto ioctlRet = ioctl(fd, STMF_IOCTL_VALIDATE_VIEW, &stmfIoctl);
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto /* save available lun number */
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto "addViewEntryIoctl"
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto ":error(%d)",
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * stmfValidateView
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * Purpose: Validate or get lun # base on TG, HG of view entry
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * viewEntry - view entry structure to use
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto /* initialize and set internal view entry */
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto bcopy(viewEntry->targetGroup, iViewEntry.targetGroup,
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * set users return view entry index valid flag to false
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * in case of failure
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto /* Check to ensure service exists */
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto /* call init */
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * Open control node for stmf
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto if ((ret = openStmf(OPEN_STMF, &fd)) != STMF_STATUS_SUCCESS)
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * Validate lun# in the view entry from the driver
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto /* save available lun number */