This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 61989fee80f613970445e9658979a7b9f58fe9fb (commit) via 30114714f7740b3ee309e0be05e679c7e03816ba (commit) from 40ac22bb63526e9a935d804513204a85a665d13a (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 61989fee80f613970445e9658979a7b9f58fe9fb Author: Bogdan Pricope bogdan.pricope@linaro.org Date: Fri Jun 8 16:44:49 2018 +0300
linux-gen: pktio: move pktio socket stats to a new file
Cleanup pktio code by moving socket stats functions to a new file.
Signed-off-by: Bogdan Pricope bogdan.pricope@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index b730a92e..6fb0fb32 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -113,6 +113,8 @@ noinst_HEADERS = \ include/odp_packet_io_ring_internal.h \ include/odp_packet_socket.h \ include/odp_socket_common.h \ + include/odp_packet_io_stats_common.h \ + include/odp_packet_io_stats.h \ include/odp_sysfs_stats.h \ include/odp_ethtool_stats.h \ include/odp_ethtool_rss.h \ @@ -204,6 +206,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_weak.c \ pktio/stats/ethtool_stats.c \ pktio/stats/sysfs_stats.c \ + pktio/stats/packet_io_stats.c \ pktio/dpdk.c \ pktio/dpdk_parse.c \ pktio/socket_common.c \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 776a8442..d2446d19 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -26,6 +26,7 @@ extern "C" { #include <odp_align_internal.h> #include <odp_debug_internal.h> #include <odp_packet_io_ring_internal.h> +#include <odp_packet_io_stats_common.h> #include <odp_queue_if.h>
#include <odp_config_internal.h> @@ -89,11 +90,7 @@ struct pktio_entry { classifier_t cls; /**< classifier linked with this pktio*/ odp_pktio_stats_t stats; /**< statistic counters for pktio */ odp_proto_chksums_t in_chksums; /**< Checksums validation settings */ - enum { - STATS_SYSFS = 0, - STATS_ETHTOOL, - STATS_UNSUPPORTED - } stats_type; + pktio_stats_type_t stats_type; char name[PKTIO_NAME_LEN]; /**< name of pktio provided to pktio_open() */
@@ -221,11 +218,6 @@ extern const pktio_if_ops_t null_pktio_ops; extern const pktio_if_ops_t ipc_pktio_ops; extern const pktio_if_ops_t * const pktio_if_ops[];
-int sock_stats_fd(pktio_entry_t *pktio_entry, - odp_pktio_stats_t *stats, - int fd); -int sock_stats_reset_fd(pktio_entry_t *pktio_entry, int fd); - /** * Try interrupt-driven receive * diff --git a/platform/linux-generic/include/odp_packet_io_stats.h b/platform/linux-generic/include/odp_packet_io_stats.h new file mode 100644 index 00000000..4ed46e0a --- /dev/null +++ b/platform/linux-generic/include/odp_packet_io_stats.h @@ -0,0 +1,30 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PACKET_IO_STATS_H_ +#define ODP_PACKET_IO_STATS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/std_types.h> +#include <odp/api/packet_io.h> +#include <odp/api/packet_io_stats.h> +#include <odp_packet_io_internal.h> +#include <odp_packet_io_stats_common.h> + +int sock_stats_fd(pktio_entry_t *pktio_entry, + odp_pktio_stats_t *stats, + int fd); +int sock_stats_reset_fd(pktio_entry_t *pktio_entry, int fd); + +pktio_stats_type_t sock_stats_type_fd(pktio_entry_t *pktio_entry, int fd); + +#ifdef __cplusplus +} +#endif +#endif /* ODP_PACKET_IO_STATS_H_ */ diff --git a/platform/linux-generic/include/odp_packet_io_stats_common.h b/platform/linux-generic/include/odp_packet_io_stats_common.h new file mode 100644 index 00000000..19bd7c44 --- /dev/null +++ b/platform/linux-generic/include/odp_packet_io_stats_common.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PACKET_IO_STATS_COMMON_H_ +#define ODP_PACKET_IO_STATS_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + STATS_SYSFS = 0, + STATS_ETHTOOL, + STATS_UNSUPPORTED +} pktio_stats_type_t; + +#ifdef __cplusplus +} +#endif +#endif /* ODP_PACKET_IO_STATS_COMMON_H_ */ diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 6333847d..0da2b7af 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -16,6 +16,7 @@ #include <odp/api/plat/time_inlines.h>
#include <odp_packet_io_internal.h> +#include <odp_packet_io_stats.h> #include <odp_ethtool_stats.h> #include <odp_ethtool_rss.h> #include <odp_socket_common.h> diff --git a/platform/linux-generic/pktio/pktio_common.c b/platform/linux-generic/pktio/pktio_common.c index ca297fd5..f0abadd1 100644 --- a/platform/linux-generic/pktio/pktio_common.c +++ b/platform/linux-generic/pktio/pktio_common.c @@ -8,83 +8,8 @@ #include "config.h"
#include <odp_packet_io_internal.h> -#include <odp_ethtool_stats.h> -#include <odp_sysfs_stats.h> -#include <odp_classification_internal.h> #include <errno.h>
-int sock_stats_reset_fd(pktio_entry_t *pktio_entry, int fd) -{ - int err = 0; - odp_pktio_stats_t cur_stats; - - if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { - memset(&pktio_entry->s.stats, 0, - sizeof(odp_pktio_stats_t)); - return 0; - } - - memset(&cur_stats, 0, sizeof(odp_pktio_stats_t)); - - if (pktio_entry->s.stats_type == STATS_ETHTOOL) { - (void)ethtool_stats_get_fd(fd, - pktio_entry->s.name, - &cur_stats); - } else if (pktio_entry->s.stats_type == STATS_SYSFS) { - err = sysfs_stats(pktio_entry, &cur_stats); - if (err != 0) - ODP_ERR("stats error\n"); - } - - if (err == 0) - memcpy(&pktio_entry->s.stats, &cur_stats, - sizeof(odp_pktio_stats_t)); - - return err; -} - -int sock_stats_fd(pktio_entry_t *pktio_entry, - odp_pktio_stats_t *stats, - int fd) -{ - odp_pktio_stats_t cur_stats; - int ret = 0; - - if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) - return 0; - - memset(&cur_stats, 0, sizeof(odp_pktio_stats_t)); - if (pktio_entry->s.stats_type == STATS_ETHTOOL) { - (void)ethtool_stats_get_fd(fd, - pktio_entry->s.name, - &cur_stats); - } else if (pktio_entry->s.stats_type == STATS_SYSFS) { - sysfs_stats(pktio_entry, &cur_stats); - } - - stats->in_octets = cur_stats.in_octets - - pktio_entry->s.stats.in_octets; - stats->in_ucast_pkts = cur_stats.in_ucast_pkts - - pktio_entry->s.stats.in_ucast_pkts; - stats->in_discards = cur_stats.in_discards - - pktio_entry->s.stats.in_discards; - stats->in_errors = cur_stats.in_errors - - pktio_entry->s.stats.in_errors; - stats->in_unknown_protos = cur_stats.in_unknown_protos - - pktio_entry->s.stats.in_unknown_protos; - - stats->out_octets = cur_stats.out_octets - - pktio_entry->s.stats.out_octets; - stats->out_ucast_pkts = cur_stats.out_ucast_pkts - - pktio_entry->s.stats.out_ucast_pkts; - stats->out_discards = cur_stats.out_discards - - pktio_entry->s.stats.out_discards; - stats->out_errors = cur_stats.out_errors - - pktio_entry->s.stats.out_errors; - - return ret; -} - static int sock_recv_mq_tmo_select(pktio_entry_t * const *entry, const int index[], unsigned num_q, unsigned *from, diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 97a063c7..cee97f2c 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -39,8 +39,7 @@ #include <odp_socket_common.h> #include <odp_packet_internal.h> #include <odp_packet_io_internal.h> -#include <odp_ethtool_stats.h> -#include <odp_sysfs_stats.h> +#include <odp_packet_io_stats.h> #include <odp_align_internal.h> #include <odp_debug_internal.h> #include <odp_errno_define.h> @@ -148,7 +147,6 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, struct sockaddr_ll sa_ll; char shm_name[ODP_SHM_NAME_LEN]; pkt_sock_t *pkt_sock = pkt_priv(pktio_entry); - odp_pktio_stats_t cur_stats;
/* Init pktio entry */ memset(pkt_sock, 0, sizeof(*pkt_sock)); @@ -200,21 +198,10 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, goto error; }
- err = ethtool_stats_get_fd(pkt_priv(pktio_entry)->sockfd, - pktio_entry->s.name, - &cur_stats); - if (err != 0) { - err = sysfs_stats(pktio_entry, &cur_stats); - if (err != 0) { - pktio_entry->s.stats_type = STATS_UNSUPPORTED; - ODP_DBG("pktio: %s unsupported stats\n", - pktio_entry->s.name); - } else { - pktio_entry->s.stats_type = STATS_SYSFS; - } - } else { - pktio_entry->s.stats_type = STATS_ETHTOOL; - } + pktio_entry->s.stats_type = sock_stats_type_fd(pktio_entry, + pkt_sock->sockfd); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) + ODP_DBG("pktio: %s unsupported stats\n", pktio_entry->s.name);
err = sock_stats_reset(pktio_entry); if (err != 0) diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 6718eb9e..459c6552 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -31,8 +31,7 @@ #include <odp_socket_common.h> #include <odp_packet_internal.h> #include <odp_packet_io_internal.h> -#include <odp_ethtool_stats.h> -#include <odp_sysfs_stats.h> +#include <odp_packet_io_stats.h> #include <odp_debug_internal.h> #include <odp_errno_define.h> #include <odp_classification_datamodel.h> @@ -587,7 +586,6 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, { int if_idx; int ret = 0; - odp_pktio_stats_t cur_stats;
if (disable_pktio) return -1; @@ -651,21 +649,10 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, goto error; }
- ret = ethtool_stats_get_fd(pkt_priv(pktio_entry)->sockfd, - pktio_entry->s.name, - &cur_stats); - if (ret != 0) { - ret = sysfs_stats(pktio_entry, &cur_stats); - if (ret != 0) { - pktio_entry->s.stats_type = STATS_UNSUPPORTED; - ODP_DBG("pktio: %s unsupported stats\n", - pktio_entry->s.name); - } else { - pktio_entry->s.stats_type = STATS_SYSFS; - } - } else { - pktio_entry->s.stats_type = STATS_ETHTOOL; - } + pktio_entry->s.stats_type = sock_stats_type_fd(pktio_entry, + pkt_sock->sockfd); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) + ODP_DBG("pktio: %s unsupported stats\n", pktio_entry->s.name);
ret = sock_stats_reset_fd(pktio_entry, pkt_priv(pktio_entry)->sockfd); diff --git a/platform/linux-generic/pktio/stats/packet_io_stats.c b/platform/linux-generic/pktio/stats/packet_io_stats.c new file mode 100644 index 00000000..be87b519 --- /dev/null +++ b/platform/linux-generic/pktio/stats/packet_io_stats.c @@ -0,0 +1,97 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" + +#include <string.h> +#include <odp_packet_io_stats.h> +#include <odp_ethtool_stats.h> +#include <odp_sysfs_stats.h> + +int sock_stats_reset_fd(pktio_entry_t *pktio_entry, int fd) +{ + int err = 0; + odp_pktio_stats_t cur_stats; + + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { + memset(&pktio_entry->s.stats, 0, + sizeof(odp_pktio_stats_t)); + return 0; + } + + memset(&cur_stats, 0, sizeof(odp_pktio_stats_t)); + + if (pktio_entry->s.stats_type == STATS_ETHTOOL) { + (void)ethtool_stats_get_fd(fd, + pktio_entry->s.name, + &cur_stats); + } else if (pktio_entry->s.stats_type == STATS_SYSFS) { + err = sysfs_stats(pktio_entry, &cur_stats); + if (err != 0) + ODP_ERR("stats error\n"); + } + + if (err == 0) + memcpy(&pktio_entry->s.stats, &cur_stats, + sizeof(odp_pktio_stats_t)); + + return err; +} + +int sock_stats_fd(pktio_entry_t *pktio_entry, + odp_pktio_stats_t *stats, + int fd) +{ + odp_pktio_stats_t cur_stats; + int ret = 0; + + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) + return 0; + + memset(&cur_stats, 0, sizeof(odp_pktio_stats_t)); + if (pktio_entry->s.stats_type == STATS_ETHTOOL) { + (void)ethtool_stats_get_fd(fd, + pktio_entry->s.name, + &cur_stats); + } else if (pktio_entry->s.stats_type == STATS_SYSFS) { + sysfs_stats(pktio_entry, &cur_stats); + } + + stats->in_octets = cur_stats.in_octets - + pktio_entry->s.stats.in_octets; + stats->in_ucast_pkts = cur_stats.in_ucast_pkts - + pktio_entry->s.stats.in_ucast_pkts; + stats->in_discards = cur_stats.in_discards - + pktio_entry->s.stats.in_discards; + stats->in_errors = cur_stats.in_errors - + pktio_entry->s.stats.in_errors; + stats->in_unknown_protos = cur_stats.in_unknown_protos - + pktio_entry->s.stats.in_unknown_protos; + + stats->out_octets = cur_stats.out_octets - + pktio_entry->s.stats.out_octets; + stats->out_ucast_pkts = cur_stats.out_ucast_pkts - + pktio_entry->s.stats.out_ucast_pkts; + stats->out_discards = cur_stats.out_discards - + pktio_entry->s.stats.out_discards; + stats->out_errors = cur_stats.out_errors - + pktio_entry->s.stats.out_errors; + + return ret; +} + +pktio_stats_type_t sock_stats_type_fd(pktio_entry_t *pktio_entry, int fd) +{ + odp_pktio_stats_t cur_stats; + + if (!ethtool_stats_get_fd(fd, pktio_entry->s.name, &cur_stats)) + return STATS_ETHTOOL; + + if (!sysfs_stats(pktio_entry, &cur_stats)) + return STATS_SYSFS; + + return STATS_UNSUPPORTED; +}
commit 30114714f7740b3ee309e0be05e679c7e03816ba Author: Bogdan Pricope bogdan.pricope@linaro.org Date: Thu Jun 7 15:28:00 2018 +0300
linux-gen: pktio: move ethtool and sysfs stats files to new folder
Cleanup code structure by moving stats related files to new folder and creating header file for sysfs stats.
Signed-off-by: Bogdan Pricope bogdan.pricope@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index dae6e5bb..b730a92e 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -113,6 +113,7 @@ noinst_HEADERS = \ include/odp_packet_io_ring_internal.h \ include/odp_packet_socket.h \ include/odp_socket_common.h \ + include/odp_sysfs_stats.h \ include/odp_ethtool_stats.h \ include/odp_ethtool_rss.h \ include/odp_pcapng.h \ @@ -201,10 +202,11 @@ __LIB__libodp_linux_la_SOURCES = \ odp_traffic_mngr.c \ odp_version.c \ odp_weak.c \ + pktio/stats/ethtool_stats.c \ + pktio/stats/sysfs_stats.c \ pktio/dpdk.c \ pktio/dpdk_parse.c \ pktio/socket_common.c \ - pktio/ethtool_stats.c \ pktio/ethtool_rss.c \ pktio/io_ops.c \ pktio/ipc.c \ @@ -215,7 +217,6 @@ __LIB__libodp_linux_la_SOURCES = \ pktio/ring.c \ pktio/socket.c \ pktio/socket_mmap.c \ - pktio/sysfs.c \ pktio/tap.c if ODP_ABI_COMPAT __LIB__libodp_linux_la_SOURCES += \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index cec2d2d6..776a8442 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -221,8 +221,6 @@ extern const pktio_if_ops_t null_pktio_ops; extern const pktio_if_ops_t ipc_pktio_ops; extern const pktio_if_ops_t * const pktio_if_ops[];
-int sysfs_stats(pktio_entry_t *pktio_entry, - odp_pktio_stats_t *stats); int sock_stats_fd(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats, int fd); diff --git a/platform/linux-generic/include/odp_sysfs_stats.h b/platform/linux-generic/include/odp_sysfs_stats.h new file mode 100644 index 00000000..bf9f4f79 --- /dev/null +++ b/platform/linux-generic/include/odp_sysfs_stats.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_SYSFS_STATS_H_ +#define ODP_SYSFS_STATS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/packet_io_stats.h> +#include <odp_packet_io_internal.h> + +int sysfs_stats(pktio_entry_t *pktio_entry, + odp_pktio_stats_t *stats); + +#ifdef __cplusplus +} +#endif +#endif /* ODP_SYSFS_STATS_H_ */ diff --git a/platform/linux-generic/pktio/pktio_common.c b/platform/linux-generic/pktio/pktio_common.c index 218196b4..ca297fd5 100644 --- a/platform/linux-generic/pktio/pktio_common.c +++ b/platform/linux-generic/pktio/pktio_common.c @@ -9,6 +9,7 @@
#include <odp_packet_io_internal.h> #include <odp_ethtool_stats.h> +#include <odp_sysfs_stats.h> #include <odp_classification_internal.h> #include <errno.h>
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 9422d85b..97a063c7 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -40,6 +40,7 @@ #include <odp_packet_internal.h> #include <odp_packet_io_internal.h> #include <odp_ethtool_stats.h> +#include <odp_sysfs_stats.h> #include <odp_align_internal.h> #include <odp_debug_internal.h> #include <odp_errno_define.h> diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index aedcceae..6718eb9e 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -32,6 +32,7 @@ #include <odp_packet_internal.h> #include <odp_packet_io_internal.h> #include <odp_ethtool_stats.h> +#include <odp_sysfs_stats.h> #include <odp_debug_internal.h> #include <odp_errno_define.h> #include <odp_classification_datamodel.h> diff --git a/platform/linux-generic/pktio/ethtool_stats.c b/platform/linux-generic/pktio/stats/ethtool_stats.c similarity index 100% rename from platform/linux-generic/pktio/ethtool_stats.c rename to platform/linux-generic/pktio/stats/ethtool_stats.c diff --git a/platform/linux-generic/pktio/sysfs.c b/platform/linux-generic/pktio/stats/sysfs_stats.c similarity index 98% rename from platform/linux-generic/pktio/sysfs.c rename to platform/linux-generic/pktio/stats/sysfs_stats.c index c85a88e5..e5fa5544 100644 --- a/platform/linux-generic/pktio/sysfs.c +++ b/platform/linux-generic/pktio/stats/sysfs_stats.c @@ -7,7 +7,7 @@ #include "config.h"
#include <odp_api.h> -#include <odp_packet_io_internal.h> +#include <odp_sysfs_stats.h> #include <odp_errno_define.h> #include <errno.h> #include <string.h>
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/Makefile.am | 8 +- .../linux-generic/include/odp_packet_io_internal.h | 14 +--- .../linux-generic/include/odp_packet_io_stats.h | 30 +++++++ .../include/odp_packet_io_stats_common.h | 23 +++++ platform/linux-generic/include/odp_sysfs_stats.h | 23 +++++ platform/linux-generic/pktio/netmap.c | 1 + platform/linux-generic/pktio/pktio_common.c | 74 ----------------- platform/linux-generic/pktio/socket.c | 22 ++--- platform/linux-generic/pktio/socket_mmap.c | 22 ++--- .../pktio/{ => stats}/ethtool_stats.c | 0 .../linux-generic/pktio/stats/packet_io_stats.c | 97 ++++++++++++++++++++++ .../pktio/{sysfs.c => stats/sysfs_stats.c} | 2 +- 12 files changed, 193 insertions(+), 123 deletions(-) create mode 100644 platform/linux-generic/include/odp_packet_io_stats.h create mode 100644 platform/linux-generic/include/odp_packet_io_stats_common.h create mode 100644 platform/linux-generic/include/odp_sysfs_stats.h rename platform/linux-generic/pktio/{ => stats}/ethtool_stats.c (100%) create mode 100644 platform/linux-generic/pktio/stats/packet_io_stats.c rename platform/linux-generic/pktio/{sysfs.c => stats/sysfs_stats.c} (98%)
hooks/post-receive