fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard/* Copyright 2010 QLogic Corporation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
db5b5f1e7e8c59712dae4a0b5c55ecee0e4c1bfcGarrett D'Amore/*
db5b5f1e7e8c59712dae4a0b5c55ecee0e4c1bfcGarrett D'Amore * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
db5b5f1e7e8c59712dae4a0b5c55ecee0e4c1bfcGarrett D'Amore */
db5b5f1e7e8c59712dae4a0b5c55ecee0e4c1bfcGarrett D'Amore
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard#pragma ident "Copyright 2010 QLogic Corporation; ql_xioctl.c"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ***********************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * * **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * * NOTICE **
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard * * COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * * ALL RIGHTS RESERVED **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * * **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ***********************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_apps.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_api.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_debug.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_init.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_iocb.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_ioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_mbx.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_xioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Local data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Local prototypes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_sdm_ioctl(ql_adapter_state_t *, int, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_sdm_setup(ql_adapter_state_t *, EXT_IOCTL **, void *, int,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t (*)(EXT_IOCTL *));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t ql_validate_signature(EXT_IOCTL *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_sdm_return(ql_adapter_state_t *, EXT_IOCTL *, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_query(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_hba_node(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_hba_port(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_disc_port(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_disc_tgt(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_fw(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_chip(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_driver(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_fcct(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_aen_reg(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_aen_get(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_scsi_passthru(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_wwpn_to_scsiaddr(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_host_idx(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_host_drvname(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_read_nvram(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_write_nvram(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_read_flash(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_write_flash(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_write_vpd(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_read_vpd(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_diagnostic_loopback(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_send_els_rnid(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_set_host_data(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_host_data(ql_adapter_state_t *, EXT_IOCTL *, int);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregardstatic void ql_qry_cna_port(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_lun_count(ql_adapter_state_t *, ql_tgt_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_report_lun(ql_adapter_state_t *, ql_tgt_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_inq_scan(ql_adapter_state_t *, ql_tgt_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_inq(ql_adapter_state_t *, ql_tgt_t *, int, ql_mbx_iocb_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t ql_get_buffer_data(caddr_t, caddr_t, uint32_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t ql_send_buffer_data(caddr_t, caddr_t, uint32_t, int);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic int ql_24xx_flash_desc(ql_adapter_state_t *);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic int ql_setup_flash(ql_adapter_state_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ql_tgt_t *ql_find_port(ql_adapter_state_t *, uint8_t *, uint16_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_flash_fcode_load(ql_adapter_state_t *, void *, uint32_t, int);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic int ql_flash_fcode_dump(ql_adapter_state_t *, void *, uint32_t,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard uint32_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_program_flash_address(ql_adapter_state_t *, uint32_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_set_rnid_parameters(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_rnid_parameters(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_reset_statistics(ql_adapter_state_t *, EXT_IOCTL *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_statistics(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_statistics_fc(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_statistics_fc4(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_set_led_state(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_led_state(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_drive_led(ql_adapter_state_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t ql_setup_led(ql_adapter_state_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t ql_wrapup_led(ql_adapter_state_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_port_summary(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_target_id(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_sfp(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_dump_sfp(ql_adapter_state_t *, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ql_fcache_t *ql_setup_fnode(ql_adapter_state_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_fcache(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_fcache_ex(ql_adapter_state_t *, EXT_IOCTL *, int);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardvoid ql_update_fcache(ql_adapter_state_t *, uint8_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_check_pci(ql_adapter_state_t *, ql_fcache_t *, uint32_t *);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void ql_flash_layout_table(ql_adapter_state_t *, uint32_t);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void ql_process_flt(ql_adapter_state_t *, uint32_t);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void ql_flash_nvram_defaults(ql_adapter_state_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_port_param(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_check_pci(ql_adapter_state_t *, ql_fcache_t *, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_pci_data(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_fwfcetrace(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_fwexttrace(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_menlo_reset(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_menlo_get_fw_version(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_menlo_update_fw(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_menlo_manage_info(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ql_suspend_hba(ql_adapter_state_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_restart_hba(ql_adapter_state_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_get_vp_cnt_id(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_vp_ioctl(ql_adapter_state_t *, EXT_IOCTL *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_qry_vport(ql_adapter_state_t *, EXT_IOCTL *, int);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void ql_access_flash(ql_adapter_state_t *, EXT_IOCTL *, int);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void ql_reset_cmd(ql_adapter_state_t *, EXT_IOCTL *);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void ql_update_flash_caches(ql_adapter_state_t *);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregardstatic void ql_get_dcbx_parameters(ql_adapter_state_t *, EXT_IOCTL *, int);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregardstatic void ql_get_xgmac_statistics(ql_adapter_state_t *, EXT_IOCTL *, int);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void ql_get_fcf_list(ql_adapter_state_t *, EXT_IOCTL *, int);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void ql_get_resource_counts(ql_adapter_state_t *, EXT_IOCTL *, int);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void ql_qry_adapter_versions(ql_adapter_state_t *, EXT_IOCTL *, int);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregardstatic int ql_set_loop_point(ql_adapter_state_t *, uint16_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ******************************************************************** */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* External IOCTL support. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ******************************************************************** */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_alloc_xioctl_resource
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocates resources needed by module code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SYS_ERRNO
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_alloc_xioctl_resource(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->xioctl != NULL) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): already allocated done\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp = kmem_zalloc(sizeof (ql_xioctl_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->xioctl = xp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate AEN tracking buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_tracking_queue = kmem_zalloc(EXT_DEF_MAX_AEN_QUEUE *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_ASYNC_EVENT), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->aen_tracking_queue == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc-2\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_xioctl_resource(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_free_xioctl_resource
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Frees resources used by module code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_free_xioctl_resource(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): already freed\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->aen_tracking_queue != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(xp->aen_tracking_queue, EXT_DEF_MAX_AEN_QUEUE *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_ASYNC_EVENT));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_tracking_queue = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(xp, sizeof (ql_xioctl_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->xioctl = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_xioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * External IOCTL processing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: function to perform
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: data type varies with request
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cred_p: credentials pointer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rval_p: pointer to result value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ENXIO: No such device or address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ENOPROTOOPT: Protocol not available
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_xioctl(ql_adapter_state_t *ha, int cmd, intptr_t arg, int mode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cred_t *cred_p, int *rval_p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started, cmd=%d\n", ha->instance, cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->xioctl == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): no context\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENXIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_QUERY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SEND_FCCT_PASSTHRU:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_REG_AEN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_AEN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SEND_SCSI_PASSTHRU:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_WWPN_TO_SCSIADDR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SEND_ELS_RNID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SET_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_HOST_IDX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_READ_NVRAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_UPDATE_NVRAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_READ_OPTION_ROM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_READ_OPTION_ROM_EX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_UPDATE_OPTION_ROM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_UPDATE_OPTION_ROM_EX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_VPD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SET_VPD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_LOOPBACK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FCACHE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FCACHE_EX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_HOST_DRVNAME:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_SFP_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_PORT_PARAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_PCI_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FWEXTTRACE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FWFCETRACE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_VP_CNT_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_VPORT_CMD:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_CC_ACCESS_FLASH:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_CC_RESET_FW:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard case EXT_CC_MENLO_MANAGE_INFO:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_sdm_ioctl(ha, cmd, (void *)arg, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* function not supported. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "function=%d not supported\n", cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ENOPROTOOPT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_sdm_ioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Provides ioctl functions for SAN/Device Management functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * AKA External Ioctl functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ioctl_code: ioctl function to perform
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: Pointer to EXT_IOCTL cmd data in application land.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ENOMEM: Alloc of local EXT_IOCTL struct failed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EFAULT: Copyin of caller's EXT_IOCTL struct failed or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copyout of EXT_IOCTL status info failed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EINVAL: Signature or version of caller's EXT_IOCTL invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EBUSY: Device busy
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_sdm_ioctl(ql_adapter_state_t *ha, int ioctl_code, void *arg, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_IOCTL *cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *vha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy argument structure (EXT_IOCTL) from application land. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = ql_sdm_setup(ha, &cmd, arg, mode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_validate_signature)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a non-zero value at this time means a problem getting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the requested information from application land, just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return the error code and hope for the best.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, sdm_setup\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Map the physical ha ptr (which the ioctl is called with)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the virtual ha that the caller is addressing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->flags & VP_ENABLED) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Check that it is within range. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (cmd->HbaSelect > (CFG_IST(ha, CFG_CTRL_2422) ?
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard MAX_24_VIRTUAL_PORTS : MAX_25_VIRTUAL_PORTS)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "Invalid HbaSelect vp index: %xh\n",
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->HbaSelect);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_INVALID_VPINDEX;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard return (EFAULT);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Special case: HbaSelect == 0 is physical ha
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->HbaSelect != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vha = ha->vp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (vha != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vha->vp_index == cmd->HbaSelect) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha = vha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vha = vha->vp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * The specified vp index may be valid(within range)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * but it's not in the list. Currently this is all
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * we can say.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vha == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_VPINDEX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * If driver is suspended, stalled, or powered down rtn BUSY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->flags & ADAPTER_SUSPENDED ||
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard ha->task_daemon_flags & DRIVER_STALL ||
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard ha->power_level != PM_LEVEL_D0) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, " %s\n", ha->flags & ADAPTER_SUSPENDED ?
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard "driver suspended" :
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (ha->task_daemon_flags & DRIVER_STALL ? "driver stalled" :
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard "FCA powered down"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EBUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return results to caller */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ql_sdm_return(ha, cmd, arg, mode)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, sdm_return\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (ioctl_code) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_QUERY_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_query(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SEND_FCCT_PASSTHRU_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcct(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_REG_AEN_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_aen_reg(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_AEN_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_aen_get(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_DATA_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_host_data(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SET_DATA_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_set_host_data(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SEND_ELS_RNID_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_send_els_rnid(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SCSI_PASSTHRU_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_scsi_passthru(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_WWPN_TO_SCSIADDR_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_wwpn_to_scsiaddr(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_HOST_IDX_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_host_idx(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_HOST_DRVNAME_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_host_drvname(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_READ_NVRAM_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_read_nvram(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_UPDATE_NVRAM_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_nvram(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_READ_OPTION_ROM_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_READ_OPTION_ROM_EX_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_read_flash(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_UPDATE_OPTION_ROM_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_UPDATE_OPTION_ROM_EX_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_LOOPBACK_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_diagnostic_loopback(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_VPD_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_read_vpd(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_SET_VPD_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_vpd(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FCACHE_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_fcache(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FCACHE_EX_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_fcache_ex(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_SFP_DATA_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_sfp(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_PORT_PARAM_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_port_param(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_PCI_DATA_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_pci_data(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FWEXTTRACE_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_fwexttrace(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_FWFCETRACE_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_fwfcetrace(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_MENLO_RESET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_menlo_reset(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_MENLO_GET_FW_VERSION:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_menlo_get_fw_version(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_MENLO_UPDATE_FW:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_menlo_update_fw(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_MENLO_MANAGE_INFO:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_menlo_manage_info(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_GET_VP_CNT_ID_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_vp_cnt_id(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_CC_VPORT_CMD_OS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_vp_ioctl(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_CC_ACCESS_FLASH_OS:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_access_flash(ha, cmd, mode);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_CC_RESET_FW_OS:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_reset_cmd(ha, cmd);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* function not supported. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, function not supported=%d\n", ioctl_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return results to caller */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_sdm_return(ha, cmd, arg, mode) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, sdm_return\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_sdm_setup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make a local copy of the EXT_IOCTL struct and validate it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd_struct: Pointer to location to store local adrs of EXT_IOCTL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: Address of application EXT_IOCTL cmd data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * val_sig: Pointer to a function to validate the ioctl signature.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EFAULT: Copy in error of application EXT_IOCTL struct.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EINVAL: Invalid version, signature.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ENOMEM: Local allocation of EXT_IOCTL failed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_sdm_setup(ql_adapter_state_t *ha, EXT_IOCTL **cmd_struct, void *arg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mode, boolean_t (*val_sig)(EXT_IOCTL *))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_IOCTL *cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate local memory for EXT_IOCTL. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *cmd_struct = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = (EXT_IOCTL *)kmem_zalloc(sizeof (EXT_IOCTL), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get argument structure. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyin(arg, (void *)cmd, sizeof (EXT_IOCTL), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check signature and the version.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If either are not valid then neither is the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure so don't attempt to return any error status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * because we can't trust what caller's arg points to.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Just return the errno.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val_sig(cmd) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, signature\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EINVAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cmd->Version > EXT_VERSION) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, version\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EINVAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == 0) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *cmd_struct = cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free((void *)cmd, sizeof (EXT_IOCTL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_validate_signature
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate the signature string for an external ioctl call.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sg: Pointer to EXT_IOCTL signature to validate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * B_TRUE: Signature is valid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * B_FALSE: Signature is NOT valid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_validate_signature(EXT_IOCTL *cmd_struct)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check signature.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If signature is not valid then neither is the rest of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the structure (e.g., can't trust it), so don't attempt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to return any error status other than the errno.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(&cmd_struct->Signature, "QLOGIC", 6) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_2(CE_CONT, "failed,\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_sdm_return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copies return data/status to application land for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ioctl call using the SAN/Device Management EXT_IOCTL call interface.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Pointer to kernel copy of requestor's EXT_IOCTL struct.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ioctl_code: ioctl function to perform
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: EXT_IOCTL cmd data in application land.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EFAULT: Copy out error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_sdm_return(ql_adapter_state_t *ha, EXT_IOCTL *cmd, void *arg, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= ddi_copyout((void *)&cmd->ResponseLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&(((EXT_IOCTL*)arg)->ResponseLen), sizeof (uint32_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= ddi_copyout((void *)&cmd->Status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&(((EXT_IOCTL*)arg)->Status),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (cmd->Status), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval |= ddi_copyout((void *)&cmd->DetailStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&(((EXT_IOCTL*)arg)->DetailStatus),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (cmd->DetailStatus), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free((void *)cmd, sizeof (EXT_IOCTL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Some copyout operation failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_query
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs all EXT_CC_QUERY functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_query(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started, cmd=%d\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* case off on command subcode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd->SubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_HBA_NODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_hba_node(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_HBA_PORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_hba_port(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_DISC_PORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_disc_port(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_DISC_TGT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_disc_tgt(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_DRIVER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_driver(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_FW:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_fw(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_CHIP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_chip(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard case EXT_SC_QUERY_CNA_PORT:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard ql_qry_cna_port(ha, cmd, mode);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard break;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case EXT_SC_QUERY_ADAPTER_VERSIONS:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_qry_adapter_versions(ha, cmd, mode);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_QUERY_DISC_LUN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* function not supported. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, Unsupported Subcode=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_hba_node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_QUERY_HBA_NODE subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_hba_node(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_HBA_NODE tmp_node = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t bufp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_HBA_NODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_HBA_NODE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_HBA_NODE, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Len=%xh\n", cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fill in the values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ha->loginparams.node_ww_name.raw_wwn, tmp_node.WWNN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf((char *)(tmp_node.Manufacturer), "QLogic Corporation");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf((char *)(tmp_node.Model), "%x", ha->device_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&tmp_node.WWNN[5], tmp_node.SerialNum, 3);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf((char *)(tmp_node.DriverVersion), QL_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_SBUS_CARD)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t verlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t w;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmpptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verlen = strlen((char *)(tmp_node.DriverVersion));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verlen + 5 > EXT_DEF_MAX_STR_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, No room for fpga version string\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte w = (uint16_t)ddi_get16(ha->sbus_fpga_dev_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->sbus_fpga_iobase + FPGA_REVISION));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpptr = (char *)&(tmp_node.DriverVersion[verlen+1]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmpptr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "Unable to insert fpga version str\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(tmpptr, "%d.%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((w & 0xf0) >> 4), (w & 0x0f));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_node.DriverAttr |= EXT_CC_HBA_NODE_SBUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf((char *)(tmp_node.FWVersion), "%01d.%02d.%02d",
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->fw_major_version, ha->fw_minor_version,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->fw_subminor_version);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard switch (ha->fw_attributes) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FWATTRIB_EF:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)(tmp_node.FWVersion), " EF");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FWATTRIB_TP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)(tmp_node.FWVersion), " TP");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FWATTRIB_IP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)(tmp_node.FWVersion), " IP");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FWATTRIB_IPX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)(tmp_node.FWVersion), " IPX");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FWATTRIB_FL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)(tmp_node.FWVersion), " FL");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FWATTRIB_FPX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)(tmp_node.FWVersion), " FLX");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* FCode version. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*LINTED [Solaris DDI_DEV_T_ANY Lint error]*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_getlongprop(DDI_DEV_T_ANY, ha->dip, PROP_LEN_AND_VAL_ALLOC |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_DONTPASS | DDI_PROP_CANSLEEP, "version", (caddr_t)&bufp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (int *)&len) == DDI_PROP_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (len < EXT_DEF_MAX_STR_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(bufp, tmp_node.OptRomVersion, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(bufp, tmp_node.OptRomVersion,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_MAX_STR_SIZE - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_node.OptRomVersion[EXT_DEF_MAX_STR_SIZE - 1] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(bufp, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf((char *)tmp_node.OptRomVersion, "0");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_node.PortCount = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_node.InterfaceType = EXT_DEF_FC_INTF_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout((void *)&tmp_node,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_HBA_NODE), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_HBA_NODE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_hba_port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_QUERY_HBA_PORT subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_hba_port(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_data_t mr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_HBA_PORT tmp_port = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t port_cnt, tgt_cnt, index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_HBA_PORT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_HBA_PORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_HBA_NODE, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fill in the values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ha->loginparams.nport_ww_name.raw_wwn, tmp_port.WWPN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[1] = ha->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[2] = ha->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[3] = ha->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* For now we are initiator only driver */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Type = EXT_DEF_INITIATOR_DEV;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->task_daemon_flags & LOOP_DOWN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.State = EXT_DEF_HBA_LOOP_DOWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.State = EXT_DEF_HBA_SUSPENDED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.State = EXT_DEF_HBA_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->flags & POINT_TO_POINT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Mode = EXT_DEF_P2P_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Mode = EXT_DEF_LOOP_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fill in the portspeed values.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * default to not yet negotiated state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSpeed = EXT_PORTSPEED_NOT_NEGOTIATED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_port.State == EXT_DEF_HBA_OK) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard switch (ha->iidma_rate) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case IIDMA_RATE_1GB:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSpeed = EXT_DEF_PORTSPEED_1GBIT;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case IIDMA_RATE_2GB:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard tmp_port.PortSpeed = EXT_DEF_PORTSPEED_2GBIT;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case IIDMA_RATE_4GB:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard tmp_port.PortSpeed = EXT_DEF_PORTSPEED_4GBIT;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case IIDMA_RATE_8GB:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard tmp_port.PortSpeed = EXT_DEF_PORTSPEED_8GBIT;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case IIDMA_RATE_10GB:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard tmp_port.PortSpeed = EXT_DEF_PORTSPEED_10GBIT;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard default:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard tmp_port.PortSpeed = EXT_DEF_PORTSPEED_UNKNOWN;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard EL(ha, "failed, data rate=%xh\n", mr.mb[1]);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Report all supported port speeds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_CTRL_25XX)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed = (EXT_DEF_PORTSPEED_8GBIT |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_4GBIT | EXT_DEF_PORTSPEED_2GBIT |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_1GBIT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Correct supported speeds based on type of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sfp that is present
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (ha->sfp_stat) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no sfp detected */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 4:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 4GB sfp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed &=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ~EXT_DEF_PORTSPEED_8GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 3:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 5:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 8GB sfp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed &=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ~EXT_DEF_PORTSPEED_1GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "sfp_stat: %xh\n", ha->sfp_stat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_8081)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_10GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (CFG_IST(ha, CFG_CTRL_2422)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed = (EXT_DEF_PORTSPEED_4GBIT |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_2GBIT | EXT_DEF_PORTSPEED_1GBIT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (CFG_IST(ha, CFG_CTRL_2300)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed = (EXT_DEF_PORTSPEED_2GBIT |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_1GBIT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (CFG_IST(ha, CFG_CTRL_6322)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_2GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (CFG_IST(ha, CFG_CTRL_2200)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_1GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.PortSupportedSpeed = EXT_DEF_PORTSPEED_UNKNOWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "unknown HBA type: %xh\n", ha->device_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard tmp_port.LinkState2 = LSB(ha->sfp_stat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tgt_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ha->dev[index].first; link != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tq->flags & TQF_INITIATOR_DEVICE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tgt_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.DiscPortCount = port_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.DiscTargetCount = tgt_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.DiscPortNameType = EXT_DEF_USE_NODE_NAME;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyout((void *)&tmp_port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_HBA_PORT), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_HBA_PORT);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done, ports=%d, targets=%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, port_cnt, tgt_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_disc_port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_QUERY_DISC_PORT subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd->Instance = Port instance in fcport chain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_disc_port(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DISC_PORT tmp_port = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t inst = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_DISC_PORT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_DISC_PORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_DISC_PORT, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = NULL, index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index < DEVICE_HEAD_LIST_SIZE && link == NULL; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ha->dev[index].first; link != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inst != cmd->Instance) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inst++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fill in the values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->node_name, tmp_port.WWNN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->port_name, tmp_port.WWPN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (link == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no matching device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, port not found port=%d\n", cmd->Instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[1] = tq->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[2] = tq->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Id[3] = tq->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Type = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_INITIATOR_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Type = (uint16_t)(tmp_port.Type |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_INITIATOR_DEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((tq->flags & TQF_TAPE_DEVICE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ql_inq_scan(ha, tq, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (tq->flags & TQF_TAPE_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Type = (uint16_t)(tmp_port.Type | EXT_DEF_TAPE_DEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_FABRIC_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Type = (uint16_t)(tmp_port.Type | EXT_DEF_FABRIC_DEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Type = (uint16_t)(tmp_port.Type | EXT_DEF_TARGET_DEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Status = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port.Bus = 0; /* Hard-coded for Solaris */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->port_name, &tmp_port.TargetId, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout((void *)&tmp_port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_DISC_PORT), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_DISC_PORT);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_disc_tgt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_QUERY_DISC_TGT subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd->Instance = Port instance in fcport chain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_disc_tgt(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DISC_TARGET tmp_tgt = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t inst = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started, target=%d\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_DISC_TARGET)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_DISC_TARGET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_DISC_TARGET, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Scan port list for requested target and fill in the values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = NULL, index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index < DEVICE_HEAD_LIST_SIZE && link == NULL; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ha->dev[index].first; link != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!VALID_TARGET_ID(ha, tq->loop_id) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq->flags & TQF_INITIATOR_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inst != cmd->Instance) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inst++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fill in the values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->node_name, tmp_tgt.WWNN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->port_name, tmp_tgt.WWPN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (link == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no matching device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_TARGET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, not found target=%d\n", cmd->Instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Id[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Id[1] = tq->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Id[2] = tq->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Id[3] = tq->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.LunCount = (uint16_t)ql_lun_count(ha, tq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tq->flags & TQF_TAPE_DEVICE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ql_inq_scan(ha, tq, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Type = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_TAPE_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Type = (uint16_t)(tmp_tgt.Type | EXT_DEF_TAPE_DEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_FABRIC_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Type = (uint16_t)(tmp_tgt.Type | EXT_DEF_FABRIC_DEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Type = (uint16_t)(tmp_tgt.Type | EXT_DEF_TARGET_DEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Status = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_tgt.Bus = 0; /* Hard-coded for Solaris. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->port_name, &tmp_tgt.TargetId, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout((void *)&tmp_tgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_DISC_TARGET), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_DISC_TARGET);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_fw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_QUERY_FW subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_fw(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_FW fw_info = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_FW)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_FW);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_FW, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (void) sprintf((char *)(fw_info.Version), "%d.%02d.%02d",
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->fw_major_version, ha->fw_minor_version,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->fw_subminor_version);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard fw_info.Attrib = ha->fw_attributes;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyout((void *)&fw_info,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_FW), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_FW);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_chip
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_QUERY_CHIP subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_chip(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_CHIP chip = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_CHIP)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_CHIP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_CHIP, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.VendorId = ha->ven_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.DeviceId = ha->device_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.SubVendorId = ha->subven_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.SubSystemId = ha->subsys_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.IoAddr = ql_pci_config_get32(ha, PCI_CONF_BASE0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.IoAddrLen = 0x100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.MemAddr = ql_pci_config_get32(ha, PCI_CONF_BASE1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.MemAddrLen = 0x100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chip.ChipRevID = ha->rev_id;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ha->flags & FUNCTION_1) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard chip.FuncNo = 1;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyout((void *)&chip,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_CHIP), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_CHIP);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_driver
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_QUERY_DRIVER subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_driver(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DRIVER qd = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_DRIVER)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DATA_OVERRUN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_DRIVER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_DRIVER, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((void *)&qd.Version[0], QL_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qd.NumOfBus = 1; /* Fixed for Solaris */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qd.TargetsPerBus = (uint16_t)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (CFG_IST(ha, (CFG_CTRL_24258081 | CFG_EXT_FW_INTERFACE)) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_24_FIBRE_DEVICES : MAX_22_FIBRE_DEVICES);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qd.LunsPerTarget = 2030;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qd.MaxTransferLen = QL_DMA_MAX_XFER_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qd.MaxDataSegments = QL_DMA_SG_LIST_LENGTH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout((void *)&qd, (void *)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_DRIVER), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_DRIVER);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_fcct
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL management server FC-CT passthrough.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: User space CT arguments pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_fcct(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_iocb_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_data_t mr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem_t *dma_mem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t pld;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pkt_size, pld_byte_cnt, *long_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_ct_iu_preamble_t *ct;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t comp_status, loop_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get CT argument structure. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ha->topology & QL_SNS_CONNECTION) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, No switch\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Login management server device. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((xp->flags & QL_MGMT_SERVER_LOGIN) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq.d_id.b.al_pa = 0xfa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq.d_id.b.area = 0xff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq.d_id.b.domain = 0xff;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tq.loop_id = (uint16_t)(CFG_IST(ha, CFG_CTRL_24258081) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MANAGEMENT_SERVER_24XX_LOOP_ID :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MANAGEMENT_SERVER_LOOP_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_login_fport(ha, &tq, tq.loop_id, LFF_NO_PRLI, &mr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, server login\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->flags |= QL_MGMT_SERVER_LOGIN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): cmd\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(cmd, 8, sizeof (EXT_IOCTL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate a DMA Memory Descriptor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem = (dma_mem_t *)kmem_zalloc(sizeof (dma_mem_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dma_mem == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Determine maximum buffer size. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen < cmd->ResponseLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld_byte_cnt = cmd->ResponseLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld_byte_cnt = cmd->RequestLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate command block. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_size = (uint32_t)(sizeof (ql_mbx_iocb_t) + pld_byte_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(pkt_size, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld = (caddr_t)pkt + sizeof (ql_mbx_iocb_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get command payload data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_buffer_data((caddr_t)(uintptr_t)cmd->RequestAdr, pld,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, mode) != cmd->RequestLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_buffer_data\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get DMA memory for the IOCB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_dma_mem(ha, dma_mem, pkt_size, LITTLE_ENDIAN_DMA,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard QL_DMA_RING_ALIGN) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "%s(%d): DMA memory "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alloc failed", QL_NAME, ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy out going payload data to IOCB DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_put8(dma_mem->acc_handle, (uint8_t *)pld,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)dma_mem->bp, pld_byte_cnt, DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync IOCB DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem->dma_handle, 0, pld_byte_cnt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup IOCB
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct = (ql_ct_iu_preamble_t *)pld;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.entry_type = CT_PASSTHRU_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->ms24.vp_index = ha->vp_index;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set loop ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.n_port_hdl = (uint16_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ct->gs_type == GS_TYPE_DIR_SERVER ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_16(SNS_24XX_HDL) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_16(MANAGEMENT_SERVER_24XX_LOOP_ID));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.timeout = LE_16(120);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set cmd/response data segment counts. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.cmd_dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.resp_dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load ct cmd byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.cmd_byte_count = LE_32(cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load ct rsp byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms24.resp_byte_count = LE_32(cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte long_ptr = (uint32_t *)&pkt->ms24.dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load MS command entry data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *long_ptr++ = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *long_ptr++ = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *long_ptr++ = (uint32_t)(LE_32(cmd->RequestLen));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load MS response entry data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *long_ptr++ = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *long_ptr++ = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *long_ptr = (uint32_t)LE_32(cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = (uint16_t)LE_16(pkt->sts24.comp_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (comp_status == CS_DATA_UNDERRUN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((BE_16(ct->max_residual_size)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = CS_COMPLETE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS || (pkt->sts24.entry_status & 0x3c) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, I/O timeout or "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "es=%xh, ss_l=%xh, rval=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts24.entry_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts24.scsi_status_l, rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.entry_type = MS_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set loop ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte loop_id = (uint16_t)(ct->gs_type == GS_TYPE_DIR_SERVER ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SIMPLE_NAME_SERVER_LOOP_ID : MANAGEMENT_SERVER_LOOP_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.loop_id_l = LSB(loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.loop_id_h = MSB(loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.loop_id_h = LSB(loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.timeout = LE_16(120);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment counts. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.cmd_dseg_count_l = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.total_dseg_count = LE_16(2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Response total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.resp_byte_count = LE_32(cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.dseg_1_length = LE_32(cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Command total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.cmd_byte_count = LE_32(cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.dseg_0_length = LE_32(cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load command/response data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.dseg_1_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->ms.dseg_1_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = (uint16_t)LE_16(pkt->sts.comp_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (comp_status == CS_DATA_UNDERRUN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((BE_16(ct->max_residual_size)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = CS_COMPLETE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS || (pkt->sts.entry_status & 0x7e) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, I/O timeout or "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "es=%xh, rval=%xh\n", pkt->sts.entry_status, rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync in coming DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem->dma_handle, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld_byte_cnt, DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy in coming DMA data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_get8(dma_mem->acc_handle, (uint8_t *)pld,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)dma_mem->bp, pld_byte_cnt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy response payload from DMA buffer to application. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): ResponseLen=%d\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(pld, 8, cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send response payload. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_send_buffer_data(pld,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen, mode) != cmd->ResponseLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, send_buffer_data\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_aen_reg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL management server Asynchronous Event Tracking Enable/Disable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_aen_reg(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_REG_AEN reg_struct;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ddi_copyin((void*)(uintptr_t)cmd->RequestAdr, &reg_struct,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (reg_struct.Enable) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->flags |= QL_AEN_TRACKING_ENABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->flags &= ~QL_AEN_TRACKING_ENABLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Empty the queue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_head = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_tail = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_aen_get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL management server Asynchronous Event Record Transfer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_aen_get(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t out_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_ASYNC_EVENT *tmp_q;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_ASYNC_EVENT aen[EXT_DEF_MAX_AEN_QUEUE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t queue_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t request_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Compute the number of events that can be returned */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_cnt = (uint8_t)(cmd->ResponseLen / sizeof (EXT_ASYNC_EVENT));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (request_cnt < EXT_DEF_MAX_AEN_QUEUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DEF_MAX_AEN_QUEUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, request_cnt < EXT_DEF_MAX_AEN_QUEUE, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Len=%xh\n", request_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 1st: Make a local copy of the entire queue content. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_q = (EXT_ASYNC_EVENT *)xp->aen_tracking_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte queue_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = xp->aen_q_head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; queue_cnt < EXT_DEF_MAX_AEN_QUEUE; ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_q[i].AsyncEventCode != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&tmp_q[i], &aen[queue_cnt],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_ASYNC_EVENT));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte queue_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_q[i].AsyncEventCode = 0; /* empty out the slot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == xp->aen_q_tail) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* done. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == EXT_DEF_MAX_AEN_QUEUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Empty the queue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_head = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_tail = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 2nd: Now transfer the queue content to user buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy the entire queue to user's buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = (uint32_t)(queue_cnt * sizeof (EXT_ASYNC_EVENT));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (queue_cnt == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (ddi_copyout((void *)&aen[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = out_size;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_enqueue_aen
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * event_code: async event code of the event to add to queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * payload: event payload for the queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INTR_LOCK must be already obtained.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_enqueue_aen(ql_adapter_state_t *ha, uint16_t event_code, void *payload)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t new_entry; /* index to current entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *mbx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_ASYNC_EVENT *aen_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started, event_code=%d\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte event_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): no context\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aen_queue = (EXT_ASYNC_EVENT *)xp->aen_tracking_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (aen_queue[xp->aen_q_tail].AsyncEventCode != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Need to change queue pointers to make room. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Increment tail for adding new entry. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_tail++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->aen_q_tail == EXT_DEF_MAX_AEN_QUEUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_tail = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->aen_q_head == xp->aen_q_tail) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We're overwriting the oldest entry, so need to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update the head pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_head++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->aen_q_head == EXT_DEF_MAX_AEN_QUEUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->aen_q_head = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_entry = xp->aen_q_tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aen_queue[new_entry].AsyncEventCode = event_code;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Update payload */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (payload != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (event_code) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBA_LIP_OCCURRED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBA_LOOP_UP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBA_LOOP_DOWN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBA_LIP_F8:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBA_LIP_RESET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBA_PORT_UPDATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MBA_RSCN_UPDATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mbx = (uint16_t *)payload;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* al_pa */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aen_queue[new_entry].Payload.RSCN.RSCNInfo[0] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(mbx[2]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aen_queue[new_entry].Payload.RSCN.RSCNInfo[1] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(mbx[2]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* domain */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aen_queue[new_entry].Payload.RSCN.RSCNInfo[2] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(mbx[1]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save in big endian */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BIG_ENDIAN_24(&aen_queue[new_entry].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Payload.RSCN.RSCNInfo[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aen_queue[new_entry].Payload.RSCN.AddrFormat =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(mbx[1]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not supported */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, event code not supported=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte event_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aen_queue[new_entry].AsyncEventCode = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_scsi_passthru
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL SCSI passthrough.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: User space SCSI command pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_scsi_passthru(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_iocb_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_data_t mr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem_t *dma_mem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t pld;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pkt_size, pld_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t qlnt, retries, cnt, cnt2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_FC_SCSI_PASSTHRU *ufc_req;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_SCSI_PASSTHRU *usp_req;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte union _passthru {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_SCSI_PASSTHRU sp_cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_FC_SCSI_PASSTHRU fc_cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } pt_req; /* Passthru request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t status, sense_sz = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_SCSI_PASSTHRU *sp_req = &pt_req.sp_cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_FC_SCSI_PASSTHRU *fc_req = &pt_req.fc_cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* SCSI request struct for SCSI passthrough IOs. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t lun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t sense_length; /* Sense buffer size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t resid; /* Residual */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *cdbp; /* Requestor's CDB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *u_sense; /* Requestor's sense buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t cdb_len; /* Requestor's CDB length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t direction;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } scsi_req;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *rsp_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *req_sense_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t residual_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rsp_info_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t req_sense_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t comp_status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t state_flags_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t state_flags_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t scsi_status_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } sts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify Sub Code and set cnt to needed request size. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->SubCode == EXT_SC_SEND_SCSI_PASSTHRU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld_size = sizeof (EXT_SCSI_PASSTHRU);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cmd->SubCode == EXT_SC_SEND_FC_SCSI_PASSTHRU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld_size = sizeof (EXT_FC_SCSI_PASSTHRU);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid SubCode=%xh\n", cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem = (dma_mem_t *)kmem_zalloc(sizeof (dma_mem_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dma_mem == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify the size of and copy in the passthru request structure. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen != pld_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, RequestLen != cnt, is=%xh, expected=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr, &pt_req,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard pld_size, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find fc_port from SCSI PASSTHRU structure fill in the scsi_req
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * request data structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->SubCode == EXT_SC_SEND_SCSI_PASSTHRU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.lun = sp_req->TargetAddr.Lun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.sense_length = sizeof (sp_req->SenseData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp = &sp_req->Cdb[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdb_len = sp_req->CdbLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.direction = sp_req->Direction;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte usp_req = (EXT_SCSI_PASSTHRU *)(uintptr_t)cmd->RequestAdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.u_sense = &usp_req->SenseData[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_TARGET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnt = QLNT_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = (uint8_t *)&sp_req->TargetAddr.Target;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, Target=%lld\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, cmd->SubCode, sp_req->TargetAddr.Target);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, name, qlnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be FC PASSTHRU, verified above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fc_req->FCScsiAddr.DestType == EXT_DEF_DESTTYPE_WWPN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnt = QLNT_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = &fc_req->FCScsiAddr.DestAddr.WWPN[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, cmd->SubCode, name[0], name[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[2], name[3], name[4], name[5], name[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, name, qlnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fc_req->FCScsiAddr.DestType ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_DESTTYPE_WWNN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnt = QLNT_NODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = &fc_req->FCScsiAddr.DestAddr.WWNN[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wwnn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, cmd->SubCode, name[0], name[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[2], name[3], name[4], name[5], name[6],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, name, qlnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fc_req->FCScsiAddr.DestType ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_DESTTYPE_PORTID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnt = QLNT_PID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = &fc_req->FCScsiAddr.DestAddr.Id[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): SubCode=%xh, PID="
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02x%02x%02x\n", ha->instance, cmd->SubCode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[0], name[1], name[2]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, name, qlnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, SubCode=%xh invalid DestType=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->SubCode, fc_req->FCScsiAddr.DestType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.lun = fc_req->FCScsiAddr.Lun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.sense_length = sizeof (fc_req->SenseData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp = &sp_req->Cdb[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdb_len = sp_req->CdbLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ufc_req = (EXT_FC_SCSI_PASSTHRU *)(uintptr_t)cmd->RequestAdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.u_sense = &ufc_req->SenseData[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.direction = fc_req->Direction;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq == NULL || !VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, fc_port not found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_NEED_AUTHENTICATION) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "target not available; loopid=%xh\n", tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEVICE_OFFLINE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate command block. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((scsi_req.direction == EXT_DEF_SCSI_PASSTHRU_DATA_IN ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.direction == EXT_DEF_SCSI_PASSTHRU_DATA_OUT) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld_size = cmd->ResponseLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_size = (uint32_t)(sizeof (ql_mbx_iocb_t) + pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(pkt_size, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld = (caddr_t)pkt + sizeof (ql_mbx_iocb_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get DMA memory for the IOCB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_dma_mem(ha, dma_mem, pld_size, LITTLE_ENDIAN_DMA,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "%s(%d): request queue DMA memory "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alloc failed", QL_NAME, ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scsi_req.direction == EXT_DEF_SCSI_PASSTHRU_DATA_IN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.direction = (uint8_t)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (CFG_IST(ha, CFG_CTRL_24258081) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CF_RD : CF_DATA_IN | CF_STAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.direction = (uint8_t)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (CFG_IST(ha, CFG_CTRL_24258081) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CF_WR : CF_DATA_OUT | CF_STAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get command payload. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_buffer_data(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld, pld_size, mode) != pld_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_buffer_data\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy out going data to DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_put8(dma_mem->acc_handle, (uint8_t *)pld,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)dma_mem->bp, pld_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem->dma_handle, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem->size, DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.direction = (uint8_t)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (CFG_IST(ha, CFG_CTRL_24258081) ? 0 : CF_STAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_size = sizeof (ql_mbx_iocb_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(pkt_size, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc-2\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pld_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* retries = ha->port_down_retry_count; */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retries = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_NOADNL_INFO;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): SCSI cdb\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(scsi_req.cdbp, 8, scsi_req.cdb_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.comp_status = CS_LOOP_DOWN_ABORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.entry_type = IOCB_CMD_TYPE_7;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set LUN number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.fcp_lun[2] = LSB(scsi_req.lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.fcp_lun[3] = MSB(scsi_req.lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set N_port handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.n_port_hdl = (uint16_t)LE_16(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set VP Index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.vp_index = ha->vp_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set target ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[0] = tq->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[1] = tq->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[2] = tq->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.timeout = (uint16_t)LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load SCSI CDB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_put8(ha->hba_buf.acc_handle, scsi_req.cdbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb, scsi_req.cdb_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < MAX_CMDSZ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = (uint16_t)(cnt + 4)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_chg_endian((uint8_t *)&pkt->cmd24.scsi_cdb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte + cnt, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set tag queue control flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.task = TA_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pld_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set transfer direction. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.control_flags = scsi_req.direction;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.total_byte_count = LE_32(pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load data descriptor. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_length = LE_32(pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.entry_type = IOCB_CMD_TYPE_3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.lun_l = LSB(scsi_req.lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.lun_h = MSB(scsi_req.lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.control_flags_l = scsi_req.direction;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < scsi_req.cdb_len; cnt++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[cnt] = scsi_req.cdbp[cnt];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pld_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.byte_count = LE_32(pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_length = LE_32(pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.entry_type = IOCB_CMD_TYPE_2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.lun_l = LSB(scsi_req.lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.lun_h = MSB(scsi_req.lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.control_flags_l = scsi_req.direction;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < scsi_req.cdb_len; cnt++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[cnt] = scsi_req.cdbp[cnt];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pld_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.byte_count = LE_32(pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_0_address = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_0_length = LE_32(pld_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Go issue command and wait for completion. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): request pkt\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(pkt, 8, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ql_issue_mbx_iocb(ha, (caddr_t)pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pld_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync in coming DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem->dma_handle, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem->size, DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy in coming DMA data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_get8(dma_mem->acc_handle, (uint8_t *)pld,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)dma_mem->bp, pld_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts24.entry_status = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->sts24.entry_status & 0x3c);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts.entry_status = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->sts.entry_status & 0x7e);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == QL_SUCCESS && pkt->sts.entry_status != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, entry_status=%xh, d_id=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts.entry_status, tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = QL_FUNCTION_PARAMETER_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard sts.comp_status = (uint16_t)(CFG_IST(ha, CFG_CTRL_24258081) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_16(pkt->sts24.comp_status) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_16(pkt->sts.comp_status));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We have verified about all the request that can be so far.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now we need to start verification of our ability to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * actually issue the CDB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.comp_status = CS_LOOP_DOWN_ABORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status == QL_SUCCESS &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sts.comp_status == CS_PORT_LOGGED_OUT ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.comp_status == CS_PORT_UNAVAILABLE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "login retry d_id=%xh\n", tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_FABRIC_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_login_fport(ha, tq, tq->loop_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LFF_NO_PLOGI, &mr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, login_fport=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "d_id=%xh\n", rval, tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_login_lport(ha, tq, tq->loop_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LLF_NONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, login_lport=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "d_id=%xh\n", rval, tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((caddr_t)pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (retries--);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.comp_status == CS_LOOP_DOWN_ABORT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Cannot issue command now, maybe later */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, suspended\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_SUSPENDED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Command error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, I/O\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup status. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.scsi_status_l = pkt->sts24.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.scsi_status_h = pkt->sts24.scsi_status_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup residuals. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.residual_length = LE_32(pkt->sts24.residual_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup state flags. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_l = pkt->sts24.state_flags_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_h = pkt->sts24.state_flags_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pld_size && sts.comp_status != CS_DATA_UNDERRUN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_h = (uint8_t)(sts.state_flags_h |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SF_GOT_BUS | SF_GOT_TARGET | SF_SENT_CMD |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SF_XFERRED_DATA | SF_GOT_STATUS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_h = (uint8_t)(sts.state_flags_h |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SF_GOT_BUS | SF_GOT_TARGET | SF_SENT_CMD |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SF_GOT_STATUS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scsi_req.direction & CF_WR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_l = (uint8_t)(sts.state_flags_l |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SF_DATA_OUT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (scsi_req.direction & CF_RD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_l = (uint8_t)(sts.state_flags_l |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SF_DATA_IN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_l = (uint8_t)(sts.state_flags_l | SF_SIMPLE_Q);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup FCP response info. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.rsp_info_length = sts.scsi_status_h & FCP_RSP_LEN_VALID ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(pkt->sts24.fcp_rsp_data_length) : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.rsp_info = &pkt->sts24.rsp_sense_data[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < sts.rsp_info_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = (uint16_t)(cnt + 4)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_chg_endian(sts.rsp_info + cnt, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup sense data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.scsi_status_h & FCP_SNS_LEN_VALID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.req_sense_length =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(pkt->sts24.fcp_sense_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_h = (uint8_t)(sts.state_flags_h |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SF_ARQ_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.req_sense_length = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.req_sense_data =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pkt->sts24.rsp_sense_data[sts.rsp_info_length];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt2 = (uint16_t)(((uintptr_t)pkt + sizeof (sts_24xx_entry_t)) -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uintptr_t)sts.req_sense_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < cnt2; cnt = (uint16_t)(cnt + 4)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_chg_endian(sts.req_sense_data + cnt, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.scsi_status_l = pkt->sts.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.scsi_status_h = pkt->sts.scsi_status_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup residuals. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.residual_length = LE_32(pkt->sts.residual_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup state flags. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_l = pkt->sts.state_flags_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.state_flags_h = pkt->sts.state_flags_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup FCP response info. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.rsp_info_length = sts.scsi_status_h & FCP_RSP_LEN_VALID ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_16(pkt->sts.rsp_info_length) : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.rsp_info = &pkt->sts.rsp_info[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup sense data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.req_sense_length = sts.scsi_status_h & FCP_SNS_LEN_VALID ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_16(pkt->sts.req_sense_length) : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.req_sense_data = &pkt->sts.req_sense_data[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): response pkt\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(&pkt->sts, 8, sizeof (sts_entry_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (sts.comp_status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_INCOMPLETE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_ABORTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_DEVICE_UNAVAILABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_PORT_UNAVAILABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_PORT_LOGGED_OUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_PORT_CONFIG_CHG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_PORT_BUSY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_LOOP_DOWN_ABORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_RESET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_QUEUE_FULL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_TIMEOUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_DATA_OVERRUN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DATA_OVERRUN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CS_DATA_UNDERRUN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DATA_UNDERRUN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If non data transfer commands fix tranfer counts.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scsi_req.cdbp[0] == SCMD_TEST_UNIT_READY ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_REZERO_UNIT ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_SEEK ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_SEEK_G1 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_RESERVE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_RELEASE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_START_STOP ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_DOORLOCK ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_VERIFY ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_WRITE_FILE_MARK ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_VERIFY_G0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_SPACE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.cdbp[0] == SCMD_ERASE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (scsi_req.cdbp[0] == SCMD_FORMAT &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (scsi_req.cdbp[1] & FPB_DATA) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Non data transfer command, clear sts_entry residual
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * length.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.residual_length = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.comp_status == CS_DATA_UNDERRUN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.comp_status = CS_COMPLETE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = pld_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Correct ISP completion status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.comp_status == CS_COMPLETE && sts.scsi_status_l == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sts.scsi_status_h & FCP_RSP_MASK) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): Correct completion\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.resid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (sts.comp_status == CS_DATA_UNDERRUN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): Correct UNDERRUN\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.resid = sts.residual_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.scsi_status_h & FCP_RESID_UNDER) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = (uint32_t)EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pld_size - scsi_req.resid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, Transfer ERROR\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): error d_id=%xh, comp_status=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "scsi_status_h=%xh, scsi_status_l=%xh\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq->d_id.b24, sts.comp_status, sts.scsi_status_h,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.scsi_status_l);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.resid = pld_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Handle residual count on SCSI check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * condition.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - If Residual Under / Over is set, use the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Residual Transfer Length field in IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - If Residual Under / Over is not set, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Transferred Data bit is set in State Flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * field of IOCB, report residual value of 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (you may want to do this for tape
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Write-type commands only). This takes care
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of logical end of tape problem and does
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not break Unit Attention.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - If Residual Under / Over is not set, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Transferred Data bit is not set in State
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Flags, report residual value equal to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * original data transfer length.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.scsi_status_l & STATUS_CHECK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_SCSI_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sts.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.scsi_status_h &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (FCP_RESID_OVER | FCP_RESID_UNDER)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.resid = sts.residual_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (sts.state_flags_h &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STATE_XFERRED_DATA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.resid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.scsi_status_l & STATUS_CHECK &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.scsi_status_h & FCP_SNS_LEN_VALID &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sts.req_sense_length) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check condition with vaild sense data flag set and sense
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * length != 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sts.req_sense_length > scsi_req.sense_length) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sense_sz = scsi_req.sense_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sense_sz = sts.req_sense_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, Check Condition Status, d_id=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_2(sts.req_sense_data, 8, sts.req_sense_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout(sts.req_sense_data, scsi_req.u_sense,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)sense_sz, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, request sense ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_SCSI_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sts.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy response payload from DMA buffer to application. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scsi_req.direction & (CF_RD | CF_DATA_IN) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): Data Return resid=%lu, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "byte_count=%u, ResponseLen=%xh\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_req.resid, pld_size, cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(pld, 8, cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send response payload. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_send_buffer_data(pld,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen, mode) != cmd->ResponseLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, send_buffer_data\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->Status != EXT_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, cmd->Status=%xh, comp_status=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "d_id=%xh\n", cmd->Status, sts.comp_status, tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done, ResponseLen=%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_wwpn_to_scsiaddr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_wwpn_to_scsiaddr(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t wwpn[EXT_DEF_WWN_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_SCSI_ADDR *tmp_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen != EXT_DEF_WWN_NAME_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "incorrect RequestLen\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard status = ddi_copyin((void*)(uintptr_t)cmd->RequestAdr, wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, wwpn, QLNT_PORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq == NULL || tq->flags & TQF_INITIATOR_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no matching device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, device not found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy out the IDs found. For now we can only return target ID. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_addr = (EXT_SCSI_ADDR *)(uintptr_t)cmd->ResponseAdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ddi_copyout((void *)wwpn, (void *)&tmp_addr->Target, 8, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_host_idx
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets host order index.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_host_idx(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t idx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (uint16_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (uint16_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < Len=%xh\n", cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idx = (uint16_t)ha->instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout((void *)&idx, (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint16_t), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (uint16_t);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_host_drvname
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets host driver name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_host_drvname(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char drvname[] = QL_NAME;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t qlnamelen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnamelen = (uint32_t)(strlen(QL_NAME)+1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < qlnamelen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = qlnamelen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen: %xh, needed: %xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen, qlnamelen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyout((void *)&drvname,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnamelen, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = qlnamelen-1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_read_nvram
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get NVRAM contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_read_nvram(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard if (cmd->ResponseLen < ha->nvram_cache->size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard cmd->DetailStatus = ha->nvram_cache->size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen != NVRAM, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get NVRAM data. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ql_nv_util_dump(ha, (void *)(uintptr_t)(cmd->ResponseAdr),
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, copy error\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard cmd->ResponseLen = ha->nvram_cache->size;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_write_nvram
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Loads NVRAM contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_write_nvram(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard if (cmd->RequestLen < ha->nvram_cache->size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
c1fad183c9a0deeb49586645ec9baa8f3c1bc8beDaniel Beauregard cmd->DetailStatus = ha->nvram_cache->size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, RequestLen != NVRAM, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load NVRAM data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_nv_util_load(ha, (void *)(uintptr_t)(cmd->RequestAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, copy error\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_write_vpd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Loads VPD contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_write_vpd(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid request for HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen < QL_24XX_VPD_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = QL_24XX_VPD_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, RequestLen != VPD len, len passed=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load VPD data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = ql_vpd_load(ha, (void *)(uintptr_t)(cmd->RequestAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, errno=%x\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_read_vpd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps VPD contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_read_vpd(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid request for HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < QL_24XX_VPD_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = QL_24XX_VPD_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < VPD len, len passed=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dump VPD data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ql_vpd_dump(ha, (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed,\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_fcache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps flash cache contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_fcache(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t bsize, boff, types, cpsize, hsize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *fptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->fcache == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, adapter fcache not setup\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize = 100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize = 400;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < bsize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = bsize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < %d, len passed=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize, cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boff = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fptr = ha->fcache;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For backwards compatibility, get one of each image type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte types = (FTYPE_BIOS | FTYPE_FCODE | FTYPE_EFI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((fptr != NULL) && (fptr->buf != NULL) && (types != 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the next image */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fptr = ql_get_fbuf(ha->fcache, types)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cpsize = (fptr->buflen < 100 ? fptr->buflen : 100);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout(fptr->buf,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr + boff),
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cpsize, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "ddicopy failed, done\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boff += 100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize += cpsize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte types &= ~(fptr->type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the firmware image -- it needs to be last in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buffer at offset 300 for backwards compatibility. Also for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * backwards compatibility, the pci header is stripped off.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fptr = ql_get_fbuf(ha->fcache, FTYPE_FW)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hsize = sizeof (pci_header_t) + sizeof (pci_data_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hsize > fptr->buflen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "header size (%xh) exceeds buflen (%xh)\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hsize, fptr->buflen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cpsize = ((fptr->buflen - hsize) < 100 ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fptr->buflen - hsize : 100);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout(fptr->buf+hsize,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr + 300),
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cpsize, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "fw ddicopy failed, done\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize += 100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = bsize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_fcache_ex
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps flash cache contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_fcache_ex(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t bsize = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t boff = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *fptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->fcache == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, adapter fcache not setup\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure user passed enough buffer space */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (fptr = ha->fcache; fptr != NULL; fptr = fptr->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize += FBUFSIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < bsize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < %d, len passed=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize, cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = bsize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boff = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fptr = ha->fcache;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((fptr != NULL) && (fptr->buf != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the next image */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout(fptr->buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr + boff),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (fptr->buflen < FBUFSIZE ? fptr->buflen : FBUFSIZE),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "failed, ddicopy at %xh, done\n", boff);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boff += FBUFSIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fptr = fptr->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = bsize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_read_flash
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get flash contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_read_flash(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "ql_stall_driver failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = xp->fdesc.flash_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ql_setup_fcache(ha) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = xp->fdesc.flash_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen=%xh, flash size=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen, xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* adjust read size to flash size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen > xp->fdesc.flash_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "adjusting req=%xh, max=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen, xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = xp->fdesc.flash_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get flash data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_flash_fcode_dump(ha,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (size_t)(cmd->ResponseLen), 0, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed,\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Resume I/O */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_driver(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "isp_abort_needed for restart\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DRIVER_STALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_write_flash
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Loads flash contents.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_write_flash(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_stall_driver(ha, 0) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "ql_stall_driver failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = xp->fdesc.flash_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ql_setup_fcache(ha) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = xp->fdesc.flash_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, RequestLen=%xh, size=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load flash data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen > xp->fdesc.flash_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = xp->fdesc.flash_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, RequestLen=%xh, flash size=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (ql_flash_fcode_load(ha,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->RequestAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)(cmd->RequestLen), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed,\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Resume I/O */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_driver(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "isp_abort_needed for restart\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DRIVER_STALL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_diagnostic_loopback
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_CC_LOOPBACK Command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_diagnostic_loopback(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_LOOPBACK_REQ plbreq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_LOOPBACK_RSP plbrsp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_data_t mr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint32_t rval;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard caddr_t bp;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint16_t opt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get loop back request. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)&plbreq, sizeof (EXT_LOOPBACK_REQ), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard opt = (uint16_t)(plbreq.Options & MBC_LOOPBACK_POINT_MASK);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check transfer length fits in buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plbreq.BufferLength < plbreq.TransferCount &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbreq.TransferCount < MAILBOX_BUFFER_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, BufferLength=%d, xfercnt=%d, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mailbox_buffer_size=%d\n", plbreq.BufferLength,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbreq.TransferCount, MAILBOX_BUFFER_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Allocate command memory. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard bp = kmem_zalloc(plbreq.TransferCount, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get loopback data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_buffer_data((caddr_t)(uintptr_t)plbreq.BufferAddress,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard bp, plbreq.TransferCount, mode) != plbreq.TransferCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin-2\n");
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard kmem_free(bp, plbreq.TransferCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f33c1cdb6d38eb0715f03cf492f31c3d4d395c98Daniel Beauregard if ((ha->task_daemon_flags & (QL_LOOP_TRANSITION | DRIVER_STALL)) ||
f33c1cdb6d38eb0715f03cf492f31c3d4d395c98Daniel Beauregard ql_stall_driver(ha, 0) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard kmem_free(bp, plbreq.TransferCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Shutdown IP. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->flags & IP_INITIALIZED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ql_shutdown_ip(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* determine topology so we can send the loopback or the echo */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Echo is supported on 2300's only and above */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_8081)) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (!(ha->task_daemon_flags & LOOP_DOWN) && opt ==
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard MBC_LOOPBACK_POINT_EXTERNAL) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (plbreq.TransferCount > 252) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard EL(ha, "transfer count (%d) > 252\n",
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard plbreq.TransferCount);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard kmem_free(bp, plbreq.TransferCount);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_INVALID_PARAM;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard plbrsp.CommandSent = INT_DEF_LB_ECHO_CMD;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard rval = ql_diag_echo(ha, 0, bp, plbreq.TransferCount,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard MBC_ECHO_ELS, &mr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_81XX)) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (void) ql_set_loop_point(ha, opt);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard plbrsp.CommandSent = INT_DEF_LB_LOOPBACK_CMD;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard rval = ql_diag_loopback(ha, 0, bp, plbreq.TransferCount,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard opt, plbreq.IterationCount, &mr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_81XX)) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (void) ql_set_loop_point(ha, 0);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (!(ha->task_daemon_flags & LOOP_DOWN) &&
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (ha->topology & QL_F_PORT) &&
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->device_id >= 0x2300) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): F_PORT topology -- using "
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard "echo\n", ha->instance);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard plbrsp.CommandSent = INT_DEF_LB_ECHO_CMD;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard rval = ql_diag_echo(ha, 0, bp, plbreq.TransferCount,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (uint16_t)(CFG_IST(ha, CFG_CTRL_8081) ?
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard MBC_ECHO_ELS : MBC_ECHO_64BIT), &mr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard plbrsp.CommandSent = INT_DEF_LB_LOOPBACK_CMD;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard rval = ql_diag_loopback(ha, 0, bp, plbreq.TransferCount,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard opt, plbreq.IterationCount, &mr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_driver(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Restart IP if it was shutdown. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->flags & IP_ENABLED && !(ha->flags & IP_INITIALIZED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ql_initialize_ip(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_isp_rcvbuf(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, diagnostic_loopback_mbx=%xh\n", rval);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard kmem_free(bp, plbreq.TransferCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return loopback data. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (ql_send_buffer_data(bp, (caddr_t)(uintptr_t)plbreq.BufferAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbreq.TransferCount, mode) != plbreq.TransferCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard kmem_free(bp, plbreq.TransferCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard kmem_free(bp, plbreq.TransferCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return loopback results. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.BufferAddress = plbreq.BufferAddress;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.BufferLength = plbreq.TransferCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.CompletionStatus = mr.mb[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (plbrsp.CommandSent == INT_DEF_LB_ECHO_CMD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.CrcErrorCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.DisparityErrorCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.FrameLengthErrorCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.IterationCountLastError = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.CrcErrorCount = mr.mb[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.DisparityErrorCount = mr.mb[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.FrameLengthErrorCount = mr.mb[3];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte plbrsp.IterationCountLastError = (mr.mb[19] >> 16) | mr.mb[18];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ddi_copyout((void *)&plbrsp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_LOOPBACK_RSP), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout-2\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_LOOPBACK_RSP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard/*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * ql_set_loop_point
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Setup loop point for port configuration.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Input:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * ha: adapter state structure.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * opt: loop point option.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Returns:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * ql local function return status code.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Context:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Kernel context.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregardstatic int
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregardql_set_loop_point(ql_adapter_state_t *ha, uint16_t opt)
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard{
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_mbx_data_t mr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard int rval;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint32_t timer;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * We get the current port config, modify the loopback field and
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * write it back out.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if ((rval = ql_get_port_config(ha, &mr)) != QL_SUCCESS) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard EL(ha, "get_port_config status=%xh\n", rval);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard return (rval);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Set the loopback mode field while maintaining the others.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Currently only internal or none are supported.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard mr.mb[1] = (uint16_t)(mr.mb[1] &~LOOPBACK_MODE_FIELD_MASK);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (opt == MBC_LOOPBACK_POINT_INTERNAL) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard mr.mb[1] = (uint16_t)(mr.mb[1] |
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard LOOPBACK_MODE(LOOPBACK_MODE_INTERNAL));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Changing the port configuration will cause the port state to cycle
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * down and back up. The indication that this has happened is that
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * the point to point flag gets set.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ADAPTER_STATE_LOCK(ha);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flags &= ~POINT_TO_POINT;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ADAPTER_STATE_UNLOCK(ha);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if ((rval = ql_set_port_config(ha, &mr)) != QL_SUCCESS) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard EL(ha, "set_port_config status=%xh\n", rval);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* wait for a while */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard for (timer = opt ? 10 : 0; timer; timer--) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (ha->flags & POINT_TO_POINT) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Delay for 1000000 usec (1 second). */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_delay(ha, 1000000);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard return (rval);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard}
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_send_els_rnid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL for extended link service RNID command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: User space CT arguments pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_send_els_rnid(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_RNID_REQ tmp_rnid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_id_t tmp_fcid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t tmp_buf, bptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t copy_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_RNID_DATA rnid_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t loop_ready_wait = 10 * 60 * 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t local_hba = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen != sizeof (EXT_RNID_REQ)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parameter error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, RequestLen < EXT_RNID_REQ, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((void*)(uintptr_t)cmd->RequestAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard &tmp_rnid, cmd->RequestLen, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find loop ID of the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_rnid.Addr.Type == EXT_DEF_TYPE_WWNN) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard bptr = CFG_IST(ha, CFG_CTRL_24258081) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)&ha->init_ctrl_blk.cb24.node_name :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)&ha->init_ctrl_blk.cb.node_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp((void *)bptr, (void *)tmp_rnid.Addr.FcAddr.WWNN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_hba = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)tmp_rnid.Addr.FcAddr.WWNN, QLNT_NODE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (tmp_rnid.Addr.Type == EXT_DEF_TYPE_WWPN) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard bptr = CFG_IST(ha, CFG_CTRL_24258081) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)&ha->init_ctrl_blk.cb24.port_name :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)&ha->init_ctrl_blk.cb.port_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp((void *)bptr, (void *)tmp_rnid.Addr.FcAddr.WWPN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_hba = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)tmp_rnid.Addr.FcAddr.WWPN, QLNT_PORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (tmp_rnid.Addr.Type == EXT_DEF_TYPE_PORTID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy caller's d_id to tmp space.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&tmp_rnid.Addr.FcAddr.Id[1], tmp_fcid.r.d_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTID_SIZE_ACTUAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BIG_ENDIAN_24(&tmp_fcid.r.d_id[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp((void *)&ha->d_id, (void *)tmp_fcid.r.d_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTID_SIZE_ACTUAL) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_hba = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, (uint8_t *)tmp_fcid.r.d_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QLNT_PID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate memory for command. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf = kmem_zalloc(SEND_RNID_RSP_SIZE, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_buf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (local_hba) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_get_rnid_params(ha, SEND_RNID_RSP_SIZE, tmp_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_rnid_params_mbx=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, SEND_RNID_RSP_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save gotten RNID data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tmp_buf, &rnid_data, sizeof (EXT_RNID_DATA));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now build the Send RNID response */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf[0] = (char)(EXT_DEF_RNID_DFORMAT_TOPO_DISC);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf[1] = (2 * EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf[3] = sizeof (EXT_RNID_DATA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ha->init_ctrl_blk.cb24.port_name, &tmp_buf[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ha->init_ctrl_blk.cb24.node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp_buf[4 + EXT_DEF_WWN_NAME_SIZE],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ha->init_ctrl_blk.cb.port_name, &tmp_buf[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ha->init_ctrl_blk.cb.node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp_buf[4 + EXT_DEF_WWN_NAME_SIZE],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((uint8_t *)&rnid_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp_buf[4 + 2 * EXT_DEF_WWN_NAME_SIZE],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_RNID_DATA));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no matching device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, device not found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, SEND_RNID_RSP_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_TARGET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_send_rnid_els(ha, tq->loop_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t)tmp_rnid.DataFormat, SEND_RNID_RSP_SIZE, tmp_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, send_rnid_mbx=%xh, id=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval, tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (LOOP_NOT_READY(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_delay(ha, 100000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (loop_ready_wait-- == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, loop not ready\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_send_rnid_els(ha, tq->loop_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t)tmp_rnid.DataFormat, SEND_RNID_RSP_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, send_rnid_mbx=%xh, id=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval, tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, SEND_RNID_RSP_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy the response */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte copy_len = (cmd->ResponseLen > SEND_RNID_RSP_SIZE) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SEND_RNID_RSP_SIZE : cmd->ResponseLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_send_buffer_data(tmp_buf, (caddr_t)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte copy_len, mode) != copy_len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = copy_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (copy_len < SEND_RNID_RSP_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DATA_OVERRUN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, EXT_STATUS_DATA_OVERRUN\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cmd->ResponseLen > SEND_RNID_RSP_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DATA_UNDERRUN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, EXT_STATUS_DATA_UNDERRUN\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, SEND_RNID_RSP_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_set_host_data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Process IOCTL subcommand to set host/adapter related data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: User space CT arguments pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_set_host_data(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started, SubCode=%d\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * case off on command subcode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd->SubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_RNID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_set_rnid_parameters(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_RST_STATISTICS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ql_reset_statistics(ha, cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_BEACON_STATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_set_led_state(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_PARMS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_BUS_MODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_DR_DUMP_BUF:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_RISC_CODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_FLASH_RAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_LUN_BITMASK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_RETRY_CNT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_RTIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_FC_LUN_BITMASK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_ADD_TARGET_DEVICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SWAP_TARGET_DEVICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_SET_SEL_TIMEOUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* function not supported. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, function not supported=%d\n", cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->Status != EXT_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, Status=%d\n", cmd->Status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_host_data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_CC_GET_DATA subcommands.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_host_data(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int out_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started, SubCode=%d\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* case off on command subcode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd->SubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_STATISTICS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = sizeof (EXT_HBA_PORT_STAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_FC_STATISTICS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = sizeof (EXT_HBA_PORT_STAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_PORT_SUMMARY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = sizeof (EXT_DEVICEDATA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_RNID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = sizeof (EXT_RNID_DATA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_TARGET_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = sizeof (EXT_DEST_ADDR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_BEACON_STATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = sizeof (EXT_BEACON_CONTROL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_FC4_STATISTICS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_size = sizeof (EXT_HBA_FC4STATISTICS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard case EXT_SC_GET_DCBX_PARAM:
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard out_size = EXT_DEF_DCBX_PARAM_BUF_SIZE;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard break;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case EXT_SC_GET_RESOURCE_CNTS:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard out_size = sizeof (EXT_RESOURCE_CNTS);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case EXT_SC_GET_FCF_LIST:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard out_size = sizeof (EXT_FCF_LIST);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_SCSI_ADDR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_ERR_DETECTIONS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_BUS_MODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_DR_DUMP_BUF:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_RISC_CODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_FLASH_RAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_LINK_STATUS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_LOOP_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_LUN_BITMASK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_PORT_DATABASE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_PORT_DATABASE_MEM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_POSITION_MAP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_RETRY_CNT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_RTIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_FC_LUN_BITMASK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_SEL_TIMEOUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* function not supported. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, function not supported=%d\n", cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < out_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = out_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen=%xh, size=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen, out_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd->SubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_RNID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_rnid_parameters(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_STATISTICS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_statistics(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_FC_STATISTICS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_statistics_fc(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_FC4_STATISTICS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_statistics_fc4(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_PORT_SUMMARY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_port_summary(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_TARGET_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_target_id(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_SC_GET_BEACON_STATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_get_led_state(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard case EXT_SC_GET_DCBX_PARAM:
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard ql_get_dcbx_parameters(ha, cmd, mode);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard break;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case EXT_SC_GET_FCF_LIST:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_get_fcf_list(ha, cmd, mode);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case EXT_SC_GET_RESOURCE_CNTS:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_get_resource_counts(ha, cmd, mode);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->Status != EXT_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, Status=%d\n", cmd->Status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ******************************************************************** */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Helper Functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ******************************************************************** */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_lun_count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get numbers of LUNS on target.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * q: device queue pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Number of LUNs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_lun_count(ql_adapter_state_t *ha, ql_tgt_t *tq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bypass LUNs that failed. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = ql_report_lun(ha, tq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cnt == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = ql_inq_scan(ha, tq, ha->maximum_luns_per_target);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_report_lun
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get numbers of LUNS using report LUN command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * q: target queue pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Number of LUNs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_report_lun(ql_adapter_state_t *ha, ql_tgt_t *tq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t retries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_iocb_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_rpt_lun_lst_t *rpt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem_t dma_mem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pkt_size, cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t comp_status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t scsi_status_h, scsi_status_l, *reqs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_size = sizeof (ql_mbx_iocb_t) + sizeof (ql_rpt_lun_lst_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(pkt_size, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rpt = (ql_rpt_lun_lst_t *)((caddr_t)pkt + sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get DMA memory for the IOCB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_dma_mem(ha, &dma_mem, sizeof (ql_rpt_lun_lst_t),
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard LITTLE_ENDIAN_DMA, QL_DMA_RING_ALIGN) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "%s(%d): DMA memory "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alloc failed", QL_NAME, ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (retries = 0; retries < 4; retries++) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.entry_type = IOCB_CMD_TYPE_7;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set N_port handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.n_port_hdl = (uint16_t)LE_16(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set target ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[0] = tq->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[1] = tq->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[2] = tq->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set Virtual Port ID */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->cmd24.vp_index = ha->vp_index;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load SCSI CDB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb[0] = SCMD_REPORT_LUNS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb[6] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(MSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb[7] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(MSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb[8] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(LSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb[9] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(LSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < MAX_CMDSZ; cnt += 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_chg_endian((uint8_t *)&pkt->cmd24.scsi_cdb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte + cnt, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set tag queue control flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.task = TA_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set transfer direction. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.control_flags = CF_RD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load data descriptor. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.total_byte_count =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(sizeof (ql_rpt_lun_lst_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_length =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(sizeof (ql_rpt_lun_lst_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.entry_type = IOCB_CMD_TYPE_3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.control_flags_l = CF_DATA_IN | CF_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[0] = SCMD_REPORT_LUNS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[6] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(MSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[7] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(MSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[8] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(LSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[9] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(LSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.byte_count =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(sizeof (ql_rpt_lun_lst_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_length =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(sizeof (ql_rpt_lun_lst_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.entry_type = IOCB_CMD_TYPE_2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.control_flags_l = CF_DATA_IN | CF_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[0] = SCMD_REPORT_LUNS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[6] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(MSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[7] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(MSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[8] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSB(LSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[9] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSB(LSW(sizeof (ql_rpt_lun_lst_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.byte_count =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(sizeof (ql_rpt_lun_lst_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_0_address = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_0_length =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(sizeof (ql_rpt_lun_lst_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync in coming DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem.dma_handle, 0, dma_mem.size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy in coming DMA data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_get8(dma_mem.acc_handle, (uint8_t *)rpt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)dma_mem.bp, dma_mem.size, DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts24.entry_status = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->sts24.entry_status & 0x3c);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = (uint16_t)LE_16(pkt->sts24.comp_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_h = pkt->sts24.scsi_status_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_l = pkt->sts24.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = scsi_status_h & FCP_RSP_LEN_VALID ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(pkt->sts24.fcp_rsp_data_length) : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs = &pkt->sts24.rsp_sense_data[cnt];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts.entry_status = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->sts.entry_status & 0x7e);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = (uint16_t)LE_16(pkt->sts.comp_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_h = pkt->sts.scsi_status_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_l = pkt->sts.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs = &pkt->sts.req_sense_data[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS && pkt->sts.entry_status != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, entry_status=%xh, d_id=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts.entry_status, tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_PARAMETER_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS || comp_status != CS_COMPLETE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_l & STATUS_CHECK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Device underrun, treat as OK. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status == CS_DATA_UNDERRUN &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_h & FCP_RESID_UNDER) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, issue_iocb=%xh, d_id=%xh, cs=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ss_h=%xh, ss_l=%xh\n", rval, tq->d_id.b24,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status, scsi_status_h, scsi_status_l);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((comp_status == CS_TIMEOUT) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (comp_status == CS_PORT_UNAVAILABLE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (comp_status == CS_PORT_LOGGED_OUT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rval == QL_ABORTED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scsi_status_l & STATUS_CHECK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "STATUS_CHECK Sense Data\n%2xh%3xh"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%3xh%3xh%3xh%3xh%3xh%3xh%3xh%3xh%3xh"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%3xh%3xh%3xh%3xh%3xh%3xh%3xh\n", reqs[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[1], reqs[2], reqs[3], reqs[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[5], reqs[6], reqs[7], reqs[8],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[9], reqs[10], reqs[11], reqs[12],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[13], reqs[14], reqs[15], reqs[16],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[17]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((caddr_t)pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): LUN list\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(rpt, 8, rpt->hdr.len + 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = (int)(BE_32(rpt->hdr.len) / 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, &dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_inq_scan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get numbers of LUNS using inquiry command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tq: target queue pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * count: scan for the number of existing LUNs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Number of LUNs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_inq_scan(ql_adapter_state_t *ha, ql_tgt_t *tq, int count)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int lun, cnt, rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_iocb_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *inq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pkt_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_size = sizeof (ql_mbx_iocb_t) + INQ_DATA_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(pkt_size, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inq = (uint8_t *)((caddr_t)pkt + sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (lun = 0; lun < MAX_LUNS; lun++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_LOOP_DOWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_inq(ha, tq, lun, pkt, INQ_DATA_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (*inq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_DIRECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_PROCESSOR: /* Appliance. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_WORM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_RODIRECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_SCANNER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_OPTICAL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_CHANGER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_ESI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DTYPE_SEQUENTIAL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq->flags |= TQF_TAPE_DEVICE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): failed, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unsupported device id=%xh, lun=%d, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "type=%xh\n", ha->instance, tq->loop_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, *inq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*inq == DTYPE_ESI || cnt >= count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rval == QL_ABORTED || rval == QL_FUNCTION_TIMEOUT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_inq
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue inquiry command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tq: target queue pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lun: LUN number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pkt: command and buffer pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * inq_len: amount of inquiry data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_inq(ql_adapter_state_t *ha, ql_tgt_t *tq, int lun, ql_mbx_iocb_t *pkt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t inq_len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem_t dma_mem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval, retries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pkt_size, cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t comp_status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t scsi_status_h, scsi_status_l, *reqs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t inq_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, loop down\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (QL_FUNCTION_TIMEOUT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt_size = (uint32_t)(sizeof (ql_mbx_iocb_t) + inq_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((caddr_t)pkt, pkt_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inq_data = (caddr_t)pkt + sizeof (ql_mbx_iocb_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get DMA memory for the IOCB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_dma_mem(ha, &dma_mem, inq_len,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard LITTLE_ENDIAN_DMA, QL_DMA_RING_ALIGN) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "%s(%d): DMA memory "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alloc failed", QL_NAME, ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (retries = 0; retries < 4; retries++) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.entry_type = IOCB_CMD_TYPE_7;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set LUN number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.fcp_lun[2] = LSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.fcp_lun[3] = MSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set N_port handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.n_port_hdl = (uint16_t)LE_16(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set target ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[0] = tq->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[1] = tq->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.target_id[2] = tq->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set Virtual Port ID */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->cmd24.vp_index = ha->vp_index;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load SCSI CDB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb[0] = SCMD_INQUIRY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.scsi_cdb[4] = inq_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < MAX_CMDSZ; cnt += 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_chg_endian((uint8_t *)&pkt->cmd24.scsi_cdb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte + cnt, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set tag queue control flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.task = TA_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set transfer direction. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.control_flags = CF_RD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.total_byte_count = LE_32(inq_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load data descriptor. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd24.dseg_0_length = LE_32(inq_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.entry_type = IOCB_CMD_TYPE_3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = CMD_TYPE_3_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.target_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.lun_l = LSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.lun_h = MSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.control_flags_l = CF_DATA_IN | CF_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[0] = SCMD_INQUIRY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.scsi_cdb[4] = inq_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.byte_count = LE_32(inq_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd3.dseg_0_length = LE_32(inq_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.entry_type = IOCB_CMD_TYPE_2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = CMD_TYPE_2_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.target_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.lun_l = LSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.lun_h = MSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.control_flags_l = CF_DATA_IN | CF_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.timeout = LE_16(15);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[0] = SCMD_INQUIRY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.scsi_cdb[4] = inq_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.byte_count = LE_32(inq_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_0_address = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem.cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd.dseg_0_length = LE_32(inq_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt, pkt_size); */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync in coming IOCB DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem.dma_handle, 0, dma_mem.size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy in coming DMA data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_get8(dma_mem.acc_handle, (uint8_t *)inq_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)dma_mem.bp, dma_mem.size, DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts24.entry_status = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->sts24.entry_status & 0x3c);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = (uint16_t)LE_16(pkt->sts24.comp_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_h = pkt->sts24.scsi_status_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_l = pkt->sts24.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = scsi_status_h & FCP_RSP_LEN_VALID ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(pkt->sts24.fcp_rsp_data_length) : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs = &pkt->sts24.rsp_sense_data[cnt];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts.entry_status = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->sts.entry_status & 0x7e);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status = (uint16_t)LE_16(pkt->sts.comp_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_h = pkt->sts.scsi_status_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_l = pkt->sts.scsi_status_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs = &pkt->sts.req_sense_data[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS && pkt->sts.entry_status != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, entry_status=%xh, d_id=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sts.entry_status, tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_PARAMETER_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS || comp_status != CS_COMPLETE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status_l & STATUS_CHECK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, issue_iocb=%xh, d_id=%xh, cs=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ss_h=%xh, ss_l=%xh\n", rval, tq->d_id.b24,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte comp_status, scsi_status_h, scsi_status_l);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((comp_status == CS_TIMEOUT) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (comp_status == CS_PORT_UNAVAILABLE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (comp_status == CS_PORT_LOGGED_OUT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scsi_status_l & STATUS_CHECK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "STATUS_CHECK Sense Data\n%2xh%3xh"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%3xh%3xh%3xh%3xh%3xh%3xh%3xh%3xh%3xh"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%3xh%3xh%3xh%3xh%3xh%3xh%3xh\n", reqs[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[1], reqs[2], reqs[3], reqs[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[5], reqs[6], reqs[7], reqs[8],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[9], reqs[10], reqs[11], reqs[12],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[13], reqs[14], reqs[15], reqs[16],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reqs[17]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, &dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_buffer_data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copies data from user space to kernal buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * src: User source buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dst: Kernal destination buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * size: Amount of data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns number of bytes transferred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_buffer_data(caddr_t src, caddr_t dst, uint32_t size, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < size; cnt++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(src++, dst++, 1, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_2(CE_CONT, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_send_buffer_data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copies data from kernal buffer to user space.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * src: Kernal source buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dst: User destination buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * size: Amount of data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns number of bytes transferred.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_send_buffer_data(caddr_t src, caddr_t dst, uint32_t size, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < size; cnt++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout(src++, dst++, 1, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_2(CE_CONT, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_find_port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Locates device queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name: device port name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns target queue pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ql_tgt_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_find_port(ql_adapter_state_t *ha, uint8_t *name, uint16_t type)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Scan port list for requested target */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ha->dev[index].first; link != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case QLNT_LOOP_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(name, &tq->loop_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (uint16_t)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (tq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case QLNT_PORT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(name, tq->port_name, 8) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (tq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case QLNT_NODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(name, tq->node_name, 8) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (tq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case QLNT_PID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(name, tq->d_id.r.d_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (tq->d_id.r.d_id)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (tq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid type=%d\n", type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_24xx_flash_desc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get flash descriptor table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_24xx_flash_desc(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chksum, *bp, data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard flash_desc_t *fdesc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ha->flash_desc_addr == 0) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): desc ptr=0\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (QL_FUNCTION_FAILED);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if ((fdesc = kmem_zalloc(sizeof (flash_desc_t), KM_SLEEP)) == NULL) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "kmem_zalloc=null\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (QL_MEMORY_ALLOC_FAILED);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard rval = ql_dump_fcode(ha, (uint8_t *)fdesc, sizeof (flash_desc_t),
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_desc_addr << 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "read status=%xh\n", rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_free(fdesc, sizeof (flash_desc_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chksum = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp = (uint16_t *)fdesc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < (sizeof (flash_desc_t)) / 2; cnt++) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard data = *bp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_16(&data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chksum += data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_32(&fdesc->flash_valid);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_16(&fdesc->flash_version);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_16(&fdesc->flash_len);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_16(&fdesc->flash_checksum);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_16(&fdesc->flash_manuf);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_16(&fdesc->flash_id);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_32(&fdesc->block_size);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_32(&fdesc->alt_block_size);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_32(&fdesc->flash_size);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_32(&fdesc->write_enable_data);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard LITTLE_ENDIAN_32(&fdesc->read_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* flash size in desc table is in 1024 bytes */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard fdesc->flash_size = fdesc->flash_size * 0x400;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (chksum != 0 || fdesc->flash_valid != FLASH_DESC_VAILD ||
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard fdesc->flash_version != FLASH_DESC_VERSION) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "invalid descriptor table\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_free(fdesc, sizeof (flash_desc_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (QL_FUNCTION_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bcopy(fdesc, &xp->fdesc, sizeof (flash_desc_t));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_free(fdesc, sizeof (flash_desc_t));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (QL_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_setup_flash
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the manufacturer and id number of the flash chip, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sets up the size parameter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * int: ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_setup_flash(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = QL_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->fdesc.flash_size != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_CTRL_2200) && !ha->subven_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (QL_FUNCTION_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Temporarily set the ha->xioctl->fdesc.flash_size to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 25xx flash size to avoid failing of ql_dump_focde.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_8021)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->xioctl->fdesc.flash_size = 0x800000;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_25XX)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->xioctl->fdesc.flash_size = 0x200000;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->xioctl->fdesc.flash_size = 0x400000;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_24xx_flash_desc(ha) == QL_SUCCESS) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "flash desc table ok, exit\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_8021)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard xp->fdesc.flash_manuf = WINBOND_FLASH;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard xp->fdesc.flash_id = WINBOND_FLASHID;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard xp->fdesc.flash_len = 0x17;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (void) ql_24xx_flash_id(ha);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_2422)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ql_24xx_flash_id(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_flash_enable(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0xaa);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x2aaa, 0x55);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0x90);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_manuf = (uint8_t)ql_read_flash_byte(ha, 0x0000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_SBUS_CARD)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0xaaaa, 0xaa);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0x55);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0xaaaa, 0x90);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_id = (uint16_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_read_flash_byte(ha, 0x0002);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0xaa);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x2aaa, 0x55);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0x90);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_id = (uint16_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_read_flash_byte(ha, 0x0001);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0xaa);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x2aaa, 0x55);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0xf0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_flash_disable(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Default flash descriptor table. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.write_statusreg_cmd = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.write_enable_bits = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.unprotect_sector_cmd = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.protect_sector_cmd = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.write_disable_bits = 0x9c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.block_size = 0x10000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.erase_cmd = 0xd8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_manuf) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AMD_FLASH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SPAN_FLASHID_2048K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x200000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AMD_FLASHID_1024K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x100000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AMD_FLASHID_512K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AMD_FLASHID_512Kt:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AMD_FLASHID_512Kb:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_SBUS_CARD)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = QL_SBUS_FCODE_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x80000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AMD_FLASHID_128K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x20000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ST_FLASH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ST_FLASHID_128K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x20000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ST_FLASHID_512K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x80000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ST_FLASHID_M25PXX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->fdesc.flash_len == 0x14) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x100000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (xp->fdesc.flash_len == 0x15) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x200000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SST_FLASH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SST_FLASHID_128K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x20000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SST_FLASHID_1024K_A:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x100000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.block_size = 0x8000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.erase_cmd = 0x52;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SST_FLASHID_1024K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SST_FLASHID_1024K_B:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x100000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SST_FLASHID_2048K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x200000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MXIC_FLASH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MXIC_FLASHID_512K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x80000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MXIC_FLASHID_1024K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x100000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MXIC_FLASHID_25LXX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->fdesc.flash_len == 0x14) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x100000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (xp->fdesc.flash_len == 0x15) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x200000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ATMEL_FLASH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ATMEL_FLASHID_1024K:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x100000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.write_disable_bits = 0xbc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.unprotect_sector_cmd = 0x39;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.protect_sector_cmd = 0x36;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case WINBOND_FLASH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case WINBOND_FLASHID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->fdesc.flash_len == 0x15) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x200000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (xp->fdesc.flash_len == 0x16) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x400000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (xp->fdesc.flash_len == 0x17) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x800000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case INTEL_FLASH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (xp->fdesc.flash_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case INTEL_FLASHID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->fdesc.flash_len == 0x11) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x200000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (xp->fdesc.flash_len == 0x12) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x400000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (xp->fdesc.flash_len == 0x13) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x800000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Try flash table later. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (rval != QL_SUCCESS && CFG_IST(ha, CFG_CTRL_24258081)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "no default id\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (QL_SUCCESS);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hack for non std 2312 and 6312 boards. hardware people need to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * use either the 128k flash chip (original), or something larger.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For driver purposes, we'll treat it as a 128k flash chip.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ha->device_id == 0x2312 || ha->device_id == 0x6312 ||
db5b5f1e7e8c59712dae4a0b5c55ecee0e4c1bfcGarrett D'Amore ha->device_id == 0x2322 || ha->device_id == 0x6322) &&
db5b5f1e7e8c59712dae4a0b5c55ecee0e4c1bfcGarrett D'Amore (xp->fdesc.flash_size > 0x20000) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (CFG_IST(ha, CFG_SBUS_CARD) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "chip exceeds max size: %xh, using 128k\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size = 0x20000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "man_id=%xh, flash_id=%xh, size=%xh\n",
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard xp->fdesc.flash_manuf, xp->fdesc.flash_id,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "unsupported mfr / type: man_id=%xh, flash_id=%xh\n",
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard xp->fdesc.flash_manuf, xp->fdesc.flash_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_flash_fcode_load
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Loads fcode data into flash from application.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: user buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * size: user buffer size.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_flash_fcode_load(ql_adapter_state_t *ha, void *bp, uint32_t bsize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *bfp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bsize > xp->fdesc.flash_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, bufsize: %xh, flash size: %xh\n", bsize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((bfp = (uint8_t *)kmem_zalloc(bsize, KM_SLEEP)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ENOMEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin(bp, bfp, bsize, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (ql_load_fcode(ha, bfp, bsize, 0) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, load_fcode\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Reset caches on all adapter instances. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_update_flash_caches(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(bfp, bsize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_load_fcode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Loads fcode in to flash.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dp: data pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * size: data length.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * addr: flash byte address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardint
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardql_load_fcode(ql_adapter_state_t *ha, uint8_t *dp, uint32_t size, uint32_t addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (ql_24xx_load_flash(ha, dp, size, addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_SBUS_CARD)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sbus has an additional check to make
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sure they don't brick the HBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dp[0] != 0xf1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, incorrect fcode for sbus\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (QL_FUNCTION_PARAMETER_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GLOBAL_HW_LOCK();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Flash Read/Write. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_flash_enable(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Erase flash prior to write. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_erase_flash(ha, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Write fcode data to flash. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < (uint32_t)size; cnt++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allow other system activity. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cnt % 0x1000 == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte drv_usecwait(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard rval = ql_program_flash_address(ha, addr++, *dp++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_flash_disable(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GLOBAL_HW_UNLOCK();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, rval=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql_flash_fcode_dump
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps FLASH to application.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: user buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bsize: user buffer size
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * faddr: flash byte address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_flash_fcode_dump(ql_adapter_state_t *ha, void *bp, uint32_t bsize,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard uint32_t faddr, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *bfp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* adjust max read size to flash size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bsize > xp->fdesc.flash_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "adjusting req=%xh, max=%xh\n", bsize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bsize = xp->fdesc.flash_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((bfp = (uint8_t *)kmem_zalloc(bsize, KM_SLEEP)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ENOMEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dump Flash fcode. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard rval = ql_dump_fcode(ha, bfp, bsize, faddr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, dump_fcode = %x\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (ddi_copyout(bfp, bp, bsize, mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(bfp, bsize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_dump_fcode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps fcode from flash.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dp: data pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * size: data length in bytes.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * startpos: starting position in flash (byte address).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_dump_fcode(ql_adapter_state_t *ha, uint8_t *dp, uint32_t size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t startpos)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cnt, data, addr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint8_t bp[4], *src;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard int fp_rval, rval = QL_SUCCESS;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard dma_mem_t mem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure startpos+size doesn't exceed flash */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (size + startpos > ha->xioctl->fdesc.flash_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "exceeded flash range, sz=%xh, stp=%xh, flsz=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size, startpos, ha->xioctl->fdesc.flash_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (QL_FUNCTION_PARAMETER_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check start addr is 32 bit aligned for 24xx */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((startpos & 0x3) != 0) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard rval = ql_24xx_read_flash(ha,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_data_addr | startpos >> 2, &data);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (rval != QL_SUCCESS) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "failed2, rval = %xh\n", rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[0] = LSB(LSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[1] = MSB(LSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[2] = LSB(MSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[3] = MSB(MSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard while (size && startpos & 0x3) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *dp++ = bp[startpos & 0x3];
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard startpos++;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard size--;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (size == 0) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done2\n",
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* adjust 24xx start addr for 32 bit words */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard addr = startpos / 4 | ha->flash_data_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard bzero(&mem, sizeof (dma_mem_t));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Check for Fast page is supported */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if ((ha->pha->task_daemon_flags & FIRMWARE_UP) &&
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (CFG_IST(ha, CFG_CTRL_2581))) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard fp_rval = QL_SUCCESS;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Setup DMA buffer. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard rval = ql_get_dma_mem(ha, &mem, size,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard LITTLE_ENDIAN_DMA, QL_DMA_DATA_ALIGN);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (rval != QL_SUCCESS) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard EL(ha, "failed, ql_get_dma_mem=%xh\n",
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard rval);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard return (ENOMEM);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard fp_rval = QL_NOT_SUPPORTED;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GLOBAL_HW_LOCK();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable Flash Read/Write. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_flash_enable(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Read fcode data from flash. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard while (size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allow other system activity. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (size % 0x1000 == 0) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_delay(ha, 100000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (fp_rval == QL_SUCCESS && (addr & 0x3f) == 0) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cnt = (size + 3) >> 2;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard fp_rval = ql_rd_risc_ram(ha, addr,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard mem.cookie.dmac_laddress, cnt);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (fp_rval == QL_SUCCESS) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard for (src = mem.bp; size; size--) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *dp++ = *src++;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard addr += cnt;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard continue;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard rval = ql_24xx_read_flash(ha, addr++,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard &data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[0] = LSB(LSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[1] = MSB(LSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[2] = LSB(MSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard bp[3] = MSB(MSW(data));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard for (cnt = 0; size && cnt < 4; size--) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *dp++ = bp[cnt++];
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *dp++ = (uint8_t)ql_read_flash_byte(ha, startpos++);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard size--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_flash_disable(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GLOBAL_HW_UNLOCK();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (mem.dma_handle != NULL) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_free_dma_resource(ha, &mem);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, rval = %xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_program_flash_address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Program flash address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * addr: flash byte address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data: data to be written to flash.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_program_flash_address(ql_adapter_state_t *ha, uint32_t addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t data)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Write Program Command Sequence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_SBUS_CARD)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0xa0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, addr, data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0xaa);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x2aaa, 0x55);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, 0x5555, 0xa0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_write_flash_byte(ha, addr, data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for write to complete. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_poll_flash(ha, addr, data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, rval=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_set_rnid_parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set RNID parameters.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: User space CT arguments pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_set_rnid_parameters(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_SET_RNID_REQ tmp_set;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_RNID_DATA *tmp_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0; /* NO response to caller. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen != sizeof (EXT_SET_RNID_REQ)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parameter error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, RequestLen < EXT_SET_RNID_REQ, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ddi_copyin((void*)(uintptr_t)cmd->RequestAdr, &tmp_set,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate memory for command. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf = kmem_zalloc(sizeof (EXT_RNID_DATA), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_buf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_get_rnid_params(ha, sizeof (EXT_RNID_DATA),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)tmp_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_rnid_params_mbx=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, sizeof (EXT_RNID_DATA));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now set the requested params. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tmp_set.IPVersion, tmp_buf->IPVersion, 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tmp_set.UDPPortNumber, tmp_buf->UDPPortNumber, 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tmp_set.IPAddress, tmp_buf->IPAddress, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_set_rnid_params(ha, sizeof (EXT_RNID_DATA),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)tmp_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, set_rnid_params_mbx=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, sizeof (EXT_RNID_DATA));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_rnid_parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get RNID parameters.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: User space CT arguments pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_rnid_parameters(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_RNID_DATA *tmp_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate memory for command. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_buf = kmem_zalloc(sizeof (EXT_RNID_DATA), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_buf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_get_rnid_params(ha, sizeof (EXT_RNID_DATA),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)tmp_buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_rnid_params_mbx=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, sizeof (EXT_RNID_DATA));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy the response */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_send_buffer_data((caddr_t)tmp_buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_RNID_DATA), mode) != sizeof (EXT_RNID_DATA)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_RNID_DATA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(tmp_buf, sizeof (EXT_RNID_DATA));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_reset_statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_RST_STATISTICS subcommand. of EXT_CC_SET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_reset_statistics(ql_adapter_state_t *ha, EXT_IOCTL *cmd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DRIVER_SUSPENDED(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (QL_FUNCTION_SUSPENDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_reset_link_status(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, reset_link_status_mbx=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TASK_DAEMON_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IosRequested = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->BytesRequested = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOInputRequests = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOOutputRequests = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOControlRequests = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOInputMByteCnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOOutputMByteCnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOOutputByteCnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOInputByteCnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TASK_DAEMON_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->ControllerErrorCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->DeviceErrorCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->TotalLipResets = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->TotalInterrupts = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_GET_STATISTICS subcommand. of EXT_CC_GET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_statistics(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_HBA_PORT_STAT ps = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_stats_t *ls;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int retry = 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ha->task_daemon_flags &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ABORT_ISP_ACTIVE | LOOP_RESYNC_ACTIVE | DRIVER_STALL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_delay(ha, 10000000); /* 10 second delay */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retry--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (retry == 0) { /* effectively 100 seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate memory for command. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ls = kmem_zalloc(sizeof (ql_link_stats_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ls == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I think these are supposed to be port statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the loop ID or port ID should be in cmd->Instance.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_get_status_counts(ha, (uint16_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->task_daemon_flags & LOOP_DOWN ? 0xFF : ha->loop_id),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (ql_link_stats_t), (caddr_t)ls, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_link_status=%xh, id=%xh\n", rval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.ControllerErrorCount = xp->ControllerErrorCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.DeviceErrorCount = xp->DeviceErrorCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.IoCount = (uint32_t)(xp->IOInputRequests +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOOutputRequests + xp->IOControlRequests);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.MBytesCount = (uint32_t)(xp->IOInputMByteCnt +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->IOOutputMByteCnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.LipResetCount = xp->TotalLipResets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.InterruptCount = xp->TotalInterrupts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.LinkFailureCount = LE_32(ls->link_fail_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.LossOfSyncCount = LE_32(ls->sync_loss_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.LossOfSignalsCount = LE_32(ls->signal_loss_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.PrimitiveSeqProtocolErrorCount = LE_32(ls->prot_err_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.InvalidTransmissionWordCount = LE_32(ls->inv_xmit_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.InvalidCRCCount = LE_32(ls->inv_crc_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ddi_copyout((void *)&ps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_HBA_PORT_STAT), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_HBA_PORT_STAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ls, sizeof (ql_link_stats_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_statistics_fc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_GET_FC_STATISTICS subcommand. of EXT_CC_GET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_statistics_fc(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_HBA_PORT_STAT ps = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_stats_t *ls;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t qlnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEST_ADDR pextdestaddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int retry = 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)&pextdestaddr, sizeof (EXT_DEST_ADDR), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnt = QLNT_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = pextdestaddr.DestAddr.WWPN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, name[0], name[1], name[2], name[3], name[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[5], name[6], name[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, name, qlnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq == NULL || !VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, fc_port not found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ha->task_daemon_flags &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ABORT_ISP_ACTIVE | LOOP_RESYNC_ACTIVE | DRIVER_STALL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_delay(ha, 10000000); /* 10 second delay */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retry--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (retry == 0) { /* effectively 100 seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, LOOP_NOT_READY\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate memory for command. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ls = kmem_zalloc(sizeof (ql_link_stats_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ls == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_get_link_status(ha, tq->loop_id, sizeof (ql_link_stats_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)ls, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_link_status=%xh, d_id=%xh\n", rval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq->d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.LinkFailureCount = LE_32(ls->link_fail_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.LossOfSyncCount = LE_32(ls->sync_loss_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.LossOfSignalsCount = LE_32(ls->signal_loss_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.PrimitiveSeqProtocolErrorCount = LE_32(ls->prot_err_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.InvalidTransmissionWordCount = LE_32(ls->inv_xmit_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ps.InvalidCRCCount = LE_32(ls->inv_crc_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ddi_copyout((void *)&ps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_HBA_PORT_STAT), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_HBA_PORT_STAT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ls, sizeof (ql_link_stats_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_statistics_fc4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_GET_FC_STATISTICS subcommand. of EXT_CC_GET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_statistics_fc4(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_HBA_FC4STATISTICS fc4stats = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc4stats.InputRequests = xp->IOInputRequests;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc4stats.OutputRequests = xp->IOOutputRequests;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc4stats.ControlRequests = xp->IOControlRequests;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc4stats.InputMegabytes = xp->IOInputMByteCnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc4stats.OutputMegabytes = xp->IOOutputMByteCnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyout((void *)&fc4stats,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_HBA_FC4STATISTICS), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_HBA_FC4STATISTICS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_set_led_state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SET_BEACON_STATE subcommand of EXT_CC_SET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_set_led_state(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_BEACON_CONTROL bstate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->RequestLen < sizeof (EXT_BEACON_CONTROL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_BEACON_CONTROL);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "done - failed, RequestLen < EXT_BEACON_CONTROL,"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Len=%xh\n", cmd->RequestLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->device_id < 0x2300) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "done - failed, Invalid function for HBA model\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ddi_copyin((void*)(uintptr_t)cmd->RequestAdr, &bstate,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->RequestLen, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "done - failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (bstate.State) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_DEF_GRN_BLINK_OFF: /* turn beacon off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->ledstate.BeaconState == BEACON_OFF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not quite an error -- LED state is already off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "LED off request -- LED is already off\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->ledstate.BeaconState = BEACON_OFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->ledstate.LEDflags = LED_ALL_OFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = ql_wrapup_led(ha)) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_DEF_GRN_BLINK_ON: /* turn beacon on */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->ledstate.BeaconState == BEACON_ON) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not quite an error -- LED state is already on */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "LED on request - LED is already on\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = ql_setup_led(ha)) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->ledstate.LEDflags = LED_YELLOW_24 | LED_AMBER_24;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->ledstate.LEDflags = LED_GREEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xp->ledstate.BeaconState = BEACON_ON;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, unknown state request %xh\n", bstate.State);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_led_state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_GET_BEACON_STATE subcommand of EXT_CC_GET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_led_state(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_BEACON_CONTROL bstate = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_BEACON_CONTROL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_BEACON_CONTROL);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "done - failed, ResponseLen < EXT_BEACON_CONTROL,"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Len=%xh\n", cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->device_id < 0x2300) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "done - failed, Invalid function for HBA model\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->task_daemon_flags & ABORT_ISP_ACTIVE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "done - failed, isp abort active\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* inform the user of the current beacon state (off or on) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bstate.State = xp->ledstate.BeaconState;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyout((void *)&bstate,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)cmd->ResponseAdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_BEACON_CONTROL), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_BEACON_CONTROL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_blink_led
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Determine the next state of the LED and drive it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_blink_led(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t nextstate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_xioctl_t *xp = ha->xioctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xp->ledstate.BeaconState == BEACON_ON) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* determine the next led state */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nextstate = (xp->ledstate.LEDflags) &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (~(RD32_IO_REG(ha, gpiod)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nextstate = (xp->ledstate.LEDflags) &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (~(RD16_IO_REG(ha, gpiod)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* turn the led on or off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_drive_led(ha, nextstate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_drive_led
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * drive the led's as determined by LEDflags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LEDflags: LED flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel/Interrupt context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_drive_led(ql_adapter_state_t *ha, uint32_t LEDflags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, (CFG_CTRL_2300 | CFG_CTRL_6322))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t gpio_enable, gpio_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup to send new data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_enable = (uint16_t)RD16_IO_REG(ha, gpioe);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_enable = (uint16_t)(gpio_enable | LED_MASK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT16_IO_REG(ha, gpioe, gpio_enable);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read current data and clear out old led data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data = (uint16_t)RD16_IO_REG(ha, gpiod);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data = (uint16_t)(gpio_data & ~LED_MASK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set in the new led data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data = (uint16_t)(gpio_data | LEDflags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* write out the new led data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT16_IO_REG(ha, gpiod, gpio_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t gpio_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup to send new data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data = RD32_IO_REG(ha, gpiod);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data |= LED_MASK_UPDATE_24;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT32_IO_REG(ha, gpiod, gpio_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read current data and clear out old led data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data = RD32_IO_REG(ha, gpiod);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data &= ~LED_MASK_COLORS_24;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set in the new led data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data |= LEDflags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* write out the new led data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT32_IO_REG(ha, gpiod, gpio_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "unsupported HBA: %xh", ha->device_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_setup_led
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup LED for driver control
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel/Interrupt context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_setup_led(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_data_t mr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* decouple the LED control from the fw */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_get_firmware_option(ha, &mr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_firmware_option=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the appropriate options */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mr.mb[1] = (uint16_t)(mr.mb[1] | FO1_DISABLE_GPIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* send it back to the firmware */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_set_firmware_option(ha, &mr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, set_firmware_option=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initally, turn the LED's off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_drive_led(ha, LED_ALL_OFF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_wrapup_led
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return LED control to the firmware
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel/Interrupt context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_wrapup_led(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_data_t mr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Turn all LED's off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_drive_led(ha, LED_ALL_OFF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t gpio_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* disable the LED update mask */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data = RD32_IO_REG(ha, gpiod);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gpio_data &= ~LED_MASK_UPDATE_24;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* write out the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT32_IO_REG(ha, gpiod, gpio_data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* give LED control back to the f/w */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_get_firmware_option(ha, &mr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_firmware_option=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mr.mb[1] = (uint16_t)(mr.mb[1] & ~FO1_DISABLE_GPIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_set_firmware_option(ha, &mr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, set_firmware_option=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_port_summary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_GET_PORT_SUMMARY subcommand. of EXT_CC_GET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The EXT_IOCTL->RequestAdr points to a single
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * UINT32 which identifies the device type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_port_summary(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEVICEDATA dd = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEVICEDATA *uddp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rlen, dev_type, index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEVICEDATAENTRY *uddep, *ddep;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep = &dd.EntryList[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the type of device the requestor is looking for.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We ignore this for now.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)&dev_type, sizeof (dev_type), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Count the number of entries to be returned. Count devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that are offlline, but have been persistently bound.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ha->dev[index].first; link != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_INITIATOR_DEVICE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue; /* Skip this one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd.TotalDevices++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compute the number of entries that can be returned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based upon the size of caller's response buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd.ReturnListEntryCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dd.TotalDevices == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rlen = sizeof (EXT_DEVICEDATA) - sizeof (EXT_DEVICEDATAENTRY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rlen = (uint32_t)(sizeof (EXT_DEVICEDATA) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sizeof (EXT_DEVICEDATAENTRY) * (dd.TotalDevices - 1)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rlen > cmd->ResponseLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, rlen > ResponseLen, rlen=%d, Len=%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rlen, cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uddp = (EXT_DEVICEDATA *)(uintptr_t)cmd->ResponseAdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uddep = &uddp->EntryList[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (index = 0; index < DEVICE_HEAD_LIST_SIZE; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ha->dev[index].first; link != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq->flags & TQF_INITIATOR_DEVICE ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue; /* Skip this one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)ddep, sizeof (EXT_DEVICEDATAENTRY));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->node_name, ddep->NodeWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->port_name, ddep->PortWWN, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->PortID[0] = tq->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->PortID[1] = tq->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->PortID[2] = tq->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->port_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (caddr_t)&ddep->TargetAddress.Target, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->DeviceFlags = tq->flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->LoopID = tq->loop_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): Tgt=%lld, loop=%xh, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wwnn=%02x%02x%02x%02x%02x%02x%02x%02x, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, ddep->TargetAddress.Target,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->LoopID, ddep->NodeWWN[0], ddep->NodeWWN[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->NodeWWN[2], ddep->NodeWWN[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->NodeWWN[4], ddep->NodeWWN[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->NodeWWN[6], ddep->NodeWWN[7],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->PortWWN[0], ddep->PortWWN[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->PortWWN[2], ddep->PortWWN[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->PortWWN[4], ddep->PortWWN[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddep->PortWWN[6], ddep->PortWWN[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyout((void *)ddep, (void *)uddep,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_DEVICEDATAENTRY), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd.ReturnListEntryCount++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uddep++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen += (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_DEVICEDATAENTRY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyout((void *)&dd, (void *)uddp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_DEVICEDATA) - sizeof (EXT_DEVICEDATAENTRY), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout-2\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen += (uint32_t)sizeof (EXT_DEVICEDATAENTRY);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_target_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_SC_GET_TARGET_ID subcommand. of EXT_CC_GET_DATA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_target_id(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t qlnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEST_ADDR extdestaddr = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t wwpn[EXT_DEF_WWN_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void*)wwpn, sizeof (EXT_DEST_ADDR), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qlnt = QLNT_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = wwpn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, name[0], name[1], name[2], name[3], name[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[5], name[6], name[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, name, qlnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq == NULL || !VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, fc_port not found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tq->port_name, (caddr_t)&extdestaddr.DestAddr.ScsiAddr.Target, 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyout((void *)&extdestaddr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void *)(uintptr_t)cmd->ResponseAdr, sizeof (EXT_DEST_ADDR), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_setup_fcache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Populates selected flash sections into the cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Driver must be in stalled state prior to entering or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add code to this function prior to calling ql_setup_flash()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_setup_fcache(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t freadpos = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fw_done = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *head = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *tail = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If we already have populated it, rtn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->fcache != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "buffer already populated\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (QL_SUCCESS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_flash_nvram_defaults(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = ql_setup_flash(ha)) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "unable to setup flash; rval=%xh\n", rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (freadpos != 0xffffffff) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate & populate this node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ftmp = ql_setup_fnode(ha)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "node alloc failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* link in the new node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (head == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte head = tail = ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tail->next = ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tail = ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Do the firmware node first for 24xx/25xx's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fw_done == 0) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard freadpos = ha->flash_fw_addr << 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fw_done = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = ql_dump_fcode(ha, ftmp->buf, FBUFSIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte freadpos)) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, 24xx dump_fcode"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " pos=%xh rval=%xh\n", freadpos, rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* checkout the pci data / format */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_check_pci(ha, ftmp, &freadpos)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "flash header incorrect\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release all resources we have */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ftmp = head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ftmp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tail = ftmp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ftmp->buf, FBUFSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ftmp, sizeof (ql_fcache_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ftmp = tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "failed, done\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->fcache = head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_update_fcache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * re-populates updated flash into the fcache. If
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcache does not exist (e.g., flash was empty/invalid on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * boot), this routine will create and the populate it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * *bpf = Pointer to flash buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bsize = Size of flash buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardvoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_update_fcache(ql_adapter_state_t *ha, uint8_t *bfp, uint32_t bsize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = QL_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t freadpos = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fw_done = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *head = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *tail = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (freadpos != 0xffffffff) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate & populate this node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ftmp = ql_setup_fnode(ha)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "node alloc failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* link in the new node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (head == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte head = tail = ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tail->next = ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tail = ftmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Do the firmware node first for 24xx's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fw_done == 0) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard freadpos = ha->flash_fw_addr << 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fw_done = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read in first FBUFSIZE bytes of this flash section */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (freadpos+FBUFSIZE > bsize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "passed buffer too small; fr=%xh, bsize=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte freadpos, bsize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(bfp+freadpos, ftmp->buf, FBUFSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* checkout the pci data / format */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_check_pci(ha, ftmp, &freadpos)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "flash header incorrect\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * release all resources we have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_rel(head);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "failed, done\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Release previous fcache resources and update with new
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_rel(ha->fcache);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->fcache = head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CACHE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_setup_fnode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocates fcache node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node = point to allocated fcache node (NULL = failed)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Driver must be in stalled state prior to entering or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add code to this function prior to calling ql_setup_flash()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ql_fcache_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_setup_fnode(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *fnode = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fnode = (ql_fcache_t *)(kmem_zalloc(sizeof (ql_fcache_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KM_SLEEP))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "fnode alloc failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fnode = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((fnode->buf = (uint8_t *)(kmem_zalloc(FBUFSIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KM_SLEEP))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "buf alloc failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(fnode, sizeof (ql_fcache_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fnode = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fnode->buflen = FBUFSIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fnode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_fcache_rel
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Releases the fcache resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * head = Pointer to fcache linked list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_fcache_rel(ql_fcache_t *head)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *ftmp = head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_fcache_t *tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release all resources we have */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ftmp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tail = ftmp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ftmp->buf, FBUFSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(ftmp, sizeof (ql_fcache_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ftmp = tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard/*
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql_update_flash_caches
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Updates driver flash caches
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Input:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ha: adapter state pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Context:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Kernel context.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardql_update_flash_caches(ql_adapter_state_t *ha)
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard uint32_t len;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_link_t *link;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_adapter_state_t *ha2;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Get base path length. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard for (len = (uint32_t)strlen(ha->devpath); len; len--) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ha->devpath[len] == ',' ||
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->devpath[len] == '@') {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Reset fcache on all adapter instances. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard for (link = ql_hba.first; link != NULL; link = link->next) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha2 = link->base_address;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (strncmp(ha->devpath, ha2->devpath, len) != 0) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard continue;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard CACHE_LOCK(ha2);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_fcache_rel(ha2->fcache);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard ha2->fcache = NULL;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ha2->vcache != NULL) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_free(ha2->vcache, QL_24XX_VPD_SIZE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha2->vcache = NULL;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard CACHE_UNLOCK(ha2);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (void) ql_setup_fcache(ha2);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard}
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_fbuf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Search the fcache list for the type specified
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fptr = Pointer to fcache linked list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ftype = Type of image to be returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pointer to ql_fcache_t.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL means not found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_fcache_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_fbuf(ql_fcache_t *fptr, uint32_t ftype)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (fptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* does this image meet criteria? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ftype & fptr->type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fptr = fptr->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_check_pci
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * checks the passed buffer for a valid pci signature and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * expected (and in range) pci length values.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For firmware type, a pci header is added since the image in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the flash does not have one (!!!).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On successful pci check, nextpos adjusted to next pci header.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -1 --> last pci image
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 --> pci header valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1 --> pci header invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_check_pci(ql_adapter_state_t *ha, ql_fcache_t *fcache, uint32_t *nextpos)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pci_header_t *pcih;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pci_data_t *pcid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t doff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *pciinfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fcache != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pciinfo = fcache->buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, null fcache ptr passed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pciinfo == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, null pciinfo ptr passed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_SBUS_CARD)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte caddr_t bufp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pciinfo[0] != SBUS_CODE_FCODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, unable to detect sbus fcode\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->type = FTYPE_FCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*LINTED [Solaris DDI_DEV_T_ANY Lint error]*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_getlongprop(DDI_DEV_T_ANY, ha->dip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PROP_LEN_AND_VAL_ALLOC | DDI_PROP_DONTPASS |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_PROP_CANSLEEP, "version", (caddr_t)&bufp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (int *)&len) == DDI_PROP_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(fcache->verstr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FCHBA_OPTION_ROM_VERSION_LEN, "%s", bufp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(bufp, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *nextpos = 0xffffffff;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): CFG_SBUS_CARD, done\n",
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (*nextpos == ha->flash_fw_addr << 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pci_header_t fwh = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pci_data_t fwd = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *buf, *bufp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build a pci header for the firmware module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((buf = (uint8_t *)(kmem_zalloc(FBUFSIZE, KM_SLEEP))) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, unable to allocate buffer\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwh.signature[0] = PCI_HEADER0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwh.signature[1] = PCI_HEADER1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwh.dataoffset[0] = LSB(sizeof (pci_header_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwh.dataoffset[1] = MSB(sizeof (pci_header_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwd.signature[0] = 'P';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwd.signature[1] = 'C';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwd.signature[2] = 'I';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwd.signature[3] = 'R';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwd.codetype = PCI_CODE_FW;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwd.pcidatalen[0] = LSB(sizeof (pci_data_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fwd.pcidatalen[1] = MSB(sizeof (pci_data_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufp = buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&fwh, bufp, sizeof (pci_header_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufp += sizeof (pci_header_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&fwd, bufp, sizeof (pci_data_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bufp += sizeof (pci_data_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(fcache->buf, bufp, (FBUFSIZE - sizeof (pci_header_t) -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (pci_data_t)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(buf, fcache->buf, FBUFSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->type = FTYPE_FW;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(fcache->verstr, FCHBA_OPTION_ROM_VERSION_LEN,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard "%d.%02d.%02d", fcache->buf[19], fcache->buf[23],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->buf[27]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_81XX)) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *nextpos = 0x200000;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_8021)) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *nextpos = 0x80000;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *nextpos = 0;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(buf, FBUFSIZE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): FTYPE_FW, done\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get to the pci header image length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pcih = (pci_header_t *)pciinfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doff = pcih->dataoffset[0] | (pcih->dataoffset[1] << 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* some header section sanity check */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pcih->signature[0] != PCI_HEADER0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pcih->signature[1] != PCI_HEADER1 || doff > 50) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "buffer format error: s0=%xh, s1=%xh, off=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pcih->signature[0], pcih->signature[1], doff);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pcid = (pci_data_t *)(pciinfo + doff);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* a slight sanity data section check */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pcid->signature[0] != 'P' || pcid->signature[1] != 'C' ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pcid->signature[2] != 'I' || pcid->signature[3] != 'R') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, data sig mismatch!\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pcid->indicator == PCI_IND_LAST_IMAGE) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): last image\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_flash_layout_table(ha, *nextpos +
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (pcid->imagelength[0] | (pcid->imagelength[1] <<
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard 8)) * PCI_SECTOR_SIZE);
c1374a13e412c4ec42cba867e57347a0e049a822Surya Prakki (void) ql_24xx_flash_desc(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *nextpos = 0xffffffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* adjust the next flash read start position */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *nextpos += (pcid->imagelength[0] |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pcid->imagelength[1] << 8)) * PCI_SECTOR_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (pcid->codetype) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PCI_CODE_X86PC:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->type = FTYPE_BIOS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PCI_CODE_FCODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->type = FTYPE_FCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PCI_CODE_EFI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->type = FTYPE_EFI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PCI_CODE_HPPA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->type = FTYPE_HPPA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcache->type = FTYPE_UNKNOWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(fcache->verstr, FCHBA_OPTION_ROM_VERSION_LEN,
f33c1cdb6d38eb0715f03cf492f31c3d4d395c98Daniel Beauregard "%d.%02d", pcid->revisionlevel[1], pcid->revisionlevel[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard/*
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql_flash_layout_table
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Obtains flash addresses from table
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Input:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ha: adapter state pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * flt_paddr: flash layout pointer address.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Context:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Kernel context.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardql_flash_layout_table(ql_adapter_state_t *ha, uint32_t flt_paddr)
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_flt_ptr_t *fptr;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint8_t *bp;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard int rval;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard uint32_t len, faddr, cnt;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard uint16_t chksum, w16;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Process flash layout table header */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard len = sizeof (ql_flt_ptr_t);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((bp = kmem_zalloc(len, KM_SLEEP)) == NULL) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "kmem_zalloc=null\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Process pointer to flash layout table */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((rval = ql_dump_fcode(ha, bp, len, flt_paddr)) != QL_SUCCESS) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "fptr dump_flash pos=%xh, status=%xh\n", flt_paddr,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard rval);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard kmem_free(bp, len);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard fptr = (ql_flt_ptr_t *)bp;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Verify pointer to flash layout table. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard for (chksum = 0, cnt = 0; cnt < len; cnt += 2) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard w16 = (uint16_t)CHAR_TO_SHORT(bp[cnt], bp[cnt + 1]);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard chksum += w16;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (chksum != 0 || fptr->sig[0] != 'Q' || fptr->sig[1] != 'F' ||
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard fptr->sig[2] != 'L' || fptr->sig[3] != 'T') {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "ptr chksum=%xh, sig=%c%c%c%c\n", chksum, fptr->sig[0],
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard fptr->sig[1], fptr->sig[2], fptr->sig[3]);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard kmem_free(bp, len);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard faddr = CHAR_TO_LONG(fptr->addr[0], fptr->addr[1], fptr->addr[2],
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard fptr->addr[3]);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard kmem_free(bp, len);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_process_flt(ha, faddr);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard}
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard/*
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ql_process_flt
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Obtains flash addresses from flash layout table
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard *
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Input:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ha: adapter state pointer.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * faddr: flash layout table byte address.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard *
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Context:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Kernel context.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardql_process_flt(ql_adapter_state_t *ha, uint32_t faddr)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard{
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_flt_hdr_t *fhdr;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_flt_region_t *frgn;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint8_t *bp, *eaddr, nv_rg, vpd_rg;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard int rval;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint32_t len, cnt, fe_addr;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint16_t chksum, w16;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started faddr=%xh\n", ha->instance, faddr);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Process flash layout table header */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((bp = kmem_zalloc(FLASH_LAYOUT_TABLE_SIZE, KM_SLEEP)) == NULL) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "kmem_zalloc=null\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard fhdr = (ql_flt_hdr_t *)bp;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Process flash layout table. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if ((rval = ql_dump_fcode(ha, bp, FLASH_LAYOUT_TABLE_SIZE, faddr)) !=
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_SUCCESS) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "fhdr dump_flash pos=%xh, status=%xh\n", faddr, rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_free(bp, FLASH_LAYOUT_TABLE_SIZE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Verify flash layout table. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard len = (uint32_t)(CHAR_TO_SHORT(fhdr->len[0], fhdr->len[1]) +
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard sizeof (ql_flt_hdr_t) + sizeof (ql_flt_region_t));
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (len > FLASH_LAYOUT_TABLE_SIZE) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard chksum = 0xffff;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard for (chksum = 0, cnt = 0; cnt < len; cnt += 2) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard w16 = (uint16_t)CHAR_TO_SHORT(bp[cnt], bp[cnt + 1]);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard chksum += w16;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard w16 = CHAR_TO_SHORT(fhdr->version[0], fhdr->version[1]);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (chksum != 0 || w16 != 1) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "table chksum=%xh, version=%d\n", chksum, w16);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_free(bp, FLASH_LAYOUT_TABLE_SIZE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard eaddr = bp + len;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Process Function/Port Configuration Map. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard nv_rg = vpd_rg = 0;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_8021)) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint16_t i;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint8_t *mbp = eaddr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_fp_cfg_map_t *cmp = (ql_fp_cfg_map_t *)mbp;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard len = (uint32_t)(CHAR_TO_SHORT(cmp->hdr.len[0],
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.len[1]));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (len > FLASH_LAYOUT_TABLE_SIZE) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard chksum = 0xffff;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard for (chksum = 0, cnt = 0; cnt < len; cnt += 2) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard w16 = (uint16_t)CHAR_TO_SHORT(mbp[cnt],
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard mbp[cnt + 1]);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard chksum += w16;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard w16 = CHAR_TO_SHORT(cmp->hdr.version[0], cmp->hdr.version[1]);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (chksum != 0 || w16 != 1 ||
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.Signature[0] != 'F' ||
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.Signature[1] != 'P' ||
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.Signature[2] != 'C' ||
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.Signature[3] != 'M') {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard EL(ha, "cfg_map chksum=%xh, version=%d, "
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard "sig=%c%c%c%c\n", chksum, w16,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.Signature[0], cmp->hdr.Signature[1],
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.Signature[2], cmp->hdr.Signature[3]);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cnt = (uint16_t)
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (CHAR_TO_SHORT(cmp->hdr.NumberEntries[0],
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->hdr.NumberEntries[1]));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Locate entry for function. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard for (i = 0; i < cnt; i++) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (cmp->cfg[i].FunctionType == FT_FC &&
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->cfg[i].FunctionNumber[0] ==
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->function_number &&
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmp->cfg[i].FunctionNumber[1] == 0) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard nv_rg = cmp->cfg[i].ConfigRegion;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard vpd_rg = cmp->cfg[i].VpdRegion;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (nv_rg == 0 || vpd_rg == 0) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard EL(ha, "cfg_map nv_rg=%d, vpd_rg=%d\n", nv_rg,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard vpd_rg);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard nv_rg = vpd_rg = 0;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Process flash layout table regions */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard for (frgn = (ql_flt_region_t *)(bp + sizeof (ql_flt_hdr_t));
f33c1cdb6d38eb0715f03cf492f31c3d4d395c98Daniel Beauregard (uint8_t *)frgn < eaddr; frgn++) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard faddr = CHAR_TO_LONG(frgn->beg_addr[0], frgn->beg_addr[1],
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard frgn->beg_addr[2], frgn->beg_addr[3]);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard faddr >>= 2;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard fe_addr = CHAR_TO_LONG(frgn->end_addr[0], frgn->end_addr[1],
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard frgn->end_addr[2], frgn->end_addr[3]);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard fe_addr >>= 2;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard switch (frgn->region) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case FLASH_8021_BOOTLOADER_REGION:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->bootloader_addr = faddr;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->bootloader_size = (fe_addr - faddr) + 1;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): bootloader_addr=%xh, "
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard "size=%xh\n", ha->instance, faddr,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->bootloader_size);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_FW_REGION:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case FLASH_8021_FW_REGION:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = faddr;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_fw_size = (fe_addr - faddr) + 1;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_fw_addr=%xh, "
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard "size=%xh\n", ha->instance, faddr,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_fw_size);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_GOLDEN_FW_REGION:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case FLASH_8021_GOLDEN_FW_REGION:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_golden_fw_addr = faddr;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_golden_fw_addr=%xh\n",
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->instance, faddr);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard case FLASH_8021_VPD_REGION:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (!vpd_rg || vpd_rg == FLASH_8021_VPD_REGION) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flash_vpd_addr = faddr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): 8021_flash_vpd_"
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard "addr=%xh\n", ha->instance, faddr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_VPD_0_REGION:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (vpd_rg) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (vpd_rg == FLASH_VPD_0_REGION) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flash_vpd_addr = faddr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): vpd_rg "
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard "flash_vpd_addr=%xh\n",
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->instance, faddr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else if (!(ha->flags & FUNCTION_1) &&
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard !(CFG_IST(ha, CFG_CTRL_8021))) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = faddr;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_vpd_addr=%xh"
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard "\n", ha->instance, faddr);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_NVRAM_0_REGION:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (nv_rg) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (nv_rg == FLASH_NVRAM_0_REGION) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ADAPTER_STATE_LOCK(ha);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flags &= ~FUNCTION_1;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ADAPTER_STATE_UNLOCK(ha);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flash_nvram_addr = faddr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): nv_rg "
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard "flash_nvram_addr=%xh\n",
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->instance, faddr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else if (!(ha->flags & FUNCTION_1)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = faddr;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_nvram_addr="
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard "%xh\n", ha->instance, faddr);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_VPD_1_REGION:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (vpd_rg) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (vpd_rg == FLASH_VPD_1_REGION) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flash_vpd_addr = faddr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): vpd_rg "
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard "flash_vpd_addr=%xh\n",
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->instance, faddr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else if (ha->flags & FUNCTION_1 &&
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard !(CFG_IST(ha, CFG_CTRL_8021))) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = faddr;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_vpd_addr=%xh"
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard "\n", ha->instance, faddr);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_NVRAM_1_REGION:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (nv_rg) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (nv_rg == FLASH_NVRAM_1_REGION) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ADAPTER_STATE_LOCK(ha);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flags |= FUNCTION_1;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ADAPTER_STATE_UNLOCK(ha);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->flash_nvram_addr = faddr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): nv_rg "
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard "flash_nvram_addr=%xh\n",
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ha->instance, faddr);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else if (ha->flags & FUNCTION_1) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = faddr;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_nvram_addr="
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard "%xh\n", ha->instance, faddr);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_DESC_TABLE_REGION:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!(CFG_IST(ha, CFG_CTRL_8021))) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_desc_addr = faddr;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_desc_addr="
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard "%xh\n", ha->instance, faddr);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_ERROR_LOG_0_REGION:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (!(ha->flags & FUNCTION_1)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = faddr;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_errlog_addr="
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard "%xh\n", ha->instance, faddr);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case FLASH_ERROR_LOG_1_REGION:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ha->flags & FUNCTION_1) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = faddr;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): flash_errlog_addr="
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard "%xh\n", ha->instance, faddr);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard default:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_free(bp, FLASH_LAYOUT_TABLE_SIZE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard}
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard/*
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql_flash_nvram_defaults
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Flash default addresses.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Input:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ha: adapter state pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Returns:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql local function return status code.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Context:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Kernel context.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardql_flash_nvram_defaults(ql_adapter_state_t *ha)
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ha->flags & FUNCTION_1) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (CFG_IST(ha, CFG_CTRL_2300)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_2300_FUNC1_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_2300_FIRMWARE_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_2422)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_2400_FUNC1_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = VPD_2400_FUNC1_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = FLASH_2400_ERRLOG_START_ADDR_1;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_desc_addr = FLASH_2400_DESCRIPTOR_TABLE;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_2400_FIRMWARE_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_25XX)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_2500_FUNC1_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = VPD_2500_FUNC1_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = FLASH_2500_ERRLOG_START_ADDR_1;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_desc_addr = FLASH_2500_DESCRIPTOR_TABLE;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_2500_FIRMWARE_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_81XX)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_data_addr = FLASH_8100_DATA_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_8100_FUNC1_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = VPD_8100_FUNC1_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = FLASH_8100_ERRLOG_START_ADDR_1;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_desc_addr = FLASH_8100_DESCRIPTOR_TABLE;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_8100_FIRMWARE_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_8021)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_data_addr = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_nvram_addr = NVRAM_8021_FUNC1_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_vpd_addr = VPD_8021_FUNC1_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_errlog_start = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_desc_addr = FLASH_8021_DESCRIPTOR_TABLE;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_fw_addr = FLASH_8021_FIRMWARE_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_fw_size = FLASH_8021_FIRMWARE_SIZE;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->bootloader_addr = FLASH_8021_BOOTLOADER_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->bootloader_size = FLASH_8021_BOOTLOADER_SIZE;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (CFG_IST(ha, CFG_CTRL_2200)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_2200_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_2200_FIRMWARE_ADDR;
13b0a758fcfb7baa02b11fa179e785c23927c95cDaniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_2300) ||
13b0a758fcfb7baa02b11fa179e785c23927c95cDaniel Beauregard (CFG_IST(ha, CFG_CTRL_6322))) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_2300_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_2300_FIRMWARE_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_2422)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_2400_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = VPD_2400_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = FLASH_2400_ERRLOG_START_ADDR_0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_desc_addr = FLASH_2400_DESCRIPTOR_TABLE;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_2400_FIRMWARE_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_25XX)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_data_addr = FLASH_24_25_DATA_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_2500_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = VPD_2500_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = FLASH_2500_ERRLOG_START_ADDR_0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_desc_addr = FLASH_2500_DESCRIPTOR_TABLE;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_2500_FIRMWARE_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_81XX)) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_data_addr = FLASH_8100_DATA_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_nvram_addr = NVRAM_8100_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_vpd_addr = VPD_8100_FUNC0_ADDR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_errlog_start = FLASH_8100_ERRLOG_START_ADDR_0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_desc_addr = FLASH_8100_DESCRIPTOR_TABLE;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->flash_fw_addr = FLASH_8100_FIRMWARE_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else if (CFG_IST(ha, CFG_CTRL_8021)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_data_addr = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_nvram_addr = NVRAM_8021_FUNC0_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_vpd_addr = VPD_8021_FUNC0_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_errlog_start = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_desc_addr = FLASH_8021_DESCRIPTOR_TABLE;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_fw_addr = FLASH_8021_FIRMWARE_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->flash_fw_size = FLASH_8021_FIRMWARE_SIZE;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->bootloader_addr = FLASH_8021_BOOTLOADER_ADDR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->bootloader_size = FLASH_8021_BOOTLOADER_SIZE;
13b0a758fcfb7baa02b11fa179e785c23927c95cDaniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "unassigned flash fn0 addr: %x\n",
13b0a758fcfb7baa02b11fa179e785c23927c95cDaniel Beauregard ha->device_id);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard}
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_sfp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns sfp data to sdmapi caller
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_sfp(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if ((CFG_IST(ha, CFG_CTRL_24258081)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid request for HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < QL_24XX_SFP_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = QL_24XX_SFP_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < SFP len, len passed=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dump SFP data in user buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ql_dump_sfp(ha, (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, copy error\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_dump_sfp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps SFP.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_dump_sfp(ql_adapter_state_t *ha, void *bp, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem_t mem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval2, rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dxfer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get memory for SFP. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval2 = ql_get_dma_mem(ha, &mem, 64, LITTLE_ENDIAN_DMA,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard QL_DMA_DATA_ALIGN)) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ql_get_dma_mem=%xh\n", rval2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < QL_24XX_SFP_SIZE; cnt += mem.size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval2 = ql_read_sfp(ha, &mem,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t)(cnt < 256 ? 0xA0 : 0xA2),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t)(cnt & 0xff));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval2 != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, read_sfp=%xh\n", rval2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy the data back */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dxfer = ql_send_buffer_data(mem.bp, bp, mem.size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode)) != mem.size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ddi copy error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi copy; byte cnt = %xh", dxfer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = EFAULT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* adjust the buffer pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bp = (caddr_t)bp + mem.size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_phys(ha, &mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_port_param
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieves or sets the firmware port speed settings
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_port_param(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_PORT_PARAM port_param = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rval = QL_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t idma_rate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_242581) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "invalid request for this HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (LOOP_NOT_READY(ha)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, loop not ready\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEVICE_OFFLINE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void*)&port_param, sizeof (EXT_PORT_PARAM), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port_param.FCScsiAddr.DestType != EXT_DEF_DESTTYPE_WWPN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "Unsupported dest lookup type: %xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.FCScsiAddr.DestType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = port_param.FCScsiAddr.DestAddr.WWPN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_9(CE_CONT, "(%d): wwpn=%02x%02x%02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, name[0], name[1], name[2], name[3], name[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name[5], name[6], name[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_find_port(ha, name, (uint16_t)QLNT_PORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq == NULL || !VALID_TARGET_ID(ha, tq->loop_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, fc_port not found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_DEV_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (port_param.Mode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_IIDMA_MODE_GET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Report the firmware's port rate for the wwpn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_iidma_rate(ha, tq->loop_id, &idma_rate,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "iidma get failed: %xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (idma_rate) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IIDMA_RATE_1GB:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Speed =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_1GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IIDMA_RATE_2GB:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Speed =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_2GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IIDMA_RATE_4GB:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Speed =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_4GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IIDMA_RATE_8GB:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Speed =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_8GBIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case IIDMA_RATE_10GB:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard port_param.Speed =
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EXT_DEF_PORTSPEED_10GBIT;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Speed =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_PORTSPEED_UNKNOWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, Port speed rate=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idma_rate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy back the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ddi_copyout((void *)&port_param,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)cmd->ResponseAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard sizeof (EXT_PORT_PARAM), mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_PORT_PARAM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_IIDMA_MODE_SET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the firmware's port rate for the wwpn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (port_param.Speed) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_DEF_PORTSPEED_1GBIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idma_rate = IIDMA_RATE_1GB;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_DEF_PORTSPEED_2GBIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idma_rate = IIDMA_RATE_2GB;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_DEF_PORTSPEED_4GBIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idma_rate = IIDMA_RATE_4GB;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_DEF_PORTSPEED_8GBIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idma_rate = IIDMA_RATE_8GB;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_DEF_PORTSPEED_10GBIT:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard port_param.Speed = IIDMA_RATE_10GB;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "invalid set iidma rate: %x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Speed);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_PARAMETER_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_iidma_rate(ha, tq->loop_id, &idma_rate,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_param.Mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "iidma set failed: %xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "invalid mode specified: %x\n", port_param.Mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_fwexttrace
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps f/w extended trace buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_fwexttrace(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard int rval;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard caddr_t payload;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "invalid request for this HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((CFG_IST(ha, CFG_ENABLE_FWEXTTRACE) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->fwexttracebuf.bp == NULL)) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "f/w extended trace is not enabled\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (cmd->ResponseLen < FWEXTSIZE) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->DetailStatus = FWEXTSIZE;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "failed, ResponseLen (%xh) < %xh (FWEXTSIZE)\n",
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen, FWEXTSIZE);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard return;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Time Stamp */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ql_fw_etrace(ha, &ha->fwexttracebuf, FTO_INSERT_TIME_STAMP);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (rval != QL_SUCCESS) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "f/w extended trace insert"
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard "time stamp failed: %xh\n", rval);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_ERR;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard return;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Disable Tracing */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ql_fw_etrace(ha, &ha->fwexttracebuf, FTO_EXT_TRACE_DISABLE);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (rval != QL_SUCCESS) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "f/w extended trace disable failed: %xh\n", rval);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_ERR;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard return;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Allocate payload buffer */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard payload = kmem_zalloc(FWEXTSIZE, KM_SLEEP);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (payload == NULL) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "failed, kmem_zalloc\n");
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_NO_MEMORY;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard return;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Sync DMA buffer. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void) ddi_dma_sync(ha->fwexttracebuf.dma_handle, 0,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard FWEXTSIZE, DDI_DMA_SYNC_FORKERNEL);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Copy trace buffer data. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard ddi_rep_get8(ha->fwexttracebuf.acc_handle, (uint8_t *)payload,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (uint8_t *)ha->fwexttracebuf.bp, FWEXTSIZE,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard DDI_DEV_AUTOINCR);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Send payload to application. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ql_send_buffer_data(payload, (caddr_t)(uintptr_t)cmd->ResponseAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen, mode) != cmd->ResponseLen) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "failed, send_buffer_data\n");
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard } else {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_OK;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard kmem_free(payload, FWEXTSIZE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_fwfcetrace
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * Dumps f/w fibre channel event trace buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_fwfcetrace(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard int rval;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard caddr_t payload;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "invalid request for this HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((CFG_IST(ha, CFG_ENABLE_FWFCETRACE) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->fwfcetracebuf.bp == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "f/w FCE trace is not enabled\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (cmd->ResponseLen < FWFCESIZE) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->DetailStatus = FWFCESIZE;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "failed, ResponseLen (%xh) < %xh (FWFCESIZE)\n",
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen, FWFCESIZE);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard return;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Disable Tracing */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard rval = ql_fw_etrace(ha, &ha->fwfcetracebuf, FTO_FCE_TRACE_DISABLE);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (rval != QL_SUCCESS) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "f/w FCE trace disable failed: %xh\n", rval);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_ERR;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard return;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Allocate payload buffer */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard payload = kmem_zalloc(FWEXTSIZE, KM_SLEEP);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (payload == NULL) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "failed, kmem_zalloc\n");
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_NO_MEMORY;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard return;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Sync DMA buffer. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (void) ddi_dma_sync(ha->fwfcetracebuf.dma_handle, 0,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard FWFCESIZE, DDI_DMA_SYNC_FORKERNEL);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Copy trace buffer data. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard ddi_rep_get8(ha->fwfcetracebuf.acc_handle, (uint8_t *)payload,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard (uint8_t *)ha->fwfcetracebuf.bp, FWFCESIZE,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard DDI_DEV_AUTOINCR);
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Send payload to application. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ql_send_buffer_data(payload, (caddr_t)(uintptr_t)cmd->ResponseAdr,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen, mode) != cmd->ResponseLen) {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard EL(ha, "failed, send_buffer_data\n");
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->ResponseLen = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard } else {
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard cmd->Status = EXT_STATUS_OK;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard kmem_free(payload, FWFCESIZE);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_pci_data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieves pci config space data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_pci_data(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t cap_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t cap_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t buf_size = 256;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First check the "Capabilities List" bit of the status register.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_pci_config_get16(ha, PCI_CONF_STAT) & PCI_STAT_CAP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the capability pointer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cap_ptr = (uint8_t)ql_pci_config_get8(ha, PCI_CONF_CAP_PTR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (cap_ptr != PCI_CAP_NEXT_PTR_NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for the pcie capability.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cap_id = (uint8_t)ql_pci_config_get8(ha, cap_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cap_id == PCI_CAP_ID_PCI_E) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf_size = 4096;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cap_ptr = (uint8_t)ql_pci_config_get8(ha,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cap_ptr + PCI_CAP_NEXT_PTR));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < buf_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = buf_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed ResponseLen < buf_size, len passed=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dump PCI config data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ql_pci_dump(ha, (void *)(uintptr_t)(cmd->ResponseAdr),
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard buf_size, mode)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, copy err pci_dump\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = buf_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_pci_dump
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dumps PCI config data to application buffer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp = user buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_pci_dump(ql_adapter_state_t *ha, uint32_t *bp, uint32_t pci_size, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pci_os;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32, *org_ptr32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = kmem_zalloc(pci_size, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ptr32 == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ENOMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* store the initial value of ptr32 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte org_ptr32 = ptr32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (pci_os = 0; pci_os < pci_size; pci_os += 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr32 = (uint32_t)ql_pci_config_get32(ha, pci_os);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_32(ptr32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout((void *)org_ptr32, (void *)bp, pci_size, mode) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(org_ptr32, pci_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_9(org_ptr32, 8, pci_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(org_ptr32, pci_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_menlo_reset
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reset Menlo
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_menlo_reset(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EXT_MENLO_RESET rst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_data_t mr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((CFG_IST(ha, CFG_CTRL_MENLO)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid request for HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TODO: only vp_index 0 can do this (?)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify the size of request structure. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (cmd->RequestLen < sizeof (EXT_MENLO_RESET)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "RequestLen=%d < %d\n", cmd->RequestLen,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard sizeof (EXT_MENLO_RESET));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get reset request. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((void *)(uintptr_t)cmd->RequestAdr,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (void *)&rst, sizeof (EXT_MENLO_RESET), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for I/O to stop and daemon to stall. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_suspend_hba(ha, 0) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "ql_stall_driver failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_hba(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_reset_menlo(ha, &mr, rst.Flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, status=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MAILBOX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (mr.mb[1] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, substatus=%d\n", mr.mb[1]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = mr.mb[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_hba(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_menlo_get_fw_version
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get Menlo firmware version.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_menlo_get_fw_version(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard int rval;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_mbx_iocb_t *pkt;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EXT_MENLO_GET_FW_VERSION ver = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((CFG_IST(ha, CFG_CTRL_MENLO)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid request for HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (cmd->ResponseLen < sizeof (EXT_MENLO_GET_FW_VERSION)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->DetailStatus = sizeof (EXT_MENLO_GET_FW_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "ResponseLen=%d < %d\n", cmd->ResponseLen,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard sizeof (EXT_MENLO_GET_FW_VERSION));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate packet. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(sizeof (ql_mbx_iocb_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.entry_type = VERIFY_MENLO_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.options_status = LE_16(VMF_DO_NOT_UPDATE_FW);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_16(&pkt->mvfy.options_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_16(&pkt->mvfy.failure_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ver.FwVersion = LE_32(pkt->mvfy.fw_version);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS || (pkt->mvfy.entry_status & 0x3c) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.options_status != CS_COMPLETE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Command error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, status=%xh, es=%xh, cs=%xh, fc=%xh\n", rval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.entry_status & 0x3c, pkt->mvfy.options_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.failure_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval != QL_SUCCESS ? rval :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (ddi_copyout((void *)&ver,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)cmd->ResponseAdr,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard sizeof (EXT_MENLO_GET_FW_VERSION), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = sizeof (EXT_MENLO_GET_FW_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_menlo_update_fw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get Menlo update firmware.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_menlo_update_fw(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_iocb_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem_t *dma_mem;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EXT_MENLO_UPDATE_FW fw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((CFG_IST(ha, CFG_CTRL_MENLO)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid request for HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TODO: only vp_index 0 can do this (?)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify the size of request structure. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (cmd->RequestLen < sizeof (EXT_MENLO_UPDATE_FW)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "RequestLen=%d < %d\n", cmd->RequestLen,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard sizeof (EXT_MENLO_UPDATE_FW));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get update fw request. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyin((caddr_t)(uintptr_t)cmd->RequestAdr, (caddr_t)&fw,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard sizeof (EXT_MENLO_UPDATE_FW), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for I/O to stop and daemon to stall. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_suspend_hba(ha, 0) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "ql_stall_driver failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_hba(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUSY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate packet. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem = (dma_mem_t *)kmem_zalloc(sizeof (dma_mem_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dma_mem == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(sizeof (ql_mbx_iocb_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_hba(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get DMA memory for the IOCB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_dma_mem(ha, dma_mem, fw.TotalByteCount, LITTLE_ENDIAN_DMA,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "%s(%d): request queue DMA memory "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alloc failed", QL_NAME, ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_hba(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get firmware data. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ql_get_buffer_data((caddr_t)(uintptr_t)fw.pFwDataBytes, dma_mem->bp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fw.TotalByteCount, mode) != fw.TotalByteCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_buffer_data\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_hba(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem->dma_handle, 0, dma_mem->size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.entry_type = VERIFY_MENLO_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.options_status = (uint16_t)LE_16(fw.Flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = dma_mem->bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.fw_version = LE_32(ptr32[2]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.fw_size = LE_32(fw.TotalByteCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.fw_sequence_size = LE_32(fw.TotalByteCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.dseg_0_length = LE_32(fw.TotalByteCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_16(&pkt->mvfy.options_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_16(&pkt->mvfy.failure_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS || (pkt->mvfy.entry_status & 0x3c) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.options_status != CS_COMPLETE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Command error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, status=%xh, es=%xh, cs=%xh, fc=%xh\n", rval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.entry_status & 0x3c, pkt->mvfy.options_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mvfy.failure_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval != QL_SUCCESS ? rval :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_hba(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_menlo_manage_info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get Menlo manage info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bp: buffer address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_menlo_manage_info(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_mbx_iocb_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem_t *dma_mem = NULL;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EXT_MENLO_MANAGE_INFO info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard /* The call is only supported for Schultz right now */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_8081)) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard ql_get_xgmac_statistics(ha, cmd, mode);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): CFG_CTRL_81XX done\n",
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard ha->instance);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!CFG_IST(ha, CFG_CTRL_8081) || !CFG_IST(ha, CFG_CTRL_MENLO)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, invalid request for HBA\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_REQUEST;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify the size of request structure. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (cmd->RequestLen < sizeof (EXT_MENLO_MANAGE_INFO)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "RequestLen=%d < %d\n", cmd->RequestLen,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard sizeof (EXT_MENLO_MANAGE_INFO));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_INVALID_PARAM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get manage info request. */
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard if (ddi_copyin((caddr_t)(uintptr_t)cmd->RequestAdr,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (caddr_t)&info, sizeof (EXT_MENLO_MANAGE_INFO), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyin\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Allocate packet. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = kmem_zalloc(sizeof (ql_mbx_iocb_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_driver(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.entry_type = MENLO_DATA_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.options_status = (uint16_t)LE_16(info.Operation);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get DMA memory for the IOCB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (info.Operation == MENLO_OP_READ_MEM ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.Operation == MENLO_OP_WRITE_MEM) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.total_byte_count = LE_32(info.TotalByteCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.parameter_1 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(info.Parameters.ap.MenloMemory.StartingAddr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem = (dma_mem_t *)kmem_zalloc(sizeof (dma_mem_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dma_mem == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, kmem_zalloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_NO_MEMORY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ql_get_dma_mem(ha, dma_mem, info.TotalByteCount,
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard LITTLE_ENDIAN_DMA, QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "%s(%d): request queue DMA memory "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "alloc failed", QL_NAME, ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_MS_NO_RESPONSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (info.Operation == MENLO_OP_WRITE_MEM) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get data. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ql_get_buffer_data(
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (caddr_t)(uintptr_t)info.pDataBytes,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem->bp, info.TotalByteCount, mode) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info.TotalByteCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, get_buffer_data\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem->dma_handle, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dma_mem->size, DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.dseg_count = LE_16(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.dseg_0_address[0] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(LSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.dseg_0_address[1] = (uint32_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(MSD(dma_mem->cookie.dmac_laddress));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.dseg_0_length = LE_32(info.TotalByteCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (info.Operation & MENLO_OP_CHANGE_CONFIG) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.parameter_1 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(info.Parameters.ap.MenloConfig.ConfigParamID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.parameter_2 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(info.Parameters.ap.MenloConfig.ConfigParamData0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.parameter_3 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(info.Parameters.ap.MenloConfig.ConfigParamData1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (info.Operation & MENLO_OP_GET_INFO) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.parameter_1 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(info.Parameters.ap.MenloInfo.InfoDataType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.parameter_2 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LE_32(info.Parameters.ap.MenloInfo.InfoContext);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_issue_mbx_iocb(ha, (caddr_t)pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_16(&pkt->mdata.options_status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LITTLE_ENDIAN_16(&pkt->mdata.failure_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS || (pkt->mdata.entry_status & 0x3c) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.options_status != CS_COMPLETE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Command error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, status=%xh, es=%xh, cs=%xh, fc=%xh\n", rval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.entry_status & 0x3c, pkt->mdata.options_status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->mdata.failure_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = rval != QL_SUCCESS ? rval :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_FUNCTION_FAILED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (info.Operation == MENLO_OP_READ_MEM) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(dma_mem->dma_handle, 0, dma_mem->size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ql_send_buffer_data((caddr_t)(uintptr_t)info.pDataBytes,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard dma_mem->bp, info.TotalByteCount, mode) !=
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard info.TotalByteCount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_free_dma_resource(ha, dma_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(dma_mem, sizeof (dma_mem_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(pkt, sizeof (ql_mbx_iocb_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_suspend_hba
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Suspends all adapter ports.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * options: BIT_0 --> leave driver stalled on exit if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * failed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_suspend_hba(ql_adapter_state_t *ha, uint32_t opt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *ha2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = QL_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Quiesce I/O on all adapter ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ql_hba.first; link != NULL; link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha2 = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha2->fru_hba_index != ha->fru_hba_index) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = ql_stall_driver(ha2, opt)) != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "ql_stall_driver status=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_restart_hba
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Restarts adapter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_restart_hba(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *ha2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Resume I/O on all adapter ports */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (link = ql_hba.first; link != NULL; link = link->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha2 = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha2->fru_hba_index != ha->fru_hba_index) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_restart_driver(ha2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_get_vp_cnt_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieves pci config space data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_get_vp_cnt_id(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *vha;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard PEXT_VPORT_ID_CNT ptmp_vp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int id = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard char name[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /*
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * To be backward compatible with older API
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * check for the size of old EXT_VPORT_ID_CNT
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (cmd->ResponseLen < sizeof (EXT_VPORT_ID_CNT) &&
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (cmd->ResponseLen != EXT_OLD_VPORT_ID_CNT_SIZE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_VPORT_ID_CNT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ResponseLen < EXT_VPORT_ID_CNT, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ptmp_vp = (EXT_VPORT_ID_CNT *)
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard kmem_zalloc(sizeof (EXT_VPORT_ID_CNT), KM_SLEEP);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ptmp_vp == NULL) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "failed, kmem_zalloc\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard return;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vha = ha->vp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (vha != NULL) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ptmp_vp->VpCnt++;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ptmp_vp->VpId[id] = vha->vp_index;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (void) ddi_pathname(vha->dip, name);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (void) strcpy((char *)ptmp_vp->vp_path[id], name);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ptmp_vp->VpDrvInst[id] = (int32_t)vha->instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vha = vha->vp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard rval = ddi_copyout((void *)ptmp_vp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_VPORT_ID_CNT);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done, vport_cnt=%d\n",
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ha->instance, ptmp_vp->VpCnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_vp_ioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs all EXT_CC_VPORT_CMD functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: Local EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_vp_ioctl(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started, cmd=%d\n", ha->instance,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* case off on command subcode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd->SubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_VF_SC_VPORT_GETINFO:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_qry_vport(ha, cmd, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* function not supported. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_UNSUPPORTED_SUBCODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, Unsupported Subcode=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->SubCode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_qry_vport
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performs EXT_VF_SC_VPORT_GETINFO subfunction.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: EXT_IOCTL cmd struct pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mode: flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * None, request status indicated in cmd->Status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kernel context.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_qry_vport(ql_adapter_state_t *vha, EXT_IOCTL *cmd, int mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *tmp_vha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_VPORT_INFO tmp_vport = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int max_vport;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", vha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->ResponseLen < sizeof (EXT_VPORT_INFO)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->DetailStatus = sizeof (EXT_VPORT_INFO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(vha, "failed, ResponseLen < EXT_VPORT_INFO, Len=%xh\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill in the vport information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(vha->loginparams.node_ww_name.raw_wwn, tmp_vport.wwnn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(vha->loginparams.nport_ww_name.raw_wwn, tmp_vport.wwpn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EXT_DEF_WWN_NAME_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_vport.state = vha->state;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard tmp_vport.id = vha->vp_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_vha = vha->pha->vp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (tmp_vha != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_vport.used++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_vha = tmp_vha->vp_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte max_vport = (CFG_IST(vha, CFG_CTRL_2422) ? MAX_24_VIRTUAL_PORTS :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_25_VIRTUAL_PORTS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (max_vport > tmp_vport.used) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_vport.free = max_vport - tmp_vport.used;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddi_copyout((void *)&tmp_vport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)(uintptr_t)(cmd->ResponseAdr),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (EXT_VPORT_INFO), mode) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->Status = EXT_STATUS_COPY_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(vha, "failed, ddi_copyout\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->ResponseLen = sizeof (EXT_VPORT_INFO);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", vha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard}
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard/*
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql_access_flash
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Performs all EXT_CC_ACCESS_FLASH_OS functions.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Input:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * pi: port info pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * cmd: Local EXT_IOCTL cmd struct pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * mode: flags.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Returns:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * None, request status indicated in cmd->Status.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Context:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Kernel context.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardql_access_flash(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard int rval;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard switch (cmd->SubCode) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_SC_FLASH_READ:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if ((rval = ql_flash_fcode_dump(ha,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr),
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (size_t)(cmd->ResponseLen), cmd->Reserved1, mode)) != 0) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "flash_fcode_dump status=%xh\n", rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_SC_FLASH_WRITE:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if ((rval = ql_r_m_w_flash(ha,
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (void *)(uintptr_t)(cmd->RequestAdr),
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard (size_t)(cmd->RequestLen), cmd->Reserved1, mode)) !=
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_SUCCESS) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "r_m_w_flash status=%xh\n", rval);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Reset caches on all adapter instances. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_update_flash_caches(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard default:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "unknown subcode=%xh\n", cmd->SubCode);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->Status = EXT_STATUS_ERR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard}
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard/*
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ql_reset_cmd
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Performs all EXT_CC_RESET_FW_OS functions.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Input:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * ha: adapter state pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * cmd: Local EXT_IOCTL cmd struct pointer.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Returns:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * None, request status indicated in cmd->Status.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard *
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Context:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard * Kernel context.
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic void
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardql_reset_cmd(ql_adapter_state_t *ha, EXT_IOCTL *cmd)
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard{
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard switch (cmd->SubCode) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_SC_RESET_FC_FW:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "isp_abort_needed\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED, 0);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard case EXT_SC_RESET_MPI_FW:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (!(CFG_IST(ha, CFG_CTRL_81XX))) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "invalid request for HBA\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->Status = EXT_STATUS_INVALID_REQUEST;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard /* Wait for I/O to stop and daemon to stall. */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard if (ql_suspend_hba(ha, 0) != QL_SUCCESS) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "ql_suspend_hba failed\n");
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->Status = EXT_STATUS_BUSY;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard } else if (ql_restart_mpi(ha) != QL_SUCCESS) {
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->Status = EXT_STATUS_ERR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint8_t timer;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /*
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * While the restart_mpi mailbox cmd may be
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * done the MPI is not. Wait at least 6 sec. or
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * exit if the loop comes up.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard for (timer = 6; timer; timer--) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!(ha->task_daemon_flags &
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard LOOP_DOWN)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard break;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Delay for 1 second. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_delay(ha, 1000000);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard ql_restart_hba(ha);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard default:
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard EL(ha, "unknown subcode=%xh\n", cmd->SubCode);
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->Status = EXT_STATUS_ERR;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard cmd->ResponseLen = 0;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard break;
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard }
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard/*
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard * ql_get_dcbx_parameters
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard * Get DCBX parameters.
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard *
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard * Input:
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard * ha: adapter state pointer.
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard * cmd: User space CT arguments pointer.
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard * mode: flags.
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard */
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregardstatic void
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregardql_get_dcbx_parameters(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard{
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard uint8_t *tmp_buf;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard int rval;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!(CFG_IST(ha, CFG_CTRL_8081))) {
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard EL(ha, "invalid request for HBA\n");
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->Status = EXT_STATUS_INVALID_REQUEST;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->ResponseLen = 0;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard return;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard }
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard /* Allocate memory for command. */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard tmp_buf = kmem_zalloc(EXT_DEF_DCBX_PARAM_BUF_SIZE, KM_SLEEP);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard if (tmp_buf == NULL) {
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard EL(ha, "failed, kmem_zalloc\n");
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->Status = EXT_STATUS_NO_MEMORY;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->ResponseLen = 0;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard return;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard }
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard /* Send command */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard rval = ql_get_dcbx_params(ha, EXT_DEF_DCBX_PARAM_BUF_SIZE,
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard (caddr_t)tmp_buf);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard if (rval != QL_SUCCESS) {
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard /* error */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, get_dcbx_params_mbx=%xh\n", rval);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard kmem_free(tmp_buf, EXT_DEF_DCBX_PARAM_BUF_SIZE);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->Status = EXT_STATUS_ERR;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->ResponseLen = 0;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard return;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard }
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard /* Copy the response */
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard if (ql_send_buffer_data((caddr_t)tmp_buf,
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard (caddr_t)(uintptr_t)cmd->ResponseAdr,
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EXT_DEF_DCBX_PARAM_BUF_SIZE, mode) != EXT_DEF_DCBX_PARAM_BUF_SIZE) {
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard EL(ha, "failed, ddi_copyout\n");
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard cmd->ResponseLen = 0;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard } else {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = EXT_DEF_DCBX_PARAM_BUF_SIZE;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard kmem_free(tmp_buf, EXT_DEF_DCBX_PARAM_BUF_SIZE);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard}
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard/*
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * ql_qry_cna_port
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Performs EXT_SC_QUERY_CNA_PORT subfunction.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard *
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Input:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * ha: adapter state pointer.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * cmd: EXT_IOCTL cmd struct pointer.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * mode: flags.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard *
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Returns:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * None, request status indicated in cmd->Status.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard *
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Context:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Kernel context.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregardstatic void
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregardql_qry_cna_port(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard{
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EXT_CNA_PORT cna_port = {0};
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!(CFG_IST(ha, CFG_CTRL_8081))) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "invalid request for HBA\n");
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_INVALID_REQUEST;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (cmd->ResponseLen < sizeof (EXT_CNA_PORT)) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->DetailStatus = sizeof (EXT_CNA_PORT);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, ResponseLen < EXT_CNA_PORT, Len=%xh\n",
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cna_port.VLanId = ha->fcoe_vlan_id;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cna_port.FabricParam = ha->fabric_params;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard bcopy(ha->fcoe_vnport_mac, cna_port.VNPortMACAddress,
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EXT_DEF_MAC_ADDRESS_SIZE);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (ddi_copyout((void *)&cna_port,
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr),
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard sizeof (EXT_CNA_PORT), mode) != 0) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, ddi_copyout\n");
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard } else {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = sizeof (EXT_CNA_PORT);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard}
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard/*
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ql_qry_adapter_versions
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Performs EXT_SC_QUERY_ADAPTER_VERSIONS subfunction.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard *
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Input:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ha: adapter state pointer.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * cmd: EXT_IOCTL cmd struct pointer.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * mode: flags.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard *
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Returns:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * None, request status indicated in cmd->Status.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard *
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Context:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Kernel context.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardql_qry_adapter_versions(ql_adapter_state_t *ha, EXT_IOCTL *cmd,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard int mode)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard{
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint8_t is_8142, mpi_cap;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint32_t ver_len, transfer_size;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard PEXT_ADAPTERREGIONVERSION padapter_ver = NULL;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* 8142s do not have a EDC PHY firmware. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard mpi_cap = (uint8_t)(ha->mpi_capability_list >> 8);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard is_8142 = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Sizeof (Length + Reserved) = 8 Bytes */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (mpi_cap == 0x02 || mpi_cap == 0x04) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ver_len = (sizeof (EXT_REGIONVERSION) * (NO_OF_VERSIONS - 1))
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard + 8;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard is_8142 = 1;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ver_len = (sizeof (EXT_REGIONVERSION) * NO_OF_VERSIONS) + 8;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Allocate local memory for EXT_ADAPTERREGIONVERSION */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver = (EXT_ADAPTERREGIONVERSION *)kmem_zalloc(ver_len,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard KM_SLEEP);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (padapter_ver == NULL) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, kmem_zalloc\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_NO_MEMORY;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->Length = 1;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Copy MPI version */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[0].Region =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EXT_OPT_ROM_REGION_MPI_RISC_FW;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[0].Version[0] =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->mpi_fw_major_version;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[0].Version[1] =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->mpi_fw_minor_version;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[0].Version[2] =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->mpi_fw_subminor_version;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[0].VersionLength = 3;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[0].Location = RUNNING_VERSION;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!is_8142) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[1].Region =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EXT_OPT_ROM_REGION_EDC_PHY_FW;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[1].Version[0] =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->phy_fw_major_version;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[1].Version[1] =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->phy_fw_minor_version;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[1].Version[2] =
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->phy_fw_subminor_version;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[1].VersionLength = 3;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->RegionVersion[1].Location = RUNNING_VERSION;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->Length = NO_OF_VERSIONS;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (cmd->ResponseLen < ver_len) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, ResponseLen < ver_len, ",
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard "RespLen=%xh ver_len=%xh\n", cmd->ResponseLen, ver_len);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Calculate the No. of valid versions being returned. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard padapter_ver->Length = (uint32_t)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ((cmd->ResponseLen - 8) / sizeof (EXT_REGIONVERSION));
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->DetailStatus = ver_len;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard transfer_size = cmd->ResponseLen;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard transfer_size = ver_len;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (ddi_copyout((void *)padapter_ver,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr),
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard transfer_size, mode) != 0) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, ddi_copyout\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = ver_len;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard kmem_free(padapter_ver, ver_len);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard}
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard/*
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * ql_get_xgmac_statistics
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Get XgMac information
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard *
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Input:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * ha: adapter state pointer.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * cmd: EXT_IOCTL cmd struct pointer.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * mode: flags.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard *
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Returns:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * None, request status indicated in cmd->Status.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard *
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Context:
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard * Kernel context.
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregardstatic void
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregardql_get_xgmac_statistics(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard{
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard int rval;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard uint32_t size;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard int8_t *tmp_buf;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EXT_MENLO_MANAGE_INFO info;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard /* Verify the size of request structure. */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (cmd->RequestLen < sizeof (EXT_MENLO_MANAGE_INFO)) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard /* Return error */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "RequestLen=%d < %d\n", cmd->RequestLen,
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard sizeof (EXT_MENLO_MANAGE_INFO));
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_INVALID_PARAM;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->DetailStatus = EXT_DSTATUS_REQUEST_LEN;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard }
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard /* Get manage info request. */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (ddi_copyin((caddr_t)(uintptr_t)cmd->RequestAdr,
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard (caddr_t)&info, sizeof (EXT_MENLO_MANAGE_INFO), mode) != 0) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, ddi_copyin\n");
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard size = info.TotalByteCount;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (!size) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard /* parameter error */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_INVALID_PARAM;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->DetailStatus = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, size=%xh\n", size);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard /* Allocate memory for command. */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard tmp_buf = kmem_zalloc(size, KM_SLEEP);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (tmp_buf == NULL) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, kmem_zalloc\n");
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_NO_MEMORY;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (!(info.Operation & MENLO_OP_GET_INFO)) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "Invalid request for 81XX\n");
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard kmem_free(tmp_buf, size);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_ERR;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard rval = ql_get_xgmac_stats(ha, size, (caddr_t)tmp_buf);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (rval != QL_SUCCESS) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard /* error */
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, get_xgmac_stats =%xh\n", rval);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard kmem_free(tmp_buf, size);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_ERR;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard return;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard if (ql_send_buffer_data(tmp_buf, (caddr_t)(uintptr_t)info.pDataBytes,
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard size, mode) != size) {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard EL(ha, "failed, ddi_copyout\n");
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = 0;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard } else {
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard cmd->ResponseLen = info.TotalByteCount;
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard }
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard kmem_free(tmp_buf, size);
7a2b99c0f2ca8f0910b76c47c895d7c6a23674deDaniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
4f8b8adc54496e548e2d73094de038a131d9cd45Daniel Beauregard}
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard/*
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ql_get_fcf_list
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Get FCF list.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard *
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Input:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ha: adapter state pointer.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * cmd: User space CT arguments pointer.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * mode: flags.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardql_get_fcf_list(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard{
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint8_t *tmp_buf;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard int rval;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EXT_FCF_LIST fcf_list = {0};
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_fcf_list_desc_t mb_fcf_list = {0};
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!(CFG_IST(ha, CFG_CTRL_81XX))) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "invalid request for HBA\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_INVALID_REQUEST;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Get manage info request. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (ddi_copyin((caddr_t)(uintptr_t)cmd->RequestAdr,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (caddr_t)&fcf_list, sizeof (EXT_FCF_LIST), mode) != 0) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, ddi_copyin\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!(fcf_list.BufSize)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Return error */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, fcf_list BufSize is=%xh\n",
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard fcf_list.BufSize);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_INVALID_PARAM;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Allocate memory for command. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_buf = kmem_zalloc(fcf_list.BufSize, KM_SLEEP);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (tmp_buf == NULL) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, kmem_zalloc\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_NO_MEMORY;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* build the descriptor */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (fcf_list.Options) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard mb_fcf_list.options = FCF_LIST_RETURN_ONE;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard mb_fcf_list.options = FCF_LIST_RETURN_ALL;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard mb_fcf_list.fcf_index = (uint16_t)fcf_list.FcfIndex;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard mb_fcf_list.buffer_size = fcf_list.BufSize;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Send command */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard rval = ql_get_fcf_list_mbx(ha, &mb_fcf_list, (caddr_t)tmp_buf);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (rval != QL_SUCCESS) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* error */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, get_fcf_list_mbx=%xh\n", rval);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard kmem_free(tmp_buf, fcf_list.BufSize);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_ERR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard /* Copy the response */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (ql_send_buffer_data((caddr_t)tmp_buf,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (caddr_t)(uintptr_t)cmd->ResponseAdr,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard fcf_list.BufSize, mode) != fcf_list.BufSize) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, ddi_copyout\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = mb_fcf_list.buffer_size;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard kmem_free(tmp_buf, fcf_list.BufSize);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard}
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard/*
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ql_get_resource_counts
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Get Resource counts:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard *
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * Input:
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * ha: adapter state pointer.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * cmd: User space CT arguments pointer.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * mode: flags.
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardstatic void
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregardql_get_resource_counts(ql_adapter_state_t *ha, EXT_IOCTL *cmd, int mode)
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard{
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard int rval;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ql_mbx_data_t mr;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EXT_RESOURCE_CNTS tmp_rc_cnt = {0};
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (!(CFG_IST(ha, CFG_CTRL_242581))) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "invalid request for HBA\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_INVALID_REQUEST;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (cmd->ResponseLen < sizeof (EXT_RESOURCE_CNTS)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_BUFFER_TOO_SMALL;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->DetailStatus = sizeof (EXT_RESOURCE_CNTS);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, ResponseLen < EXT_RESOURCE_CNTS, "
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard "Len=%xh\n", cmd->ResponseLen);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard rval = ql_get_resource_cnts(ha, &mr);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (rval != QL_SUCCESS) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "resource cnt mbx failed\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_ERR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard return;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.OrgTgtXchgCtrlCnt = (uint32_t)mr.mb[1];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.CurTgtXchgCtrlCnt = (uint32_t)mr.mb[2];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.CurXchgCtrlCnt = (uint32_t)mr.mb[3];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.OrgXchgCtrlCnt = (uint32_t)mr.mb[6];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.CurIocbBufCnt = (uint32_t)mr.mb[7];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.OrgIocbBufCnt = (uint32_t)mr.mb[10];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.NoOfSupVPs = (uint32_t)mr.mb[11];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard tmp_rc_cnt.NoOfSupFCFs = (uint32_t)mr.mb[12];
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard rval = ddi_copyout((void *)&tmp_rc_cnt,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard (void *)(uintptr_t)(cmd->ResponseAdr),
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard sizeof (EXT_RESOURCE_CNTS), mode);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (rval != 0) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->Status = EXT_STATUS_COPY_ERR;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = 0;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard EL(ha, "failed, ddi_copyout\n");
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard cmd->ResponseLen = sizeof (EXT_RESOURCE_CNTS);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard}