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
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard/* Copyright 2010 QLogic Corporation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard#pragma ident "Copyright 2010 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 **
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard * * COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * * ALL RIGHTS RESERVED **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * * **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ***********************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_apps.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_api.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_debug.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ql_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 */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic int ql_req_pkt(ql_adapter_state_t *, request_t **);
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 *);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregardstatic void ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
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;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard sp->request_ring_ptr = pkt;
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 */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_8021)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint32_t w32;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard w32 = ha->req_ring_index << 16 |
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->function_number << 5 | 4;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard do {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ddi_put32(ha->db_dev_handle, ha->nx_req_in,
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard w32);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } while (RD_REG_DWORD(ha, ha->db_read) != w32);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard WRT16_IO_REG(ha, req_in, ha->req_ring_index);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
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 */
5dfd244acc8f144280c5bc8f69ed941185fc3cccDaniel Beauregardstatic int
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)) &&
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard INTERRUPT_PENDING(ha)) {
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. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_8021)) {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard uint32_t w32;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard w32 = ha->req_ring_index << 16 |
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ha->function_number << 5 | 4;
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard do {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard ddi_put32(ha->db_dev_handle, ha->nx_req_in, w32);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } while (RD_REG_DWORD(ha, ha->db_read) != w32);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard } else {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard WRT16_IO_REG(ha, req_in, ha->req_ring_index);
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard }
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;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmd7_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
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (fcp->fcp_data_len != 0 && sp->sg_dma.dma_handle != NULL &&
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard sp->pkt->pkt_data_cookie_cnt > 1) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_cmd_24xx_type_6_iocb(ha, sp, arg);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_3(CE_CONT, "(%d): cmd6 exit\n", ha->instance);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard return;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
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
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard/*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * ql_cmd_24xx_type_6_iocb
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Setup of ISP24xx command type 6 IOCB.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Input:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * ha: adapter state pointer.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * sp: srb structure pointer.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * arg: request queue packet.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard *
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Context:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Interrupt or Kernel context, no mailbox commands allowed.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregardstatic void
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregardql_cmd_24xx_type_6_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard{
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint64_t addr;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_dma_cookie_t *cp;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint32_t *ptr32;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard uint16_t seg_cnt;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard fcp_cmd_t *fcp = sp->fcp;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_tgt_t *tq = sp->lun_queue->target_queue;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmd6_24xx_entry_t *pkt = arg;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_adapter_state_t *pha = ha->pha;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard dma_mem_t *cmem = &sp->sg_dma;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cmd6_2400_dma_t *cdma = cmem->bp;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->entry_type = IOCB_CMD_TYPE_6;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard bzero(cdma, sizeof (cmd6_2400_dma_t));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set LUN number */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->fcp_lun[2] = cdma->cmd.fcp_lun[1] = LSB(sp->lun_queue->lun_no);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->fcp_lun[3] = cdma->cmd.fcp_lun[0] = MSB(sp->lun_queue->lun_no);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set N_port handle */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set target ID */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->target_id[0] = tq->d_id.b.al_pa;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->target_id[1] = tq->d_id.b.area;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->target_id[2] = tq->d_id.b.domain;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->vp_index = ha->vp_index;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set ISP command timeout. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (sp->isp_timeout < 0x1999) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard sp->isp_timeout);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Load SCSI CDB */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_rep_put8(cmem->acc_handle, fcp->fcp_cdb, cdma->cmd.scsi_cdb,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard MAX_CMDSZ, DDI_DEV_AUTOINCR);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Set tag queue control flags
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Note:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * Cannot copy fcp->fcp_cntl.cntl_qtype directly,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * problem with x86 in 32bit kernel mode
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard switch (fcp->fcp_cntl.cntl_qtype) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case FCP_QTYPE_SIMPLE:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cdma->cmd.task = TA_STAG;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case FCP_QTYPE_HEAD_OF_Q:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cdma->cmd.task = TA_HTAG;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case FCP_QTYPE_ORDERED:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cdma->cmd.task = TA_OTAG;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case FCP_QTYPE_ACA_Q_TAG:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cdma->cmd.task = TA_ACA;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard case FCP_QTYPE_UNTAGGED:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cdma->cmd.task = TA_UNTAGGED;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard default:
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard break;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * FCP_CMND Payload Data Segment
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cp = cmem->cookies;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put16(pha->hba_buf.acc_handle, &pkt->cmnd_length,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard sizeof (fcp_cmnd_t));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(pha->hba_buf.acc_handle, &pkt->cmnd_address[0],
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cp->dmac_address);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(pha->hba_buf.acc_handle, &pkt->cmnd_address[1],
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cp->dmac_notused);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set transfer direction. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard if (fcp->fcp_cntl.cntl_write_data) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->control_flags = (uint8_t)(CF_DSD_PTR | CF_WR);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cdma->cmd.control_flags = CF_WR;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pha->xioctl->IOOutputRequests++;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pha->xioctl->IOOutputByteCnt += fcp->fcp_data_len;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard } else if (fcp->fcp_cntl.cntl_read_data) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pkt->control_flags = (uint8_t)(CF_DSD_PTR | CF_RD);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cdma->cmd.control_flags = CF_RD;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pha->xioctl->IOInputRequests++;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard pha->xioctl->IOInputByteCnt += fcp->fcp_data_len;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /*
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard * FCP_DATA Data Segment Descriptor.
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard addr = cp->dmac_laddress + sizeof (fcp_cmnd_t);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_address[0], LSD(addr));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_address[1], MSD(addr));
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Set data segment count. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put16(pha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_length,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard seg_cnt * 12 + 12);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Load total byte count. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(pha->hba_buf.acc_handle, &pkt->total_byte_count,
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard fcp->fcp_data_len);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(cmem->acc_handle, &cdma->cmd.dl, (uint32_t)fcp->fcp_data_len);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ql_chg_endian((uint8_t *)&cdma->cmd.dl, 4);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Load command data segments. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ptr32 = (uint32_t *)cdma->cookie_list;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cp = sp->pkt->pkt_data_cookie;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard while (seg_cnt--) {
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(cmem->acc_handle, ptr32++, cp->dmac_address);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(cmem->acc_handle, ptr32++, cp->dmac_notused);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard ddi_put32(cmem->acc_handle, ptr32++, (uint32_t)cp->dmac_size);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard cp++;
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard }
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard /* Sync DMA buffer. */
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard (void) ddi_dma_sync(cmem->dma_handle, 0, 0, DDI_DMA_SYNC_FORDEV);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard}
f885d00f4e3c96a769ce0228a732da31ad9d0b78Daniel Beauregard
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
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
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 QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
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 QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
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
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard if (CFG_IST(ha, CFG_CTRL_24258081)) {
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. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard index = RD16_IO_REG(ha, mailbox_out[8]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard index1 = RD16_IO_REG(ha, mailbox_out[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. */
eb82ff87b34e625264561b2d267577cf9821dab0Daniel Beauregard WRT16_IO_REG(ha, mailbox_in[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}