diff --git a/Kbuild b/Kbuild index 7b588c540425..ca146564b4c8 100644 --- a/Kbuild +++ b/Kbuild @@ -291,6 +291,9 @@ endif ifeq ($(CONFIG_WLAN_WOWL_ADD_PTRN), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_wowl_add_ptrn.o endif +ifeq ($(CONFIG_WLAN_WOWL_DEL_PTRN), y) +HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_wowl_del_ptrn.o +endif ifeq ($(CONFIG_WLAN_SET_SCAN_CFG), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_sysfs_set_scan_cfg.o endif @@ -2542,6 +2545,7 @@ cppflags-$(CONFIG_WLAN_REASSOC) += -DCONFIG_WLAN_REASSOC cppflags-$(CONFIG_WLAN_SCAN_DISABLE) += -DCONFIG_WLAN_SCAN_DISABLE cppflags-$(CONFIG_WLAN_WOW_ITO) += -DCONFIG_WLAN_WOW_ITO cppflags-$(CONFIG_WLAN_WOWL_ADD_PTRN) += -DCONFIG_WLAN_WOWL_ADD_PTRN +cppflags-$(CONFIG_WLAN_WOWL_DEL_PTRN) += -DCONFIG_WLAN_WOWL_DEL_PTRN cppflags-$(CONFIG_WLAN_SET_SCAN_CFG) += -DCONFIG_WLAN_SET_SCAN_CFG cppflags-$(CONFIG_WLAN_SET_MON_CHAN) += -DCONFIG_WLAN_SET_MON_CHAN cppflags-$(CONFIG_WLAN_SET_RADAR) += -DCONFIG_WLAN_SET_RADAR diff --git a/configs/default_defconfig b/configs/default_defconfig index 5cc49d0d1c4c..9191a6fa5d87 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -183,6 +183,7 @@ ifeq ($(CONFIG_WLAN_SYSFS), y) CONFIG_WLAN_SCAN_DISABLE := y CONFIG_WLAN_WOW_ITO := y CONFIG_WLAN_WOWL_ADD_PTRN := y + CONFIG_WLAN_WOWL_DEL_PTRN := y CONFIG_WLAN_SET_SCAN_CFG := y CONFIG_WLAN_SET_MON_CHAN := y CONFIG_WLAN_SET_RADAR := y diff --git a/core/hdd/src/wlan_hdd_sysfs.c b/core/hdd/src/wlan_hdd_sysfs.c index ee17b9716650..38b1d7bbf6c4 100644 --- a/core/hdd/src/wlan_hdd_sysfs.c +++ b/core/hdd/src/wlan_hdd_sysfs.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -636,6 +637,7 @@ hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_unit_test_target_create(adapter); hdd_sysfs_connect_info_interface_create(adapter); hdd_sysfs_wowl_add_ptrn_create(adapter); + hdd_sysfs_wowl_del_ptrn_create(adapter); hdd_sysfs_txrx_fw_stats_create(adapter); hdd_sysfs_txrx_stats_create(adapter); hdd_sysfs_get_range_ext_create(adapter); @@ -649,6 +651,7 @@ hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter) hdd_sysfs_get_range_ext_destroy(adapter); hdd_sysfs_txrx_stats_destroy(adapter); hdd_sysfs_txrx_fw_stats_destroy(adapter); + hdd_sysfs_wowl_del_ptrn_destroy(adapter); hdd_sysfs_wowl_add_ptrn_destroy(adapter); hdd_sysfs_connect_info_interface_destroy(adapter); hdd_sysfs_unit_test_target_destroy(adapter); diff --git a/core/hdd/src/wlan_hdd_sysfs_wowl_del_ptrn.c b/core/hdd/src/wlan_hdd_sysfs_wowl_del_ptrn.c new file mode 100644 index 000000000000..699572f4be80 --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_wowl_del_ptrn.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC: wlan_hdd_sysfs_wowl_del_ptrn.c + * + * implementation for creating sysfs file wowl_del_ptrn + */ + +#include +#include +#include "osif_vdev_sync.h" +#include "wlan_hdd_wowl.h" +#include + +static ssize_t +__hdd_sysfs_wowl_del_ptrn_store(struct net_device *net_dev, + char const *buf, + size_t count) +{ + struct hdd_adapter *adapter = netdev_priv(net_dev); + struct hdd_context *hdd_ctx; + char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1]; + int ret; + + if (hdd_validate_adapter(adapter)) { + hdd_err_rl("adapter validate fail"); + return -EINVAL; + } + + hdd_ctx = WLAN_HDD_GET_CTX(adapter); + ret = wlan_hdd_validate_context(hdd_ctx); + if (ret) + return ret; + + if (!wlan_hdd_validate_modules_state(hdd_ctx)) + return -EINVAL; + + ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local), + buf, count); + if (ret) { + hdd_err_rl("invalid input"); + return ret; + } + + hdd_debug("wowl_del_ptrn: count %zu buf_local:(%s)", + count, buf_local); + + if (!hdd_del_wowl_ptrn(adapter, buf_local)) { + hdd_err_rl("Failed to delete wowl ptrn"); + return -EINVAL; + } + + return count; +} + +static ssize_t +hdd_sysfs_wowl_del_ptrn_store(struct device *dev, + struct device_attribute *attr, + char const *buf, size_t count) +{ + struct net_device *net_dev = container_of(dev, struct net_device, dev); + struct osif_vdev_sync *vdev_sync; + ssize_t err_size; + + err_size = osif_vdev_sync_op_start(net_dev, &vdev_sync); + if (err_size) + return err_size; + + err_size = __hdd_sysfs_wowl_del_ptrn_store(net_dev, buf, count); + + osif_vdev_sync_op_stop(vdev_sync); + + return err_size; +} + +static DEVICE_ATTR(wowl_del_ptrn, 0220, + NULL, hdd_sysfs_wowl_del_ptrn_store); + +int hdd_sysfs_wowl_del_ptrn_create(struct hdd_adapter *adapter) +{ + int error; + + error = device_create_file(&adapter->dev->dev, + &dev_attr_wowl_del_ptrn); + if (error) + hdd_err("could not create wowl_del_ptrn sysfs file"); + + return error; +} + +void hdd_sysfs_wowl_del_ptrn_destroy(struct hdd_adapter *adapter) +{ + device_remove_file(&adapter->dev->dev, &dev_attr_wowl_del_ptrn); +} diff --git a/core/hdd/src/wlan_hdd_sysfs_wowl_del_ptrn.h b/core/hdd/src/wlan_hdd_sysfs_wowl_del_ptrn.h new file mode 100644 index 000000000000..adcced9ae870 --- /dev/null +++ b/core/hdd/src/wlan_hdd_sysfs_wowl_del_ptrn.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC: wlan_hdd_sysfs_wowl_del_ptrn.h + * + * implementation for creating sysfs file wowl_del_ptrn + */ + +#ifndef _WLAN_HDD_SYSFS_WOWL_DEL_PTRN_H +#define _WLAN_HDD_SYSFS_WOWL_DEL_PTRN_H + +#if defined(WLAN_SYSFS) && defined(CONFIG_WLAN_WOWL_DEL_PTRN) +/** + * hdd_sysfs_wowl_del_ptrn_create() - API to create wowl_del_ptrn + * @adapter: pointer to adapter + * + * this file is created per adapter. + * file path: /sys/class/net/wlanxx/wowl_del_ptrn + * where wlanxx is adapter name + * + * usage: + * echo 08:01:FFFFFFFFFFFF0000:FC > wowl_del_ptrn + * + * Return: 0 on success and errno on failure + */ +int hdd_sysfs_wowl_del_ptrn_create(struct hdd_adapter *adapter); + +/** + * hdd_sysfs_wowl_del_ptrn_destroy() - + * API to destroy wowl_del_ptrn + * @adapter: pointer to adapter + * + * Return: none + */ +void hdd_sysfs_wowl_del_ptrn_destroy(struct hdd_adapter *adapter); +#else +static inline int +hdd_sysfs_wowl_del_ptrn_create(struct hdd_adapter *adapter) +{ + return 0; +} + +static inline void +hdd_sysfs_wowl_del_ptrn_destroy(struct hdd_adapter *adapter) +{ +} +#endif +#endif /* #ifndef _WLAN_HDD_SYSFS_WOWL_DEL_PTRN_H */