[4/4] net/failsafe: support secondary process
Checks
Commit Message
Add implementation for probe in secondary.
Failsafe will attempt to attach all the sub-devices in
secondary process.
Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/net/failsafe/failsafe.c | 43 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
Comments
On Thu, 28 Feb 2019 15:49:28 +0000
Raslan Darawsheh <rasland@mellanox.com> wrote:
>
> static int
> +devargs_already_listed(struct rte_devargs *devargs)
Why not make this function bool?
static bool
devargs_already_listed(...)
On Thu, 28 Feb 2019 15:49:28 +0000
Raslan Darawsheh <rasland@mellanox.com> wrote:
> + eth_dev->rx_pkt_burst = (eth_rx_burst_t)&failsafe_rx_burst;
> + eth_dev->tx_pkt_burst = (eth_tx_burst_t)&failsafe_tx_burst;
Why is cast necessary here. The function signature should match.
Hi Stephen,
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, February 28, 2019 7:25 PM
> To: Raslan Darawsheh <rasland@mellanox.com>
> Cc: gaetan.rivet@6wind.com; dev@dpdk.org; Thomas Monjalon
> <thomas@monjalon.net>
> Subject: Re: [dpdk-dev] [PATCH 4/4] net/failsafe: support secondary process
>
> On Thu, 28 Feb 2019 15:49:28 +0000
> Raslan Darawsheh <rasland@mellanox.com> wrote:
>
> > + eth_dev->rx_pkt_burst =
> (eth_rx_burst_t)&failsafe_rx_burst;
> > + eth_dev->tx_pkt_burst =
> (eth_tx_burst_t)&failsafe_tx_burst;
>
> Why is cast necessary here. The function signature should match.
I don't think it's necessary, but this is the same as the primary process implementation
Kindest regards
Raslan Darawsheh
05/03/2019 10:33, Raslan Darawsheh:
> Hi Stephen,
>
> From: Stephen Hemminger <stephen@networkplumber.org>
> > On Thu, 28 Feb 2019 15:49:28 +0000
> > Raslan Darawsheh <rasland@mellanox.com> wrote:
> >
> > > + eth_dev->rx_pkt_burst =
> > (eth_rx_burst_t)&failsafe_rx_burst;
> > > + eth_dev->tx_pkt_burst =
> > (eth_tx_burst_t)&failsafe_tx_burst;
> >
> > Why is cast necessary here. The function signature should match.
>
> I don't think it's necessary, but this is the same as the primary process implementation
If it's not necessary, better to not add them.
Don't worry about consistency for pointer casting :)
@@ -313,10 +313,27 @@ fs_rte_eth_free(const char *name)
}
static int
+devargs_already_listed(struct rte_devargs *devargs)
+{
+ struct rte_devargs *list_da;
+
+ RTE_EAL_DEVARGS_FOREACH(devargs->bus->name, list_da) {
+ if (strcmp(list_da->name, devargs->name) == 0)
+ /* devargs already in the list */
+ return 1;
+ }
+ return 0;
+}
+
+static int
rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
{
const char *name;
struct rte_eth_dev *eth_dev;
+ struct sub_device *sdev;
+ struct rte_devargs devargs;
+ uint8_t i;
+ int ret;
name = rte_vdev_device_name(vdev);
INFO("Initializing " FAILSAFE_DRIVER_NAME " for %s",
@@ -329,9 +346,33 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
ERROR("Failed to probe %s", name);
return -1;
}
- /* TODO: request info from primary to set up Rx and Tx */
eth_dev->dev_ops = &failsafe_ops;
eth_dev->device = &vdev->device;
+ eth_dev->rx_pkt_burst = (eth_rx_burst_t)&failsafe_rx_burst;
+ eth_dev->tx_pkt_burst = (eth_tx_burst_t)&failsafe_tx_burst;
+ /*
+ * Failsafe will attempt to probe all of its sub-devices.
+ * Any failure in sub-devices is not a fatal error.
+ * A sub-device can be plugged later.
+ */
+ FOREACH_SUBDEV(sdev, i, eth_dev) {
+ /* rebuild devargs to be able to get the bus name. */
+ ret = rte_devargs_parse(&devargs,
+ sdev->devargs.name);
+ if (ret != 0) {
+ ERROR("Failed to parse devargs %s",
+ devargs.name);
+ continue;
+ }
+ if (!devargs_already_listed(&devargs)) {
+ ret = rte_dev_probe(devargs.name);
+ if (ret != 0) {
+ ERROR("Failed to probe devargs %s",
+ devargs.name);
+ continue;
+ }
+ }
+ }
rte_eth_dev_probing_finish(eth_dev);
return 0;
}