new file mode 100644
@@ -0,0 +1,354 @@
+// SPDX-License-Identifier: MIT
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#include "hw.h"
+#include "vif.h"
+#include "cecli.h"
+#include "vendor_cmd.h"
+#include "wrs/wrs_api.h"
+#include "chip.h"
+#include "fw/msg_tx.h"
+#include "channel.h"
+#include "calib.h"
+#include "tx/tx_queue.h"
+#include "tx/tx.h"
+#include "stats.h"
+#include "power_cli.h"
+#include "bf.h"
+#include "edca.h"
+#include "traffic.h"
+#include "reg/reg_cli.h"
+#include "radio.h"
+#include "temperature.h"
+#include "rx/rx_filter.h"
+#include "dfs/dfs.h"
+#include "utils/math.h"
+#include "cecli.h"
+#include "utils/utils.h"
+#include "fw/fw_dbg.h"
+#include "ext/vlan_dscp.h"
+#include "vns.h"
+#include "motion_sense.h"
+#include "version.h"
+#include "enhanced_tim.h"
+#include "rssi.h"
+#include "cca.h"
+#include "noise.h"
+#include "twt_cli.h"
+#include "omi.h"
+#include "config.h"
+
+int cl_cecli_agc_params(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ return cl_agc_params_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_bf(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_bf_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_calib(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ return cl_calib_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_cca(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ return cl_cca_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_chip(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ if (data) {
+ char *str = (char *)data;
+
+ return cl_chip_config_set(cl_hw->chip, str, strlen(str) + 1);
+ }
+
+ return -1;
+}
+
+int cl_cecli_config(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_config_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_debug(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ cl_hw->conf->ce_debug_level = *(s8 *)data;
+ cl_hw->chip->conf->ce_debug_level = *(s8 *)data;
+
+ return 0;
+}
+
+int cl_cecli_dfs(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ u16 ret_buf_len = PAGE_SIZE;
+ char *ret_buf = kzalloc(ret_buf_len, GFP_KERNEL);
+
+ if (ret_buf) {
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ if (cl_dfs_cli(cl_hw, cli_params, ret_buf, &ret_buf_len))
+ cl_vendor_reply(cl_hw, ret_buf, (int)ret_buf_len);
+
+ kfree(ret_buf);
+ } else {
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+int cl_cecli_edca(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ return cl_edca_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_fw(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_fw_dbg_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_motion(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_motion_sense_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_noise(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ return cl_noise_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_omi(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_omi_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_power(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ return cl_power_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_qos(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cl_vif *cl_vif = NETDEV_TO_CL_VIF(wdev->netdev);
+
+ return data ? cl_vlan_dscp_cli(cl_hw, cl_vif, (char *)data) : -1;
+}
+
+int cl_cecli_radio(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ bool radio_on = *(bool *)data;
+
+ return cl_radio_cli(cl_hw, radio_on);
+}
+
+int cl_cecli_reg(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_reg_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_sounding(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_sounding_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_stats(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cl_vif *cl_vif = NETDEV_TO_CL_VIF(wdev->netdev);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ return cl_stats_cli(cl_hw, cl_vif, cli_params);
+}
+
+int cl_cecli_tcv(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ if (data) {
+ char *str = (char *)data;
+
+ return cl_tcv_config_set(cl_hw, str, strlen(str) + 1);
+ }
+
+ return -1;
+}
+
+int cl_cecli_temp(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ struct cli_params *cli_params = (struct cli_params *)data;
+
+ cl_temperature_cli(cl_hw, cli_params);
+ return 0;
+}
+
+int cl_cecli_traffic(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_traffic_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_twt(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_twt_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_txq(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_txq_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_version(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ cl_version_cli(cl_hw);
+ return 0;
+}
+
+int cl_cecli_vns(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_vns_cli(cl_hw, cli_params);
+}
+
+int cl_cecli_wrs(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cli_params *cli_params = (struct cli_params *)data;
+ struct cl_vif *cl_vif = NETDEV_TO_CL_VIF(wdev->netdev);
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+
+ return cl_wrs_api_cli(cl_hw, cl_vif, cli_params);
+}
+
+int cl_cecli_help(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct cl_hw *cl_hw = WIPHY_TO_CL_HW(wiphy);
+ char *ret_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ int err = 0;
+
+ if (!ret_buf)
+ return -ENOMEM;
+
+ snprintf(ret_buf, PAGE_SIZE,
+ "usage:\n"
+ "agc_params - AGC params\n"
+ "bf - Beem Forming\n"
+ "cca - CCA related\n"
+ "chip - Set nvram per chip\n"
+ "config - Debug configuration\n"
+ "debug - Set Debug level\n"
+ "dfs - Dynamic Frequency Selection\n"
+ "edca - Enhanced Distributed Channel Access\n"
+ "fw - Firmware related\n"
+ "motion - Motion feature\n"
+ "noise - Noise related\n"
+ "omi - OM infrastructure\n"
+ "power - Power related\n"
+ "qos - Quality Of Service\n"
+ "radio - Set radio on/off\n"
+ "reg - Register related\n"
+ "sounding - Sounding related\n"
+ "stats - Statistics related\n"
+ "tcv - Set nvram per tcv\n"
+ "temp - Temperature related\n"
+ "traffic - Traffic related\n"
+ "twt - Target Wake Time\n"
+ "txq - TX queue\n"
+ "version - Read Version\n"
+ "vns - Very Near Station\n"
+ "wrs - Weighted Rate Selection\n");
+
+ err = cl_vendor_reply(cl_hw, ret_buf, strlen(ret_buf));
+ kfree(ret_buf);
+
+ return err;
+}