diff options
author | Sara Sharon <sara.sharon@intel.com> | 2016-08-09 13:03:52 -0400 |
---|---|---|
committer | Luca Coelho <luciano.coelho@intel.com> | 2016-09-19 03:09:36 -0400 |
commit | 4857d6cbf7ca4e040ac2b24687464c76e0be96ff (patch) | |
tree | 005e9be2fdda13ecf09debda5b4f8c89ffb0366b /drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | |
parent | aacf8f189b03b3d3c2e577a6d4ef5872bf4d393f (diff) |
iwlwifi: mvm: support packet injection
For automatic testing packet injection can be useful.
Support injection through debugfs.
Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c')
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c index b34489817c70..540b7c9deaef 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | |||
@@ -917,6 +917,59 @@ static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm, | |||
917 | return ret ?: count; | 917 | return ret ?: count; |
918 | } | 918 | } |
919 | 919 | ||
920 | static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm, | ||
921 | char *buf, size_t count, | ||
922 | loff_t *ppos) | ||
923 | { | ||
924 | struct iwl_rx_cmd_buffer rxb = { | ||
925 | ._rx_page_order = 0, | ||
926 | .truesize = 0, /* not used */ | ||
927 | ._offset = 0, | ||
928 | }; | ||
929 | struct iwl_rx_packet *pkt; | ||
930 | struct iwl_rx_mpdu_desc *desc; | ||
931 | int bin_len = count / 2; | ||
932 | int ret = -EINVAL; | ||
933 | |||
934 | /* supporting only 9000 descriptor */ | ||
935 | if (!mvm->trans->cfg->mq_rx_supported) | ||
936 | return -ENOTSUPP; | ||
937 | |||
938 | rxb._page = alloc_pages(GFP_ATOMIC, 0); | ||
939 | if (!rxb._page) | ||
940 | return -ENOMEM; | ||
941 | pkt = rxb_addr(&rxb); | ||
942 | |||
943 | ret = hex2bin(page_address(rxb._page), buf, bin_len); | ||
944 | if (ret) | ||
945 | goto out; | ||
946 | |||
947 | /* avoid invalid memory access */ | ||
948 | if (bin_len < sizeof(*pkt) + sizeof(*desc)) | ||
949 | goto out; | ||
950 | |||
951 | /* check this is RX packet */ | ||
952 | if (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd) != | ||
953 | WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)) | ||
954 | goto out; | ||
955 | |||
956 | /* check the length in metadata matches actual received length */ | ||
957 | desc = (void *)pkt->data; | ||
958 | if (le16_to_cpu(desc->mpdu_len) != | ||
959 | (bin_len - sizeof(*desc) - sizeof(*pkt))) | ||
960 | goto out; | ||
961 | |||
962 | local_bh_disable(); | ||
963 | iwl_mvm_rx_mpdu_mq(mvm, NULL, &rxb, 0); | ||
964 | local_bh_enable(); | ||
965 | ret = 0; | ||
966 | |||
967 | out: | ||
968 | iwl_free_rxb(&rxb); | ||
969 | |||
970 | return ret ?: count; | ||
971 | } | ||
972 | |||
920 | static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file, | 973 | static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file, |
921 | char __user *user_buf, | 974 | char __user *user_buf, |
922 | size_t count, loff_t *ppos) | 975 | size_t count, loff_t *ppos) |
@@ -1454,6 +1507,7 @@ MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8); | |||
1454 | MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8); | 1507 | MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8); |
1455 | MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl, | 1508 | MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl, |
1456 | (IWL_RSS_INDIRECTION_TABLE_SIZE * 2)); | 1509 | (IWL_RSS_INDIRECTION_TABLE_SIZE * 2)); |
1510 | MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512); | ||
1457 | 1511 | ||
1458 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING | 1512 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
1459 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256); | 1513 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256); |
@@ -1502,6 +1556,7 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir) | |||
1502 | MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR); | 1556 | MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR); |
1503 | MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR); | 1557 | MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR); |
1504 | MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR); | 1558 | MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR); |
1559 | MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, S_IWUSR); | ||
1505 | if (!debugfs_create_bool("enable_scan_iteration_notif", | 1560 | if (!debugfs_create_bool("enable_scan_iteration_notif", |
1506 | S_IRUSR | S_IWUSR, | 1561 | S_IRUSR | S_IWUSR, |
1507 | mvm->debugfs_dir, | 1562 | mvm->debugfs_dir, |