X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Ffailsafe%2Ffailsafe_private.h;h=7754248ff827f7d81b510d403bdddb761699bb87;hb=ac6881ea6b6101d6de7b1e3900d47afaa08bcc2d;hp=d2d92af28bbdf9cb5c04d817b44d5098dd7a431d;hpb=6265ab51b827e6c33d5c01fe7dd13057b642c88e;p=dpdk.git diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index d2d92af28b..7754248ff8 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -38,7 +38,7 @@ #include #include -#include +#include #include #define FAILSAFE_DRIVER_NAME "Fail-safe PMD" @@ -48,6 +48,7 @@ #define PMD_FAILSAFE_PARAM_STRING \ "dev()," \ "exec()," \ + "fd()," \ "mac=mac_addr," \ "hotplug_poll=u64" \ "" @@ -57,13 +58,15 @@ #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_ */