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
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Hermon Queue Pair Modify Routines
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * This contains all the routines necessary to implement the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * ModifyQP() verb. This includes all the code for legal
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitions to and from Reset, Init, RTR, RTS, SQD, SQErr,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and Error.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_reset2init(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_init2init(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_init2rtr(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_rtr2rts(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_rts2rts(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_rts2sqd(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_sqd2rts(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_sqd2sqd(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_sqerr2rts(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_to_error(hermon_state_t *state, hermon_qphdl_t qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_reset2err(hermon_state_t *state, hermon_qphdl_t qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic uint_t hermon_check_rdma_enable_flags(ibt_cep_modify_flags_t flags,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_validate_resp_rsrc(hermon_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_validate_init_depth(hermon_state_t *state,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorstatic int hermon_qp_validate_mtu(hermon_state_t *state, uint_t mtu);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_modify()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor/* ARGSUSED */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_modify(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * TODO add support for SUSPEND and RESUME
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 is a case for every possible QP state. In each case, we
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * check that no flags are set which are not valid for the possible
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitions from that state. If these tests pass and the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * state transition we are attempting is legal, then we call one
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * of the helper functions. Each of these functions does some
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * additional setup before posting the 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 (!(HERMON_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 an Hermon 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 = HERMON_QP_RTR; /* Ready to Receive */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Convert the current IBTF QP state to an Hermon QP state */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cur_state = HERMON_QP_RTR; /* Ready to Receive */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cur_state = HERMON_QP_SQERR; /* Send Queue Error */
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 * Verify state transition is to either "Init", back to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * "Reset", or to "Error".
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - ambiguous flags */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Reset" to "Init"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = hermon_qp_reset2init(state, qp, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_INIT);
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 HERMON_QP_RESET.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note: We return here because we do not want to fall
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * through to the hermon_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"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_ERR);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
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 hermon_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 = hermon_wrid_from_reset_handling(state, qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (hermon_qp_to_reset(state, qp) != DDI_SUCCESS) {
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RESET);
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 * 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 * Attempt to transition from "Init" to "RTR"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = hermon_qp_init2rtr(state, qp, flags, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RTR);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Init" to "Init"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = hermon_qp_init2init(state, qp, flags, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_INIT);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Init" to "Reset"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RESET);
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 status = hermon_wrid_to_reset_handling(state, qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Init" to "Error"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_ERR);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
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 * Verify state transition is to either "RTS", "Reset",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * or "Error"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - ambiguous flags */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTR" to "RTS"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = hermon_qp_rtr2rts(state, qp, flags, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RTS);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTR" to "Reset"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RESET);
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 status = hermon_wrid_to_reset_handling(state, qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTR" to "Error"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_ERR);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
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 * 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 = hermon_qp_rts2rts(state, qp, flags, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RTS);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTS" to "SQD"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_SQD);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* hack because of the lack of fw support for SQD */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTS" to "Reset"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RESET);
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 status = hermon_wrid_to_reset_handling(state, qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "RTS" to "Error"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_ERR);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
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 * Verify state transition is to either "RTS", "Reset", or
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQErr" to "RTS"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = hermon_qp_sqerr2rts(state, qp, flags, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RTS);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQErr" to "Reset"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RESET);
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 status = hermon_wrid_to_reset_handling(state, qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQErr" to "Error"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_ERR);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
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 * 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 = hermon_qp_sqd2sqd(state, qp, flags, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_SQD);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If still draining SQ, then fail transition attempt
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * to RTS, even though this is now done is two steps
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * (see below) if the consumer has tried this before
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * it's drained, let him fail and wait appropriately
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * IBA 1.2 has changed - most/all the things that were
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * done in SQD2RTS can be done in SQD2SQD. So make this
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * a 2-step process. First, set any attributes requsted
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * w/ SQD2SQD, but no real transition.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * First, Attempt to transition from "SQD" to "SQD"
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = hermon_qp_sqd2sqd(state, qp, flags, info_p);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_SQD);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The, attempt to transition from "SQD" to "RTS", but
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * request only the state transition, no attributes
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RTS);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQD" to "Reset"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RESET);
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 status = hermon_wrid_to_reset_handling(state, qp);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "SQD" to "Error"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_ERR);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Verify state transition is to either "Reset" or back to
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Attempt to transition from "Error" to "Reset"
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor HERMON_SET_QP_POST_SEND_STATE(qp, HERMON_QP_RESET);
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 status = hermon_wrid_to_reset_handling(state, qp);
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 HERMON_QP_ERR.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Invalid transition - return error */
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 HERMON_WARNING(state, "unknown QP state in modify");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_reset2init()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_reset2init(hermon_state_t *state, hermon_qphdl_t qp,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Fill in the common fields in the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->log_sq_size = highbit(qp->qp_sq_bufsz) - 1;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->log_rq_size = highbit(qp->qp_rq_bufsz) - 1;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cqnmask = (1 << state->hs_cfg_profile->cp_log_num_cq) - 1;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor (qp->qp_sq_cqhdl == NULL) ? 0 : qp->qp_sq_cqhdl->cq_cqnum & cqnmask;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor (qp->qp_rq_cqhdl == NULL) ? 0 : qp->qp_rq_cqhdl->cq_cqnum & cqnmask;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* dbr is now an address, not an index */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->dbr_addrh = ((uint64_t)qp->qp_rq_pdbr >> 32);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->dbr_addrl = ((uint64_t)qp->qp_rq_pdbr & 0xFFFFFFFC) >> 2;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * qpc->wqe_baseaddr is replaced by LKey from the cMPT, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * page_offset, mtt_base_addr_h/l, and log2_page_size will
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * be used to map the WQE buffer
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * NOTE that the cMPT is created implicitly when the QP is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitioned from reset to init
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->mtt_base_addrl = (qp->qp_mrhdl->mr_mttaddr) >> 3;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->mtt_base_addrh = (uint32_t)((qp->qp_mrhdl->mr_mttaddr >> 32) &
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor qp_srq_en = (qp->qp_alloc_flags & IBT_QP_USES_SRQ) != 0;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * Fast Registration Work Requests and Reserved Lkey are enabled
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor * with the single IBT bit stored in qp_rlky.
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor /* 1.2 verbs extensions disabled for now */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor qpc->header_sep = 0; /* disable header separation for now */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor qpc->rss = qp->qp_alloc_flags & IBT_QP_USES_RSS ? 1 : 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->inline_scatter = 0; /* disable inline scatter for now */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now fill in the QPC fields which are specific to transport type
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* Set the QKey */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set MTU and message max. Hermon checks the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * MTU settings rather than just the port MTU,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * so set it to maximum size.
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 (hermon_pkeyindex_is_valid(state, pkeyindx)) {
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor /* fill in the RSS fields */
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor rssp = (struct hermon_hw_rss_s *)&qpc->pri_addr_path;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor rssp->tcp_ipv4 = (flags & IBT_RSS_HASH_TCP_IPV4) != 0;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor rssp->tcp_ipv4 = (flags & IBT_RSS_HASH_TCP_IPV6) != 0;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor bcopy(ud->ud_rss.rss_toe_key, rssp->rss_key, 40);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor } else if (qp->qp_serv_type == HERMON_QP_RFCI) {
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor } else if (qp->qp_serv_type == HERMON_QP_FEXCH) {
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor } else if (qp->qp_serv_type == HERMON_QP_FCMND) {
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor exch_base = hermon_fcoib_check_exch_base_off(state,
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 (hermon_pkeyindex_is_valid(state, 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 (hermon_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 HERMON_WARNING(state, "unknown QP transport type in rst2init");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RST2INIT_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, RST2INIT_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: RST2INIT_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor hermon_fm_ereport(state, HCA_SYS_ERR, HCA_ERR_SRV_LOST);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_init2init()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_init2init(hermon_state_t *state, hermon_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 fields to be filled in for this command,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * we begin with the QPC fields which are 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 * set port is not supported in init2init - however, in init2rtr it will
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * take the entire qpc, including the embedded sched_q in the path
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * structure - so, we can just skip setting the opmask for it explicitly
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and allow it to be set later on
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qp->qp_portnum = portnum - 1; /* save it away */
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 (hermon_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 (hermon_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 |= hermon_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 /* port# cannot be set in this transition - defer to init2rtr */
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 (hermon_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 HERMON_WARNING(state, "unknown QP transport type in init2init");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the INIT2INIT_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, INIT2INIT_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: INIT2INIT_QP command "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_init2rtr()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_init2rtr(hermon_state_t *state, hermon_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 few common fields to be filled in for this command,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * we just do the QPC fields that are 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, Hermon checks the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * MTU settings rather than just the port MTU, so we will
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * set it to maximum size for all UD.
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 (hermon_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 = hermon_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* set the primary port number/sched_q */
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 (hermon_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 Hermon. So we force 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
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (hermon_qp_validate_resp_rsrc(state, rc, &rra_max) !=
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* don't need to set up ra_buff_indx, implicit for hermon */
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 (hermon_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 |= hermon_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 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 (hermon_pkeyindex_is_valid(state, pkeyindx)) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set the common primary address path fields
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor status = hermon_set_addr_path(state, adds_vect, qpc_path,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* set the primary port num/schedq */
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 (hermon_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 (hermon_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 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 (hermon_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 HERMON_WARNING(state, "unknown QP transport type in init2rtr");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the INIT2RTR_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, INIT2RTR_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: INIT2RTR_QP command "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_rtr2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_rtr2rts(hermon_state_t *state, hermon_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 * 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 /* in qpc now, not path */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Set "ack_req_freq" based on the configuration variable
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->ack_req_freq = state->hs_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 (hermon_qp_validate_init_depth(state, rc, &sra_max) !=
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 |= hermon_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 * 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 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 (hermon_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 * 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 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 (hermon_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 HERMON_WARNING(state, "unknown QP transport type in rtr2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RTR2RTS_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, RTR2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: RTR2RTS_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_rts2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_rts2rts(hermon_state_t *state, hermon_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 fields to be filled in for this command,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * we begin with the QPC fields which are 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 |= hermon_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 * 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 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 (hermon_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 * 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 * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (hermon_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 HERMON_WARNING(state, "unknown QP transport type in rts2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RTS2RTS_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, RTS2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: RTS2RTS_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_rts2sqd()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_rts2sqd(hermon_state_t *state, hermon_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 Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, RTS2SQD_QP, NULL, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: 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 * hermon_qp_sqd2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_sqd2rts(hermon_state_t *state, hermon_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 fields in the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now fill in the QPC fields which are 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 (hermon_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 |= hermon_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 * 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 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 (hermon_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 "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 * 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 * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (hermon_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 HERMON_WARNING(state, "unknown QP transport type in sqd2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the SQD2RTS_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, SQD2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: SQD2RTS_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_sqd2sqd()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_sqd2sqd(hermon_state_t *state, hermon_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 fields in the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now fill in the QPC fields which are 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 (hermon_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 |= hermon_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 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 HERMON_CMD_OP_RETRYCNT | HERMON_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 * 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 (hermon_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 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 (hermon_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 * 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 * 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 (hermon_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 * Check for valid alternate path port number and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Check for valid alternate path PKey index and fill
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (hermon_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 HERMON_WARNING(state, "unknown QP transport type in sqd2sqd");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the SQD2SQD_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, SQD2SQD_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: SQD2SQD_QP command failed: "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_sqerr2rts()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_sqerr2rts(hermon_state_t *state, hermon_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 fields to be filled in for this command,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * we begin with the QPC fields which are 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 HERMON_WARNING(state, "unknown QP transport type in sqerr2rts");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the SQERR2RTS_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, SQERR2RTS_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: SQERR2RTS_QP command "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_to_error()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_to_error(hermon_state_t *state, hermon_qphdl_t qp)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the TOERR_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, TOERR_QP, NULL, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: TOERR_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor hermon_fm_ereport(state, HCA_SYS_ERR, HCA_ERR_SRV_LOST);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_to_reset()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_to_reset(hermon_state_t *state, hermon_qphdl_t qp)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Grab the temporary QPC entry from QP software state
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the TORST_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, TORST_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: TORST_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor hermon_fm_ereport(state, HCA_SYS_ERR, HCA_ERR_SRV_LOST);
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor status = hermon_fcoib_fexch_mkey_fini(state, qp->qp_pdhdl,
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor cmn_err(CE_NOTE, "hermon%d: fexch_mkey_fini failed "
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_qp_reset2err()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_reset2err(hermon_state_t *state, hermon_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 Hermon hardware. This is accomplished by
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitioning the QP to "Init" as an intermediate step and then,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * immediately transitioning to "Error".
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When this function returns success, the QP context will be owned by
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * the Hermon 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 fields in the QPC
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* dbr is now an address, not an index */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->dbr_addrh = ((uint64_t)qp->qp_rq_pdbr >> 32);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->dbr_addrl = ((uint64_t)qp->qp_rq_pdbr & 0xFFFFFFFC) >> 2;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * qpc->wqe_baseaddr is replaced by LKey from the cMPT, and
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * page_offset, mtt_base_addr_h/l, and log2_page_size will
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * be used to map the WQE buffer
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * NOTE that the cMPT is created implicitly when the QP is
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * transitioned from reset to init
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->mtt_base_addrh = (qp->qp_mrhdl->mr_mttaddr) >> 32 & 0xFF;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->mtt_base_addrl = (qp->qp_mrhdl->mr_mttaddr) >> 3 & 0xFFFFFFFF;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cqnmask = (1 << state->hs_cfg_profile->cp_log_num_cq) - 1;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor (qp->qp_sq_cqhdl == NULL) ? 0 : qp->qp_sq_cqhdl->cq_cqnum & cqnmask;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor (qp->qp_rq_cqhdl == NULL) ? 0 : qp->qp_rq_cqhdl->cq_cqnum & cqnmask;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->log_sq_size = highbit(qp->qp_sq_bufsz) - 1;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->log_rq_size = highbit(qp->qp_rq_bufsz) - 1;
17a2b317610f531d565bf4e940433aab2d9e6985Bill Taylor qpc->srq_en = (qp->qp_alloc_flags & IBT_QP_USES_SRQ) != 0;
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->fre = 0; /* default disable fast registration WR */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor qpc->rlky = 0; /* default disable reserved lkey */
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 HERMON_WARNING(state, "unknown QP transport type in rst2err");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Post the RST2INIT_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We do a HERMON_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 = hermon_cmn_qp_cmd_post(state, RST2INIT_QP, qpc, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: RST2INIT_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor hermon_fm_ereport(state, HCA_SYS_ERR, HCA_ERR_SRV_LOST);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Now post the TOERR_QP command to the Hermon firmware
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * We still do a HERMON_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 = hermon_cmn_qp_cmd_post(state, TOERR_QP, NULL, qp->qp_qpnum,
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor cmn_err(CE_NOTE, "hermon%d: TOERR_QP command failed: %08x\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor hermon_fm_ereport(state, HCA_SYS_ERR, HCA_ERR_SRV_LOST);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor if (hermon_qp_to_reset(state, qp) != DDI_SUCCESS) {
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor HERMON_WARNING(state, "failed to reset QP context");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * hermon_check_rdma_enable_flags()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_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 * hermon_qp_validate_resp_rsrc()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_validate_resp_rsrc(hermon_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->hs_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 * hermon_qp_validate_init_depth()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_validate_init_depth(hermon_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->hs_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 * hermon_qp_validate_mtu()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Context: Can be called from interrupt or base context.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylorhermon_qp_validate_mtu(hermon_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->hs_cfg_profile->cp_max_mtu)) {