Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libethernet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HAL
libethernet
Commits
ea91b056
Commit
ea91b056
authored
1 year ago
by
Arun Muthusamy
Committed by
Rahul Thakur
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
RMON stats and eth_stats implementation for HSGMII LAN driver
parent
4a363a69
No related branches found
No related tags found
1 merge request
!11
RMON stats and eth_stats implementation for HSGMII LAN driver
Pipeline
#118752
passed
1 year ago
Stage: static_code_analysis
Stage: compile_test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
econet/ecnt_prvt.c
+114
-0
114 additions, 0 deletions
econet/ecnt_prvt.c
econet/econet.c
+10
-0
10 additions, 0 deletions
econet/econet.c
with
125 additions
and
1 deletion
Makefile
+
1
−
1
View file @
ea91b056
...
@@ -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)
...
...
This diff is collapsed.
Click to expand it.
econet/ecnt_prvt.c
+
114
−
0
View file @
ea91b056
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
econet/econet.c
+
10
−
0
View file @
ea91b056
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment