1/*	$NetBSD: rf_dagutils.h,v 1.22 2021/07/23 00:54:45 oster Exp $	*/
2/*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
5 *
6 * Author: Mark Holland, William V. Courtright II
7 *
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
21 *  School of Computer Science
22 *  Carnegie Mellon University
23 *  Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 */
28
29/*************************************************************************
30 *
31 * rf_dagutils.h -- header file for utility routines for manipulating DAGs
32 *
33 *************************************************************************/
34
35
36#include <dev/raidframe/raidframevar.h>
37
38#include "rf_dagfuncs.h"
39#include "rf_general.h"
40
41#ifndef _RF__RF_DAGUTILS_H_
42#define _RF__RF_DAGUTILS_H_
43
44struct RF_RedFuncs_s {
45	void     (*regular) (RF_DagNode_t *);
46	const char   *RegularName;
47	void     (*simple) (RF_DagNode_t *);
48	const char   *SimpleName;
49};
50
51typedef struct RF_FuncList_s {
52	RF_VoidFuncPtr fp;
53   	struct RF_FuncList_s *next;
54} RF_FuncList_t;
55
56extern const RF_RedFuncs_t rf_xorFuncs;
57extern const RF_RedFuncs_t rf_xorRecoveryFuncs;
58
59void rf_InitNode(RF_DagNode_t *, RF_NodeStatus_t, int,
60		 void (*) (RF_DagNode_t *),
61		 void (*) (RF_DagNode_t *),
62		 void (*) (void *, int),
63		 int, int, int, int, RF_DagHeader_t *,
64		 const char *, RF_AllocListElem_t *);
65
66void rf_FreeDAG(RF_DagHeader_t *);
67int rf_ConfigureDAGs(RF_ShutdownList_t **, RF_Raid_t *, RF_Config_t *);
68
69RF_DagHeader_t *rf_AllocDAGHeader(RF_Raid_t *);
70void    rf_FreeDAGHeader(RF_Raid_t *raidPtr, RF_DagHeader_t * dh);
71
72RF_DagNode_t *rf_AllocDAGNode(RF_Raid_t *);
73void rf_FreeDAGNode(RF_Raid_t *, RF_DagNode_t *);
74
75RF_DagList_t *rf_AllocDAGList(RF_Raid_t *);
76void rf_FreeDAGList(RF_Raid_t *, RF_DagList_t *);
77
78void *rf_AllocDAGPCache(RF_Raid_t *);
79void rf_FreeDAGPCache(RF_Raid_t *, void *);
80
81RF_FuncList_t *rf_AllocFuncList(RF_Raid_t *);
82void rf_FreeFuncList(RF_Raid_t *, RF_FuncList_t *);
83
84void *rf_AllocBuffer(RF_Raid_t *, RF_DagHeader_t *, int);
85void *rf_AllocIOBuffer(RF_Raid_t *, int);
86void rf_FreeIOBuffer(RF_Raid_t *, RF_VoidPointerListElem_t *);
87void *rf_AllocStripeBuffer(RF_Raid_t *, RF_DagHeader_t *, int);
88void rf_FreeStripeBuffer(RF_Raid_t *, RF_VoidPointerListElem_t *);
89
90char *rf_NodeStatusString(RF_DagNode_t *);
91void rf_PrintNodeInfoString(RF_DagNode_t *);
92int rf_AssignNodeNums(RF_DagHeader_t *);
93int rf_RecurAssignNodeNums(RF_DagNode_t *, int, int);
94void rf_ResetDAGHeaderPointers(RF_DagHeader_t *, RF_DagHeader_t *);
95void rf_RecurResetDAGHeaderPointers(RF_DagNode_t *, RF_DagHeader_t *);
96void rf_PrintDAGList(RF_DagHeader_t *);
97int rf_ValidateDAG(RF_DagHeader_t *);
98void rf_redirect_asm(RF_Raid_t *, RF_AccessStripeMap_t *);
99void rf_MapUnaccessedPortionOfStripe(RF_Raid_t *, RF_RaidLayout_t *,
100				     RF_AccessStripeMap_t *, RF_DagHeader_t *,
101				     RF_AccessStripeMapHeader_t **, int *,
102				     char **, char **, RF_AllocListElem_t *);
103int rf_PDAOverlap(RF_RaidLayout_t *, RF_PhysDiskAddr_t *, RF_PhysDiskAddr_t *);
104void rf_GenerateFailedAccessASMs(RF_Raid_t *, RF_AccessStripeMap_t *,
105				 RF_PhysDiskAddr_t *, RF_DagHeader_t *,
106				 RF_AccessStripeMapHeader_t **,
107				 int *, char **, char *, RF_AllocListElem_t *);
108
109/* flags used by RangeRestrictPDA */
110#define RF_RESTRICT_NOBUFFER 0
111#define RF_RESTRICT_DOBUFFER 1
112
113void rf_RangeRestrictPDA(RF_Raid_t *, RF_PhysDiskAddr_t *,
114			 RF_PhysDiskAddr_t *, int, int);
115
116int rf_compute_workload_shift(RF_Raid_t *, RF_PhysDiskAddr_t *);
117void rf_SelectMirrorDiskIdle(RF_DagNode_t *);
118void rf_SelectMirrorDiskPartition(RF_DagNode_t *);
119
120#endif				/* !_RF__RF_DAGUTILS_H_ */
121