From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-0016ce01.pphosted.com (mx0a-0016ce01.pphosted.com [67.231.148.157]) by dpdk.org (Postfix) with ESMTP id 2973A2B9E for ; Fri, 4 Mar 2016 23:28:49 +0100 (CET) Received: from pps.filterd (m0045602.ppops.net [127.0.0.1]) by mx0a-0016ce01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u24MRJBj025467; Fri, 4 Mar 2016 14:28:46 -0800 Received: from avcashub1.qlogic.com ([198.186.0.116]) by mx0a-0016ce01.pphosted.com with ESMTP id 21bguj2pbt-1 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NOT); Fri, 04 Mar 2016 14:28:46 -0800 Received: from AVMB3.qlogic.org ([fe80::689d:1159:4632:e0eb]) by avcashub2.qlogic.org ([::1]) with mapi id 14.03.0235.001; Fri, 4 Mar 2016 14:28:45 -0800 From: Rasesh Mody To: Chas Williams <3chas3@gmail.com>, "dev@dpdk.org" , "Bruce Richardson" Thread-Topic: [dpdk-dev] [PATCH 1/2] bnx2x: fix error handling in bnx2x_loop_obtain_resources() Thread-Index: AQHRQ2OCHlaYK6Po9EGMZYayNFLbqZ9KQkMw Date: Fri, 4 Mar 2016 22:28:44 +0000 Message-ID: <2552F74A0BCCBE4DBE2AD218C81B2811086B1525@avmb3.qlogic.org> References: <1451522271-16924-1-git-send-email-3chas3@gmail.com> In-Reply-To: <1451522271-16924-1-git-send-email-3chas3@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.1.4.10] disclaimer: bypass Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5800 definitions=8094 signatures=670697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1601100000 definitions=main-1603040390 Cc: "Charles \(Chas\) Williams" Subject: Re: [dpdk-dev] [PATCH 1/2] bnx2x: fix error handling in bnx2x_loop_obtain_resources() 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: , X-List-Received-Date: Fri, 04 Mar 2016 22:28:49 -0000 > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Chas Williams > Sent: Wednesday, December 30, 2015 4:38 PM >=20 > From: "Charles (Chas) Williams" >=20 > bnx2x_loop_obtain_resources() returns a struct containing the status and > the error message. If bnx2x_do_req4pf() fails, it shouldn't return both = of > these fields set to 0 indicating failure and no error. >=20 > Further, bnx2x_do_req4pf() needs to be able fail and return NO_RESOURCES > so that bnx2x_loop_obtain_resources() can negotiate reduced resource > requirments. This requires additional checking around bnx2x_do_req4pf(). >=20 > Signed-off-by: Chas Williams <3chas3@gmail.com> > --- Acked-by: Rasesh Mody The change looks good. Thanks! Rasesh > drivers/net/bnx2x/bnx2x_vfpf.c | 75 +++++++++++++++++++----------------- > ------ > 1 file changed, 33 insertions(+), 42 deletions(-) >=20 > diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c > b/drivers/net/bnx2x/bnx2x_vfpf.c index 765cc92..34b6360 100644 > --- a/drivers/net/bnx2x/bnx2x_vfpf.c > +++ b/drivers/net/bnx2x/bnx2x_vfpf.c > @@ -122,16 +122,10 @@ bnx2x_do_req4pf(struct bnx2x_softc *sc, > phys_addr_t phys_addr) > break; > } >=20 > - if (i =3D=3D BNX2X_VF_CHANNEL_TRIES) { > + if (!*status) { > PMD_DRV_LOG(ERR, "Response from PF timed > out"); > return -EAGAIN; > } > - > - if (BNX2X_VF_STATUS_SUCCESS !=3D *status) { > - PMD_DRV_LOG(ERR, "Bad reply from PF : %u", > - *status); > - return -EINVAL; > - } > } else { > PMD_DRV_LOG(ERR, "status should be zero before > message" > "to pf was sent"); > @@ -193,10 +187,10 @@ struct bnx2x_obtain_status > bnx2x_loop_obtain_resources(struct bnx2x_softc *sc) > do { > PMD_DRV_LOG(DEBUG, "trying to get resources"); >=20 > - if ( bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr) ) > { > + if (bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr)) { > /* timeout */ > status.success =3D 0; > - status.err_code =3D 0; > + status.err_code =3D -EAGAIN; > return status; > } >=20 > @@ -310,8 +304,8 @@ void > bnx2x_vf_close(struct bnx2x_softc *sc) > { > struct vf_release_tlv *query; > + struct vf_common_reply_tlv *reply =3D > +&sc->vf2pf_mbox->resp.common_reply; > int vf_id =3D bnx2x_read_vf_id(sc); > - int ret; >=20 > if (vf_id >=3D 0) { > query =3D &sc->vf2pf_mbox->query[0].release; > @@ -322,11 +316,9 @@ bnx2x_vf_close(struct bnx2x_softc *sc) > BNX2X_TLV_APPEND(query, query->first_tlv.length, > BNX2X_VF_TLV_LIST_END, > sizeof(struct channel_list_end_tlv)); >=20 > - ret =3D bnx2x_do_req4pf(sc, sc- > >vf2pf_mbox_mapping.paddr); > - > - if (ret) { > + bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > + if (reply->status !=3D BNX2X_VF_STATUS_SUCCESS) > PMD_DRV_LOG(ERR, "Failed to release VF"); > - } > } > } >=20 > @@ -335,7 +327,8 @@ int > bnx2x_vf_init(struct bnx2x_softc *sc) > { > struct vf_init_tlv *query; > - int i, ret; > + struct vf_common_reply_tlv *reply =3D &sc->vf2pf_mbox- > >resp.common_reply; > + int i; >=20 > query =3D &sc->vf2pf_mbox->query[0].init; > bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_INIT, @@ > -352,11 +345,10 @@ bnx2x_vf_init(struct bnx2x_softc *sc) > BNX2X_TLV_APPEND(query, query->first_tlv.length, > BNX2X_VF_TLV_LIST_END, > sizeof(struct channel_list_end_tlv)); >=20 > - ret =3D bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > - > - if (ret) { > + bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > + if (reply->status !=3D BNX2X_VF_STATUS_SUCCESS) { > PMD_DRV_LOG(ERR, "Failed to init VF"); > - return ret; > + return -EINVAL; > } >=20 > PMD_DRV_LOG(DEBUG, "VF was initialized"); @@ -367,8 +359,9 @@ > void bnx2x_vf_unload(struct bnx2x_softc *sc) { > struct vf_close_tlv *query; > + struct vf_common_reply_tlv *reply =3D > +&sc->vf2pf_mbox->resp.common_reply; > struct vf_q_op_tlv *query_op; > - int i, vf_id, ret; > + int i, vf_id; >=20 > vf_id =3D bnx2x_read_vf_id(sc); > if (vf_id > 0) { > @@ -384,10 +377,10 @@ bnx2x_vf_unload(struct bnx2x_softc *sc) > BNX2X_VF_TLV_LIST_END, > sizeof(struct channel_list_end_tlv)); >=20 > - ret =3D bnx2x_do_req4pf(sc, sc- > >vf2pf_mbox_mapping.paddr); > - if (ret) > + bnx2x_do_req4pf(sc, sc- > >vf2pf_mbox_mapping.paddr); > + if (reply->status !=3D BNX2X_VF_STATUS_SUCCESS) > PMD_DRV_LOG(ERR, > - "Bad reply for vf_q %d > teardown", i); > + "Bad reply for vf_q %d teardown", > i); > } >=20 > bnx2x_vf_set_mac(sc, false); > @@ -402,11 +395,10 @@ bnx2x_vf_unload(struct bnx2x_softc *sc) > BNX2X_VF_TLV_LIST_END, > sizeof(struct channel_list_end_tlv)); >=20 > - ret =3D bnx2x_do_req4pf(sc, sc- > >vf2pf_mbox_mapping.paddr); > - > - if (ret) > + bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > + if (reply->status !=3D BNX2X_VF_STATUS_SUCCESS) > PMD_DRV_LOG(ERR, > - "Bad reply from PF for close message"); > + "Bad reply from PF for close message"); > } > } >=20 > @@ -469,8 +461,8 @@ int > bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, > int leading) { > struct vf_setup_q_tlv *query; > + struct vf_common_reply_tlv *reply =3D > +&sc->vf2pf_mbox->resp.common_reply; > uint16_t flags =3D bnx2x_vf_q_flags(leading); > - int ret; >=20 > query =3D &sc->vf2pf_mbox->query[0].setup_q; > bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q, > @@ -485,11 +477,10 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, > struct bnx2x_fastpath *fp, int lead > BNX2X_TLV_APPEND(query, query->first_tlv.length, > BNX2X_VF_TLV_LIST_END, > sizeof(struct channel_list_end_tlv)); >=20 > - ret =3D bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > - > - if (ret) { > + bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > + if (reply->status !=3D BNX2X_VF_STATUS_SUCCESS) { > PMD_DRV_LOG(ERR, "Failed to setup VF queue[%d]", > - fp->index); > + fp->index); > return -EINVAL; > } >=20 > @@ -548,7 +539,7 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc, > struct ecore_config_rss_params *params) { > struct vf_rss_tlv *query; > - int ret; > + struct vf_common_reply_tlv *reply =3D > +&sc->vf2pf_mbox->resp.common_reply; >=20 > query =3D &sc->vf2pf_mbox->query[0].update_rss; >=20 > @@ -568,10 +559,10 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc, > query->rss_result_mask =3D params->rss_result_mask; > query->rss_flags =3D params->rss_flags; >=20 > - ret =3D bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > - if (ret) { > - PMD_DRV_LOG(ERR, "Failed to send message to PF, rc %d", > ret); > - return ret; > + bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > + if (reply->status !=3D BNX2X_VF_STATUS_SUCCESS) { > + PMD_DRV_LOG(ERR, "Failed to configure RSS"); > + return -EINVAL;; > } >=20 > return 0; > @@ -581,8 +572,8 @@ int > bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc) { > struct vf_set_q_filters_tlv *query; > + struct vf_common_reply_tlv *reply =3D > +&sc->vf2pf_mbox->resp.common_reply; > unsigned long tx_mask; > - int ret; >=20 > query =3D &sc->vf2pf_mbox->query[0].set_q_filters; > bnx2x_init_first_tlv(sc, &query->first_tlv, > BNX2X_VF_TLV_SET_Q_FILTERS, @@ -598,10 +589,10 @@ > bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc) > BNX2X_TLV_APPEND(query, query->first_tlv.length, > BNX2X_VF_TLV_LIST_END, > sizeof(struct channel_list_end_tlv)); >=20 > - ret =3D bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > - if (ret) { > - PMD_DRV_LOG(ERR, "Failed to send message to PF, rc %d", > ret); > - return ret; > + bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr); > + if (reply->status !=3D BNX2X_VF_STATUS_SUCCESS) { > + PMD_DRV_LOG(ERR, "Failed to set RX mode"); > + return -EINVAL; > } >=20 > return 0; > -- > 2.5.0