From: "Kerlin, MarcinX" <marcinx.kerlin@intel.com>
To: "Pattan, Reshma" <reshma.pattan@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>
Cc: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>,
"thomas.monjalon@6wind.com" <thomas.monjalon@6wind.com>
Subject: Re: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against overwrite device data
Date: Thu, 29 Sep 2016 13:41:42 +0000 [thread overview]
Message-ID: <68D830D942438745AD09BAFA99E33E812BD873@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <3AEA2BF9852C6F48A459DA490692831F010A91F9@IRSMSX109.ger.corp.intel.com>
Hi Reshma,
> -----Original Message-----
> From: Pattan, Reshma
> Sent: Wednesday, September 28, 2016 4:04 PM
> To: Kerlin, MarcinX <marcinx.kerlin@intel.com>; dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> thomas.monjalon@6wind.com; Kerlin, MarcinX <marcinx.kerlin@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against
> overwrite device data
>
>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marcin Kerlin
> > Sent: Tuesday, September 27, 2016 12:13 PM
> > To: dev@dpdk.org
> > Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> > thomas.monjalon@6wind.com; Kerlin, MarcinX <marcinx.kerlin@intel.com>
> > Subject: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection
> > against overwrite device data
> >
> > +int
> > +rte_eth_dev_release_dev_data(uint8_t port_id) {
> > + char device[RTE_ETH_NAME_MAX_LEN];
> > + struct rte_eth_dev_data *eth_dev_data = NULL;
> > +
> > +
> > @@ -631,6 +691,8 @@ int
> > rte_eth_dev_detach(uint8_t port_id, char *name) {
> > struct rte_pci_addr addr;
> > + struct rte_eth_dev_data *eth_dev_data = NULL;
> > + char device[RTE_ETH_NAME_MAX_LEN];
> > int ret = -1;
> >
> > if (name == NULL) {
> > @@ -642,6 +704,15 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
> > if (rte_eth_dev_is_detachable(port_id))
> > goto err;
> >
> > + /* get device name by port id */
> > + if (rte_eth_dev_get_name_by_port(port_id, device))
> > + goto err;
> > +
> > + /* look for an entry in the shared device data */
> > + eth_dev_data = rte_eth_dev_get_dev_data_by_name(device);
> > + if (eth_dev_data == NULL)
> > + goto err;
> > +
> > if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
> > ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
> > if (ret < 0)
> > @@ -661,6 +732,9 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
> > goto err;
> > }
> >
> > + /* clear an entry in the shared device data */
> > + memset(eth_dev_data, 0, sizeof(struct rte_eth_dev_data));
> > +
> > return 0;
> >
>
> In this function, the new code chunks together is nothing but the function "
> rte_eth_dev_release_dev_data()".
> So u can call the function itself rather than a duplicate code.
It was intentional, reason:
If I call function in place:
(1) beginning: then I lose device name for function below rte_eth_dev_detach_vdev (1.1):
a) this is important for drivers that hold name in shared rte_eth_dev_data[]
b) not important for drivers that prepare own rte_eth_dev_data e.g pcap (rte_eth_pcap.c, line 816)
(2) end: then I lose device name for my function rte_eth_dev_release_dev_data, because in the above function
rte_eth_dev_detach_vdev (1.1) for e.g pcap is call rte_free(eth_dev->data) which removes me a pointer to the
name (rte_eth_pcap.c, line 1079).
rte_eth_dev_detach (uint8_t port_id, char *name){
...
(1) rte_eth_dev_release_dev_data(port_id);
if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
if (ret < 0)
goto err;
ret = rte_eth_dev_detach_pdev(port_id, &addr);
if (ret < 0)
goto err;
snprintf(name, RTE_ETH_NAME_MAX_LEN,
"%04x:%02x:%02x.%d",
addr.domain, addr.bus,
addr.devid, addr.function);
} else {
(1.1) ret = rte_eth_dev_detach_vdev(port_id, name);
if (ret < 0)
goto err;
}
(2) rte_eth_dev_release_dev_data(port_id);
...
}
This is reason why I keep name at the beginning but I release the name at the end function after detach.
At this point I do not see how the code directly replace by one function call.
Regards,
Marcin
>
> Thanks,
> Reshma
next prev parent reply other threads:[~2016-09-29 13:41 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-02 8:58 [dpdk-dev] [PATCH 0/2] app/testpmd: improve multiprocess support Marcin Kerlin
2016-09-02 8:58 ` [dpdk-dev] [PATCH 1/2] librte_ether: ensure not overwrite device data in mp app Marcin Kerlin
2016-09-11 12:23 ` Yuanhan Liu
2016-09-20 14:06 ` [dpdk-dev] [PATCH v2 0/2] app/testpmd: improve multiprocess support Marcin Kerlin
2016-09-20 14:31 ` Marcin Kerlin
2016-09-20 14:31 ` [dpdk-dev] [PATCH v2 1/2] librte_ether: ensure not overwrite device data in mp app Marcin Kerlin
2016-09-20 16:14 ` Pattan, Reshma
2016-09-22 14:11 ` Kerlin, MarcinX
2016-09-23 14:12 ` Thomas Monjalon
2016-09-26 15:07 ` Kerlin, MarcinX
2016-09-20 16:48 ` Pattan, Reshma
2016-09-22 14:21 ` Kerlin, MarcinX
2016-09-26 14:53 ` [dpdk-dev] [PATCH v3 0/2] app/testpmd: improve multiprocess support Marcin Kerlin
2016-09-26 14:53 ` [dpdk-dev] [PATCH v3 1/2] librte_ether: ensure not overwrite device data in mp app Marcin Kerlin
2016-09-27 3:06 ` Yuanhan Liu
2016-09-27 10:01 ` Kerlin, MarcinX
2016-09-27 10:29 ` [dpdk-dev] [PATCH v4 0/2] app/testpmd: improve multiprocess support Marcin Kerlin
2016-09-27 11:13 ` Marcin Kerlin
2016-09-27 11:13 ` [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against overwrite device data Marcin Kerlin
2016-09-28 11:00 ` Pattan, Reshma
2016-09-28 14:03 ` Pattan, Reshma
2016-09-29 13:41 ` Kerlin, MarcinX [this message]
2016-09-30 14:00 ` [dpdk-dev] [PATCH v5 0/2] app/testpmd: improve multiprocess support Marcin Kerlin
2016-09-30 14:00 ` [dpdk-dev] [PATCH v5 1/2] librte_ether: add protection against overwrite device data Marcin Kerlin
2016-09-30 15:00 ` Pattan, Reshma
2016-10-06 9:41 ` Thomas Monjalon
2016-10-06 13:57 ` Kerlin, MarcinX
2016-10-06 14:20 ` Thomas Monjalon
2016-10-06 14:52 ` Thomas Monjalon
2016-10-07 12:23 ` Kerlin, MarcinX
2016-10-11 8:52 ` Thomas Monjalon
2016-09-30 14:24 ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: improve handling of multiprocess Marcin Kerlin
2016-09-30 15:02 ` Pattan, Reshma
2016-09-30 15:03 ` [dpdk-dev] [PATCH v5 0/2] app/testpmd: improve multiprocess support Pattan, Reshma
2016-10-18 7:57 ` Sergio Gonzalez Monroy
2016-09-27 11:13 ` [dpdk-dev] [PATCH v4 2/2] app/testpmd: improve handling of multiprocess Marcin Kerlin
2016-09-28 10:57 ` Pattan, Reshma
2016-09-28 11:34 ` Kerlin, MarcinX
2016-09-28 12:08 ` Pattan, Reshma
2016-09-26 14:53 ` [dpdk-dev] [PATCH v3 " Marcin Kerlin
2016-09-20 14:31 ` [dpdk-dev] [PATCH v2 " Marcin Kerlin
2016-09-02 8:58 ` [dpdk-dev] [PATCH " Marcin Kerlin
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=68D830D942438745AD09BAFA99E33E812BD873@IRSMSX102.ger.corp.intel.com \
--to=marcinx.kerlin@intel.com \
--cc=dev@dpdk.org \
--cc=pablo.de.lara.guarch@intel.com \
--cc=reshma.pattan@intel.com \
--cc=thomas.monjalon@6wind.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).