1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte * CDDL HEADER START
3fcf3ce44SJohn Forte *
4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte *
8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte * and limitations under the License.
12fcf3ce44SJohn Forte *
13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte *
19fcf3ce44SJohn Forte * CDDL HEADER END
20fcf3ce44SJohn Forte */
21fcf3ce44SJohn Forte /*
22fcf3ce44SJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23fcf3ce44SJohn Forte * Use is subject to license terms.
24fcf3ce44SJohn Forte */
25fcf3ce44SJohn Forte
26fcf3ce44SJohn Forte /*
27fcf3ce44SJohn Forte * Description
28fcf3ce44SJohn Forte * mpapi-sun.c - Implements the Sun Extension to the Multipath Management
29*55fea89dSDan Cross * API Version 1.0
30fcf3ce44SJohn Forte */
31fcf3ce44SJohn Forte
32fcf3ce44SJohn Forte #include <dlfcn.h>
33fcf3ce44SJohn Forte #include <pthread.h>
34fcf3ce44SJohn Forte #include "mpapi.h"
35fcf3ce44SJohn Forte #include "mpapi-sun.h"
36fcf3ce44SJohn Forte #include "mpapi-plugin.h"
37fcf3ce44SJohn Forte
38fcf3ce44SJohn Forte extern MPPLUGININFO_T plugintable[MP_MAX_NUM_PLUGINS];
39fcf3ce44SJohn Forte
40fcf3ce44SJohn Forte extern pthread_mutex_t mp_lib_mutex;
41fcf3ce44SJohn Forte extern MP_STATUS validate_object(MP_OID obj, MP_OBJECT_TYPE objType,
42fcf3ce44SJohn Forte MP_UINT32 flag);
43fcf3ce44SJohn Forte
Sun_MP_SendScsiCmd(MP_OID pathOid,struct uscsi_cmd * cmd)44fcf3ce44SJohn Forte MP_STATUS Sun_MP_SendScsiCmd(
45fcf3ce44SJohn Forte MP_OID pathOid, struct uscsi_cmd *cmd)
46fcf3ce44SJohn Forte {
47fcf3ce44SJohn Forte Sun_MP_SendScsiCmdFn PassFunc;
48fcf3ce44SJohn Forte MP_UINT32 index;
49fcf3ce44SJohn Forte MP_STATUS status;
50fcf3ce44SJohn Forte
51fcf3ce44SJohn Forte if ((status = validate_object(pathOid, MP_OBJECT_TYPE_PATH_LU,
52fcf3ce44SJohn Forte MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
53fcf3ce44SJohn Forte return (status);
54fcf3ce44SJohn Forte }
55fcf3ce44SJohn Forte
56fcf3ce44SJohn Forte (void) pthread_mutex_lock(&mp_lib_mutex);
57fcf3ce44SJohn Forte
58fcf3ce44SJohn Forte index = pathOid.ownerId - 1;
59fcf3ce44SJohn Forte if (plugintable[index].hdlPlugin != NULL) {
60fcf3ce44SJohn Forte PassFunc = (Sun_MP_SendScsiCmdFn)
61fcf3ce44SJohn Forte dlsym(plugintable[index].hdlPlugin,
62fcf3ce44SJohn Forte "Sun_MP_SendScsiCmd");
63fcf3ce44SJohn Forte
64fcf3ce44SJohn Forte if (PassFunc != NULL) {
65fcf3ce44SJohn Forte status = PassFunc(pathOid, cmd);
66fcf3ce44SJohn Forte } else {
67fcf3ce44SJohn Forte status = MP_STATUS_UNSUPPORTED;
68fcf3ce44SJohn Forte }
69fcf3ce44SJohn Forte } else {
70fcf3ce44SJohn Forte status = MP_STATUS_FAILED;
71fcf3ce44SJohn Forte }
72fcf3ce44SJohn Forte
73fcf3ce44SJohn Forte (void) pthread_mutex_unlock(&mp_lib_mutex);
74fcf3ce44SJohn Forte return (status);
75fcf3ce44SJohn Forte }
76