-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get statistic from proc #111
Open
chen042531
wants to merge
2
commits into
free5gc:master
Choose a base branch
from
chen042531:get_statistic_from_proc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include "far.h" | ||
|
||
#include "util.h" | ||
#include "dev.h" | ||
|
||
struct list_head proc_gtp5g_dev; | ||
struct proc_gtp5g_pdr { | ||
|
@@ -96,6 +97,7 @@ struct proc_dir_entry *proc_gtp5g_qer = NULL; | |
struct proc_dir_entry *proc_gtp5g_urr = NULL; | ||
struct proc_dir_entry *proc_gtp5g_qos = NULL; | ||
struct proc_dir_entry *proc_gtp5g_seq = NULL; | ||
struct proc_dir_entry *proc_gtp5g_statistic = NULL; | ||
struct proc_gtp5g_pdr proc_pdr; | ||
struct proc_gtp5g_far proc_far; | ||
struct proc_gtp5g_qer proc_qer; | ||
|
@@ -344,6 +346,39 @@ static ssize_t proc_seq_write(struct file *filp, const char __user *buffer, | |
return -1; | ||
} | ||
|
||
static int gtp5g_statistic_read(struct seq_file *s, void *v) | ||
{ | ||
u8 found = 0; | ||
struct gtp5g_dev *gtp; | ||
|
||
|
||
GTP5G_TRC(NULL, "gtp5g_statistic_read"); | ||
|
||
list_for_each_entry_rcu(gtp, &proc_gtp5g_dev, proc_list) { | ||
if (strcmp(get_dev_name(), netdev_name(gtp->dev)) == 0) { | ||
found = 1; | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
GTP5G_ERR(NULL, "Given dev: %s not exists\n", get_dev_name()); | ||
return -1; | ||
} | ||
|
||
seq_printf(s, "Statistic: \n"); | ||
seq_printf(s, "\t RX UL(bytes) : %llu\n", (u64)atomic_read(>p->rx.ul_byte)); | ||
seq_printf(s, "\t TX UL(bytes) : %llu\n", (u64)atomic_read(>p->tx.ul_byte)); | ||
seq_printf(s, "\t RX DL(bytes) : %llu\n", (u64)atomic_read(>p->rx.dl_byte)); | ||
seq_printf(s, "\t TX DL(bytes) : %llu\n", (u64)atomic_read(>p->tx.dl_byte)); | ||
|
||
seq_printf(s, "\t RX UL(packets) : %llu\n", (u64)atomic_read(>p->rx.ul_pkt)); | ||
seq_printf(s, "\t TX UL(packets) : %llu\n", (u64)atomic_read(>p->tx.ul_pkt)); | ||
seq_printf(s, "\t RX DL(packets) : %llu\n", (u64)atomic_read(>p->rx.dl_pkt)); | ||
seq_printf(s, "\t TX DL(packets) : %llu\n", (u64)atomic_read(>p->tx.dl_pkt)); | ||
|
||
return 0; | ||
} | ||
|
||
static ssize_t proc_pdr_write(struct file *filp, const char __user *buffer, | ||
size_t len, loff_t *dptr) | ||
{ | ||
|
@@ -628,6 +663,11 @@ static int proc_seq_read(struct inode *inode, struct file *file) | |
return single_open(file, gtp5g_seq_read, NULL); | ||
} | ||
|
||
static int proc_statistic_read(struct inode *inode, struct file *file) | ||
{ | ||
return single_open(file, gtp5g_statistic_read, NULL); | ||
} | ||
|
||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) | ||
static const struct proc_ops proc_gtp5g_dbg_ops = { | ||
.proc_open = proc_dbg_read, | ||
|
@@ -761,6 +801,23 @@ static const struct file_operations proc_gtp5g_seq_ops = { | |
}; | ||
#endif | ||
|
||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) | ||
static const struct proc_ops proc_gtp5g_statistic_ops = { | ||
.proc_open = proc_statistic_read, | ||
.proc_read = seq_read, | ||
.proc_lseek = seq_lseek, | ||
.proc_release = single_release, | ||
}; | ||
#else | ||
static const struct file_operations proc_gtp5g_statistic_ops = { | ||
.owner = THIS_MODULE, | ||
.open = proc_statistic_read, | ||
.read = seq_read, | ||
.llseek = seq_lseek, | ||
.release = single_release, | ||
}; | ||
#endif | ||
|
||
int create_proc(void) | ||
{ | ||
proc_gtp5g = proc_mkdir("gtp5g", NULL); | ||
|
@@ -817,8 +874,17 @@ int create_proc(void) | |
goto remove_qos_proc; | ||
} | ||
|
||
proc_gtp5g_statistic = proc_create("statistic", (S_IFREG | S_IRUGO | S_IWUGO), | ||
proc_gtp5g, &proc_gtp5g_statistic_ops); | ||
if (!proc_gtp5g_statistic) { | ||
GTP5G_ERR(NULL, "Failed to create /proc/gtp5g/statistic\n"); | ||
goto remove_statistic_proc; | ||
} | ||
|
||
return 0; | ||
|
||
remove_statistic_proc: | ||
remove_proc_entry("statistic", proc_gtp5g); | ||
remove_qos_proc: | ||
remove_proc_entry("qos", proc_gtp5g); | ||
remove_urr_proc: | ||
|
@@ -838,6 +904,7 @@ int create_proc(void) | |
|
||
void remove_proc() | ||
{ | ||
remove_proc_entry("statistic", proc_gtp5g); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modify proc dev name to |
||
remove_proc_entry("qos", proc_gtp5g); | ||
remove_proc_entry("seq", proc_gtp5g); | ||
remove_proc_entry("urr", proc_gtp5g); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modify proc dev name to
stats