Skip to content
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

Implement customized naming for wiphy #57

Merged
merged 1 commit into from
Jan 30, 2024
Merged

Conversation

vax-r
Copy link
Collaborator

@vax-r vax-r commented Jan 16, 2024

Summary

The default phy%d naming for wiphy in linux kernel depends on the value of a static variable wiphy_counter. Since they never attempts to decrease the value of wiphy_counter even a wiphy is unregistered or freed, this behavior ensures the naming and indexing for wiphy will be absolutely unique.

However, the kernel might have other projects also utilize wiphy structure, which will cause some confusion of wiphy's index and naming when using struct wiphy. We implement a custom-made name "vw_phy%d" for wiphy in our project, in order to seperate the naming and indexing for struct wiphy in our project.

As for the troublesome behavior causing by the never-decreasing index of wiphy structure as decribed in #54 , we suggest to make some changes when doing manual testing by finding the wiphy index of the interface first, and use the index to query the actual wiphy's name for the interface as describe in the changes of README.md.

Reference

Related issue

Fix #54

@vax-r vax-r requested a review from jserv January 16, 2024 16:23
@vax-r
Copy link
Collaborator Author

vax-r commented Jan 16, 2024

I just figured out why does the value of variable wiphy_counter never decreased.
Since in this way they can ensure the name of each wiphy is abolutely unique.
There'll be no need to submit patches to linux kernel community.
However, I think we should still have a customized naming and indexing for wiphy in vwifi to separate vwifi's wiphy from other wiphy used in the kernel (you might have other projects also utilizing struct wiphy).
I'll refine git commit message and the comments in the code later.

vwifi.c Outdated
@@ -71,6 +74,10 @@ static DEFINE_SPINLOCK(vif_list_lock);
/* SME stands for "station management entity" */
enum sme_state { SME_DISCONNECTED, SME_CONNECTING, SME_CONNECTED };

/* Each virtual interface contains a wiphy, wvifi_wiphy_counter is responsible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweak the comment style. i.e.,

/* Each virtual interface contains a wiphy, wvifi_wiphy_counter is responsible
 * for recording the number of wiphy in vwifi.
 */

Be aware of the position of the ending mark.

vwifi.c Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved

/* Reference:
* Linux Kernel Tag : v6.7.1
* The default phy%d naming for wiphy in linux kernel depends on the value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to mention Linux kernel since this module is intended to be specific to it.

scripts/verify.sh Outdated Show resolved Hide resolved
@vax-r vax-r requested a review from jserv January 30, 2024 06:42
vwifi.c Outdated
wiphy = wiphy_new_nm(&vwifi_cfg_ops, 0, NULL);

/* Reference:
* https://elixir.bootlin.com/linux/latest/source/net/wireless/core.c#L450
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "latest," specify the kernel version. That is, https://elixir.bootlin.com/linux/v6.7/source/net/wireless/core.c#L447

The default phy%d naming for wiphy in linux kernel depends on the value
 of a static variable wiphy_counter. Since they never attempts to
 decrease the value of wiphy_counter even a wiphy is unregistered or
 freed, this behavior ensures the naming and indexing for wiphy will
 be absolutely unique.

However, the kernel might have other projects also utilize wiphy
structure, which will cause some confusion of wiphy's index and naming
when using `struct wiphy`. We implement a custom-made name "vw_phy%d"
for wiphy in our project, in order to seperate the naming and indexing
for `struct wiphy` in our project.

As for the troublesome behavior causing by the never-decreasing index of
wiphy structure as decribed in sysprog21#54, we suggest to make some changes when
doing manual testing by finding the wiphy index of the interface first,
and use the index to query the actual wiphy's name for the interface as
describe in the changes of README.md.

Close sysprog21#54
@vax-r vax-r requested a review from jserv January 30, 2024 07:37
@jserv jserv merged commit baf4714 into sysprog21:main Jan 30, 2024
4 checks passed
@jserv
Copy link
Contributor

jserv commented Jan 30, 2024

Thank @vax-r for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wiphy physical device name alters when doing manual testing
2 participants