ql_iocb.c revision 16dd44c265271a75647fb0bb41109bb7c585a526
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
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard/* Copyright 2009 QLogic Corporation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard#pragma ident "Copyright 2009 QLogic Corporation; ql_iocb.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 **
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * * COPYRIGHT (C) 1996-2009 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_iocb.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_isr.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_xioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Local Function Prototypes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_continuation_iocb(ql_adapter_state_t *, ddi_dma_cookie_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t, boolean_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void ql_isp24xx_rcvbuf(ql_adapter_state_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_start_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The start IOCB is responsible for building request packets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on request ring and modifying ISP input pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp: srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_start_iocb(ql_adapter_state_t *vha, ql_srb_t *sp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_link_t *link;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t *ptr64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *ha = vha->pha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Acquire ring lock. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_RING_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * If the pending queue is not empty maintain order
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * by puting this srb at the tail and geting the head.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((link = ha->pending_cmds.first) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_add_link_b(&ha->pending_cmds, &sp->cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove command from pending command queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_remove_link(&ha->pending_cmds, &sp->cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get command from pending command queue if not empty. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((link = ha->pending_cmds.first) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Release ring specific lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_RING_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): empty done\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove command from pending command queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_remove_link(&ha->pending_cmds, &sp->cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* start this request and as many others as possible */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_q_cnt < sp->req_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate number of free request entries. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = RD16_IO_REG(ha, req_out);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_ring_index < cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt = (uint16_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cnt - ha->req_ring_index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt = (uint16_t)(REQUEST_ENTRY_CNT -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->req_ring_index - cnt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_q_cnt != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /*
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * If no room in request ring put this srb at
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * the head of the pending queue and exit.
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_q_cnt < sp->req_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_8(CE_CONT, "(%d): request ring full,"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " req_q_cnt=%d, req_ring_index=%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, ha->req_q_cnt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_ring_index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_add_link_t(&ha->pending_cmds, &sp->cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for room in outstanding command list. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->osc_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->osc_index == MAX_OUTSTANDING_COMMANDS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->osc_index = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->outstanding_cmds[ha->osc_index] == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /*
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * If no room in outstanding array put this srb at
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * the head of the pending queue and exit.
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cnt == MAX_OUTSTANDING_COMMANDS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_8(CE_CONT, "(%d): no room in outstanding "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "array\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_add_link_t(&ha->pending_cmds, &sp->cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* nothing to stop us now. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->outstanding_cmds[ha->osc_index] = sp;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* create and save a unique response identifier in the srb */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->handle = ha->adapter_stats->ncmds << OSC_INDEX_SHIFT |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->osc_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt -= sp->req_cnt;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* build the iocb in the request ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = ha->request_ring_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->flags |= SRB_IN_TOKEN_ARRAY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Zero out packet. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr64 = (uint64_t *)pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64++ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64++ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64++ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64 = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup IOCB common data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_count = (uint8_t)sp->req_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sys_define = (uint8_t)ha->req_ring_index;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* mark the iocb with the response identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &pkt->handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* Setup IOCB unique data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sp->iocb)(vha, sp, pkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->flags |= SRB_ISP_STARTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_5(CE_CONT, "(%d,%d): req packet, sp=%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->instance, vha->vp_index, (void *)sp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_5((uint8_t *)pkt, 8, REQUEST_ENTRY_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(ha->hba_buf.dma_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_Q_BUFFER_OFFSET), (size_t)REQUEST_ENTRY_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust ring index. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_ring_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_ring_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr = ha->request_ring_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Reset watchdog timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->wdg_q_time = sp->init_wdg_q_time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /*
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * Send it by setting the new ring index in the ISP Request
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * Ring In Pointer register. This is the mechanism
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * used to notify the isp that a new iocb has been
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * placed on the request ring.
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT16_IO_REG(ha, req_in, ha->req_ring_index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Update outstanding command count statistic. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->adapter_stats->ncmds++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard /* if there is a pending command, try to start it. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((link = ha->pending_cmds.first) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove command from pending command queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp = link->base_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_remove_link(&ha->pending_cmds, &sp->cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Release ring specific lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_RING_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_req_pkt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function is responsible for locking ring and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getting a zeroed out request packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pkt: address for packet pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_req_pkt(ql_adapter_state_t *vha, request_t **pktp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *long_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t timer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = QL_FUNCTION_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *ha = vha->pha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Wait for 30 seconds for slot. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (timer = 30000; timer != 0; timer--) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Acquire ring lock. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_RING_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_q_cnt == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate number of free request entries. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = RD16_IO_REG(ha, req_out);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_ring_index < cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt = (uint16_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cnt - ha->req_ring_index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt = (uint16_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (REQUEST_ENTRY_CNT -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->req_ring_index - cnt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_q_cnt != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found empty request ring slot? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_q_cnt != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pktp = ha->request_ring_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Zero out packet. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte long_ptr = (uint32_t *)ha->request_ring_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < REQUEST_ENTRY_SIZE/4; cnt++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *long_ptr++ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Setup IOCB common data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr->entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr->sys_define =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t)ha->req_ring_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ha->request_ring_ptr->handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)QL_FCA_BRAND);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = QL_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Release request queue lock. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_RING_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte drv_usecwait(MILLISEC);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for pending interrupts. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX protect interrupt routine from calling itself.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need to revisit this routine. So far we never
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hit this case as req slot was available
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!(curthread->t_flag & T_INTR_THREAD)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (RD16_IO_REG(ha, istatus) & RISC_INT)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ql_isr((caddr_t)ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->intr_claimed = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTR_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, rval = %xh, isp_abort_needed\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_isp_cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function is responsible for modifying ISP input pointer.
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * This action notifies the isp that a new request has been
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard * added to the request ring.
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Releases ring lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_isp_cmd(ql_adapter_state_t *vha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *ha = vha->pha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_5(CE_CONT, "(%d): req packet:\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_5((uint8_t *)ha->request_ring_ptr, 8, REQUEST_ENTRY_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(ha->hba_buf.dma_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_Q_BUFFER_OFFSET), (size_t)REQUEST_ENTRY_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust ring index. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_ring_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_ring_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr = ha->request_ring_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set chip new ring index. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT16_IO_REG(ha, req_in, ha->req_ring_index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Release ring lock. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_RING_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_command_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of command IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp: srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_command_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32, cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t seg_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcp_cmd_t *fcp = sp->fcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = sp->lun_queue->target_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd_entry_t *pkt = arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set LUN number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->lun_l = LSB(sp->lun_queue->lun_no);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->lun_h = MSB(sp->lun_queue->lun_no);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set target ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set tag queue control flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fcp->fcp_cntl.cntl_qtype == FCP_QTYPE_HEAD_OF_Q) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags_l = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->control_flags_l | CF_HTAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fcp->fcp_cntl.cntl_qtype == FCP_QTYPE_ORDERED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags_l = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->control_flags_l | CF_OTAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* else if (fcp->fcp_cntl.cntl_qtype == FCP_QTYPE_SIMPLE) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags_l = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->control_flags_l | CF_STAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load SCSI CDB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_put8(ha->hba_buf.acc_handle, fcp->fcp_cdb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->scsi_cdb, MAX_CMDSZ, DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = IOCB_CMD_TYPE_3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = CMD_TYPE_3_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = IOCB_CMD_TYPE_2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = CMD_TYPE_2_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fcp->fcp_data_len == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->xioctl->IOControlRequests++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set transfer direction. Load Data segments.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fcp->fcp_cntl.cntl_write_data) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags_l = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->control_flags_l | CF_DATA_OUT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->xioctl->IOOutputRequests++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->xioctl->IOOutputByteCnt += fcp->fcp_data_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fcp->fcp_cntl.cntl_read_data) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags_l = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->control_flags_l | CF_DATA_IN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->xioctl->IOInputRequests++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->xioctl->IOInputByteCnt += fcp->fcp_data_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count, fcp->fcp_data_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load command data segment. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)&pkt->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_data_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (cnt && seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_continuation_iocb(ha, cp, seg_cnt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (boolean_t)(CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_continuation_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of continuation IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cp: cookie list pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * seg_cnt: number of segments.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * addr64: 64 bit addresses.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_continuation_iocb(ql_adapter_state_t *ha, ddi_dma_cookie_t *cp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t seg_cnt, boolean_t addr64)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cont_entry_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t *ptr64;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32, cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync DMA buffer. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(ha->hba_buf.dma_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REQUEST_Q_BUFFER_OFFSET), REQUEST_ENTRY_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust ring pointer, and deal with wrap. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_ring_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->req_ring_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr = ha->request_ring_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->request_ring_ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = (cont_entry_t *)ha->request_ring_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Zero out packet. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr64 = (uint64_t *)pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64++ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64++ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64++ = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ptr64++ = 0; *ptr64 = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sys_define = (uint8_t)ha->req_ring_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addr64) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = CONTINUATION_TYPE_1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = CONT_TYPE_1_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &((cont_type_1_entry_t *)pkt)->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (cnt && seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = CONTINUATION_TYPE_0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = CONT_TYPE_0_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)&pkt->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (cnt && seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_5(CE_CONT, "(%d): packet:\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_5((uint8_t *)pkt, 8, REQUEST_ENTRY_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_command_24xx_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of ISP24xx command IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp: srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_command_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32, cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t seg_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcp_cmd_t *fcp = sp->fcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = sp->lun_queue->target_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd_24xx_entry_t *pkt = arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *pha = ha->pha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = IOCB_CMD_TYPE_7;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set LUN number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->fcp_lun[2] = LSB(sp->lun_queue->lun_no);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->fcp_lun[3] = MSB(sp->lun_queue->lun_no);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set N_port handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set target ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_id[0] = tq->d_id.b.al_pa;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_id[1] = tq->d_id.b.area;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_id[2] = tq->d_id.b.domain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->vp_index = ha->vp_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->isp_timeout < 0x1999) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->isp_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load SCSI CDB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_rep_put8(pha->hba_buf.acc_handle, fcp->fcp_cdb, pkt->scsi_cdb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_CMDSZ, DDI_DEV_AUTOINCR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cnt = 0; cnt < MAX_CMDSZ; cnt += 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_chg_endian((uint8_t *)&pkt->scsi_cdb + cnt, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set tag queue control flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cannot copy fcp->fcp_cntl.cntl_qtype directly,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * problem with x86 in 32bit kernel mode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (fcp->fcp_cntl.cntl_qtype) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCP_QTYPE_SIMPLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->task = TA_STAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCP_QTYPE_HEAD_OF_Q:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->task = TA_HTAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCP_QTYPE_ORDERED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->task = TA_OTAG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCP_QTYPE_ACA_Q_TAG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->task = TA_ACA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCP_QTYPE_UNTAGGED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->task = TA_UNTAGGED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fcp->fcp_data_len == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pha->xioctl->IOControlRequests++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set transfer direction. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fcp->fcp_cntl.cntl_write_data) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags = CF_WR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pha->xioctl->IOOutputRequests++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pha->xioctl->IOOutputByteCnt += fcp->fcp_data_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (fcp->fcp_cntl.cntl_read_data) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags = CF_RD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pha->xioctl->IOInputRequests++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pha->xioctl->IOInputByteCnt += fcp->fcp_data_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(pha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, &pkt->total_byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcp->fcp_data_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load command data segment. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)&pkt->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_data_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_continuation_iocb(pha, cp, seg_cnt, B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_marker
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function issues marker IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * loop_id: device loop ID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lun: device LUN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: marker modifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_marker(ql_adapter_state_t *ha, uint16_t loop_id, uint16_t lun,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t type)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mrk_entry_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_req_pkt(ha, (request_t **)&pkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval == QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = MARKER_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_CTRL_2425)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte marker_24xx_entry_t *pkt24 =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (marker_24xx_entry_t *)pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt24->modifier = type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set LUN number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt24->fcp_lun[2] = LSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt24->fcp_lun[3] = MSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt24->vp_index = ha->vp_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set N_port handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->pha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pkt24->n_port_hdl, loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->modifier = type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->lun_l = LSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->lun_h = MSB(lun);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_l = LSB(loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_h = MSB(loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->target_h = LSB(loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue command to ISP */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_isp_cmd(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_ms_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of name/management server IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp = srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg = request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_ms_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t seg_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = sp->lun_queue->target_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ms_entry_t *pkt = arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build command packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = MS_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set loop ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->loop_id_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->loop_id_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->loop_id_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set cmd data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->cmd_dseg_count_l = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set total data segment count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt = (uint16_t)(sp->pkt->pkt_resp_cookie_cnt + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->total_dseg_count, seg_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load ct cmd byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &pkt->cmd_byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->pkt->pkt_cmdlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load ct rsp byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &pkt->resp_byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->pkt->pkt_rsplen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load MS command data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)&pkt->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_cmd_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load MS response entry data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_resp_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_continuation_iocb(ha, cp, seg_cnt, B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_ms_24xx_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of name/management server IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp: srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_ms_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t seg_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = sp->lun_queue->target_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct_passthru_entry_t *pkt = arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_adapter_state_t *pha = ha->pha;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build command packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = CT_PASSTHRU_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set loop ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->vp_index = ha->vp_index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->isp_timeout < 0x1999) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->isp_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set cmd/response data segment counts. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(pha->hba_buf.acc_handle, &pkt->cmd_dseg_count, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt = (uint16_t)sp->pkt->pkt_resp_cookie_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(pha->hba_buf.acc_handle, &pkt->resp_dseg_count, seg_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load ct cmd byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, &pkt->cmd_byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->pkt->pkt_cmdlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load ct rsp byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, &pkt->resp_byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->pkt->pkt_rsplen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load MS command entry data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)&pkt->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_cmd_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load MS response entry data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_resp_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(pha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_continuation_iocb(pha, cp, seg_cnt, B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_ip_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of IP IOCB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp: srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_ip_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32, cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t seg_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = sp->lun_queue->target_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip_entry_t *pkt = arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set loop ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->loop_id_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->loop_id_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->loop_id_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set control flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags_l = BIT_6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->pkt->pkt_tran_flags & FC_TRAN_HI_PRIORITY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->control_flags_h = BIT_7;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt = (uint16_t)sp->pkt->pkt_cmd_cookie_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->pkt->pkt_cmdlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build command packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = IP_A64_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = IP_A64_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = IP_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt = IP_DATA_SEGMENTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load command entry data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)&pkt->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_cmd_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (cnt && seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_continuation_iocb(ha, cp, seg_cnt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (boolean_t)(CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_ip_24xx_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of IP IOCB for ISP24xx.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp: srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg: request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_ip_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *ptr32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t seg_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq = sp->lun_queue->target_queue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip_cmd_entry_t *pkt = arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = IP_CMD_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set N_port handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->hdl_status, tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->isp_timeout < 0x1999) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout_hdl,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->isp_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set data segment count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt = (uint16_t)sp->pkt->pkt_cmd_cookie_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load total byte count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->pkt->pkt_cmdlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set control flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->control_flags,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t)(BIT_0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set frame header control flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->frame_hdr_cntrl_flgs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint16_t)(IPCF_LAST_SEQ | IPCF_FIRST_SEQ));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load command data segment. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptr32 = (uint32_t *)&pkt->dseg_0_address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_cmd_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build continuation packets.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (seg_cnt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_continuation_iocb(ha, cp, seg_cnt, B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_isp_rcvbuf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Locates free buffers and places it on the receive buffer queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_isp_rcvbuf(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcvbuf_t *container;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard uint16_t rcv_q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t index1 = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int debounce_count = QL_MAX_DEBOUNCE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_srb_t *sp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ring_updated = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_CTRL_2425)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_isp24xx_rcvbuf(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Acquire adapter state lock. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ADAPTER_STATE_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate number of free receive buffer entries. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = RD16_IO_REG(ha, mailbox[8]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index1 = RD16_IO_REG(ha, mailbox[8]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index1 == index) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = index1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (debounce_count --);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (debounce_count < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "max mb8 debounce retries exceeded\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcv_q_cnt = (uint16_t)(ha->rcvbuf_ring_index < index ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index - ha->rcvbuf_ring_index : RCVBUF_CONTAINER_CNT -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->rcvbuf_ring_index - index));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rcv_q_cnt == RCVBUF_CONTAINER_CNT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcv_q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load all free buffers in ISP receive buffer ring. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index = 0;
16dd44c265271a75647fb0bb41109bb7c585a526Daniel Beauregard while (rcv_q_cnt > (uint16_t)0 && index < QL_UB_LIMIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Locate a buffer to give. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (index < QL_UB_LIMIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp = ha->ub_array[index];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp = ubp->ub_fca_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((sp->ub_type == FC_TYPE_IS8802_SNAP) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->flags & IP_INITIALIZED) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sp->flags & SRB_UB_IN_FCA) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(sp->flags & (SRB_UB_IN_ISP |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SRB_UB_FREE_REQUESTED | SRB_UB_CALLBACK |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SRB_UB_ACQUIRED)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->flags |= SRB_UB_IN_ISP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index < QL_UB_LIMIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcv_q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte container = ha->rcvbuf_ring_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build container.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)&container->bufp[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->ub_buffer.cookie.dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)&container->bufp[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->ub_buffer.cookie.dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &container->handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSW(sp->handle));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_outcnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust ring index. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->rcvbuf_ring_index++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->rcvbuf_ring_index == RCVBUF_CONTAINER_CNT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->rcvbuf_ring_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->rcvbuf_ring_ptr = ha->rcvbuf_ring_bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->rcvbuf_ring_ptr++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ring_updated = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ring_updated) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync queue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ddi_dma_sync(ha->hba_buf.dma_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (off_t)RCVBUF_Q_BUFFER_OFFSET, (size_t)RCVBUF_QUEUE_SIZE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORDEV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set chip new ring index. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WRT16_IO_REG(ha, mailbox[8], ha->rcvbuf_ring_index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Release adapter state lock. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ADAPTER_STATE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_isp24xx_rcvbuf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Locates free buffers and send it to adapter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_isp24xx_rcvbuf(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcvbuf_t *container;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_srb_t *sp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip_buf_pool_entry_t *pkt = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Locate a buffer to give. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (index = 0; index < QL_UB_LIMIT; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp = ha->ub_array[index];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp = ubp->ub_fca_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((sp->ub_type == FC_TYPE_IS8802_SNAP) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->flags & IP_INITIALIZED) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sp->flags & SRB_UB_IN_FCA) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(sp->flags & (SRB_UB_IN_ISP |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SRB_UB_FREE_REQUESTED | SRB_UB_CALLBACK |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SRB_UB_ACQUIRED)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_outcnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->flags |= SRB_UB_IN_ISP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (index == QL_UB_LIMIT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get IOCB packet for buffers. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_req_pkt(ha, (request_t **)&pkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed, ql_req_pkt=%x\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_outcnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->flags &= ~SRB_UB_IN_ISP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = IP_BUF_POOL_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte container = &pkt->buffers[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build container.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &container->bufp[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->ub_buffer.cookie.dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle, &container->bufp[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->ub_buffer.cookie.dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &container->handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LSW(sp->handle));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->buffer_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte container++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt->buffer_count == IP_POOL_BUFFERS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_isp_cmd(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_isp_cmd(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_modify_lun
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function enables, modifies or disables ISP to respond as a target.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * count = number buffers for incoming commands.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql local function return status code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_modify_lun(ql_adapter_state_t *ha)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enable_lun_entry_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = QL_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t index, ubcount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Count the number of SCSI unsolicited buffers, that have been
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ADAPTER_STATE_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubcount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_LOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (index = 0; index < QL_UB_LIMIT; index++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp = ha->ub_array[index];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_srb_t *sp = ubp->ub_fca_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->ub_type == FC_TYPE_SCSI_FCP &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(sp->flags & SRB_UB_FREE_REQUESTED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubcount++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_UB_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(ha->flags & TARGET_MODE_INITIALIZED) && (ubcount == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = ql_req_pkt(ha, (request_t **)&pkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ha->flags & TARGET_MODE_INITIALIZED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubcount == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Disable the target mode Luns */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(ha->ub_command_count != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(ha->ub_notify_count != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->flags &= ~(TARGET_MODE_INITIALIZED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_command_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = ENABLE_LUN_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->command_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->immediate_notify_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Modify the command count for target mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte modify_lun_entry_t *ml_pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t cmd_count, notify_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(ha->ub_command_count != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(ha->ub_notify_count != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * calculate the new value of command count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and notify count and then issue the command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to change the values in the firmware.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt = (modify_lun_entry_t *)pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->entry_type = MODIFY_LUN_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubcount < 255) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save one for immediate notify. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubcount > 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd_count = (uint8_t)(ubcount - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd_count = (uint8_t)ubcount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte notify_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd_count = 255;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubcount - 255 < 255) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte notify_count = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ubcount - 255);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte notify_count = 255;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd_count > ha->ub_command_count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cmd_count value increased */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->command_count = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd_count - ha->ub_command_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->operators = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ml_pkt->operators | BIT_0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (notify_count > ha->ub_notify_count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->immediate_notify_count =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t)(notify_count -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->operators = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ml_pkt->operators | BIT_2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (notify_count <
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->immediate_notify_count =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t)(ha->ub_notify_count -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte notify_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->operators = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ml_pkt->operators | BIT_3);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cmd_count value reduced */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->command_count = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ha->ub_command_count - cmd_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ml_pkt->command_count != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->operators = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ml_pkt->operators | BIT_1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (notify_count > ha->ub_notify_count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->immediate_notify_count =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t)(notify_count -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->operators = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ml_pkt->operators | BIT_2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (notify_count <
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->immediate_notify_count =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t)(ha->ub_notify_count -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte notify_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ml_pkt->operators = (uint8_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ml_pkt->operators | BIT_3);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Update the driver's command/notify count values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_command_count = cmd_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count = notify_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(ubcount != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Enable the Luns for the target mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = ENABLE_LUN_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubcount < 255) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save one for immediate notify. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubcount > 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_command_count = (uint8_t)(ubcount - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_command_count = (uint8_t)ubcount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_command_count = 255;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ubcount - 255 < 255) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count = (uint8_t)(ubcount - 255);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->ub_notify_count = 255;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ha->flags |= TARGET_MODE_INITIALIZED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->command_count = ha->ub_command_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->immediate_notify_count = ha->ub_notify_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ADAPTER_STATE_UNLOCK(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Issue command to ISP */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_isp_cmd(ha);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != QL_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "failed=%xh\n", rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_notify_acknowledge_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of notify acknowledge IOCB for pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * immediate notify entry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha: adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cmd: target command context pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pkt: request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_notify_acknowledge_iocb(ql_adapter_state_t *ha, tgt_cmd_t *cmd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte notify_acknowledge_entry_t *pkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = NOTIFY_ACKNOWLEDGE_TYPE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->initiator_id_l = cmd->initiator_id_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->initiator_id_h = cmd->initiator_id_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Handle LIP reset event. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->status == 0xe) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->flags_l = BIT_5;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->flags_h = BIT_0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->status, cmd->status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->task_flags_l = cmd->task_flags_l;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->task_flags_h = cmd->task_flags_h;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->sequence_id = cmd->rx_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_continue_target_io_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of continue target I/O IOCB for pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * accept target I/O entry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp = srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg = request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_continue_target_io_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_dma_cookie_t *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_id_t d_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ql_tgt_t *tq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctio_entry_t *pkt = arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte d_id.b24 = sp->pkt->pkt_cmd_fhdr.d_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tq = ql_d_id_to_queue(ha, d_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tq == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EL(ha, "Unknown Initiator d_id %xh", d_id.b24);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->initiator_id_l = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->initiator_id_h = MSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->initiator_id_h = LSB(tq->loop_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->rx_id = sp->pkt->pkt_cmd_fhdr.rx_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set ISP command timeout. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->isp_timeout < 0x1999) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sp->isp_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->flags & SRB_FCP_DATA_PKT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->pkt->pkt_tran_type == FC_PKT_OUTBOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->flags_l = BIT_6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (sp->pkt->pkt_tran_type == FC_PKT_INBOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->flags_l = BIT_7;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->flags_h = BIT_1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set relative offset. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)&pkt->relative_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)sp->pkt->pkt_cmd_fhdr.ro);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* (sp->flags & SRB_FCP_RSP_PKT) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->flags_l = BIT_7 | BIT_6 | BIT_1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->flags_h = BIT_7 | BIT_1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Load data segments.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sp->pkt->pkt_cmdlen != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = sp->pkt->pkt_cmd_cookie;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Transfer length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)&pkt->type.s0_32bit.byte_count,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load data segments. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->dseg_count_l = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = CTIO_TYPE_3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pkt->type.s0_64bit.dseg_0_address[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pkt->type.s0_64bit.dseg_0_address[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_notused);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pkt->type.s0_64bit.dseg_0_length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->entry_type = CTIO_TYPE_2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pkt->type.s0_32bit.dseg_0_address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp->dmac_address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddi_put32(ha->hba_buf.acc_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)(void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pkt->type.s0_32bit.dseg_0_length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t)cp->dmac_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ql_continue_target_io_2400_iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup of continue target I/O IOCB for pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * accept target I/O entry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ha = adapter state pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sp = srb structure pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg = request queue packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Context:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Interrupt or Kernel context, no mailbox commands allowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteql_continue_target_io_2400_iocb(ql_adapter_state_t *ha, ql_srb_t *sp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}