Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drensber
Copy link
Contributor

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.

@github-actions github-actions bot added the area: Wi-Fi Wi-Fi label Apr 16, 2025
@drensber drensber force-pushed the adding_iface_status_to_infineon_wifi_driver branch 2 times, most recently from 246a979 to 40a8960 Compare April 16, 2025 15:15
Copy link
Member

@jukkar jukkar left a 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.

@drensber drensber force-pushed the adding_iface_status_to_infineon_wifi_driver branch 2 times, most recently from beff44c to f09fb8d Compare April 17, 2025 13:28
@drensber
Copy link
Contributor Author

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.

@drensber
Copy link
Contributor Author

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?

@rlubos
Copy link
Collaborator

rlubos commented Apr 17, 2025

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.

@drensber drensber requested a review from jukkar April 17, 2025 15:35
jukkar
jukkar previously approved these changes Apr 19, 2025
@kartben kartben requested a review from Copilot April 19, 2025 07:14
Copy link

@Copilot Copilot AI left a 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) {

Comment on lines +806 to +803
strncpy(status->ssid, bss_info.SSID, bss_info.SSID_len);

Copy link
Preview

Copilot AI Apr 19, 2025

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.

Suggested change
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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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]>
@drensber drensber force-pushed the adding_iface_status_to_infineon_wifi_driver branch from f09fb8d to 298f0a3 Compare April 24, 2025 16:06
@drensber
Copy link
Contributor Author

drensber commented May 6, 2025

Do I need to do anything else here, or are we just waiting for someone else to review?

@beechwoods-software
Copy link

@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.

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.

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)
Copy link
Collaborator

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,
Copy link
Collaborator

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);
Copy link
Collaborator

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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

whitespace

Comment on lines +806 to +803
strncpy(status->ssid, bss_info.SSID, bss_info.SSID_len);

Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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 :).

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

Successfully merging this pull request may close these issues.

5 participants