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

wifi: Add full AP mode support (using hostapd) #75224

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

nxf58150
Copy link
Contributor

@nxf58150 nxf58150 commented Jul 1, 2024

Added support of setting up AP with hostapd.
Once flag CONFIG_WIFI_NM_HOSTAPD_AP is enabled, softAP related commands in l2 wifi_shell.c will be handled by hostapd.
Increase max value of CONFIG_WIFI_SHELL_MAX_AP_STA from 5 to 8. The softAP of NXP wifi chip can support up to 8 stations.

Copy link

github-actions bot commented Jul 1, 2024

Hello @nxf58150, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@nxf58150 nxf58150 force-pushed the hostapd_support branch 4 times, most recently from 9141d95 to de7eb95 Compare July 2, 2024 01:27
Comment on lines 315 to 316
struct hostapd_iface *iface = ctx;
char *ifname = iface->bss[0]->conf->iface;
Copy link
Member

Choose a reason for hiding this comment

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

Could we call this something else than iface, it gets easily mixed up with zephyr network interface variable which is also called iface all over the place in zephyr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about use name "ap_ctx" instead of "iface" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to ap_ctx here.

Comment on lines 844 to 853
bss->nas_identifier = os_strdup("ap.example.com");
bss->eap_sim_db = os_strdup("unix:/tmp/hlr_auc_gw.sock");
os_memcpy(conf->country, "US ", 3);
Copy link
Member

Choose a reason for hiding this comment

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

The domain socket is something that is not needed in zephyr.
Also the hardcoded values look wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed line 845.

iface = net_if_get_wifi_uap();
/* Allocate and parse configuration for full interface files */
dev = net_if_get_device(iface);
strncpy(ifname, dev->name, IFNAMSIZ);
Copy link
Member

Choose a reason for hiding this comment

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

We should not use device name as an interface name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@jukkar
Copy link
Member

jukkar commented Jul 2, 2024

Isn't this depend on zephyrproject-rtos/hostap#15, the west.yml should be updated too in that case.

@krish2718 krish2718 changed the title Hostapd support wifi: Add full AP mode support (using hostapd) Jul 2, 2024
Copy link
Collaborator

@krish2718 krish2718 left a comment

Choose a reason for hiding this comment

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

I don't see the dynamic interfaces support for HOSTAPD_AP i.e., monitoring interface state events and accordingly stop/start using the interface, is this planned?

@@ -171,6 +175,9 @@ config WIFI_NM_WPA_SUPPLICANT_WPA3
config WIFI_NM_WPA_SUPPLICANT_AP
bool "AP mode support"

config WIFI_NM_HOSTAPD_AP
bool "AP mode hostapd support"
Copy link
Collaborator

Choose a reason for hiding this comment

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

hostapd based full AP mode and we can fix WIFI_NM_WPA_SUPPLICANT_AP to SoftAP mode support based on WPA supplicant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Comment on lines +985 to +1210
if (!hostapd_cli_cmd_v("set ssid %s", params->ssid)) {
goto out;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use a macro do the NULL check + goto out, like we did for WPA supplicant.

Copy link
Contributor Author

@nxf58150 nxf58150 Jul 4, 2024

Choose a reason for hiding this comment

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

Below format is against the requirement of coding style and caused check fail:
image
image
I will keep it like this for now. Maybe we can do code enhancement in the future.

return ret;
}

