From patchwork Tue Oct 11 23:05:00 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: 16493 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 A831D8D35; Wed, 12 Oct 2016 01:05:23 +0200 (CEST) Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by dpdk.org (Postfix) with ESMTP id B00E66CD7 for ; Wed, 12 Oct 2016 01:05:18 +0200 (CEST) Received: by mail-qk0-f194.google.com with SMTP id n189so2479972qke.1 for ; Tue, 11 Oct 2016 16:05:18 -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=aXMUqvjLZ+o6j/1NV93bGQyoCpo8MAOiuP2U0zcHdr4=; b=gGJGfQcgLNxDOBcJSm2skiLHIG9i7J7LFvOMxxDYumkU4QN5lXfVJsgOZQ1xJsBZ3P gRk+Pb9R9XZ6iANGAmArZWmXPxkE972MVFg83a2fXoPpqol6klStE4rX8CJ8VQr6U798 p7RS703eujFFdShvPLve+s7e1nxI18N7X9kLEA71cvE/0Dm7nfcM2xypgCyG1/fOoTqO gsXMpMm3We5Mdk0ZP9icJ7GMEkghKkSpLb8V2WwCDXfoNFSoVZqoJP0KN78M13c+y0Xq mYvxIsalu0K9Dz3An46cmLCv7H0CMnBMkujb+H5k/1mYlLK+GW+At8JTnC/JX89sbK+U AS0Q== 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=aXMUqvjLZ+o6j/1NV93bGQyoCpo8MAOiuP2U0zcHdr4=; b=MCLdAwK5Y7cKgZVNNawlUhzEi3DlX1uOEyV17e1uWqSUKh+GGrJeTox4wN05cW5wxp O/u35v1Flt4nV5fYrIK1YQsmBI9unjGCIFqyUeMDCqmFfNrVlxBnvPAnX7ZTM0qNOl77 1OltWHQWJPCWLFz/oJK36wlag3e1Ov1HckUsx4/lFG5x9ITLvPFZs/zIHI4KLKuGQhls gCOsRUah/JjtVCqK5CduhrVDeUMM10lsB+ESEqrh4ocYSShD8MbMifp/omrK5c65Q8oY v90e/BPnN9ZMJjXq2VLz0JhAFccO4vtwYVjZruwYsMwG1fgZf3hsZLVfdg12Cm8QdssO +c/Q== X-Gm-Message-State: AA6/9Rn6nszC32TdGfw5vbj1lqy/4D3QX4XIezp8xoq4qjUp80ItTI9F7zN/zVHNhyfn5Q== X-Received: by 10.55.21.69 with SMTP id f66mr5496261qkh.131.1476227118085; Tue, 11 Oct 2016 16:05:18 -0700 (PDT) Received: from monolith.home (pool-96-255-41-157.washdc.fios.verizon.net. [96.255.41.157]) by smtp.gmail.com with ESMTPSA id u129sm1863194qkf.25.2016.10.11.16.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Oct 2016 16:05:17 -0700 (PDT) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: harish.patil@qlogic.com, Chas Williams <3chas3@gmail.com> Date: Tue, 11 Oct 2016 19:05:00 -0400 Message-Id: <1476227101-19268-9-git-send-email-3chas3@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476227101-19268-1-git-send-email-3chas3@gmail.com> References: <1476227101-19268-1-git-send-email-3chas3@gmail.com> Subject: [dpdk-dev] [PATCH v3 09/10] net/bnx2x: don't return structs 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" bnx2x_loop_obtain_resources() returns a struct. This routine either succeeds or fails -- We don't need a struct for that. Fixes: 540a211084a7 ("bnx2x: driver core") Signed-off-by: Chas Williams <3chas3@gmail.com> --- drivers/net/bnx2x/bnx2x_vfpf.c | 51 ++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c index 0a8a6ed..c47beb0 100644 --- a/drivers/net/bnx2x/bnx2x_vfpf.c +++ b/drivers/net/bnx2x/bnx2x_vfpf.c @@ -186,31 +186,23 @@ static inline int bnx2x_read_vf_id(struct bnx2x_softc *sc) #define BNX2X_VF_OBTAIN_MAC_FILTERS 1 #define BNX2X_VF_OBTAIN_MC_FILTERS 10 -struct bnx2x_obtain_status { - int success; - int err_code; -}; - static -struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc) +int bnx2x_loop_obtain_resources(struct bnx2x_softc *sc) { - int tries = 0; struct vf_acquire_resp_tlv *resp = &sc->vf2pf_mbox->resp.acquire_resp, - *sc_resp = &sc->acquire_resp; - struct vf_resource_query *res_query; - struct vf_resc *resc; - struct bnx2x_obtain_status status; + *sc_resp = &sc->acquire_resp; + struct vf_resource_query *res_query; + struct vf_resc *resc; int res_obtained = false; + int tries = 0; + int rc; do { PMD_DRV_LOG(DEBUG, "trying to get resources"); - if (bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr)) { - /* timeout */ - status.success = 0; - status.err_code = -EAGAIN; - return status; - } + rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); + if (rc) + return rc; memcpy(sc_resp, resp, sizeof(sc->acquire_resp)); @@ -221,12 +213,12 @@ struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc) PMD_DRV_LOG(DEBUG, "resources obtained successfully"); res_obtained = true; } else if (sc_resp->status == BNX2X_VF_STATUS_NO_RESOURCES && - tries < BNX2X_VF_OBTAIN_MAX_TRIES) { + tries < BNX2X_VF_OBTAIN_MAX_TRIES) { PMD_DRV_LOG(DEBUG, "PF cannot allocate requested amount of resources"); res_query = &sc->vf2pf_mbox->query[0].acquire.res_query; - resc = &sc_resp->resc; + resc = &sc_resp->resc; /* PF refused our request. Try to decrease request params */ res_query->num_txqs = min(res_query->num_txqs, resc->num_txqs); @@ -238,24 +230,21 @@ struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc) memset(&sc->vf2pf_mbox->resp, 0, sizeof(union resp_tlvs)); } else { - PMD_DRV_LOG(ERR, "Resources cannot be obtained. Status of handling: %d. Aborting", - sc_resp->status); - status.success = 0; - status.err_code = -EAGAIN; - return status; + PMD_DRV_LOG(ERR, "Failed to get the requested " + "amount of resources: %d.", + sc_resp->status); + return -EINVAL; } } while (!res_obtained); - status.success = 1; - return status; + return 0; } int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_count) { struct vf_acquire_tlv *acq = &sc->vf2pf_mbox->query[0].acquire; int vf_id; - struct bnx2x_obtain_status obtain_status; - int rc = 0; + int rc; bnx2x_vf_close(sc); bnx2x_vf_prep(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq)); @@ -287,11 +276,9 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_ sizeof(struct channel_list_end_tlv)); /* requesting the resources in loop */ - obtain_status = bnx2x_loop_obtain_resources(sc); - if (!obtain_status.success) { - rc = obtain_status.err_code; + rc = bnx2x_loop_obtain_resources(sc); + if (rc) goto out; - } struct vf_acquire_resp_tlv sc_resp = sc->acquire_resp;