From: Chas Williams <3chas3@gmail.com>
To: dev@dpdk.org
Cc: harish.patil@qlogic.com, Chas Williams <3chas3@gmail.com>
Subject: [dpdk-dev] [PATCH v3 09/10] net/bnx2x: don't return structs
Date: Tue, 11 Oct 2016 19:05:00 -0400 [thread overview]
Message-ID: <1476227101-19268-9-git-send-email-3chas3@gmail.com> (raw)
In-Reply-To: <1476227101-19268-1-git-send-email-3chas3@gmail.com>
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;
--
2.7.4
next prev parent reply other threads:[~2016-10-11 23:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 23:04 [dpdk-dev] [PATCH v3 01/10] net/bnx2x: set cache line based on build configuration Chas Williams
2016-10-11 23:04 ` [dpdk-dev] [PATCH v3 02/10] net/bnx2x: remove unused preprocessor symbols and code Chas Williams
2016-10-11 23:04 ` [dpdk-dev] [PATCH v3 03/10] net/bnx2x: remove delay during device startup Chas Williams
2016-10-11 23:04 ` [dpdk-dev] [PATCH v3 04/10] net/bnx2x: remove unused RX queue code Chas Williams
2016-10-11 23:04 ` [dpdk-dev] [PATCH v3 05/10] net/bnx2x: restrict RX mask flags sent to the PF Chas Williams
2016-10-11 23:04 ` [dpdk-dev] [PATCH v3 06/10] net/bnx2x: replace macro with static function Chas Williams
2016-10-11 23:04 ` [dpdk-dev] [PATCH v3 07/10] net/bnx2x: serialize access to pf2vf mailbox Chas Williams
2016-10-11 23:04 ` [dpdk-dev] [PATCH v3 08/10] net/bnx2x: check return codes during VF mailbox operation Chas Williams
2016-10-11 23:05 ` Chas Williams [this message]
2016-10-11 23:05 ` [dpdk-dev] [PATCH v3 10/10] net/bnx2x: merge debug register operations into headers Chas Williams
2016-10-13 9:45 ` [dpdk-dev] [PATCH v3 01/10] net/bnx2x: set cache line based on build configuration Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476227101-19268-9-git-send-email-3chas3@gmail.com \
--to=3chas3@gmail.com \
--cc=dev@dpdk.org \
--cc=harish.patil@qlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).