4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * CDDL HEADER START
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * The contents of this file are subject to the terms of the
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * Common Development and Distribution License (the "License").
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * You may not use this file except in compliance with the License.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * or http://www.opensolaris.org/os/licensing.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * See the License for the specific language governing permissions
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * and limitations under the License.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * When distributing Covered Code, include this CDDL HEADER in each
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * If applicable, add the following below this CDDL HEADER, with the
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * fields enclosed by brackets "[]" replaced with your own identifying
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * information: Portions Copyright [yyyy] [name of copyright owner]
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * CDDL HEADER END
3abb112f8485b33b6b9b52b340bede0a333c10bfGarrett D'Amore/* Copyright © 2003-2011 Emulex. All rights reserved. */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * Source file containing the implementation of fma support in driver
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanstatic int oce_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err,
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * function to initialize driver fma support
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * dev - software handle to the device
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan if (dev->fm_caps == DDI_FM_NOT_CAPABLE) {
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (void) ddi_fm_init(dev->dip, &dev->fm_caps, &ibc);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan ddi_fm_handler_register(dev->dip, oce_fm_error_cb,
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan} /* oce_fm_init */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * function to deinitialize driver fma support
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * dev - software handle to the device
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan if (dev->fm_caps == DDI_FM_NOT_CAPABLE) {
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan} /* oce_fm_fini */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * function to check the access handle
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * dev - software handle to the device
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * acc_handle - access handle
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * return fm error status
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanoce_fm_check_acc_handle(struct oce_dev *dev, ddi_acc_handle_t acc_handle)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan if (!DDI_FM_ACC_ERR_CAP(dev->fm_caps)) {
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (void) ddi_fm_acc_err_get(acc_handle, &fme, DDI_FME_VERSION);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (void) ddi_fm_acc_err_clear(acc_handle, DDI_FME_VERSION);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan} /* oce_fm_chk_ach */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * function to check error updates associated with a dma handle
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * dev - software handle to the device
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * dma_handle - dma handle to the resources on which to check for errors
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * return error code. DDI_FM_OK => no error
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanoce_fm_check_dma_handle(struct oce_dev *dev, ddi_dma_handle_t dma_handle)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan if (!DDI_FM_DMA_ERR_CAP(dev->fm_caps)) {
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (void) ddi_fm_dma_err_get(dma_handle, &fme, DDI_FME_VERSION);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan} /* oce_fm_chk_dh */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * function to report an error to the FMA framework
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * dev - software handle to the device
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * detail - OS defined string that provides the kind of error to report
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanoce_fm_ereport(struct oce_dev *dev, char *detail)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan if (!DDI_FM_EREPORT_CAP(dev->fm_caps) || detail == NULL) {
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan (void) snprintf(buf, FM_MAX_CLASS, "%s.%s", DDI_FM_DEVICE, detail);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan ddi_fm_ereport_post(dev->dip, buf, ena, DDI_NOSLEEP,
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan FM_VERSION, DATA_TYPE_UINT8, FM_EREPORT_VERS0, NULL);
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan} /* oce_fm_ereport */
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * callback function registered with the FMA infrastructure. This callback is
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * called by the nexux driver if there is an error with the device
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * dip - dev_info_t structure for this device
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * err - error information provided by the nexus
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * impl_data - callback data
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan * return error code. DDI_FM_OK => no error
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathanoce_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err, const void *impl_data)
4d0e50075058332ce0cd62bc2669a8a4dea45da0Sukumar Swaminathan /* Driver must handle the dma/access error */