/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _SYS_BLKDEV_H
#define _SYS_BLKDEV_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* This describes a fairly simple block device. The idea here is that
* these things want to take advantage of the common labelling support,
* but do not need all the capabilities of SCSA. So we make quite a few
* simplifications:
*
* 1) Device block size is a power of 2 greater or equal to 512 bytes.
* An optional physical block size can be reported if the underlying
* device uses larger block sizes internally, so that writes can be
* aligned properly.
*
* 2) Non-rotating media. We assume a simple linear layout.
*
* 3) Fixed queue depth, for each device. The adapter driver reports
* the queue depth at registration. We don't have any form of
* dynamic flow control.
*
* 4) Negligible power management support. The framework does not support
* fine grained power management. If the adapter driver wants to use
* such, it will need to manage power on its own.
*
* need to manage this on its own behalf.
*
* 6) No request priorities. Transfers are assumed to execute in
* roughly FIFO order. The adapter driver may reorder them, but the
* submitter has no control over that.
*
* 7) No request cancellation. Once submitted, the job completes or
* fails. It cannot be canceled.
*
* 8) Limited support for removable media. There is no support for
* locking bay doors or mechanised media bays. This could be
* added, but at present the only such interesting devices are
* covered by the SCSI disk driver.
*/
struct bd_xfer {
/*
* NB: If using DMA the br_ndmac will be non-zero. Otherwise
* the br_kaddr will be non-NULL.
*/
unsigned x_ndmac;
unsigned x_flags;
};
struct bd_drive {
int d_target;
int d_lun;
char *d_vendor;
char *d_product;
char *d_model;
char *d_serial;
char *d_revision;
};
struct bd_media {
/*
* NB: The block size must be a power of two not less than
* DEV_BSIZE (512). Other values of the block size will
* simply not function and the media will be rejected.
*
* The block size must also divide evenly into the device's
* d_maxxfer field. If the maxxfer is a power of two larger
* than the block size, then this will automatically be
* satisfied.
*
* The physical block size (m_pblksize) must be 0 or a power
* of two not less than the block size.
*/
};
struct bd_ops {
int o_version;
};
#define BD_OPS_VERSION_0 0
struct bd_errstats {
/* these are managed by blkdev itself */
/* the following are updated on behalf of the HW driver */
};
#define BD_ERR_MEDIA 0
/*
* Note, one handler *per* address. Drivers with multiple targets at
* different addresses must use separate handles.
*/
void bd_free_handle(bd_handle_t);
int bd_detach_handle(bd_handle_t);
void bd_state_change(bd_handle_t);
void bd_xfer_done(bd_xfer_t *, int);
void bd_mod_init(struct dev_ops *);
void bd_mod_fini(struct dev_ops *);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_BLKDEV_H */