X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fwifi-firmware.c;h=0c3118fb73aec2b19667097bae19f606d864b97c;hb=c2a32db4948b649d0c3ed1aed27d5501bd732f66;hp=797e3c417d42708d2c35f1d9038d09c210032aa1;hpb=4e8243e660e10cafd8351bc834ac1baefa4dfc69;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git diff --git a/src/wifi-firmware.c b/src/wifi-firmware.c index 797e3c4..0c3118f 100755 --- a/src/wifi-firmware.c +++ b/src/wifi-firmware.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "log.h" #include "util.h" @@ -33,11 +35,12 @@ #define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh" #define WLAN_IFACE_NAME "wlan0" -#if defined(TIZEN_TV) -#define WLAN_P2P_IFACE_NAME "p2p0" -#else /* defined(TIZEN_TV) */ -#define WLAN_P2P_IFACE_NAME "wlan0" -#endif /* defined(TIZEN_TV) */ +#define WLAN_P2P_IFACE_NAME_TV "p2p0" +#define WLAN_P2P_IFACE_NAME_COMMON "wlan0" +#define WLAN_P2P_IFACE_NAME ((TIZEN_TV) ? (WLAN_P2P_IFACE_NAME_TV) : (WLAN_P2P_IFACE_NAME_COMMON)) +#define QUAD_CPUS_COUNT 4 +#define TEMP_BUFFER_LEN 100 +#define WIFI_MAC_ADD_PATH "/sys/class/net/wlan0/address" static int __netconfig_sta_firmware_start(void) { @@ -82,7 +85,9 @@ static int __netconfig_sta_firmware_stop(void) static int __netconfig_p2p_firmware_start(void) { -#if defined TIZEN_P2P_ENABLE + if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "p2p", NULL }; @@ -100,14 +105,13 @@ static int __netconfig_p2p_firmware_start(void) DBG("Successfully loaded p2p device driver"); return 0; -#else - return -ENODEV; -#endif } static int __netconfig_p2p_firmware_stop(void) { -#if defined TIZEN_P2P_ENABLE + if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL }; @@ -123,14 +127,14 @@ static int __netconfig_p2p_firmware_stop(void) DBG("Successfully removed p2p device driver"); return 0; -#else - return -ENODEV; -#endif } static int __netconfig_softap_firmware_start(void) { -#if defined TIZEN_TETHERING_ENABLE + if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_TETHERING) + && !netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_SOFTAP)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "softap", NULL }; @@ -145,14 +149,14 @@ static int __netconfig_softap_firmware_start(void) DBG("Successfully loaded softap device driver"); return 0; -#else - return -ENODEV; -#endif } static int __netconfig_softap_firmware_stop(void) { -#if defined TIZEN_TETHERING_ENABLE + if (!netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_TETHERING) + && !netconfig_check_feature_supported(NETCONFIG_SUPPORTED_FEATURE_WIFI_SOFTAP)) + return -ENODEV; + int rv = 0; const char *path = WLAN_DRIVER_SCRIPT; char *const args[] = { "/usr/bin/wlan.sh", "stop", NULL }; @@ -168,9 +172,6 @@ static int __netconfig_softap_firmware_stop(void) DBG("Successfully removed softap device driver"); return 0; -#else - return -ENODEV; -#endif } static int __netconfig_wifi_firmware_start(enum netconfig_wifi_firmware type) @@ -211,19 +212,76 @@ static int __netconfig_wifi_firmware_stop(enum netconfig_wifi_firmware type) return -ENXIO; } +static int __netconfig_set_rps_cpus(void) +{ + int fd, curr; + ssize_t count; + char t_buf[TEMP_BUFFER_LEN]; + char r_buf[TEMP_BUFFER_LEN]; + + if (access(WIFI_MAC_ADD_PATH, F_OK) != 0) { + DBG("WiFi driver is not loaded... "); + return -1; + } else { + DBG("WiFi driver loaded... "); + } + + snprintf(t_buf, TEMP_BUFFER_LEN, "/sys/class/net/wlan0/queues/rx-0/rps_cpus"); + DBG("Command : [%s]", t_buf); + curr = 0; + + while ((fd = open(t_buf, O_RDWR | O_CLOEXEC)) >= 0) { + curr++; + count = read(fd, r_buf, 1); + + if (count < 0) { + DBG("read failed"); + close(fd); + return -1; + } else { + DBG("read size = %zd", count); + } + + if (r_buf[0] == 'e') { + close(fd); + DBG("e is already written"); + snprintf(t_buf, TEMP_BUFFER_LEN, "/sys/class/net/wlan0/queues/rx-%d/rps_cpus", curr); + DBG("Command : [%s]", t_buf); + continue; + } else { + DBG("writing e"); + } + + if (lseek(fd, 0, SEEK_SET) < 0) { + DBG("lseek failed"); + close(fd); + return -1; + } + + count = write(fd, "e", 1); + + if (count < 0) { + DBG("write failed"); + close(fd); + return -1; + } else { + DBG("write size = %zd", count); + } + + close(fd); + snprintf(t_buf, TEMP_BUFFER_LEN, "/sys/class/net/wlan0/queues/rx-%d/rps_cpus", curr); + DBG("Command : [%s]", t_buf); + } + + return 0; +} + int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable) { int err; static enum netconfig_wifi_firmware current_driver = NETCONFIG_WIFI_OFF; enum netconfig_wifi_firmware alias = type; -#if defined WLAN_CONCURRENT_MODE - int flight_mode = 0; - - if (type == NETCONFIG_WIFI_P2P) - alias = NETCONFIG_WIFI_STA; -#endif - DBG("Wi-Fi current firmware %d (type: %d %s)", current_driver, type, enable == TRUE ? "enable" : "disable"); @@ -232,21 +290,6 @@ int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable) return -EALREADY; } else if (current_driver == alias) { -#if defined WLAN_CONCURRENT_MODE - netconfig_vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode); - if (flight_mode == 0 && type == NETCONFIG_WIFI_STA && - netconfig_is_wifi_direct_on() == TRUE) { - netconfig_interface_down(WIFI_IFNAME); - - return -EALREADY; - } - - if (type == NETCONFIG_WIFI_P2P && wifi_state_get_technology_state() > NETCONFIG_WIFI_TECH_OFF) { - netconfig_interface_down(WLAN_P2P_IFACE_NAME); - - return -EALREADY; - } -#endif err = __netconfig_wifi_firmware_stop(type); if (err < 0 && err != -EALREADY) return err; @@ -260,18 +303,8 @@ int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable) } if (current_driver > NETCONFIG_WIFI_OFF) { - if (current_driver == alias) { - -#if defined WLAN_CONCURRENT_MODE - if (type == NETCONFIG_WIFI_STA) - netconfig_interface_up(WIFI_IFNAME); -#if defined TIZEN_P2P_ENABLE - else if (type == NETCONFIG_WIFI_P2P) - netconfig_interface_up(WLAN_P2P_IFACE_NAME); -#endif -#endif + if (current_driver == alias) return -EALREADY; - } return -EIO; } @@ -282,6 +315,9 @@ int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable) else current_driver = alias; + if (__netconfig_set_rps_cpus() < 0) + DBG("Failed to set rps_cpus"); + return err; } @@ -289,7 +325,7 @@ gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, co { int err; - g_return_val_if_fail(firmware != NULL, FALSE); + g_return_val_if_fail(firmware != NULL, TRUE); DBG("Wi-Fi firmware start %s", device != NULL ? device : "null"); @@ -312,7 +348,7 @@ gboolean handle_start(WifiFirmware *firmware, GDBusMethodInvocation *context, co } else netconfig_error_wifi_driver_failed(context); - return FALSE; + return TRUE; } wifi_firmware_complete_start(firmware, context); @@ -323,7 +359,7 @@ gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, con { int err; - g_return_val_if_fail(firmware != NULL, FALSE); + g_return_val_if_fail(firmware != NULL, TRUE); DBG("Wi-Fi firmware stop %s", device != NULL ? device : "null"); @@ -340,7 +376,7 @@ gboolean handle_stop(WifiFirmware *firmware, GDBusMethodInvocation *context, con else netconfig_error_wifi_driver_failed(context); - return FALSE; + return TRUE; } wifi_firmware_complete_stop(firmware, context);