net/mrvl: fix mbuf to bpool lookup
[dpdk.git] / drivers / net / failsafe / failsafe_private.h
index d2d92af..7754248 100644 (file)
@@ -38,7 +38,7 @@
 
 #include <rte_atomic.h>
 #include <rte_dev.h>
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_devargs.h>
 
 #define FAILSAFE_DRIVER_NAME "Fail-safe PMD"
@@ -48,6 +48,7 @@
 #define PMD_FAILSAFE_PARAM_STRING      \
        "dev(<ifc>),"                   \
        "exec(<shell command>),"        \
+       "fd(<fd number>),"              \
        "mac=mac_addr,"                 \
        "hotplug_poll=u64"              \
        ""
 #define FAILSAFE_MAX_ETHPORTS 2
 #define FAILSAFE_MAX_ETHADDR 128
 
+#define DEVARGS_MAXLEN 4096
+
 /* TYPES */
 
 struct rxq {
        struct fs_priv *priv;
        uint16_t qid;
-       /* id of last sub_device polled */
-       uint8_t last_polled;
+       /* next sub_device to poll */
+       struct sub_device *sdev;
        unsigned int socket_id;
        struct rte_eth_rxq_info info;
        rte_atomic64_t refcnt[];
@@ -93,8 +96,14 @@ enum dev_state {
        DEV_STARTED,
 };
 
+struct fs_stats {
+       struct rte_eth_stats stats;
+       uint64_t timestamp;
+};
+
 struct sub_device {
        /* Exhaustive DPDK device description */
+       struct sub_device *next;
        struct rte_devargs devargs;
        struct rte_bus *bus;
        struct rte_device *dev;
@@ -103,9 +112,11 @@ struct sub_device {
        /* Device state machine */
        enum dev_state state;
        /* Last stats snapshot passed to user */
-       struct rte_eth_stats stats_snapshot;
+       struct fs_stats stats_snapshot;
        /* Some device are defined as a command line */
        char *cmdline;
+       /* Others are retrieved through a file descriptor */
+       char *fd_str;
        /* fail-safe device backreference */
        struct rte_eth_dev *fs_dev;
        /* flag calling for recollection */
@@ -185,10 +196,10 @@ int failsafe_eth_dev_state_sync(struct rte_eth_dev *dev);
 void failsafe_dev_remove(struct rte_eth_dev *dev);
 void failsafe_stats_increment(struct rte_eth_stats *to,
                                struct rte_eth_stats *from);
-int failsafe_eth_rmv_event_callback(uint8_t port_id,
+int failsafe_eth_rmv_event_callback(uint16_t port_id,
                                    enum rte_eth_event_type type,
                                    void *arg, void *out);
-int failsafe_eth_lsc_event_callback(uint8_t port_id,
+int failsafe_eth_lsc_event_callback(uint16_t port_id,
                                    enum rte_eth_event_type event,
                                    void *cb_arg, void *out);
 
@@ -264,13 +275,13 @@ extern int mac_from_arg;
  * a: (rte_atomic64_t)
  */
 #define FS_ATOMIC_P(a) \
-       rte_atomic64_add(&(a), 1)
+       rte_atomic64_set(&(a), 1)
 
 /**
  * a: (rte_atomic64_t)
  */
 #define FS_ATOMIC_V(a) \
-       rte_atomic64_sub(&(a), 1)
+       rte_atomic64_set(&(a), 0)
 
 /**
  * s: (struct sub_device *)
@@ -370,4 +381,15 @@ fs_switch_dev(struct rte_eth_dev *dev,
        rte_wmb();
 }
 
+/*
+ * Adjust error value and rte_errno to the fail-safe actual error value.
+ */
+static inline int
+fs_err(struct sub_device *sdev, int err)
+{
+       /* A device removal shouldn't be reported as an error. */
+       if (sdev->remove == 1 || err == -EIO)
+               return rte_errno = 0;
+       return err;
+}
 #endif /* _RTE_ETH_FAILSAFE_PRIVATE_H_ */