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