/*
* Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
* All rights reserved
* www.brocade.com
*
* Linux driver for Brocade Fibre Channel Host Bus Adapter.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License (GPL) Version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <bfa.h>
#include <cs/bfa_debug.h>
#include <bfa_cb_ioim_macros.h>
BFA_TRC_FILE(HAL, IOIM);
/*
* forward declarations.
*/
static bfa_boolean_t bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim);
static bfa_boolean_t bfa_ioim_sge_setup(struct bfa_ioim_s *ioim);
static void bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim);
static bfa_boolean_t bfa_ioim_send_abort(struct bfa_ioim_s *ioim);
static void bfa_ioim_notify_cleanup(struct bfa_ioim_s *ioim);
static void __bfa_cb_ioim_good_comp(void *cbarg, bfa_boolean_t complete);
static void __bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete);
static void __bfa_cb_ioim_abort(void *cbarg, bfa_boolean_t complete);
static void __bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete);
static void __bfa_cb_ioim_pathtov(void *cbarg, bfa_boolean_t complete);
/**
* bfa_ioim_sm
*/
/**
* IO state machine events
*/
enum bfa_ioim_event {
BFA_IOIM_SM_START = 1, /* io start request from host */
BFA_IOIM_SM_COMP_GOOD = 2, /* io good comp, resource free */
BFA_IOIM_SM_COMP = 3, /* io comp, resource is free */
BFA_IOIM_SM_COMP_UTAG = 4, /* io comp, resource is free */
BFA_IOIM_SM_DONE = 5, /* io comp, resource not free */
BFA_IOIM_SM_FREE = 6, /* io resource is freed */
BFA_IOIM_SM_ABORT = 7, /* abort request from scsi stack */
BFA_IOIM_SM_ABORT_COMP = 8, /* abort from f/w */
BFA_IOIM_SM_ABORT_DONE = 9, /* abort completion from f/w */
BFA_IOIM_SM_QRESUME = 10, /* CQ space available to queue IO */
BFA_IOIM_SM_SGALLOCED = 11, /* SG page allocation successful */
BFA_IOIM_SM_SQRETRY = 12, /* sequence recovery retry */
BFA_IOIM_SM_HCB = 13, /* bfa callback complete */
BFA_IOIM_SM_CLEANUP = 14,