14c06356bSdh142964 /* 24c06356bSdh142964 * CDDL HEADER START 34c06356bSdh142964 * 44c06356bSdh142964 * The contents of this file are subject to the terms of the 54c06356bSdh142964 * Common Development and Distribution License (the "License"). 64c06356bSdh142964 * You may not use this file except in compliance with the License. 74c06356bSdh142964 * 84c06356bSdh142964 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 94c06356bSdh142964 * or http://www.opensolaris.org/os/licensing. 104c06356bSdh142964 * See the License for the specific language governing permissions 114c06356bSdh142964 * and limitations under the License. 124c06356bSdh142964 * 134c06356bSdh142964 * When distributing Covered Code, include this CDDL HEADER in each 144c06356bSdh142964 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 154c06356bSdh142964 * If applicable, add the following below this CDDL HEADER, with the 164c06356bSdh142964 * fields enclosed by brackets "[]" replaced with your own identifying 174c06356bSdh142964 * information: Portions Copyright [yyyy] [name of copyright owner] 184c06356bSdh142964 * 194c06356bSdh142964 * CDDL HEADER END 204c06356bSdh142964 */ 214c06356bSdh142964 224c06356bSdh142964 /* 23*60aabb4cSChris Horne * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 244c06356bSdh142964 */ 254c06356bSdh142964 264c06356bSdh142964 #ifndef _SYS_DAMAP_IMPL_H 274c06356bSdh142964 #define _SYS_DAMAP_IMPL_H 284c06356bSdh142964 294c06356bSdh142964 #include <sys/isa_defs.h> 304c06356bSdh142964 #include <sys/dditypes.h> 314c06356bSdh142964 #include <sys/time.h> 324c06356bSdh142964 #include <sys/cmn_err.h> 334c06356bSdh142964 #include <sys/ddi_impldefs.h> 344c06356bSdh142964 #include <sys/ddi_implfuncs.h> 354c06356bSdh142964 #include <sys/ddi_isa.h> 364c06356bSdh142964 #include <sys/model.h> 374c06356bSdh142964 #include <sys/devctl.h> 384c06356bSdh142964 #include <sys/nvpair.h> 394c06356bSdh142964 #include <sys/sysevent.h> 404c06356bSdh142964 #include <sys/bitset.h> 414c06356bSdh142964 #include <sys/sdt.h> 424c06356bSdh142964 434c06356bSdh142964 #ifdef __cplusplus 444c06356bSdh142964 extern "C" { 454c06356bSdh142964 #endif 464c06356bSdh142964 474c06356bSdh142964 typedef struct dam dam_t; 484c06356bSdh142964 494c06356bSdh142964 /* 504c06356bSdh142964 * activate_cb: Provider callback when reported address is activated 514c06356bSdh142964 * deactivate_cb: Provider callback when address has been released 524c06356bSdh142964 * 534c06356bSdh142964 * configure_cb: Class callout to configure newly activated addresses 544c06356bSdh142964 * unconfig_cb: Class callout to unconfigure deactivated addresses 554c06356bSdh142964 */ 564c06356bSdh142964 typedef void (*activate_cb_t)(void *, char *addr, int idx, void **privp); 57d189c170SReed typedef void (*deactivate_cb_t)(void *, char *addr, int idx, void *priv, 58d189c170SReed damap_deact_rsn_t deact_rsn); 594c06356bSdh142964 601b115575SJohn Danielson typedef int (*configure_cb_t)(void *, dam_t *mapp, id_t map_id); 611b115575SJohn Danielson typedef int (*unconfig_cb_t)(void *, dam_t *mapp, id_t map_id); 621b115575SJohn Danielson 634c06356bSdh142964 644c06356bSdh142964 struct dam { 654c06356bSdh142964 char *dam_name; 661b115575SJohn Danielson int dam_flags; /* map state and cv flags */ 671b115575SJohn Danielson int dam_options; /* map options */ 684c06356bSdh142964 int dam_rptmode; /* report mode */ 69*60aabb4cSChris Horne clock_t dam_stable_ticks; /* stabilization */ 704c06356bSdh142964 uint_t dam_size; /* max index for addr hash */ 714c06356bSdh142964 id_t dam_high; /* highest index allocated */ 724c06356bSdh142964 timeout_id_t dam_tid; /* timeout(9F) ID */ 734c06356bSdh142964 744c06356bSdh142964 void *dam_activate_arg; /* activation private */ 754c06356bSdh142964 activate_cb_t dam_activate_cb; /* activation callback */ 764c06356bSdh142964 deactivate_cb_t dam_deactivate_cb; /* deactivation callback */ 774c06356bSdh142964 784c06356bSdh142964 void *dam_config_arg; /* config-private */ 794c06356bSdh142964 configure_cb_t dam_configure_cb; /* configure callout */ 804c06356bSdh142964 unconfig_cb_t dam_unconfig_cb; /* unconfigure callout */ 814c06356bSdh142964 824c06356bSdh142964 ddi_strid *dam_addr_hash; /* addresss to ID hash */ 834c06356bSdh142964 bitset_t dam_active_set; /* activated address set */ 844c06356bSdh142964 bitset_t dam_stable_set; /* stable address set */ 854c06356bSdh142964 bitset_t dam_report_set; /* reported address set */ 864c06356bSdh142964 void *dam_da; /* per-address soft state */ 874c06356bSdh142964 hrtime_t dam_last_update; /* last map update */ 884c06356bSdh142964 hrtime_t dam_last_stable; /* last map stable */ 894c06356bSdh142964 int dam_stable_cnt; /* # of times map stabilized */ 904c06356bSdh142964 int dam_stable_overrun; 91*60aabb4cSChris Horne kcondvar_t dam_sync_cv; 924c06356bSdh142964 kmutex_t dam_lock; 934c06356bSdh142964 kstat_t *dam_kstatsp; 94*60aabb4cSChris Horne int dam_sync_to_cnt; 954c06356bSdh142964 }; 964c06356bSdh142964 974c06356bSdh142964 #define DAM_SPEND 0x10 /* stable pending */ 984c06356bSdh142964 #define DAM_DESTROYPEND 0x20 /* in process of being destroyed */ 994c06356bSdh142964 #define DAM_SETADD 0x100 /* fullset update pending */ 1004c06356bSdh142964 1014c06356bSdh142964 /* 1024c06356bSdh142964 * per address softstate stucture 1034c06356bSdh142964 */ 1044c06356bSdh142964 typedef struct { 1054c06356bSdh142964 uint_t da_flags; /* flags */ 1061b115575SJohn Danielson int da_jitter; /* address re-report count */ 1074c06356bSdh142964 int da_ref; /* refcount on address */ 1084c06356bSdh142964 void *da_ppriv; /* stable provider private */ 1094c06356bSdh142964 void *da_cfg_priv; /* config/unconfig private */ 1104c06356bSdh142964 nvlist_t *da_nvl; /* stable nvlist */ 1114c06356bSdh142964 void *da_ppriv_rpt; /* reported provider-private */ 1124c06356bSdh142964 nvlist_t *da_nvl_rpt; /* reported nvlist */ 113*60aabb4cSChris Horne int64_t da_deadline; /* ddi_get_lbolt64 value when stable */ 1144c06356bSdh142964 hrtime_t da_last_report; /* timestamp of last report */ 1154c06356bSdh142964 int da_report_cnt; /* # of times address reported */ 1164c06356bSdh142964 hrtime_t da_last_stable; /* timestamp of last stable address */ 1174c06356bSdh142964 int da_stable_cnt; /* # of times address has stabilized */ 1184c06356bSdh142964 char *da_addr; /* string in dam_addr_hash (for mdb) */ 1194c06356bSdh142964 } dam_da_t; 1204c06356bSdh142964 1214c06356bSdh142964 /* 1224c06356bSdh142964 * dam_da_t.da_flags 1234c06356bSdh142964 */ 1244c06356bSdh142964 #define DA_INIT 0x1 /* address initizized */ 1251b115575SJohn Danielson #define DA_FAILED_CONFIG 0x2 /* address failed configure */ 1264c06356bSdh142964 #define DA_RELE 0x4 /* adddress released */ 1274c06356bSdh142964 1284c06356bSdh142964 1294c06356bSdh142964 /* 1304c06356bSdh142964 * report type 1314c06356bSdh142964 */ 1324c06356bSdh142964 #define RPT_ADDR_ADD 0 1334c06356bSdh142964 #define RPT_ADDR_DEL 1 1344c06356bSdh142964 1354c06356bSdh142964 #define DAM_IN_REPORT(m, i) (bitset_in_set(&(m)->dam_report_set, (i))) 1364c06356bSdh142964 #define DAM_IS_STABLE(m, i) (bitset_in_set(&(m)->dam_active_set, (i))) 1374c06356bSdh142964 1384c06356bSdh142964 /* 1394c06356bSdh142964 * DAM statistics 1404c06356bSdh142964 */ 1414c06356bSdh142964 struct dam_kstats { 1421b115575SJohn Danielson struct kstat_named dam_cycles; 1431b115575SJohn Danielson struct kstat_named dam_overrun; 1441b115575SJohn Danielson struct kstat_named dam_jitter; 1451b115575SJohn Danielson struct kstat_named dam_active; 1464c06356bSdh142964 }; 1474c06356bSdh142964 1484c06356bSdh142964 #ifdef __cplusplus 1494c06356bSdh142964 } 1504c06356bSdh142964 #endif 1514c06356bSdh142964 1524c06356bSdh142964 #endif /* _SYS_DAMAP_IMPL_H */ 153