[3/4] net/failsafe: replace local sub-device with shared data
Checks
Commit Message
In multiprocess context, the pointer to sub-device is shared between
processes. Previously, it was a pointer to per process eth_dev so
it's needed to replace this dependency.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
drivers/net/failsafe/failsafe_eal.c | 2 +-
drivers/net/failsafe/failsafe_ether.c | 7 ++++---
drivers/net/failsafe/failsafe_private.h | 11 +++++++----
3 files changed, 12 insertions(+), 8 deletions(-)
Comments
On Thu, 28 Feb 2019 15:49:27 +0000
Raslan Darawsheh <rasland@mellanox.com> wrote:
>
> /* sdev: (struct sub_device *) */
> #define ETH(sdev) \
> - ((sdev)->edev)
> + (sdev->data == NULL ? NULL : &rte_eth_devices[sdev->data->port_id])
Macro arguments should always be parenthesised and you can shorten
by using abbreviated trigraph.
#define ETH(sdev) \
((sdev)->data ? &rte_eth_devices[(sdev)->data->port_id] : )
@@ -112,7 +112,7 @@ fs_bus_init(struct rte_eth_dev *dev)
continue;
}
}
- ETH(sdev) = &rte_eth_devices[pid];
+ sdev->data = rte_eth_devices[pid].data;
SUB_ID(sdev) = i;
sdev->fs_port_id = dev->data->port_id;
sdev->dev = ETH(sdev)->device;
@@ -267,18 +267,19 @@ static void
fs_dev_remove(struct sub_device *sdev)
{
int ret;
+ struct rte_eth_dev *edev = ETH(sdev);
if (sdev == NULL)
return;
switch (sdev->state) {
case DEV_STARTED:
failsafe_rx_intr_uninstall_subdevice(sdev);
- rte_eth_dev_stop(PORT_ID(sdev));
+ rte_eth_dev_stop(edev->data->port_id);
sdev->state = DEV_ACTIVE;
/* fallthrough */
case DEV_ACTIVE:
failsafe_eth_dev_unregister_callbacks(sdev);
- rte_eth_dev_close(PORT_ID(sdev));
+ rte_eth_dev_close(edev->data->port_id);
sdev->state = DEV_PROBED;
/* fallthrough */
case DEV_PROBED:
@@ -287,7 +288,7 @@ fs_dev_remove(struct sub_device *sdev)
ERROR("Bus detach failed for sub_device %u",
SUB_ID(sdev));
} else {
- rte_eth_dev_release_port(ETH(sdev));
+ rte_eth_dev_release_port(edev);
}
sdev->state = DEV_PARSED;
/* fallthrough */
@@ -100,13 +100,16 @@ struct fs_stats {
uint64_t timestamp;
};
+/*
+ * Allocated in shared memory.
+ */
struct sub_device {
/* Exhaustive DPDK device description */
struct sub_device *next;
struct rte_devargs devargs;
- struct rte_bus *bus;
- struct rte_device *dev;
- struct rte_eth_dev *edev;
+ struct rte_bus *bus; /* per process. */
+ struct rte_device *dev; /* per process. */
+ struct rte_eth_dev_data *data; /* shared between processes */
uint8_t sid;
/* Device state machine */
enum dev_state state;
@@ -257,7 +260,7 @@ extern int failsafe_mac_from_arg;
/* sdev: (struct sub_device *) */
#define ETH(sdev) \
- ((sdev)->edev)
+ (sdev->data == NULL ? NULL : &rte_eth_devices[sdev->data->port_id])
/* sdev: (struct sub_device *) */
#define PORT_ID(sdev) \