blob: 56a1ae70609f2e11108f9c6fba62599867ec461b [file] [log] [blame]
developerfd40db22021-04-29 10:08:25 +08001// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */
developer175704f2021-06-22 17:33:53 +08003#ifndef __MT76_VENDOR_H
4#define __MT76_VENDOR_H
developerfd40db22021-04-29 10:08:25 +08005
developer175704f2021-06-22 17:33:53 +08006#include <errno.h>
7#include <linux/nl80211.h>
8#include <netlink/attr.h>
developerfd40db22021-04-29 10:08:25 +08009#include <stdbool.h>
10#include <stdint.h>
11#include <stdio.h>
developerfd40db22021-04-29 10:08:25 +080012#include <unl.h>
13
14typedef uint8_t u8;
15typedef uint16_t u16;
16typedef uint32_t u32;
17typedef uint64_t u64;
18typedef int8_t s8;
19typedef int16_t s16;
20typedef int32_t s32;
21typedef 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
33struct nl_msg;
34struct nlattr;
35
36enum mtk_nl80211_vendor_subcmds {
37 MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2,
38};
39
40enum 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,
developer175704f2021-06-22 17:33:53 +080049 MTK_VENDOR_ATTR_CSI_CTRL_INTERVAL,
developerfd40db22021-04-29 10:08:25 +080050
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
61enum 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
93struct csi_data {
94 s16 data_i[CSI_MAX_COUNT];
95 s16 data_q[CSI_MAX_COUNT];
96 s8 rssi;
97 u8 snr;
developera1e20de2021-06-17 10:33:53 +080098 u32 ts;
developerfd40db22021-04-29 10:08:25 +080099 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
developerfd40db22021-04-29 10:08:25 +0800109extern struct unl unl;
developerfd40db22021-04-29 10:08:25 +0800110
developer175704f2021-06-22 17:33:53 +0800111int mt76_csi_set(int idx, int argc, char **argv);
112int mt76_csi_dump(int idx, int argc, char **argv);
developerfd40db22021-04-29 10:08:25 +0800113
114#endif