-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: wifi: infineon: add .iface_status method #88718
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
base: main
Are you sure you want to change the base?
drivers: wifi: infineon: add .iface_status method #88718
Conversation
246a979
to
40a8960
Compare
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.
Minor nits about the coding style, you could see what the rest of the airoc_wifi.c
looks like and follow suit.
beff44c
to
f09fb8d
Compare
I changed all of these things according to your preferences. Looking at the Zephyr Coding Guidelines, I'm not sure that any of them are actually established rules, so perhaps that's why the automated checks didn't catch any of them. |
I think the twister failure is a problem on your side, not a problem with the code that I pushed. Can someone look into this and re-run the tests? |
Looked like some environmental issue, I've retriggered failed stage, tests are now running. |
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.
Pull Request Overview
This PR adds an .iface_status method to the Infineon WiFi driver so that the "wifi status" command on the network shell works as expected.
- Added the implementation of airoc_iface_status to report interface mode, state, SSID, channel, and other connection parameters.
- Updated the wifi_mgmt_ops structure to include the new .iface_status method.
- Introduced an additional header include for whd_wlioctl.h required by the new functionality.
Comments suppressed due to low confidence (1)
drivers/wifi/infineon/airoc_wifi.c:774
- The variable 'airoc_if' is referenced without a visible declaration in this diff. Verify that it is properly declared and initialized in an accessible scope before use.
if (airoc_if == NULL) {
strncpy(status->ssid, bss_info.SSID, bss_info.SSID_len); | ||
|
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.
Using strncpy without explicitly appending a null terminator risks leaving status->ssid unterminated. Consider ensuring the string is null-terminated (and that the destination buffer is large enough) after copying.
strncpy(status->ssid, bss_info.SSID, bss_info.SSID_len); | |
if (status->ssid_len < sizeof(status->ssid)) { | |
strncpy(status->ssid, bss_info.SSID, status->ssid_len); | |
status->ssid[status->ssid_len] = '\0'; // Ensure null-termination | |
} else { | |
LOG_ERR("SSID length exceeds buffer size"); | |
return -EINVAL; // Return an error if the buffer is too small | |
} |
Copilot uses AI. Check for mistakes.
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.
I think Copilot's advice is invalid in this particular case. The SSID is defined by zephyr to be a character string with a max length of 32 and an accompanying SSID_len field to specify the actual length. If I were to use one character of the ssid field as a null terminator, the maximum length would become 31.
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.
You don't need to NULL terminate SSID buffer in the status, but you are using source length to copy to destination, so, this can overflow, it's always better to use destination length or do explicit NULL checking.
The .iface_status method of the wifi_mgmt_ops API needs to be added so that the "wifi status" command on the network shell will work. Signed-off-by: Dave Rensberger <[email protected]>
f09fb8d
to
298f0a3
Compare
Do I need to do anything else here, or are we just waiting for someone else to review? |
@Kludentwo @rlubos @krish2718 @MaochenWang1 Could someone else please review this? My understanding is that after a certain amount of time (60 days?) it will just be closed to inactivity. I don't think this should be too controversial of a PR. Even if it isn't a perfect implementation, it's better than having "wifi status" or .iface_status() not work at all, and any deficiencies can be addressed after there's a baseline implementation in place. |
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.
Please remove all whitespace changes or move them to a separate commit for easier review.
@@ -25,7 +26,7 @@ LOG_MODULE_REGISTER(infineon_airoc_wifi, CONFIG_WIFI_LOG_LEVEL); | |||
#endif | |||
|
|||
#ifndef AIROC_WIFI_PACKET_POOL_SIZE | |||
#define AIROC_WIFI_PACKET_POOL_SIZE (1600) | |||
#define AIROC_WIFI_PACKET_POOL_SIZE (1600) |
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.
nit, whitespace changes (you can do those in a separate commit if you want for easier review)
@@ -49,8 +50,8 @@ int airoc_wifi_init_primary(const struct device *dev, whd_interface_t *interface | |||
whd_netif_funcs_t *netif_funcs, whd_buffer_funcs_t *buffer_if); | |||
|
|||
/* Allocate network pool */ | |||
NET_BUF_POOL_FIXED_DEFINE(airoc_pool, AIROC_WIFI_PACKET_POOL_COUNT, | |||
AIROC_WIFI_PACKET_POOL_SIZE, 0, NULL); | |||
NET_BUF_POOL_FIXED_DEFINE(airoc_pool, AIROC_WIFI_PACKET_POOL_COUNT, AIROC_WIFI_PACKET_POOL_SIZE, 0, |
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.
whitespace
@@ -236,7 +237,7 @@ static whd_result_t airoc_wifi_host_buffer_get(whd_buffer_t *buffer, whd_buffer_ | |||
*buffer = buf; | |||
|
|||
/* Set buffer size */ | |||
(void) airoc_wifi_buffer_set_size(*buffer, size); | |||
(void)airoc_wifi_buffer_set_size(*buffer, size); |
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.
whitespace
@@ -302,7 +303,7 @@ static int airoc_mgmt_send(const struct device *dev, struct net_pkt *pkt) | |||
} | |||
|
|||
/* Allocate Network Buffer from pool with Packet Length + Data Header */ | |||
ret = airoc_wifi_host_buffer_get((whd_buffer_t *) &buf, WHD_NETWORK_TX, | |||
ret = airoc_wifi_host_buffer_get((whd_buffer_t *)&buf, WHD_NETWORK_TX, |
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.
whitespace
strncpy(status->ssid, bss_info.SSID, bss_info.SSID_len); | ||
|
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.
You don't need to NULL terminate SSID buffer in the status, but you are using source length to copy to destination, so, this can overflow, it's always better to use destination length or do explicit NULL checking.
|
||
/* Unbelievably, this appears to be the only way to determine the phy mode with | ||
* the whd SDK that we're currently using. Note that the logic below is only valid on | ||
* devices that are limited to the 2.4Ghz band. Other versions of the SDK and chip |
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.
Even for 2.4G only devices, WIFI_6 can still be an option if rate > 54, if your device supports.
|
||
whd_wifi_get_channel(airoc_if, (int *)&status->channel); | ||
|
||
status->band = (status->channel <= CH_MAX_2G_CHANNEL) ? WIFI_FREQ_BAND_2_4_GHZ |
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.
nit, may not be applicable here, but won't be true once 6GHz support is added :).
The .iface_status method of the wifi_mgmt_ops API needs to be added so that the "wifi status" command on the network shell will work.