damap_impl.h revision 4c06356b0f0fffb4fc1b6eccc8e5d8e2254a84d6
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_DAMAP_IMPL_H
#define _SYS_DAMAP_IMPL_H
#include <sys/isa_defs.h>
#include <sys/dditypes.h>
#include <sys/ddi_impldefs.h>
#include <sys/ddi_implfuncs.h>
#include <sys/sysevent.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* activate_cb: Provider callback when reported address is activated
* deactivate_cb: Provider callback when address has been released
*
* configure_cb: Class callout to configure newly activated addresses
* unconfig_cb: Class callout to unconfigure deactivated addresses
*/
struct dam {
char *dam_name;
int dam_flags; /* state and locks */
int dam_options; /* options at map creation */
int dam_rptmode; /* report mode */
void *dam_activate_arg; /* activation private */
void *dam_config_arg; /* config-private */
void *dam_da; /* per-address soft state */
int dam_stable_cnt; /* # of times map stabilized */
int dam_stable_overrun;
};
/*
* damap.dam_flags
*/
#define DAM_LOCK(m, l) { \
mutex_enter(&(m)->dam_lock); \
while ((m)->dam_flags & (l)) \
(m)->dam_flags |= (l); \
mutex_exit(&(m)->dam_lock); \
}
#define DAM_UNLOCK(m, l) { \
mutex_enter(&(m)->dam_lock); \
(m)->dam_flags &= ~(l); \
mutex_exit(&(m)->dam_lock); \
}
#define DAM_FLAG_SET(m, f) { \
mutex_enter(&(m)->dam_lock); \
(m)->dam_flags |= f; \
mutex_exit(&(m)->dam_lock); \
}
#define DAM_FLAG_CLR(m, f) { \
mutex_enter(&(m)->dam_lock); \
(m)->dam_flags &= ~f; \
mutex_exit(&(m)->dam_lock); \
}
/*
* per address softstate stucture
*/
typedef struct {
int da_jitter; /* address report count */
int da_ref; /* refcount on address */
void *da_ppriv; /* stable provider private */
void *da_cfg_priv; /* config/unconfig private */
void *da_ppriv_rpt; /* reported provider-private */
int da_report_cnt; /* # of times address reported */
int da_stable_cnt; /* # of times address has stabilized */
char *da_addr; /* string in dam_addr_hash (for mdb) */
} dam_da_t;
/*
* dam_da_t.da_flags
*/
/*
* report type
*/
#define RPT_ADDR_ADD 0
#define RPT_ADDR_DEL 1
/*
* DAM statistics
*/
struct dam_kstats {
struct kstat_named dam_stable;
struct kstat_named dam_stable_blocked;
struct kstat_named dam_rereport;
struct kstat_named dam_numstable;
};
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DAMAP_IMPL_H */