Skip to content
Snippets Groups Projects
Commit ea91b056 authored by Arun Muthusamy's avatar Arun Muthusamy Committed by Rahul Thakur
Browse files

RMON stats and eth_stats implementation for HSGMII LAN driver

parent 4a363a69
No related branches found
No related tags found
1 merge request!11RMON stats and eth_stats implementation for HSGMII LAN driver
Pipeline #118752 passed
...@@ -21,7 +21,7 @@ endif ...@@ -21,7 +21,7 @@ endif
ifeq ($(PLATFORM),ECONET) ifeq ($(PLATFORM),ECONET)
CFLAGS += -Itest_stub $(LIBETH_CFLAGS) CFLAGS += -Itest_stub $(LIBETH_CFLAGS)
objs_lib += econet/econet.o econet/ecnt_prvt.o objs_lib += econet/econet.o econet/ecnt_prvt.o
LIBS += -lapi_lib_switchmgr LIBS += -lapi_lib_switchmgr -lapi_lib_fe
endif endif
ifeq ($(PLATFORM),LINUX) ifeq ($(PLATFORM),LINUX)
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <easy/easy.h> #include <easy/easy.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/sockios.h>
#include "../ethernet.h" #include "../ethernet.h"
...@@ -44,6 +47,7 @@ ...@@ -44,6 +47,7 @@
#include "libapi_lib_switchmgr.h" #include "libapi_lib_switchmgr.h"
#endif #endif
#include "libapi_lib_fe.h"
#define TC3162_MAX_LINE_LEN (100) #define TC3162_MAX_LINE_LEN (100)
#define TC3162_DUPLEX_MODE_LEN (32) #define TC3162_DUPLEX_MODE_LEN (32)
#define TC3162_SPEED_MODE_LEN (32) #define TC3162_SPEED_MODE_LEN (32)
...@@ -51,12 +55,122 @@ ...@@ -51,12 +55,122 @@
#define IFNAME_ETH0 "eth0." #define IFNAME_ETH0 "eth0."
#define IFNAME_NAS "nas" #define IFNAME_NAS "nas"
#define IFNAME_AE_WAN "ae_wan" #define IFNAME_AE_WAN "ae_wan"
#define DRIVER_NAME "hsgmii_lan"
#define DRIVER_NAME_LEN 20
#define HSGMII_INDEX 2
/* Not defined in Econet library */ /* Not defined in Econet library */
ECNT_SWITCHMGR_RET switchmgr_lib_get_port_link_state(u8 port, ECNT_SWITCHMGR_RET switchmgr_lib_get_port_link_state(u8 port,
ECNT_SWITCHMGR_LINK_STATE *p_link_state, ECNT_SWITCHMGR_LINK_STATE *p_link_state,
ECNT_SWITCHMGR_LINK_SPEED *p_speed); ECNT_SWITCHMGR_LINK_SPEED *p_speed);
static int get_drv_info_by_ifname(char *ifname, char *buffer)
{
int fd;
int ret = -1;
struct ifreq ifr;
struct ethtool_drvinfo info;
if (ifname == NULL || buffer == NULL)
return ret;
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0)
return ret;
memset(&info, 0, sizeof(info));
info.cmd = ETHTOOL_GDRVINFO;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
ifr.ifr_data = (void *)&info;
if (ioctl(fd, SIOCETHTOOL, &ifr) != 0)
goto exit;
strcpy(buffer, info.driver);
ret = 0;
exit:
close(fd);
return ret;
}
int hsgmii_lan_prvt_get_port_statistics(char *ifname, struct eth_stats *stats, struct eth_rmon_stats *rstats) {
ECNT_FEMGR_GDMA2_TX_STATISTICS tx_stats;
ECNT_FEMGR_GDMA2_RX_STATISTICS rx_stats;
char driver_name[DRIVER_NAME_LEN];
if (get_drv_info_by_ifname(ifname, driver_name))
return -1;
if (!strncmp(driver_name, DRIVER_NAME, DRIVER_NAME_LEN)) {
if (!fe_lib_get_hsgmii_tx_statistics(&tx_stats, HSGMII_INDEX)) {
if (stats != NULL) {
stats->tx_bytes = 0;
stats->tx_packets = tx_stats.frame_cnt;
stats->tx_errors = 0;
stats->tx_ucast_packets = 0;
stats->tx_mcast_packets = tx_stats.broadcast;
stats->tx_bcast_packets = tx_stats.multicast;
stats->tx_discard_packets = tx_stats.drop_cnt;
stats->rx_unknown_packets = 0;
}
if (rstats != NULL) {
rstats->tx.packets = tx_stats.frame_cnt;
rstats->tx.bytes = 0;
rstats->tx.bcast_packets = tx_stats.broadcast;
rstats->tx.mcast_packets = tx_stats.multicast;
rstats->tx.crc_err_packets = 0;
rstats->tx.under_sz_packets = 0;
rstats->tx.over_sz_packets = 0;
rstats->tx.packets_64bytes = tx_stats.eq_64;
rstats->tx.packets_65to127bytes = tx_stats.from_65_to_127;
rstats->tx.packets_256to511bytes = tx_stats.from_256_to_511;
rstats->tx.packets_512to1023bytes = tx_stats.from_512_to_1023;
rstats->tx.packets_1024to1518bytes = tx_stats.from_1024_to_1518;
}
}
if (!fe_lib_get_hsgmii_rx_statistics(&rx_stats, HSGMII_INDEX)){
if (rstats != NULL) {
rstats->rx.packets = rx_stats.frame_cnt;
rstats->rx.bytes = 0;
rstats->rx.bcast_packets = rx_stats.broadcast;
rstats->rx.mcast_packets = rx_stats.multicast;
rstats->rx.crc_err_packets = rx_stats.crc;
rstats->rx.under_sz_packets = rx_stats.undersize;
rstats->rx.over_sz_packets = rx_stats.oversize;
rstats->rx.packets_64bytes = rx_stats.eq_64;
rstats->rx.packets_65to127bytes = rx_stats.from_65_to_127;
rstats->rx.packets_256to511bytes = rx_stats.from_256_to_511;
rstats->rx.packets_512to1023bytes = rx_stats.from_512_to_1023;
rstats->rx.packets_1024to1518bytes = rx_stats.from_1024_to_1518;
}
if (stats != NULL) {
stats->rx_bytes = 0;
stats->rx_packets = rx_stats.frame_cnt;
stats->rx_errors = 0;
stats->rx_ucast_packets = 0;
stats->rx_mcast_packets = rx_stats.multicast;
stats->rx_bcast_packets = rx_stats.broadcast;
stats->rx_discard_packets = rx_stats.drop_cnt;
stats->rx_unknown_packets = 0;
}
}
return 0;
}
return -1;
}
int ecnt_prvt_get_port_statistics(uint32_t port, int ecnt_prvt_get_port_statistics(uint32_t port,
struct eth_stats *stats, struct eth_stats *stats,
struct eth_rmon_stats *rstats) struct eth_rmon_stats *rstats)
......
...@@ -64,6 +64,10 @@ int econet_eth_get_stats(const char *ifname, struct eth_stats *stats) ...@@ -64,6 +64,10 @@ int econet_eth_get_stats(const char *ifname, struct eth_stats *stats)
port_num = ecnt_prvt_get_port_num(ifname); port_num = ecnt_prvt_get_port_num(ifname);
if (port_num == ECNT_PRVT_PORT_NUM_INVALID) { if (port_num == ECNT_PRVT_PORT_NUM_INVALID) {
/* Check and fetch stats if the Interface belongs to hsgmii_lan driver */
if (!hsgmii_lan_prvt_get_port_statistics(ifname, stats, NULL)) {
return 0;
}
libethernet_err("invalid port name: %s\n", ifname); libethernet_err("invalid port name: %s\n", ifname);
return -1; return -1;
} }
...@@ -82,6 +86,12 @@ int econet_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rstats) ...@@ -82,6 +86,12 @@ int econet_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rstats)
port_num = ecnt_prvt_get_port_num(ifname); port_num = ecnt_prvt_get_port_num(ifname);
if (port_num == ECNT_PRVT_PORT_NUM_INVALID) { if (port_num == ECNT_PRVT_PORT_NUM_INVALID) {
/* Check and fetch rstats if the Interface belongs to hsgmii_lan driver */
if (!hsgmii_lan_prvt_get_port_statistics(ifname, NULL, rstats)) {
return 0;
}
libethernet_err("invalid port name: %s\n", ifname); libethernet_err("invalid port name: %s\n", ifname);
return -1; return -1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment