developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: ISC |
| 2 | /* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */ |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 3 | #ifndef __MT76_VENDOR_H |
| 4 | #define __MT76_VENDOR_H |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 5 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 6 | #include <errno.h> |
| 7 | #include <linux/nl80211.h> |
| 8 | #include <netlink/attr.h> |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 9 | #include <stdbool.h> |
| 10 | #include <stdint.h> |
| 11 | #include <stdio.h> |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 12 | #include <unl.h> |
| 13 | |
| 14 | typedef uint8_t u8; |
| 15 | typedef uint16_t u16; |
| 16 | typedef uint32_t u32; |
| 17 | typedef uint64_t u64; |
| 18 | typedef int8_t s8; |
| 19 | typedef int16_t s16; |
| 20 | typedef int32_t s32; |
| 21 | typedef int64_t s64, ktime_t; |
| 22 | |
| 23 | #define MTK_NL80211_VENDOR_ID 0x0ce7 |
| 24 | |
| 25 | #ifndef ARRAY_SIZE |
| 26 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 27 | #endif |
| 28 | |
| 29 | #ifndef DIV_ROUND_UP |
| 30 | #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) |
| 31 | #endif |
| 32 | |
| 33 | struct nl_msg; |
| 34 | struct nlattr; |
| 35 | |
| 36 | enum mtk_nl80211_vendor_subcmds { |
| 37 | MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2, |
| 38 | }; |
| 39 | |
| 40 | enum mtk_vendor_attr_csi_ctrl { |
| 41 | MTK_VENDOR_ATTR_CSI_CTRL_UNSPEC, |
| 42 | |
| 43 | MTK_VENDOR_ATTR_CSI_CTRL_CFG, |
| 44 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_MODE, |
| 45 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_TYPE, |
| 46 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_VAL1, |
| 47 | MTK_VENDOR_ATTR_CSI_CTRL_CFG_VAL2, |
| 48 | MTK_VENDOR_ATTR_CSI_CTRL_MAC_ADDR, |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 49 | MTK_VENDOR_ATTR_CSI_CTRL_INTERVAL, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 50 | |
| 51 | MTK_VENDOR_ATTR_CSI_CTRL_DUMP_NUM, |
| 52 | |
| 53 | MTK_VENDOR_ATTR_CSI_CTRL_DATA, |
| 54 | |
| 55 | /* keep last */ |
| 56 | NUM_MTK_VENDOR_ATTRS_CSI_CTRL, |
| 57 | MTK_VENDOR_ATTR_CSI_CTRL_MAX = |
| 58 | NUM_MTK_VENDOR_ATTRS_CSI_CTRL - 1 |
| 59 | }; |
| 60 | |
| 61 | enum mtk_vendor_attr_csi_data { |
| 62 | MTK_VENDOR_ATTR_CSI_DATA_UNSPEC, |
| 63 | MTK_VENDOR_ATTR_CSI_DATA_PAD, |
| 64 | |
| 65 | MTK_VENDOR_ATTR_CSI_DATA_VER, |
| 66 | MTK_VENDOR_ATTR_CSI_DATA_TS, |
| 67 | MTK_VENDOR_ATTR_CSI_DATA_RSSI, |
| 68 | MTK_VENDOR_ATTR_CSI_DATA_SNR, |
| 69 | MTK_VENDOR_ATTR_CSI_DATA_BW, |
| 70 | MTK_VENDOR_ATTR_CSI_DATA_CH_IDX, |
| 71 | MTK_VENDOR_ATTR_CSI_DATA_TA, |
| 72 | MTK_VENDOR_ATTR_CSI_DATA_I, |
| 73 | MTK_VENDOR_ATTR_CSI_DATA_Q, |
| 74 | MTK_VENDOR_ATTR_CSI_DATA_INFO, |
| 75 | MTK_VENDOR_ATTR_CSI_DATA_RSVD1, |
| 76 | MTK_VENDOR_ATTR_CSI_DATA_RSVD2, |
| 77 | MTK_VENDOR_ATTR_CSI_DATA_RSVD3, |
| 78 | MTK_VENDOR_ATTR_CSI_DATA_RSVD4, |
| 79 | MTK_VENDOR_ATTR_CSI_DATA_TX_ANT, |
| 80 | MTK_VENDOR_ATTR_CSI_DATA_RX_ANT, |
| 81 | MTK_VENDOR_ATTR_CSI_DATA_MODE, |
| 82 | MTK_VENDOR_ATTR_CSI_DATA_H_IDX, |
| 83 | |
| 84 | /* keep last */ |
| 85 | NUM_MTK_VENDOR_ATTRS_CSI_DATA, |
| 86 | MTK_VENDOR_ATTR_CSI_DATA_MAX = |
| 87 | NUM_MTK_VENDOR_ATTRS_CSI_DATA - 1 |
| 88 | }; |
| 89 | |
| 90 | #define CSI_MAX_COUNT 256 |
| 91 | #define ETH_ALEN 6 |
| 92 | |
| 93 | struct csi_data { |
| 94 | s16 data_i[CSI_MAX_COUNT]; |
| 95 | s16 data_q[CSI_MAX_COUNT]; |
| 96 | s8 rssi; |
| 97 | u8 snr; |
developer | a1e20de | 2021-06-17 10:33:53 +0800 | [diff] [blame] | 98 | u32 ts; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 99 | u8 data_bw; |
| 100 | u8 pri_ch_idx; |
| 101 | u8 ta[ETH_ALEN]; |
| 102 | u32 info; |
| 103 | u8 rx_mode; |
| 104 | u32 h_idx; |
| 105 | u16 tx_idx; |
| 106 | u16 rx_idx; |
| 107 | }; |
| 108 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 109 | extern struct unl unl; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 110 | |
developer | 175704f | 2021-06-22 17:33:53 +0800 | [diff] [blame] | 111 | int mt76_csi_set(int idx, int argc, char **argv); |
| 112 | int mt76_csi_dump(int idx, int argc, char **argv); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 113 | |
| 114 | #endif |