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 *
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * You can obtain a copy of the license at
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * http://www.opensource.org/licenses/cddl1.txt.
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Copyright (c) 2004-2011 Emulex. All rights reserved.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#include <emlxs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEMLXS_MSG_DEF(EMLXS_IP_C);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_ip_handle_event(emlxs_hba_t *hba, CHANNEL *cp, IOCBQ *iocbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpEvent++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpStray++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_stray_ip_completion_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "cmd=0x%x iotag=0x%x status=0x%x perr=0x%x",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (uint32_t)cmd->ULPCOMMAND, (uint32_t)cmd->ULPIOTAG,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmd->ULPSTATUS, cmd->un.ulpWord[4]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->channelno != hba->channel_ip) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpStray++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = sbp->iocbq.port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan switch (cmd->ULPCOMMAND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Error: Abnormal BCAST command completion (Local error)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_BCAST_CN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_BCAST64_CN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpBcastCompleted++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpBcastError++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "XMIT BCAST completion error cmd=0x%x status=0x%x "
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "[%08x,%08x]", cmd->ULPCOMMAND, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.ulpWord[4], cmd->un.ulpWord[5]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_pkt_complete(sbp, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.grsp.perr.statLocalError, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Error: Abnormal XMIT SEQUENCE command completion
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * (Local error)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_SEQUENCE_CR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_SEQUENCE64_CR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpSeqCompleted++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpSeqError++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "XMIT SEQUENCE CR completion error: cmd=%x status=0x%x "
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "[%08x,%08x]", cmd->ULPCOMMAND, cmd->ULPSTATUS,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan cmd->un.ulpWord[4], cmd->un.ulpWord[5]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_pkt_complete(sbp, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.grsp.perr.statLocalError, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Normal BCAST completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_BCAST_CX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_BCAST64_CX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpBcastCompleted++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpBcastGood++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "XMIT BCAST CN completion: cmd=%x status=0x%x [%08x,%08x]",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmd->ULPCOMMAND, cmd->ULPSTATUS, cmd->un.ulpWord[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.ulpWord[5]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_pkt_complete(sbp, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.grsp.perr.statLocalError, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Normal XMIT SEQUENCE completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_SEQUENCE_CX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CMD_XMIT_SEQUENCE64_CX:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpSeqCompleted++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "XMIT SEQUENCE CR completion: cmd=%x status=0x%x"
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "[%08x,%08x]", cmd->ULPCOMMAND, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.ulpWord[4], cmd->un.ulpWord[5]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cmd->ULPSTATUS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpSeqError++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((cmd->ULPSTATUS == IOSTAT_LOCAL_REJECT) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((cmd->un.ulpWord[4] & 0xff) == IOERR_NO_XRI)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ndlp = (NODELIST *)sbp->node;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((cmd->ULPCONTEXT == ndlp->nlp_Xri) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan !(ndlp->nlp_flag[hba->channel_ip] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NLP_RPI_XRI)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_Xri = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) emlxs_create_xri(port, cp, ndlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpSeqGood++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_pkt_complete(sbp, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.grsp.perr.statLocalError, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpStray++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_invalid_ip_msg,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "Invalid iocb: cmd=0x%x", cmd->ULPCOMMAND);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* switch(cmd->ULPCOMMAND) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_ip_handle_event() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_ip_handle_unsol_req(emlxs_port_t *port, CHANNEL *cp, IOCBQ *iocbq,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp, uint32_t size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NETHDR *nd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *mac;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ub_priv_t *ub_priv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t IpDropped = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t IpBcastReceived = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t IpSeqReceived = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MAX_VPORTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = &VPORT(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!(port->flag & EMLXS_INI_BOUND) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(port->flag & EMLXS_PORT_IP_UP)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ubp =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (fc_unsol_buf_t *)emlxs_ub_get(port, size,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan FC_TYPE_IS8802_SNAP, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!ubp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Theoretically we should never get here. */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* There should be one DMA buffer for every ub */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* buffer. If we are out of ub buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* then some how this matching has been corrupted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_ip_dropped_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Buffer not found. paddr=%lx",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan PADDR(cmd->un.cont64[0].addrHigh,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.cont64[0].addrLow));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(mp->virt, ubp->ub_buffer, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ub_priv = ubp->ub_fca_private;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan nd = (NETHDR *)ubp->ub_buffer;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mac = nd->fc_srcname.IEEE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp = emlxs_node_find_mac(port, mac);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sid = ndlp->nlp_DID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ndlp->nlp_Xri == 0) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan !(ndlp->nlp_flag[hba->channel_ip] & NLP_RPI_XRI)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) emlxs_create_xri(port, cp, ndlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If no node is found, then check if this is a
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * broadcast frame
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (cmd->un.xrseq.w5.hcsw.Fctl & BC) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sid = cmd->un.ulpWord[4] & 0x00ffffff;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan else {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* We have to drop this frame because we do not have */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* the S_ID of the request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_ip_dropped_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Node not found. mac=%02x%02x%02x%02x%02x%02x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void) emlxs_fca_ub_release((opaque_t)port, 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ubp->ub_token);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd->un.xrseq.w5.hcsw.Fctl & BC) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IpBcastReceived++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IpSeqReceived++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup frame header
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp->ub_frame.r_ctl = cmd->un.xrseq.w5.hcsw.Rctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp->ub_frame.type = cmd->un.xrseq.w5.hcsw.Type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp->ub_frame.s_id = sid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp->ub_frame.ox_id = ub_priv->token;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ubp->ub_frame.rx_id = cmd->ULPCONTEXT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp->ub_class = FC_TRAN_CLASS3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ub_callback(port, ubp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IpDropped = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteout:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IpDropped) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpDropped++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IpBcastReceived) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpBcastReceived++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IpSeqReceived) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpSeqReceived++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_ip_handle_unsol_req() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_ip_handle_rcv_seq_list(emlxs_hba_t *hba, CHANNEL *cp, IOCBQ *iocbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t bdeAddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBQE_t *hbqE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t hbq_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t hbqe_tag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan RING *rp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No action required for now.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rp = &hba->sli.sli3.ring[cp->channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpRcvEvent++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Receive sequence list: cmd=0x%x iotag=0x%x status=0x%x "
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "w4=0x%x channelno=0x%x", cmd->ULPCOMMAND, cmd->ULPIOTAG,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmd->ULPSTATUS, cmd->un.ulpWord[4], cp->channelno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cmd->ULPSTATUS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hbqE = (HBQE_t *)&iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hbq_id = hbqE->unt.ext.HBQ_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hbqe_tag = hbqE->unt.ext.HBQE_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_HBQ_ENABLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBQ_INIT_t *hbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hbq = &hba->sli.sli3.hbq_table[hbq_id];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpUbPosted--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hbqe_tag >= hbq->HBQ_numEntries) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mp = hba->sli.sli3.hbq_table
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan [hbq_id].HBQ_PostBufs[hbqe_tag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for valid buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(cmd->un.cont64[0].tus.f.bdeFlags & BUFF_TYPE_INVALID)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bdeAddr =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan PADDR(cmd->un.cont64[0].addrHigh,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.cont64[0].addrLow);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = emlxs_mem_get_vaddr(hba, rp, bdeAddr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteout:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_HBQ_ENABLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_update_HBQ_index(hba, hbq_id);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_IPBUF, (void *)mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_post_buffer(hba, rp, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.IpDropped++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_ip_handle_rcv_seq_list() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Process a create_xri command completion.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_handle_create_xri(emlxs_hba_t *hba, CHANNEL *cp, IOCBQ *iocbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld int32_t rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_stray_ip_completion_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "create_xri: cmd=0x%x iotag=0x%x status=0x%x w4=0x%x. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "NULL sbp found.",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmd->ULPCOMMAND, cmd->ULPIOTAG, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.ulpWord[4]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check for first xmit completion in sequence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp = (NODELIST *)sbp->node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!ndlp) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_bad_ip_completion_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "create_xri: cmd=0x%x iotag=0x%x status=0x%x w4=0x%x. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "NULL node found.",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld cmd->ULPCOMMAND, cmd->ULPIOTAG, cmd->ULPSTATUS,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld cmd->un.ulpWord[4]);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rval = EIO;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto done;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cmd->ULPSTATUS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_bad_ip_completion_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "create_xri: cmd=0x%x iotag=0x%x status=0x%x w4=0x%x. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Completion error.",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmd->ULPCOMMAND, cmd->ULPIOTAG, cmd->ULPSTATUS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.ulpWord[4]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_flag[cp->channelno] &= ~NLP_RPI_XRI;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rval = EIO;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_Xri = cmd->ULPCONTEXT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_flag[cp->channelno] &= ~NLP_RPI_XRI;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "create_xri completed: DID=0x%x Xri=0x%x iotag=0x%x",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_DID, ndlp->nlp_Xri, cmd->ULPIOTAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfelddone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = sbp->pkt;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (pkt) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_pkt_free(pkt);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_handle_create_xri() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Issue an iocb command to create an exchange with the remote Nport
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * specified by the NODELIST entry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_create_xri(emlxs_port_t *port, CHANNEL *cp, NODELIST *ndlp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if an XRI has already been requested */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_Xri != 0 ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (ndlp->nlp_flag[cp->channelno] & NLP_RPI_XRI)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_flag[cp->channelno] |= NLP_RPI_XRI;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(pkt = emlxs_pkt_alloc(port, 0, 0, 0, KM_NOSLEEP))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "create_xri failed: Unable to allocate pkt. did=0x%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_DID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto fail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)pkt->pkt_fca_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = &sbp->iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Clear the PACKET_ULP_OWNED flag */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->pkt_flags &= ~PACKET_ULP_OWNED;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the iotag by registering the packet */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iotag = emlxs_register_pkt(cp, sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!iotag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No more command slots available, retry later
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_free(pkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "create_xri failed: Unable to allocate IOTAG. did=0x%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_DID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto fail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPIOTAG = iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCONTEXT = ndlp->nlp_Rpi;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPLE = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND = CMD_CREATE_XRI_CR;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPOWNER = OWN_CHIP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initalize iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->port = (void *)port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->node = (void *)ndlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel = (void *)cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->node = (void *)ndlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->channel = cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_ip_detail_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "create_xri sent: DID=0x%x Xri=0x%x iotag=0x%x", ndlp->nlp_DID,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ndlp->nlp_Xri, iotag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, cp, iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefail:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the XRI flag */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_flag[cp->channelno] &= ~NLP_RPI_XRI;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_create_xri() */