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 /* 239aed1621SDavid Hollister * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 244c06356bSdh142964 * Use is subject to license terms. 254c06356bSdh142964 */ 264c06356bSdh142964 274c06356bSdh142964 #ifndef _SYS_DAMAP_H 284c06356bSdh142964 #define _SYS_DAMAP_H 294c06356bSdh142964 304c06356bSdh142964 #ifdef __cplusplus 314c06356bSdh142964 extern "C" { 324c06356bSdh142964 #endif 334c06356bSdh142964 344c06356bSdh142964 /* 354c06356bSdh142964 * Delta (device) Address Map Interfaces 364c06356bSdh142964 * 374c06356bSdh142964 * These interfaces provide time-stablized sets of 'addresses', 384c06356bSdh142964 * where addresses are string representations of device 394c06356bSdh142964 * or bus-specific address. The mechanisms include interfaces to 404c06356bSdh142964 * report and remove address from a map, time stabilization, callouts 414c06356bSdh142964 * to higher-level configuration and unconfiguration actions, and 424c06356bSdh142964 * address lookup functions. 434c06356bSdh142964 * 444c06356bSdh142964 * Per Address Reports 454c06356bSdh142964 * With per-address reporting, the caller reports the addition and removal 464c06356bSdh142964 * each address visible to it. Each report is independently time stabilized; 474c06356bSdh142964 * Once a report has stabilized, the reported address is either 484c06356bSdh142964 * activated & configured, or unconfigured & released. 494c06356bSdh142964 * 504c06356bSdh142964 * Full Set Reports 514c06356bSdh142964 * When using fullset reporting, the report provider enumerates the entire 524c06356bSdh142964 * set of addresses visible to the provider at a given point in time. 534c06356bSdh142964 * The entire set is then stabilized. 544c06356bSdh142964 * Upon stabilizing, any newly reported addresses are activated & configured 554c06356bSdh142964 * and any previously active addresses which are no longer visible are 564c06356bSdh142964 * automatically unconfigured and released, freeing the provider from 574c06356bSdh142964 * the need to explicitly unconfigure addresses no longer present. 584c06356bSdh142964 * 594c06356bSdh142964 * Stabilization 604c06356bSdh142964 * Once an address has been reported (or reported as removed), the report 614c06356bSdh142964 * is time stabilized before the framework initiates a configuration 624c06356bSdh142964 * or unconfiguration action. If the address is re-reported while undergoing 634c06356bSdh142964 * stabilization, the timer is reset for either the address or the full 644c06356bSdh142964 * set of addresses reported to the map. 654c06356bSdh142964 * 664c06356bSdh142964 * Activation/Release 674c06356bSdh142964 * Once a reported address has passed its stabilization, the address is 684c06356bSdh142964 * 'activated' by the framework. Once activated, the address is passed 694c06356bSdh142964 * to a configuration callout to perform whatever actions are necessary. 704c06356bSdh142964 * If a reported address is deleted or fails to stabilize, the address 714c06356bSdh142964 * is released by the map. 724c06356bSdh142964 * A report provider may register callback functions to be invoked 734c06356bSdh142964 * as part of the address activation & release process. In addition to 744c06356bSdh142964 * the callbacks, a provider can also supply a handle to provider-private 754c06356bSdh142964 * data at the time an address is reported. This handle is returned to 764c06356bSdh142964 * provider as an argument to the activation & release callbacks. 774c06356bSdh142964 * 784c06356bSdh142964 * Lookup/Access 794c06356bSdh142964 * The set of stable addresses contained in a map can be obtained by 804c06356bSdh142964 * calling interfaces to lookup either a single address or the full 814c06356bSdh142964 * list of stable addresses. 824c06356bSdh142964 */ 834c06356bSdh142964 844c06356bSdh142964 /* 854c06356bSdh142964 * damap_t: Handle to a delta address map 864c06356bSdh142964 * damap_id_t: Handle to an entry of damap_t 874c06356bSdh142964 */ 884c06356bSdh142964 typedef struct __damap_dm *damap_t; 894c06356bSdh142964 typedef id_t damap_id_t; 904c06356bSdh142964 911b115575SJohn Danielson /* 921b115575SJohn Danielson * damap_id_list_t: List of damap_id_handles 931b115575SJohn Danielson * NB. Not Used 941b115575SJohn Danielson */ 951b115575SJohn Danielson typedef struct __damap_id_list *damap_id_list_t; 961b115575SJohn Danielson 974c06356bSdh142964 #define NODAM (damap_id_t)0 984c06356bSdh142964 994c06356bSdh142964 /* 1004c06356bSdh142964 * activate_cb: Provider callback when reported address is activated 1014c06356bSdh142964 * deactivate_cb: Provider callback when address has been released 1024c06356bSdh142964 * 1034c06356bSdh142964 * configure_cb: Class callout to configure newly activated addresses 1044c06356bSdh142964 * unconfig_cb: Class callout to unconfigure deactivated addresses 1054c06356bSdh142964 */ 106d189c170SReed typedef enum { 107d189c170SReed DAMAP_DEACT_RSN_GONE = 0, 1089aed1621SDavid Hollister DAMAP_DEACT_RSN_CFG_FAIL, 1099aed1621SDavid Hollister DAMAP_DEACT_RSN_UNSTBL 110d189c170SReed } damap_deact_rsn_t; 111d189c170SReed 1124c06356bSdh142964 typedef void (*damap_activate_cb_t)(void *, char *, int, void **); 113d189c170SReed typedef void (*damap_deactivate_cb_t)(void *, char *, int, void *, 114d189c170SReed damap_deact_rsn_t); 1154c06356bSdh142964 1161b115575SJohn Danielson typedef int (*damap_configure_cb_t)(void *, damap_t *, damap_id_t); 1171b115575SJohn Danielson typedef int (*damap_unconfig_cb_t)(void *, damap_t *, damap_id_t); 1184c06356bSdh142964 1194c06356bSdh142964 /* 1204c06356bSdh142964 * Map reporting mode 1214c06356bSdh142964 */ 1224c06356bSdh142964 typedef enum {DAMAP_REPORT_PERADDR, DAMAP_REPORT_FULLSET} damap_rptmode_t; 1234c06356bSdh142964 1241b115575SJohn Danielson /* 1251b115575SJohn Danielson * Map create options flags 1261b115575SJohn Danielson * DAMAP_SERIALCONFIG - serialize activate/deactivate operations 1271b115575SJohn Danielson * DAMAP_MTCONFIG - multithread config/unconfg operations 1281b115575SJohn Danielson */ 1291b115575SJohn Danielson #define DAMAP_SERIALCONFIG 0 1301b115575SJohn Danielson #define DAMAP_MTCONFIG 1 1314c06356bSdh142964 1321b115575SJohn Danielson int damap_create(char *, damap_rptmode_t, int, clock_t, 1334c06356bSdh142964 void *, damap_activate_cb_t, damap_deactivate_cb_t, 1344c06356bSdh142964 void *, damap_configure_cb_t, damap_unconfig_cb_t, 1354c06356bSdh142964 damap_t **); 1364c06356bSdh142964 void damap_destroy(damap_t *); 1374c06356bSdh142964 1384c06356bSdh142964 char *damap_name(damap_t *); 1394c06356bSdh142964 int damap_sync(damap_t *); 1404c06356bSdh142964 1414c06356bSdh142964 int damap_addr_add(damap_t *, char *, damap_id_t *, nvlist_t *, void *); 1424c06356bSdh142964 int damap_addr_del(damap_t *, char *); 1434c06356bSdh142964 int damap_addrid_del(damap_t *, int); 1444c06356bSdh142964 1451b115575SJohn Danielson /* 1461b115575SJohn Danielson * modifiers to damap_addrset_end() 1471b115575SJohn Danielson */ 1481b115575SJohn Danielson #define DAMAP_END_RESET 1 1491b115575SJohn Danielson #define DAMAP_END_ABORT 2 1501b115575SJohn Danielson 1514c06356bSdh142964 int damap_addrset_begin(damap_t *); 1521b115575SJohn Danielson int damap_addrset_add(damap_t *, char *, damap_id_t *, 1531b115575SJohn Danielson nvlist_t *, void *); 1544c06356bSdh142964 int damap_addrset_end(damap_t *, int); 155*0b53804eSReed int damap_addrset_flush(damap_t *); 1564c06356bSdh142964 int damap_addrset_reset(damap_t *, int); 1574c06356bSdh142964 damap_id_t damap_id_next(damap_t *, damap_id_list_t, damap_id_t); 1584c06356bSdh142964 char *damap_id2addr(damap_t *, damap_id_t); 1594c06356bSdh142964 nvlist_t *damap_id2nvlist(damap_t *, damap_id_t); 1604c06356bSdh142964 int damap_id_hold(damap_t *, damap_id_t); 1614c06356bSdh142964 void damap_id_rele(damap_t *, damap_id_t); 1624c06356bSdh142964 int damap_id_ref(damap_t *, damap_id_t); 1634c06356bSdh142964 void damap_id_list_rele(damap_t *, damap_id_list_t); 1644c06356bSdh142964 void *damap_id_priv_get(damap_t *, damap_id_t); 1654c06356bSdh142964 void damap_id_priv_set(damap_t *, damap_id_t, void *); 1664c06356bSdh142964 damap_id_t damap_lookup(damap_t *, char *); 1674c06356bSdh142964 int damap_lookup_all(damap_t *, damap_id_list_t *); 1684c06356bSdh142964 1694c06356bSdh142964 #define DAM_SUCCESS 0 1704c06356bSdh142964 #define DAM_EEXIST 1 1714c06356bSdh142964 #define DAM_MAPFULL 2 1724c06356bSdh142964 #define DAM_EINVAL 3 1734c06356bSdh142964 #define DAM_FAILURE 4 1744c06356bSdh142964 #define DAM_SHAME 5 1754c06356bSdh142964 1764c06356bSdh142964 #ifdef __cplusplus 1774c06356bSdh142964 } 1784c06356bSdh142964 #endif 1794c06356bSdh142964 1804c06356bSdh142964 #endif /* _SYS_DAMAP_H */ 181