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
b7656aa6
Commit
b7656aa6
authored
1 year ago
by
Mohd Husaam Mehdi
Browse files
Options
Downloads
Patches
Plain Diff
Add support for clear_stats
parent
ea91b056
Branches
Branches containing commit
No related tags found
1 merge request
!12
Add support for clear_stats
Pipeline
#124378
failed
1 year ago
Stage: static_code_analysis
Stage: compile_test
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bcm/bcm.c
+26
-0
26 additions, 0 deletions
bcm/bcm.c
econet/econet.c
+22
-0
22 additions, 0 deletions
econet/econet.c
ethernet.c
+10
-0
10 additions, 0 deletions
ethernet.c
ethernet.h
+3
-0
3 additions, 0 deletions
ethernet.h
with
61 additions
and
0 deletions
bcm/bcm.c
+
26
−
0
View file @
b7656aa6
...
@@ -474,6 +474,31 @@ int bcm_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
...
@@ -474,6 +474,31 @@ int bcm_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
return
0
;
return
0
;
}
}
int
bcm_eth_clear_stats
(
const
char
*
ifname
)
{
int
ret
,
unit
=
-
1
,
port
=
-
1
;
struct
ethswctl_data
data
;
memset
(
&
data
,
0
,
sizeof
(
struct
ethswctl_data
));
ret
=
bcm_eth_get_unit_port
(
ifname
,
&
unit
,
&
port
);
if
(
ret
)
return
-
1
;
data
.
op
=
ETHSWSTATPORTCLR
;
data
.
port
=
port
;
data
.
unit
=
unit
;
ret
=
eth_ioctl
(
ifname
,
SIOCETHSWCTLOPS
,
&
data
,
sizeof
(
struct
ethswctl_data
));
if
(
ret
!=
0
)
{
libethernet_err
(
"ioctl failed! ret = %d
\n
"
,
ret
);
return
-
1
;
}
return
0
;
}
const
struct
eth_ops
bcm_eth_ops
=
{
const
struct
eth_ops
bcm_eth_ops
=
{
.
ifname
=
"eth"
,
.
ifname
=
"eth"
,
//.up = bcm_eth_up,
//.up = bcm_eth_up,
...
@@ -485,4 +510,5 @@ const struct eth_ops bcm_eth_ops = {
...
@@ -485,4 +510,5 @@ const struct eth_ops bcm_eth_ops = {
.
poweron_phy
=
bcm_eth_poweron_phy
,
.
poweron_phy
=
bcm_eth_poweron_phy
,
.
poweroff_phy
=
bcm_eth_poweroff_phy
,
.
poweroff_phy
=
bcm_eth_poweroff_phy
,
.
reset_phy
=
bcm_eth_reset_phy
,
.
reset_phy
=
bcm_eth_reset_phy
,
.
clear_stats
=
bcm_eth_clear_stats
,
};
};
This diff is collapsed.
Click to expand it.
econet/econet.c
+
22
−
0
View file @
b7656aa6
...
@@ -138,6 +138,27 @@ int econet_eth_reset_phy(const char *name, int phy_id)
...
@@ -138,6 +138,27 @@ int econet_eth_reset_phy(const char *name, int phy_id)
return
0
;
return
0
;
}
}
int
econet_clear_stats
(
const
char
*
ifname
)
{
char
clear_stats_filename
[
128
]
=
{
0
};
FILE
*
fp
=
NULL
;
// clear stats files are named as eth0.1_clear_stats etc.
snprintf
(
clear_stats_filename
,
sizeof
(
clear_stats_filename
),
"/proc/tc3162/%s_clear_stats"
,
ifname
);
fp
=
fopen
(
clear_stats_filename
,
"w"
);
if
(
!
fp
)
{
libethernet_err
(
"%s(): fopen() failed for %s
\n
"
,
__func__
,
clear_stats_filename
);
return
-
1
;
}
else
{
// just write 1 to clear the stats
fprintf
(
fp
,
"1"
);
fclose
(
fp
);
}
return
0
;
}
/* Declare separate eth ops for all known Econet interfaces */
/* Declare separate eth ops for all known Econet interfaces */
#define ECNT_ETH_OPS(__name, __interface_name) \
#define ECNT_ETH_OPS(__name, __interface_name) \
const struct eth_ops __name = { \
const struct eth_ops __name = { \
...
@@ -149,6 +170,7 @@ const struct eth_ops __name = { \
...
@@ -149,6 +170,7 @@ const struct eth_ops __name = { \
.poweron_phy = econet_eth_poweron_phy, \
.poweron_phy = econet_eth_poweron_phy, \
.poweroff_phy = econet_eth_poweroff_phy, \
.poweroff_phy = econet_eth_poweroff_phy, \
.reset_phy = econet_eth_reset_phy, \
.reset_phy = econet_eth_reset_phy, \
.clear_stats = econet_clear_stats, \
}
}
ECNT_ETH_OPS
(
econet_gen_eth_ops
,
"eth"
);
ECNT_ETH_OPS
(
econet_gen_eth_ops
,
"eth"
);
...
...
This diff is collapsed.
Click to expand it.
ethernet.c
+
10
−
0
View file @
b7656aa6
...
@@ -165,6 +165,16 @@ int eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
...
@@ -165,6 +165,16 @@ int eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
return
-
1
;
return
-
1
;
}
}
int
eth_clear_stats
(
const
char
*
ifname
)
{
const
struct
eth_ops
*
eth
=
get_eth_driver
(
ifname
);
if
(
eth
&&
eth
->
clear_stats
)
return
eth
->
clear_stats
(
ifname
);
return
-
1
;
}
int
eth_poweron_phy
(
const
char
*
ifname
,
struct
eth_phy
p
)
int
eth_poweron_phy
(
const
char
*
ifname
,
struct
eth_phy
p
)
{
{
const
struct
eth_ops
*
eth
=
get_eth_driver
(
ifname
);
const
struct
eth_ops
*
eth
=
get_eth_driver
(
ifname
);
...
...
This diff is collapsed.
Click to expand it.
ethernet.h
+
3
−
0
View file @
b7656aa6
...
@@ -207,6 +207,8 @@ struct eth_ops {
...
@@ -207,6 +207,8 @@ struct eth_ops {
int
(
*
get_stats
)(
const
char
*
ifname
,
struct
eth_stats
*
s
);
int
(
*
get_stats
)(
const
char
*
ifname
,
struct
eth_stats
*
s
);
int
(
*
get_info
)(
const
char
*
ifname
,
struct
eth_info
*
info
);
int
(
*
get_info
)(
const
char
*
ifname
,
struct
eth_info
*
info
);
int
(
*
get_rmon_stats
)(
const
char
*
ifname
,
struct
eth_rmon_stats
*
rmon
);
int
(
*
get_rmon_stats
)(
const
char
*
ifname
,
struct
eth_rmon_stats
*
rmon
);
int
(
*
clear_stats
)(
const
char
*
ifname
);
};
};
...
@@ -220,6 +222,7 @@ int eth_set_operstate(const char *ifname, ifopstatus_t s);
...
@@ -220,6 +222,7 @@ int eth_set_operstate(const char *ifname, ifopstatus_t s);
int
eth_get_stats
(
const
char
*
ifname
,
struct
eth_stats
*
c
);
int
eth_get_stats
(
const
char
*
ifname
,
struct
eth_stats
*
c
);
int
eth_get_info
(
const
char
*
ifname
,
struct
eth_info
*
info
);
int
eth_get_info
(
const
char
*
ifname
,
struct
eth_info
*
info
);
int
eth_get_rmon_stats
(
const
char
*
ifname
,
struct
eth_rmon_stats
*
rmon
);
int
eth_get_rmon_stats
(
const
char
*
ifname
,
struct
eth_rmon_stats
*
rmon
);
int
eth_clear_stats
(
const
char
*
ifname
);
int
eth_reset_phy
(
const
char
*
ifname
,
int
phy_id
);
int
eth_reset_phy
(
const
char
*
ifname
,
int
phy_id
);
int
eth_poweroff_phy
(
const
char
*
ifname
,
struct
eth_phy
p
);
int
eth_poweroff_phy
(
const
char
*
ifname
,
struct
eth_phy
p
);
...
...
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