int hapd_config_network(struct hostapd_iface *iface,
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC, the commands itself are common b/w SoftAP and FullAP, so, may be if you write a wrapper to choose wpa_cli_cmd_v vs hostapd_cli_cmd_v, we can reuse the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean reuse the code of configuring network? I think the commands between softAP and fullAP are different.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes.

I think the commands between softAP and fullAP are different.

Ok, let me check the differences in commands then, thanks.

@krish2718
Copy link
Collaborator

Should we also extend wifi_nm_iface_type with FAP i.e., FULL AP?

  • SoftAP -> WPA supplicant
  • FullAP -> hostapd

@nxf58150
Copy link
Contributor Author

nxf58150 commented Jul 3, 2024

I don't see the dynamic interfaces support for HOSTAPD_AP i.e., monitoring interface state events and accordingly stop/start using the interface, is this planned?

@nxf58150 nxf58150 closed this Jul 3, 2024
@nxf58150 nxf58150 reopened this Jul 3, 2024
@nxf58150
Copy link
Contributor Author

nxf58150 commented Jul 3, 2024

I don't see the dynamic interfaces support for HOSTAPD_AP i.e., monitoring interface state events and accordingly stop/start using the interface, is this planned?

Currently, we are not using dynamic interface support on hostapd. We need time to do research on this. How about we keep it like this for now? Will do code enhancement in the future.

@krish2718
Copy link
Collaborator

I don't see the dynamic interfaces support for HOSTAPD_AP i.e., monitoring interface state events and accordingly stop/start using the interface, is this planned?

Currently, we are not using dynamic interface support on hostapd. We need time to do research on this. How about we keep it like this for now? Will do code enhancement in the future.

But other drivers might still use it (Nordic driver uses it, but still not upstream). May be add a Kconfig dependency on depends on !WIFI_NM_WPA_SUPPLICANT_INF_MON?

@nxf58150
Copy link
Contributor Author

nxf58150 commented Jul 3, 2024

Should we also extend wifi_nm_iface_type with FAP i.e., FULL AP?

  • SoftAP -> WPA supplicant
  • FullAP -> hostapd

Setting up AP with hostapd or wpa_supplicant is transparent for user so I think extending wifi_nm_iface_type maybe not a necessary task. By checking the type, user will know the interface is AP, no matter it is SoftAP or FullAP.
If we don't extend it, will it affect setting up AP with wpa_supplicant?

@krish2718
Copy link
Collaborator

Should we also extend wifi_nm_iface_type with FAP i.e., FULL AP?

  • SoftAP -> WPA supplicant
  • FullAP -> hostapd

Setting up AP with hostapd or wpa_supplicant is transparent for user so I think extending wifi_nm_iface_type maybe not a necessary task. By checking the type, user will know the interface is AP, no matter it is SoftAP or FullAP. If we don't extend it, will it affect setting up AP with wpa_supplicant?

Agreed, in that case let's rename SAP ->AP and hide Soft/Full.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Jul 4, 2024

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
hostap zephyrproject-rtos/hostap@77a4cad zephyrproject-rtos/hostap@7761b17 (main) zephyrproject-rtos/[email protected]

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hostap DNM This PR should not be merged (Do Not Merge) labels Jul 4, 2024
@nxf58150
Copy link
Contributor Author

nxf58150 commented Jul 4, 2024

Isn't this depend on zephyrproject-rtos/hostap#15, the west.yml should be updated too in that case.

Updated west.yml.

Added new flag CONFIG_WIFI_NM_HOSTAPD_AP for hostapd support. Once this
flag is enabled, softAP will be setup by hostapd. Both wpa_supplicant
and hostapd uses same task and eloop.
Included necessary hostapd files when compiling wifi samples if
CONFIG_WIFI_NM_HOSTAPD_AP is enabled. Added hostapd support for all
softAP command of L2 wifi shell commands.

Signed-off-by: Hui Bai <[email protected]>
Enable CONFIG_IEEE80211AC flag for 11AC support when setting up
AP with hostapd.

Signed-off-by: Hui Bai <[email protected]>
Increase max count of CONFIG_WIFI_SHELL_MAX_AP_STA from 5 to 8. The
SoftAP of NXP wifi chip can support up to 8 stations.

Signed-off-by: Hui Bai <[email protected]>
Link mode shows unknown when legacy (A or bg only) device connects to
APUT. Set the link mode to WIFI_2 when the host freq over 4000 and set
link mode to WIFI_3 when the host freq over 2000.

Signed-off-by: Hui Bai <[email protected]>
Increase wifi connect input parameters max count to 13. Previous count
7 is not enough if other security type is supported.
When enabling softAP, the parameter cnx_params in cmd_wifi_ap_enable()
is with static key word. Then the parameter will always save
configurations of last time. Remove static keyword to eliminate effects
of configs from last tim and do memset before setting up softAP.

Signed-off-by: Hui Bai <[email protected]>
@jukkar
Copy link
Member

jukkar commented Aug 27, 2024

@nxf58150 the hostap PR is now merged, please update manifest file and re-submit this one

Update hostap repo to latest in west.yml

Signed-off-by: Hui Bai <[email protected]>
@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Aug 28, 2024
@nxf58150
Copy link
Contributor Author

@nxf58150 the hostap PR is now merged, please update manifest file and re-submit this one

Updated manifest file.

@nashif nashif merged commit 386263c into zephyrproject-rtos:main Aug 28, 2024
26 of 27 checks passed
Copy link

Hi @nxf58150!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

@nxf58150 nxf58150 deleted the hostapd_support branch August 29, 2024 01:48
@nxf58150 nxf58150 restored the hostapd_support branch August 29, 2024 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants