From patchwork Thu Sep 29 10:20:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chas Williams <3chas3@gmail.com> X-Patchwork-Id: 16218 X-Patchwork-Delegate: bruce.richardson@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A007B68F8; Thu, 29 Sep 2016 12:21:15 +0200 (CEST) Received: from mail-yw0-f196.google.com (mail-yw0-f196.google.com [209.85.161.196]) by dpdk.org (Postfix) with ESMTP id DC933591F for ; Thu, 29 Sep 2016 12:21:04 +0200 (CEST) Received: by mail-yw0-f196.google.com with SMTP id t67so2758283ywg.1 for ; Thu, 29 Sep 2016 03:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YC1DDAQRVRxOWxI2OEBDr1riwSYQ4wL0ig/iHc2nG4k=; b=j5wHPX1v2eGNkJ8Oo6qItQRi8JgPH6PrWz1xl7WISMgJAEgtfZWuYfoa2rZ3UDrk/A QcpfqBLj5JuriuQ9hFkByR5/AsB2tbVJog4R//jLpedNnNHsEyYtrY/UovwEckNTqSwy +GbnmLXLbAVIx25LXvhFkkoiqMkKFPB0mG7X7Zpt0ipUASPh81tsJRdH0jAM0Ub7wOhH kAAr8XVw3UUKPwgtJBOzHi9YrvnC6v/8FxlsFv0Jruf/JUtAOCkA1cKTPdCOC2SuBYd8 novF+oVJLqUY2GmtYeoZyMECXSBg80Wte1OoKp7z865WIcWj7FkCfbYuelJGtK77+24I at4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YC1DDAQRVRxOWxI2OEBDr1riwSYQ4wL0ig/iHc2nG4k=; b=G1eJM7xtLDNPm5/YWD2gKgYYKmF71tdNYW7oaXITJ3YLKpbc2a0n5KZRqfARXvVTGV mZxePmd4L+y01JNVcWNXHsQcTurokIKA/yBeVZ1HsmrClz9QvDjEh5cS0Gbv5S9ZN6Iq a7jmBMukTR6CHC6bFfA51quPn9UAwDKHMtbHJWcWMnVYT/MYlYBzaxdVF7GAyN2FG6OY 4UqsYE97BOnnPJQ2MIzmO8ALy9FHhragTX6fvlAcLUH+fkJGsz4A17VYrDMhQZubMX3d zi0KbfuSz3P//U0cf54wqZapBLct6U96U3DjEj6jr8JdIeo2eIhGT6tWYAuXOhitn3dJ /fqA== X-Gm-Message-State: AA6/9RnV7T2DcYiYFTEN8OJJjOFraUt0GCEv2wPlKmi5xwpAvQlsW2t14Ou44o0XhfLw7A== X-Received: by 10.129.120.22 with SMTP id t22mr339291ywc.51.1475144464130; Thu, 29 Sep 2016 03:21:04 -0700 (PDT) Received: from monolith.home (pool-96-231-205-104.washdc.fios.verizon.net. [96.231.205.104]) by smtp.gmail.com with ESMTPSA id z133sm5302430ywb.51.2016.09.29.03.21.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2016 03:21:03 -0700 (PDT) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: harish.patil@qlogic.com, Chas Williams <3chas3@gmail.com> Date: Thu, 29 Sep 2016 06:20:47 -0400 Message-Id: <1475144449-22176-8-git-send-email-3chas3@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475144449-22176-1-git-send-email-3chas3@gmail.com> References: <1475144449-22176-1-git-send-email-3chas3@gmail.com> Subject: [dpdk-dev] [PATCH v2 08/10] bnx2x: Check return codes during VF mailbox operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Refactor bnx2x_do_req4pf() to be easier to read and return errors when the transaction fails -- Previously, it could succeed when the control channel was down. Fixes: 540a211084a7 ("bnx2x: driver core") Signed-off-by: Chas Williams <3chas3@gmail.com> --- drivers/net/bnx2x/bnx2x_vfpf.c | 110 +++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 49 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c index 4bcd4ff..9b18ed6 100644 --- a/drivers/net/bnx2x/bnx2x_vfpf.c +++ b/drivers/net/bnx2x/bnx2x_vfpf.c @@ -118,39 +118,36 @@ bnx2x_do_req4pf(struct bnx2x_softc *sc, phys_addr_t phys_addr) uint8_t *status = &sc->vf2pf_mbox->resp.common_reply.status; uint8_t i; - if (!*status) { - bnx2x_check_bull(sc); - if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) { - PMD_DRV_LOG(ERR, "channel is down. Aborting message sending"); - *status = BNX2X_VF_STATUS_SUCCESS; - return 0; - } + if (*status) { + PMD_DRV_LOG(ERR, "status should be zero before message" + " to pf was sent"); + return -EINVAL; + } - REG_WR(sc, BNX2X_VF_CMD_ADDR_LO, U64_LO(phys_addr)); - REG_WR(sc, BNX2X_VF_CMD_ADDR_HI, U64_HI(phys_addr)); + bnx2x_check_bull(sc); + if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) { + PMD_DRV_LOG(ERR, "channel is down. Aborting message sending"); + return -EINVAL; + } - /* memory barrier to ensure that FW can read phys_addr */ - wmb(); + REG_WR(sc, BNX2X_VF_CMD_ADDR_LO, U64_LO(phys_addr)); + REG_WR(sc, BNX2X_VF_CMD_ADDR_HI, U64_HI(phys_addr)); - REG_WR8(sc, BNX2X_VF_CMD_TRIGGER, 1); + /* memory barrier to ensure that FW can read phys_addr */ + wmb(); - /* Do several attempts until PF completes - * "." is used to show progress - */ - for (i = 0; i < BNX2X_VF_CHANNEL_TRIES; i++) { - DELAY_MS(BNX2X_VF_CHANNEL_DELAY); - if (*status) - break; - } + REG_WR8(sc, BNX2X_VF_CMD_TRIGGER, 1); - if (!*status) { - PMD_DRV_LOG(ERR, "Response from PF timed out"); - return -EAGAIN; - } - } else { - PMD_DRV_LOG(ERR, "status should be zero before message" - "to pf was sent"); - return -EINVAL; + /* Do several attempts until PF completes */ + for (i = 0; i < BNX2X_VF_CHANNEL_TRIES; i++) { + DELAY_MS(BNX2X_VF_CHANNEL_DELAY); + if (*status) + break; + } + + if (!*status) { + PMD_DRV_LOG(ERR, "Response from PF timed out"); + return -EAGAIN; } PMD_DRV_LOG(DEBUG, "Response from PF was received"); @@ -338,6 +335,7 @@ bnx2x_vf_close(struct bnx2x_softc *sc) struct vf_release_tlv *query; struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply; int vf_id = bnx2x_read_vf_id(sc); + int rc; if (vf_id >= 0) { query = &sc->vf2pf_mbox->query[0].release; @@ -349,8 +347,8 @@ bnx2x_vf_close(struct bnx2x_softc *sc) BNX2X_VF_TLV_LIST_END, sizeof(struct channel_list_end_tlv)); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); - if (reply->status != BNX2X_VF_STATUS_SUCCESS) + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS) PMD_DRV_LOG(ERR, "Failed to release VF"); bnx2x_vf_finalize(sc, &query->first_tlv); @@ -363,7 +361,7 @@ bnx2x_vf_init(struct bnx2x_softc *sc) { struct vf_init_tlv *query; struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply; - int i, rc = 0; + int i, rc; query = &sc->vf2pf_mbox->query[0].init; bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_INIT, @@ -381,7 +379,9 @@ bnx2x_vf_init(struct bnx2x_softc *sc) BNX2X_VF_TLV_LIST_END, sizeof(struct channel_list_end_tlv)); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc) + goto out; if (reply->status != BNX2X_VF_STATUS_SUCCESS) { PMD_DRV_LOG(ERR, "Failed to init VF"); rc = -EINVAL; @@ -400,7 +400,7 @@ bnx2x_vf_unload(struct bnx2x_softc *sc) struct vf_close_tlv *query; struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply; struct vf_q_op_tlv *query_op; - int i, vf_id; + int i, vf_id, rc; vf_id = bnx2x_read_vf_id(sc); if (vf_id > 0) { @@ -417,8 +417,8 @@ bnx2x_vf_unload(struct bnx2x_softc *sc) BNX2X_VF_TLV_LIST_END, sizeof(struct channel_list_end_tlv)); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); - if (reply->status != BNX2X_VF_STATUS_SUCCESS) + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS) PMD_DRV_LOG(ERR, "Bad reply for vf_q %d teardown", i); @@ -437,8 +437,8 @@ bnx2x_vf_unload(struct bnx2x_softc *sc) BNX2X_VF_TLV_LIST_END, sizeof(struct channel_list_end_tlv)); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); - if (reply->status != BNX2X_VF_STATUS_SUCCESS) + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS) PMD_DRV_LOG(ERR, "Bad reply from PF for close message"); @@ -507,7 +507,7 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int lead struct vf_setup_q_tlv *query; struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply; uint16_t flags = bnx2x_vf_q_flags(leading); - int rc = 0; + int rc; query = &sc->vf2pf_mbox->query[0].setup_q; bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q, @@ -523,13 +523,15 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int lead BNX2X_VF_TLV_LIST_END, sizeof(struct channel_list_end_tlv)); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc) + goto out; if (reply->status != BNX2X_VF_STATUS_SUCCESS) { PMD_DRV_LOG(ERR, "Failed to setup VF queue[%d]", fp->index); rc = -EINVAL; } - +out: bnx2x_vf_finalize(sc, &query->first_tlv); return rc; @@ -540,7 +542,7 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set) { struct vf_set_q_filters_tlv *query; struct vf_common_reply_tlv *reply; - int rc = 0; + int rc; query = &sc->vf2pf_mbox->query[0].set_q_filters; bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS, @@ -561,7 +563,9 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set) BNX2X_VF_TLV_LIST_END, sizeof(struct channel_list_end_tlv)); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc) + goto out; reply = &sc->vf2pf_mbox->resp.common_reply; while (BNX2X_VF_STATUS_FAILURE == reply->status && @@ -572,7 +576,9 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set) rte_memcpy(query->filters[0].mac, sc->pf2vf_bulletin->mac, ETH_ALEN); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc) + goto out; } if (BNX2X_VF_STATUS_SUCCESS != reply->status) { @@ -580,7 +586,7 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set) reply->status); rc = -EINVAL; } - +out: bnx2x_vf_finalize(sc, &query->first_tlv); return rc; @@ -592,7 +598,7 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc, { struct vf_rss_tlv *query; struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply; - int rc = 0; + int rc; query = &sc->vf2pf_mbox->query[0].update_rss; @@ -613,12 +619,15 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc, query->rss_result_mask = params->rss_result_mask; query->rss_flags = params->rss_flags; - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc) + goto out; + if (reply->status != BNX2X_VF_STATUS_SUCCESS) { PMD_DRV_LOG(ERR, "Failed to configure RSS"); rc = -EINVAL; } - +out: bnx2x_vf_finalize(sc, &query->first_tlv); return rc; @@ -629,7 +638,7 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc) { struct vf_set_q_filters_tlv *query; struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply; - int rc = 0; + int rc; query = &sc->vf2pf_mbox->query[0].set_q_filters; bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS, @@ -667,7 +676,10 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc) BNX2X_VF_TLV_LIST_END, sizeof(struct channel_list_end_tlv)); - bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc) + goto out; + if (reply->status != BNX2X_VF_STATUS_SUCCESS) { PMD_DRV_LOG(ERR, "Failed to set RX mode"); rc = -EINVAL;