From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David Harton (dharton)" Subject: Re: [PATCH v3] ethdev: modifiy vlan_offload_set_t to return int Date: Fri, 1 Sep 2017 00:40:56 +0000 Message-ID: References: <20170825133319.15207-1-dharton@cisco.com> <20170825134717.18376-1-dharton@cisco.com> <2775824.X3T22OWxbu@xps> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , "ferruh.yigit@intel.com" , "ajit.khaparde@broadcom.com" , "John Daley (johndale)" , "konstantin.ananyev@intel.com" , "jingjing.wu@intel.com" , "beilei.xing@intel.com" , "jing.d.chen@intel.com" , "adrien.mazarguil@6wind.com" , "nelio.laranjeiro@6wind.com" , "alejandro.lucero@netronome.com" , "hemant.agrawal@nxp.com" , "rasesh.mody@cavium.com" , "harish.patil@cavium.com" , "skhare@vmware.com" , "yliu@fridaylinux.org" , "maxime.coquelin@redhat.com" , To: Thomas Monjalon Return-path: Received: from alln-iport-4.cisco.com (alln-iport-4.cisco.com [173.37.142.91]) by dpdk.org (Postfix) with ESMTP id 06F713B5 for ; Fri, 1 Sep 2017 02:41:15 +0200 (CEST) In-Reply-To: <2775824.X3T22OWxbu@xps> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Thomas, > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Thursday, August 31, 2017 6:04 PM > To: David Harton (dharton) > Cc: dev@dpdk.org; ferruh.yigit@intel.com; ajit.khaparde@broadcom.com; Joh= n > Daley (johndale) ; konstantin.ananyev@intel.com; > jingjing.wu@intel.com; beilei.xing@intel.com; jing.d.chen@intel.com; > adrien.mazarguil@6wind.com; nelio.laranjeiro@6wind.com; > alejandro.lucero@netronome.com; hemant.agrawal@nxp.com; > rasesh.mody@cavium.com; harish.patil@cavium.com; skhare@vmware.com; > yliu@fridaylinux.org; maxime.coquelin@redhat.com; > allain.legacy@windriver.com > Subject: Re: [dpdk-dev] [PATCH v3] ethdev: modifiy vlan_offload_set_t to > return int >=20 > Hi, >=20 > 25/08/2017 15:47, David Harton: > > Some devices may not support or fail setting VLAN offload > > configuration based on dynamic circurmstances so the > > vlan_offload_set_t vector is modified to return an int so > > the caller can determine success or not. >=20 > I agree with allowing to return an error. >=20 > Comments on details below. >=20 > The title could be changed to better reflect the purpose: > ethdev: allow returning error on VLAN configuration Sure. >=20 > > --- a/doc/guides/rel_notes/release_17_11.rst > > +++ b/doc/guides/rel_notes/release_17_11.rst > > @@ -124,7 +124,7 @@ ABI Changes > > Also, make sure to start the actual text at the margin. > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > - > > +* Changed return type of ``vlan_offload_set_t`` from ``void`` to ``int= ``. >=20 > It should be referenced as an API change (instead of ABI change). > (and line spacing must be kept) Sure I'll move it to API. Line spacing? You mean 80 char width? I followed an example from a previo= us release so I'm not sure what you mean. >=20 > We also need to bump the library version but it can be done with > bigger changes in ethdev. Ok. >=20 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -2049,10 +2049,16 @@ struct rte_eth_dev * > > int ret =3D 0; > > int mask =3D 0; > > int cur, org =3D 0; > > + uint8_t org_strip, org_filter, org_extend; > > > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > dev =3D &rte_eth_devices[port_id]; > > > > + /* save original values in case of failure */ > > + org_strip =3D dev->data->dev_conf.rxmode.hw_vlan_strip; > > + org_filter =3D dev->data->dev_conf.rxmode.hw_vlan_filter; > > + org_extend =3D dev->data->dev_conf.rxmode.hw_vlan_extend; >=20 > Please waste one more char to write "orig" instead of "org". Will do. >=20 > > - (*dev->dev_ops->vlan_offload_set)(dev, mask); > > + ret =3D (*dev->dev_ops->vlan_offload_set)(dev, mask); > > + if (ret) { > > + /* hit an error restore original values */ > > + dev->data->dev_conf.rxmode.hw_vlan_strip =3D org_strip; > > + dev->data->dev_conf.rxmode.hw_vlan_filter =3D org_filter; > > + dev->data->dev_conf.rxmode.hw_vlan_extend =3D org_extend; > > + } >=20 > Isn't it the responsibility of the PMD to restore values in case of error= ? > I understand it is there to factorize error handling code, right? By setting the dev_conf.rxmode.hw_vlan_* fields this function is claiming=20 ownership of that data and therefore it should be the one to reset it. > Do we want to document this behaviour with the ops prototype? Why? Shouldn't any function that doesn't do what it was asked to do=20 leave the system in its original state and in fact if it doesn't that=20 is when it should be documented what the behavior is? Otherwise every=20 caller has to implement some cleanup code and would have to be given=20 information to know how to perform that cleanup as well which seems=20 more complicated. Thanks, Dave