1219974Smav#-
2219974Smav# Copyright (c) 2010 Alexander Motin
3219974Smav# All rights reserved.
4219974Smav#
5219974Smav# Redistribution and use in source and binary forms, with or without
6219974Smav# modification, are permitted provided that the following conditions
7219974Smav# are met:
8219974Smav#
9219974Smav# 1. Redistributions of source code must retain the above copyright
10219974Smav#    notice, this list of conditions and the following disclaimer.
11219974Smav# 2. Redistributions in binary form must reproduce the above copyright
12219974Smav#    notice, this list of conditions and the following disclaimer in the
13219974Smav#    documentation and/or other materials provided with the distribution.
14219974Smav#
15219974Smav# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16219974Smav# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17219974Smav# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18219974Smav# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19219974Smav# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20219974Smav# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21219974Smav# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22219974Smav# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23219974Smav# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24219974Smav# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25219974Smav#
26219974Smav# $FreeBSD: releng/11.0/sys/geom/raid/g_raid_tr_if.m 219974 2011-03-24 21:31:32Z mav $
27219974Smav
28219974Smav#include <sys/param.h>
29219974Smav#include <sys/lock.h>
30219974Smav#include <sys/malloc.h>
31219974Smav#include <sys/mutex.h>
32219974Smav#include <sys/sbuf.h>
33219974Smav#include <sys/bus.h>
34219974Smav#include <machine/bus.h>
35219974Smav#include <sys/systm.h>
36219974Smav#include <geom/geom.h>
37219974Smav#include <geom/raid/g_raid.h>
38219974Smav
39219974Smav# The G_RAID transformation class interface.
40219974Smav
41219974SmavINTERFACE g_raid_tr;
42219974Smav
43219974Smav# Default implementations of methods.
44219974SmavCODE {
45219974Smav	static int
46219974Smav	g_raid_tr_locked_default(struct g_raid_tr_object *tr, void *argp)
47219974Smav	{
48219974Smav
49219974Smav		return (0);
50219974Smav	}
51219974Smav};
52219974Smav
53219974SmavHEADER {
54219974Smav#define G_RAID_TR_TASTE_FAIL		-1
55219974Smav#define G_RAID_TR_TASTE_SUCCEED		 0
56219974Smav};
57219974Smav
58219974Smav# taste() - volume taste method.
59219974SmavMETHOD int taste {
60219974Smav	struct g_raid_tr_object *tr;
61219974Smav	struct g_raid_volume *volume;
62219974Smav};
63219974Smav
64219974Smav# event() - events handling method.
65219974SmavMETHOD int event {
66219974Smav	struct g_raid_tr_object *tr;
67219974Smav	struct g_raid_subdisk *sd;
68219974Smav	u_int event;
69219974Smav};
70219974Smav
71219974Smav# start() - begin operation.
72219974SmavMETHOD int start {
73219974Smav	struct g_raid_tr_object *tr;
74219974Smav};
75219974Smav
76219974Smav# stop() - stop operation.
77219974SmavMETHOD int stop {
78219974Smav	struct g_raid_tr_object *tr;
79219974Smav};
80219974Smav
81219974Smav# iorequest() - manage forward transformation and generates requests to disks.
82219974SmavMETHOD void iostart {
83219974Smav	struct g_raid_tr_object *tr;
84219974Smav	struct bio *bp;
85219974Smav};
86219974Smav
87219974Smav# iodone() - manages backward transformation and reports completion status.
88219974SmavMETHOD void iodone {
89219974Smav	struct g_raid_tr_object *tr;
90219974Smav	struct g_raid_subdisk *sd;
91219974Smav	struct bio *bp;
92219974Smav};
93219974Smav
94219974Smav# kerneldump() - optimized for rebustness (simplified) kernel dumping routine.
95219974SmavMETHOD int kerneldump {
96219974Smav	struct g_raid_tr_object *tr;
97219974Smav	void *virtual;
98219974Smav	vm_offset_t physical;
99219974Smav	off_t offset;
100219974Smav	size_t length;
101219974Smav} DEFAULT g_raid_tr_kerneldump_common;
102219974Smav
103219974Smav# locked() - callback method for lock().
104219974SmavMETHOD int locked {
105219974Smav	struct g_raid_tr_object *tr;
106219974Smav	void *argp;
107219974Smav} DEFAULT g_raid_tr_locked_default;
108219974Smav
109219974Smav# free() - destructor.
110219974SmavMETHOD int free {
111219974Smav	struct g_raid_tr_object *tr;
112219974Smav};
113219974Smav
114219974Smav# idle() - callback when the volume is idle for a while and the TR wants
115219974Smav# to schedule some work for that idle period.
116219974SmavMETHOD int idle {
117219974Smav	struct g_raid_tr_object *tr;
118219974Smav};
119