zephyr/subsys/net/l2/ethernet/eth_stats.h
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00

221 lines
4.3 KiB
C

/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ETH_STATS_H__
#define __ETH_STATS_H__
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
#include <net/net_ip.h>
#include <net/net_stats.h>
#include <net/net_if.h>
static inline void eth_stats_update_bytes_rx(struct net_if *iface,
uint32_t bytes)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->bytes.received += bytes;
}
static inline void eth_stats_update_bytes_tx(struct net_if *iface,
uint32_t bytes)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->bytes.sent += bytes;
}
static inline void eth_stats_update_pkts_rx(struct net_if *iface)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->pkts.rx++;
}
static inline void eth_stats_update_pkts_tx(struct net_if *iface)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->pkts.tx++;
}
static inline void eth_stats_update_broadcast_rx(struct net_if *iface)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->broadcast.rx++;
}
static inline void eth_stats_update_broadcast_tx(struct net_if *iface)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->broadcast.tx++;
}
static inline void eth_stats_update_multicast_rx(struct net_if *iface)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->multicast.rx++;
}
static inline void eth_stats_update_multicast_tx(struct net_if *iface)
{
const struct ethernet_api *api = (const struct ethernet_api *)
net_if_get_device(iface)->api;
struct net_stats_eth *stats;
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->multicast.tx++;
}
static inline void eth_stats_update_errors_rx(struct net_if *iface)
{
struct net_stats_eth *stats;
const struct ethernet_api *api;
if (!iface) {
return;
}
api = ((const struct ethernet_api *)
net_if_get_device(iface)->api);
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->errors.rx++;
}
static inline void eth_stats_update_errors_tx(struct net_if *iface)
{
struct net_stats_eth *stats;
const struct ethernet_api *api = ((const struct ethernet_api *)
net_if_get_device(iface)->api);
if (!api->get_stats) {
return;
}
stats = api->get_stats(net_if_get_device(iface));
if (!stats) {
return;
}
stats->errors.tx++;
}
#else /* CONFIG_NET_STATISTICS_ETHERNET */
#define eth_stats_update_bytes_rx(iface, bytes)
#define eth_stats_update_bytes_tx(iface, bytes)
#define eth_stats_update_pkts_rx(iface)
#define eth_stats_update_pkts_tx(iface)
#define eth_stats_update_broadcast_rx(iface)
#define eth_stats_update_broadcast_tx(iface)
#define eth_stats_update_multicast_rx(iface)
#define eth_stats_update_multicast_tx(iface)
#define eth_stats_update_errors_rx(iface)
#define eth_stats_update_errors_tx(iface)
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
#endif /* __ETH_STATS_H__ */