/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <ctype.h>
#include <libipmi.h>
#include <libnvpair.h>
#include <libuutil.h>
#include <limits.h>
#include <stddef.h>
#include <string.h>
#include "diskmon_conf.h"
#include "dm_platform.h"
#include "util.h"
/* For the purposes of disk capacity, a <X>B is 1000x, not 1024x */
typedef enum {
typedef struct ipmi_cache_entry {
union {
} ic_data;
/*
* The textual strings that are used in the actions may be one of the
* following forms:
*
* [1] `fru gid=<n> hdd=<m>'
* [2] `sensor id=<x> assert=<y> deassert=<z>'
*
* The generic parser will take a string and spit out the first token
* (e.g. `fru' or `sensor') and an nvlist that contains the key-value
* pairs in the rest of the string. The assumption is that there are
* no embedded spaces or tabs in the keys or values.
*/
static boolean_t
{
int digits = 0;
str += 2;
str++;
}
while (*str != 0) {
return (B_FALSE);
}
str++;
digits++;
}
}
static void
{
while (*str != 0) {
str++;
}
}
static boolean_t
{
char *action;
int actionlen;
return (B_FALSE);
/* Look for a name=val construct */
*eq = 0;
eq++;
/*
* Convert token to lowercase to preserve
* case-insensitivity, because nvlist doesn't
* do case-insensitive lookups
*/
/* Integer property */
} else {
/* String property */
eq) != 0)
}
/* Boolean property */
} else /* Parse error (`X=' is invalid) */
}
} else
if (!rv) {
if (*cmdp) {
}
}
return (rv);
}
static int
{
char *buf;
return (-1);
}
/*
* Print the size of the disk to a temporary buffer whose size is
* 1 more than the size of the buffer in the ipmi request data
* structure, so we can get the full 8 characters (instead of 7 + NUL)
*/
"%.1f%s",
"KB"))));
return (-1);
/* find a cache entry or create one if necessary */
break;
}
}
return (0);
}
static int
{
int ret;
/* We need at least 2 properties: `sid' and (`amask' || `dmask'): */
(!am_present && !dam_present)) {
return (-1);
}
log_warn("IPMI Plugin: Invalid sensor id `0x%llx'.\n",
(longlong_t)sid);
return (-1);
} else if (assertmask > UINT16_MAX) {
log_warn("IPMI Plugin: Invalid assertion mask `0x%llx'.\n",
return (-1);
} else if (assertmask > UINT16_MAX) {
log_warn("IPMI Plugin: Invalid deassertion mask `0x%llx'.\n",
return (-1);
}
if (am_present) {
}
if (dam_present) {
}
/* find a cache entry or create one if necessary */
break;
}
}
if (am_present) {
}
if (dam_present) {
}
return (ret);
}
static char *
{
int len;
int i = 0;
/* The protocol is the string before the separator, but in lower-case */
if (s) {
while (i < len) {
i++;
}
}
return (proto);
}
static char *
{
/* The action is the string after the separator */
return (s ? (s + 1) : NULL);
}
static int
{
char *cmd;
return (-1);
}
(void) pthread_mutex_lock(&g_ipmi_mtx);
} else {
}
}
(void) pthread_mutex_unlock(&g_ipmi_mtx);
return (rv);
}
int
{
}
int
{
}
int
dm_platform_resync(void)
{
int rv = 0;
(void) pthread_mutex_lock(&g_ipmi_mtx);
/*
* maintained across reboots. Note that we must update the FRU
* information first, as certain sensor states prevent this from
* working.
*/
}
}
(void) pthread_mutex_unlock(&g_ipmi_mtx);
return (rv);
}
int
dm_platform_init(void)
{
int err;
char *msg;
== NULL) {
return (-1);
}
if ((g_ipmi_cache_pool = uu_list_pool_create(
"ipmi_cache", sizeof (ipmi_cache_entry_t),
return (-1);
== NULL)
return (-1);
return (0);
}
void
dm_platform_fini(void)
{
if (g_ipmi_hdl)
if (g_ipmi_cache) {
}
}
if (g_ipmi_cache_pool)
}