sfxge_bar.c revision 49ef7e0638c8b771d8a136eae78b1c0f99acc8e0
1N/A/*
1N/A * Copyright (c) 2008-2016 Solarflare Communications Inc.
1N/A * All rights reserved.
1N/A *
1N/A * Redistribution and use in source and binary forms, with or without
1N/A * modification, are permitted provided that the following conditions are met:
1N/A *
1N/A * 1. Redistributions of source code must retain the above copyright notice,
1N/A * this list of conditions and the following disclaimer.
1N/A * 2. Redistributions in binary form must reproduce the above copyright notice,
1N/A * this list of conditions and the following disclaimer in the documentation
1N/A * and/or other materials provided with the distribution.
1N/A *
1N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1N/A * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1N/A * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1N/A * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1N/A * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
1N/A * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1N/A * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
1N/A * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1N/A * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1N/A *
1N/A * The views and conclusions contained in the software and documentation are
1N/A * those of the authors and should not be interpreted as representing official
1N/A * policies, either expressed or implied, of the FreeBSD Project.
1N/A */
1N/A
1N/A#include <sys/types.h>
1N/A#include <sys/ddi.h>
1N/A#include <sys/sunddi.h>
1N/A#include <sys/stream.h>
1N/A#include <sys/dlpi.h>
1N/A
1N/A#include "sfxge.h"
1N/A
1N/Aint
1N/Asfxge_bar_init(sfxge_t *sp)
1N/A{
1N/A efsys_bar_t *esbp = &(sp->s_bar);
1N/A ddi_device_acc_attr_t devacc;
1N/A int rc;
1N/A
1N/A devacc.devacc_attr_version = DDI_DEVICE_ATTR_V0;
1N/A devacc.devacc_attr_endian_flags = DDI_NEVERSWAP_ACC;
1N/A devacc.devacc_attr_dataorder = DDI_STRICTORDER_ACC;
1N/A
1N/A if (ddi_regs_map_setup(sp->s_dip, EFX_MEM_BAR, &(esbp->esb_base), 0, 0,
1N/A &devacc, &(esbp->esb_handle)) != DDI_SUCCESS) {
1N/A rc = ENODEV;
1N/A goto fail1;
1N/A }
1N/A
1N/A mutex_init(&(esbp->esb_lock), NULL, MUTEX_DRIVER, NULL);
1N/A
1N/A return (0);
1N/A
1N/Afail1:
1N/A DTRACE_PROBE1(fail1, int, rc);
1N/A
1N/A return (rc);
1N/A}
1N/A
1N/Avoid
1N/Asfxge_bar_fini(sfxge_t *sp)
1N/A{
1N/A efsys_bar_t *esbp = &(sp->s_bar);
1N/A
1N/A ddi_regs_map_free(&(esbp->esb_handle));
1N/A
1N/A mutex_destroy(&(esbp->esb_lock));
1N/A
1N/A esbp->esb_base = NULL;
1N/A esbp->esb_handle = NULL;
1N/A}
1N/A