9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The contents of this file are subject to the terms of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Common Development and Distribution License (the "License").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You may not use this file except in compliance with the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When distributing Covered Code, include this CDDL HEADER in each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If applicable, add the following below this CDDL HEADER, with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fields enclosed by brackets "[]" replaced with your own identifying
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information: Portions Copyright [yyyy] [name of copyright owner]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER END
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Use is subject to license terms.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Tavor Queue Pair Modify Routines
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This contains all the routines necessary to implement the Tavor
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ModifyQP() verb. This includes all the code for legal transitions to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and from Reset, Init, RTR, RTS, SQD, SQErr, and Error.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_reset2init(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_init2init(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_init2rtr(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_rtr2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_rts2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_rts2sqd(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_sqd2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_sqd2sqd(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_sqerr2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_to_error(tavor_state_t *state, tavor_qphdl_t qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_reset2err(tavor_state_t *state, tavor_qphdl_t qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic uint_t tavor_check_rdma_enable_flags(ibt_cep_modify_flags_t flags,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_validate_resp_rsrc(tavor_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_validate_init_depth(tavor_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int tavor_qp_validate_mtu(tavor_state_t *state, uint_t mtu);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_modify()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* ARGSUSED */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_modify(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Lock the QP so that we can modify it atomically. After grabbing
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the lock, get the current QP state. We will use this current QP
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * state to determine the legal transitions (and the checks that need
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to be performed.)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Below you will find a case for every possible QP state. In each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * case we check that no flags are set which are not valid for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * possible transitions from that state. If these tests pass (and if
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the state transition we are attempting is legal), then we call
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * one of the helper functions. Each of these functions does some
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * additional setup before posting a Tavor firmware command for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate state transition.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify that the transport type matches between the serv_type and the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * qp_trans. A caller to IBT must specify the qp_trans field as
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * IBT_UD_SRV, IBT_RC_SRV, or IBT_UC_SRV, depending on the QP. We
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * check here that the correct value was specified, based on our
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * understanding of the QP serv type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Because callers specify part of a 'union' based on what QP type they
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * think they're working with, this ensures that we do not pickup bogus
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * data if the caller thought they were working with a different QP
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (!(TAVOR_QP_TYPE_VALID(info_p->qp_trans, qp->qp_serv_type))) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If this is a transition to RTS (which is valid from RTR, RTS,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * SQError, and SQ Drain) then we should honor the "current QP state"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specified by the consumer. This means converting the IBTF QP state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in "info_p->qp_current_state" to a Tavor QP state. Otherwise, we
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * assume that we already know the current state (i.e. whatever it was
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * last modified to or queried as - in "qp->qp_state").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cur_state = TAVOR_QP_RTR; /* Ready to Receive */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Convert the current IBTF QP state to a Tavor QP state */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cur_state = TAVOR_QP_RTR; /* Ready to Receive */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cur_state = TAVOR_QP_SQERR; /* Send Queue Error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_modify_inv_currqpstate_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor okflags = (IBT_CEP_SET_STATE | IBT_CEP_SET_RESET_INIT |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for attempts to modify invalid attributes from the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "Reset" state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(IBT_QP_ATTR_RO, "reset: invalid flag");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "Init", back to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "Reset", or to "Error".
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - ambiguous flags */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "reset: ambiguous flags");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Reset" to "Init"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_reset2init(state, qp, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Reset" back to "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Nothing to do here really... just drop the lock
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return success. The qp->qp_state should
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * already be set to TAVOR_QP_RESET.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note: We return here because we do not want to fall
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * through to the tavor_wrid_from_reset_handling()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * routine below (since we are not really moving
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * _out_ of the "Reset" state.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Reset" to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "reset: invalid transition");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Do any additional handling necessary here for the transition
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * from the "Reset" state (e.g. re-initialize the workQ WRID
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * lists). Note: If tavor_wrid_from_reset_handling() fails,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then we attempt to transition the QP back to the "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * state. If that fails, then it is an indication of a serious
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * problem (either HW or SW). So we print out a warning
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * message and return failure.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_wrid_from_reset_handling(state, qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_qp_to_reset(state, qp) != DDI_SUCCESS) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(status, "reset: wrid_from_reset hdl");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor okflags = (IBT_CEP_SET_STATE | IBT_CEP_SET_INIT_RTR |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor IBT_CEP_SET_MIN_RNR_NAK | IBT_CEP_SET_ALT_PATH |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for attempts to modify invalid attributes from the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "Init" state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(IBT_QP_ATTR_RO, "init: invalid flag");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "RTR", back to "Init",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to "Reset", or to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - ambiguous flags */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "init: ambiguous flags");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Init" to "RTR"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_init2rtr(state, qp, flags, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Init" to "Init"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_init2init(state, qp, flags, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Init" to "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Do any additional handling necessary for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transition _to_ the "Reset" state (e.g. update the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * workQ WRID lists)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Init" to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "init: invalid transition");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor okflags = (IBT_CEP_SET_STATE | IBT_CEP_SET_RTR_RTS |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor IBT_CEP_SET_RNR_NAK_RETRY | IBT_CEP_SET_RDMARA_OUT |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for attempts to modify invalid attributes from the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "RTR" state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(IBT_QP_ATTR_RO, "rtr: invalid flag");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "RTS", "Reset",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * or "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - ambiguous flags */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "reset: ambiguous flags");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTR" to "RTS"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_rtr2rts(state, qp, flags, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTR" to "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Do any additional handling necessary for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transition _to_ the "Reset" state (e.g. update the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * workQ WRID lists)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTR" to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "rtr: invalid transition");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor okflags = (IBT_CEP_SET_STATE | IBT_CEP_SET_RDMA_R |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for attempts to modify invalid attributes from the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "RTS" state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(IBT_QP_ATTR_RO, "rts: invalid flag");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "RTS", "SQD", "Reset",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * or "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTS" to "RTS"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_rts2rts(state, qp, flags, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* qp->qp_state = TAVOR_QP_RTS; */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTS" to "SQD"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTS" to "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Do any additional handling necessary for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transition _to_ the "Reset" state (e.g. update the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * workQ WRID lists)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTS" to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "rts: invalid transition");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor okflags = (IBT_CEP_SET_STATE | IBT_CEP_SET_RDMA_R |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for attempts to modify invalid attributes from the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "SQErr" state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(IBT_QP_ATTR_RO, "sqerr: invalid flag");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "RTS", "Reset", or
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQErr" to "RTS"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_sqerr2rts(state, qp, flags, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQErr" to "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Do any additional handling necessary for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transition _to_ the "Reset" state (e.g. update the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * workQ WRID lists)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQErr" to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "sqerr: invalid transition");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor okflags = (IBT_CEP_SET_STATE | IBT_CEP_SET_ADDS_VECT |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor IBT_CEP_SET_RDMARA_OUT | IBT_CEP_SET_RDMARA_IN |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for attempts to modify invalid attributes from the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "SQD" state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(IBT_QP_ATTR_RO, "sqd: invalid flag");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "SQD", "RTS", "Reset",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * or "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQD" to "SQD"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_sqd2sqd(state, qp, flags, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If still draining SQ, then fail transition attempt
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQD" to "RTS"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_qp_sqd2rts(state, qp, flags, info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQD" to "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Do any additional handling necessary for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transition _to_ the "Reset" state (e.g. update the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * workQ WRID lists)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQD" to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "sqd: invalid transition");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "Reset" or back to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Error" to "Reset"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status"/"errormsg", goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Do any additional handling necessary for the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transition _to_ the "Reset" state (e.g. update the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * workQ WRID lists)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Error" back to "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Nothing to do here really... just drop the lock
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return success. The qp->qp_state should
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * already be set to TAVOR_QP_ERR.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor "error: invalid transition");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP state. If we got here then it's a warning of
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * a probably serious problem. So print a message and return
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP state in modify");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set "status" and "errormsg" and goto failure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_FAIL(IBT_QP_STATE_INVALID, "invalid curr QP state");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_modify_fail, TAVOR_TNF_ERROR, "",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_reset2init()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_reset2init(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Fill in the common and/or Tavor-specific fields in the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->sched_q = TAVOR_QP_SCHEDQ_GET(qp->qp_qpnum);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now fill in the QPC fields which are specific to transport type
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the QKey */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Check for valid port number and fill it in */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Check for valid PKey index and fill it in */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_ERROR, "", tnf_uint, pkeyindx, pkeyindx);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the RDMA (recv) enable/disable flags */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rre = (info_p->qp_flags & IBT_CEP_RDMA_RD) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rae = (info_p->qp_flags & IBT_CEP_ATOMIC) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Check for valid port number and fill it in */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Check for valid PKey index and fill it in */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_ERROR, "", tnf_uint, pkeyindx, pkeyindx);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set the RDMA (recv) enable/disable flags. Note: RDMA Read
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and Atomic are ignored by default.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Check for valid port number and fill it in */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Check for valid PKey index and fill it in */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_TNF_ERROR, "", tnf_uint, pkeyindx, pkeyindx);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in rst2init");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_reset2init_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RST2INIT_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, RST2INIT_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: RST2INIT_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_reset2init_cmd_fail, TAVOR_TNF_ERROR, "",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_init2init()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_init2init(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Since there are no common and/or Tavor-specific fields to be filled
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in for this command, we begin with the QPC fields which are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific to transport type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the port for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * check for valid port number and fill it in. Also set the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the QKey for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the port for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * check for valid port number and fill it in. Also set the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (recv) enable/disable flags and set the appropriate flag in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "opmask" parameter
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor opmask |= tavor_check_rdma_enable_flags(flags, info_p, qpc);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the port for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * check for valid port number and fill it in. Also set the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Write (recv) enable/disable and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter. Note: RDMA Read and Atomic are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not valid for UC transport.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in init2init");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_init2init_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the INIT2INIT_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, INIT2INIT_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: INIT2INIT_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_init2init_inv_qpstate_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_init2rtr()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_init2rtr(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Since there are no common and/or Tavor-specific fields to be filled
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in for this command, we begin with the QPC fields which are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific to transport type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If this UD QP is also a "special QP" (QP0 or QP1), then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the MTU is 256 bytes. However, Tavor HW requires us to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the MTU to 4 (which is the IB code for a 2K MTU).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If this is not a special QP, then we set the MTU to the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * configured maximum (which defaults to 2K). Note: the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * QPC "msg_max" must also be set so as to correspond with
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the specified MTU value.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->msg_max = qpc->mtu + 7; /* must equal MTU plus seven */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Save away the MTU value. This is used in future sqd2sqd
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitions, as the MTU must remain the same in future
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the QKey for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set the common primary address path fields
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The following values are apparently "required" here (as
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * they are part of the IBA-defined "Remote Node Address
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Vector"). However, they are also going to be "required"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * later - at RTR2RTS_QP time. Not sure why. But we set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * them here anyway.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Setup the destination QP, recv PSN, MTU, max msg size,etc.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note max message size is defined to be the maximum IB
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * allowed message size (which is 2^31 bytes). Also max
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * MTU is defined by HCA port properties.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If this QP is using an SRQ, 'ric' must be set to 1.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->ric = (qp->qp_srq_en == TAVOR_QP_SRQ_ENABLED) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_qp_validate_mtu(state, mtu) != DDI_SUCCESS) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Save away the MTU value. This is used in future sqd2sqd
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitions, as the MTU must remain the same in future
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Though it is a "required" parameter, "min_rnr_nak" is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * optionally specifiable in Tavor. So we hardcode the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * optional flag here.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check that the number of specified "incoming RDMA resources"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * is valid. And if it is, then setup the "rra_max" and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "ra_buf_index" fields in the QPC to point to the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * pre-allocated RDB resources (in DDR)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_qp_validate_resp_rsrc(state, rc, &rra_max) !=
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->ra_buff_indx = qp->qp_rdb_ddraddr >> TAVOR_RDB_SIZE_SHIFT;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (recv) enable/disable flags and set the appropriate flag in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "opmask" parameter
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor opmask |= tavor_check_rdma_enable_flags(flags, info_p, qpc);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_alt_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copy the "RNR Retry count" value from the primary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * path. Just as we did above, we need to hardcode
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the optional flag here (see below).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set the common primary address path fields
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Setup the destination QP, recv PSN, MTU, max msg size,etc.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note max message size is defined to be the maximum IB
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * allowed message size (which is 2^31 bytes). Also max
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * MTU is defined by HCA port properties.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_qp_validate_mtu(state, mtu) != DDI_SUCCESS) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Save away the MTU value. This is used in future sqd2sqd
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitions, as the MTU must remain the same in future
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Write (recv) enable/disable and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter. Note: RDMA Read and Atomic are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not valid for UC transport.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in init2rtr");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_init2rtr_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the INIT2RTR_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, INIT2RTR_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: INIT2RTR_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_rtr2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_rtr2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Fill in the common and/or Tavor-specific fields in the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->flight_lim = TAVOR_QP_FLIGHT_LIM_UNLIMITED;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now fill in the QPC fields which are specific to transport type
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the send PSN */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the QKey for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Setup the send PSN, ACK timeout, and retry counts
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set "ack_req_freq" based on the configuration variable
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->ack_req_freq = state->ts_cfg_profile->cp_ackreq_freq;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check that the number of specified "outgoing RDMA resources"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * is valid. And if it is, then setup the "sra_max"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriately
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_qp_validate_init_depth(state, rc, &sra_max) !=
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Configure the QP to allow (sending of) all types of RC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * traffic. Tavor hardware allows these bits to be set to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * zero (thereby disabling certain outgoing RDMA types), but
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * we do not desire to do this.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (recv) enable/disable flags and set the appropriate flag in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "opmask" parameter
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor opmask |= tavor_check_rdma_enable_flags(flags, info_p, qpc);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (rc->rc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_rtr2rts_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the "Minimum RNR NAK" value
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for this QP, then fill it in and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_alt_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copy the "RNR Retry count" value from the primary
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * path. Just as we did above, we need to hardcode
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the optional flag here (see below).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the send PSN */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Configure the QP to allow (sending of) all types of allowable
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * UC traffic (i.e. RDMA Write).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Write (recv) enable/disable and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter. Note: RDMA Read and Atomic are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not valid for UC transport.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (uc->uc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_rtr2rts_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in rtr2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_rtr2rts_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RTR2RTS_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, RTR2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: RTR2RTS_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_rts2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_rts2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Since there are no common and/or Tavor-specific fields to be filled
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in for this command, we begin with the QPC fields which are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific to transport type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the QKey for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (recv) enable/disable flags and set the appropriate flag in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "opmask" parameter
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor opmask |= tavor_check_rdma_enable_flags(flags, info_p, qpc);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (rc->rc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_rts2rts_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the "Minimum RNR NAK" value
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for this QP, then fill it in and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_alt_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Write (recv) enable/disable and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter. Note: RDMA Read and Atomic are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not valid for UC transport.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (uc->uc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_rts2rts_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in rts2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_rts2rts_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RTS2RTS_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, RTS2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: RTS2RTS_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_rts2sqd()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_rts2sqd(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set a flag to indicate whether or not the consumer is interested
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in receiving the SQ drained event. Since we are going to always
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * request hardware generation of the SQD event, we use the value in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_forward_sqd_event" to determine whether or not to pass the event
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to the IBTF or to silently consume it.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qp->qp_forward_sqd_event = (flags & IBT_CEP_SET_SQD_EVENT) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RTS2SQD_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, RTS2SQD_QP, NULL, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: RTS2SQD_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Mark the current QP state as "SQ Draining". This allows us to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * distinguish between the two underlying states in SQD. (see QueryQP()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_sqd2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_sqd2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Since there are no common and/or Tavor-specific fields to be filled
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in for this command, we begin with the QPC fields which are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific to transport type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the QKey for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (recv) enable/disable flags and set the appropriate flag in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "opmask" parameter
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor opmask |= tavor_check_rdma_enable_flags(flags, info_p, qpc);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (rc->rc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_sqd2rts_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_alt_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the "Minimum RNR NAK" value
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for this QP, then fill it in and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Write (recv) enable/disable and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter. Note: RDMA Read and Atomic are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not valid for UC transport.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (uc->uc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_sqd2rts_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in sqd2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_sqd2rts_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the SQD2RTS_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, SQD2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: SQD2RTS_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_sqd2sqd()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_sqd2sqd(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor uint_t portnum, pkeyindx, rdma_ra_out, rdma_ra_in;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Since there are no common and/or Tavor-specific fields to be filled
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in for this command, we begin with the QPC fields which are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific to transport type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the QKey for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (recv) enable/disable flags and set the appropriate flag in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "opmask" parameter
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor opmask |= tavor_check_rdma_enable_flags(flags, info_p, qpc);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional primary path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common primary address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * MTU changes as part of sqd2sqd are not allowed.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Simply keep the same MTU value here, stored in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * qphdl from init2rtr time.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_CMD_OP_RETRYCNT | TAVOR_CMD_OP_ACKTIMEOUT |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (rc->rc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_sqd2sqd_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the port for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * check for valid port number and fill it in. Also set the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_alt_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the number of "outgoing
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * RDMA resources" for this QP, then check for valid value and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in. Also set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the number of "incoming
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * RDMA resources" for this QP, then check for valid value and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * update the "rra_max" and "ra_buf_index" fields in the QPC to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * point to the pre-allocated RDB resources (in DDR). Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the "Local Ack Timeout" value
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for this QP, then fill it in and set the appropriate flag in
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc_path->ack_timeout = rc->rc_path.cep_timeout;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the "Retry Count" for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the "RNR Retry Count" for this
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * QP, then fill it in and set the appropriate flag in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the "Minimum RNR NAK" value
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * for this QP, then fill it in and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Write (recv) enable/disable and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter. Note: RDMA Read and Atomic are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not valid for UC transport.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional primary path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common primary address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * MTU changes as part of sqd2sqd are not allowed.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Simply keep the same MTU value here, stored in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * qphdl from init2rtr time.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the path migration state for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * this QP, then check for valid state and fill it in. Also
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor } else if (uc->uc_mig_state == IBT_STATE_REARMED) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_sqd2sqd_inv_mig_state_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the PKey index for this QP,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * then check for valid PKey index and fill it in. Also set
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the appropriate flag in the "opmask" parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for optional alternate path and fill in the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * appropriate QPC fields if one is specified
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the common alternate address path fields */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in sqd2sqd");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_sqd2sqd_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the SQD2SQD_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, SQD2SQD_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: SQD2SQD_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_sqerr2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_sqerr2rts(tavor_state_t *state, tavor_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Since there are no common and/or Tavor-specific fields to be filled
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in for this command, we begin with the QPC fields which are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * specific to transport type.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If we are attempting to modify the QKey for this QP, then
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fill it in and set the appropriate flag in the "opmask"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * parameter.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if any of the flags indicate a change in the RDMA
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Write (recv) enable/disable and set the appropriate flag
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * in the "opmask" parameter. Note: RDMA Read and Atomic are
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not valid for UC transport.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in sqerr2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_sqerr2rts_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the SQERR2RTS_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, SQERR2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: SQERR2RTS_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_sqerr2rts_inv_qpstate_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_to_error()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_to_error(tavor_state_t *state, tavor_qphdl_t qp)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the TOERR_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, TOERR_QP, NULL, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: TOERR_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_to_reset()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_to_reset(tavor_state_t *state, tavor_qphdl_t qp)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the TORST_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, TORST_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: TORST_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_reset2err()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_reset2err(tavor_state_t *state, tavor_qphdl_t qp)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * In order to implement the transition from "Reset" directly to the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "Error" state, it is necessary to first give ownership of the QP
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * context to the Tavor hardware. This is accomplished by transitioning
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the QP to "Init" as an intermediate step and then, immediately
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitioning to "Error".
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When this function returns success, the QP context will be owned by
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the Tavor hardware and will be in the "Error" state.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Fill in the common and/or Tavor-specific fields in the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->sched_q = TAVOR_QP_SCHEDQ_GET(qp->qp_qpnum);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now fill in the QPC fields which are specific to transport type
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the UD parameters to an invalid default */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the RC parameters to invalid default */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the UC parameters to invalid default */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Invalid QP transport type. If we got here then it's a
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * warning of a probably serious problem. So print a message
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and return failure
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "unknown QP transport type in rst2err");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_0(tavor_qp_reset2err_inv_transtype_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RST2INIT_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". If we got raised to interrupt level by priority
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * inversion, we do not want to block in this routine waiting for
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, RST2INIT_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: RST2INIT_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TNF_PROBE_1(tavor_qp_reset2err_rst2init_cmd_fail,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now post the TOERR_QP command to the Tavor firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We still do a TAVOR_NOSLEEP here because we are still holding the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "qp_lock". Note: If this fails (which it really never should),
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * it indicates a serious problem in the HW or SW. We try to move
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the QP back to the "Reset" state if possible and print a warning
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * message if not. In any case, we return an error here.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = tavor_cmn_qp_cmd_post(state, TOERR_QP, NULL, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_CONT, "Tavor: TOERR_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (tavor_qp_to_reset(state, qp) != DDI_SUCCESS) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor TAVOR_WARNING(state, "failed to reset QP context");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_check_rdma_enable_flags()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_check_rdma_enable_flags(ibt_cep_modify_flags_t flags,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rre = (info_p->qp_flags & IBT_CEP_RDMA_RD) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rwe = (info_p->qp_flags & IBT_CEP_RDMA_WR) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rae = (info_p->qp_flags & IBT_CEP_ATOMIC) ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_validate_resp_rsrc()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_validate_resp_rsrc(tavor_state_t *state, ibt_qp_rc_attr_t *rc,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if number of responder resources is too large. Return an
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * error if it is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (rdma_ra_in > state->ts_cfg_profile->cp_hca_max_rdma_in_qp) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If the number of responder resources is too small, round it up.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Then find the next highest power-of-2
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_validate_init_depth()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_validate_init_depth(tavor_state_t *state, ibt_qp_rc_attr_t *rc,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check if requested initiator depth is too large. Return an error
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (rdma_ra_out > state->ts_cfg_profile->cp_hca_max_rdma_out_qp) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If the requested initiator depth is too small, round it up.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Then find the next highest power-of-2
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * tavor_qp_validate_mtu()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylortavor_qp_validate_mtu(tavor_state_t *state, uint_t mtu)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for invalid MTU values (i.e. zero or any value larger than
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the HCA's port maximum).
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if ((mtu == 0) || (mtu > state->ts_cfg_profile->cp_max_mtu)) {