Path: blob/main/sys/contrib/dev/mediatek/mt76/mt76x02_dfs.h
48378 views
/* SPDX-License-Identifier: ISC */1/*2* Copyright (C) 2016 Lorenzo Bianconi <[email protected]>3*/45#ifndef __MT76x02_DFS_H6#define __MT76x02_DFS_H78#include <linux/types.h>9#include <linux/nl80211.h>1011#define MT_DFS_GP_INTERVAL (10 << 4) /* 64 us unit */12#define MT_DFS_NUM_ENGINES 41314/* bbp params */15#define MT_DFS_SYM_ROUND 016#define MT_DFS_DELTA_DELAY 217#define MT_DFS_VGA_MASK 018#define MT_DFS_PWR_GAIN_OFFSET 319#define MT_DFS_PWR_DOWN_TIME 0xf20#define MT_DFS_RX_PE_MASK 0xff21#define MT_DFS_PKT_END_MASK 022#define MT_DFS_CH_EN 0xf2324/* sw detector params */25#define MT_DFS_EVENT_LOOP 6426#define MT_DFS_SW_TIMEOUT (HZ / 20)27#define MT_DFS_EVENT_WINDOW (HZ / 5)28#define MT_DFS_SEQUENCE_WINDOW (200 * (1 << 20))29#define MT_DFS_EVENT_TIME_MARGIN 200030#define MT_DFS_PRI_MARGIN 431#define MT_DFS_SEQUENCE_TH 63233#define MT_DFS_FCC_MAX_PRI ((28570 << 1) + 1000)34#define MT_DFS_FCC_MIN_PRI (3000 - 2)35#define MT_DFS_JP_MAX_PRI ((80000 << 1) + 1000)36#define MT_DFS_JP_MIN_PRI (28500 - 2)37#define MT_DFS_ETSI_MAX_PRI (133333 + 125000 + 117647 + 1000)38#define MT_DFS_ETSI_MIN_PRI (4500 - 20)3940struct mt76x02_radar_specs {41u8 mode;42u16 avg_len;43u16 e_low;44u16 e_high;45u16 w_low;46u16 w_high;47u16 w_margin;48u32 t_low;49u32 t_high;50u16 t_margin;51u32 b_low;52u32 b_high;53u32 event_expiration;54u16 pwr_jmp;55};5657#define MT_DFS_CHECK_EVENT(x) ((x) != GENMASK(31, 0))58#define MT_DFS_EVENT_ENGINE(x) (((x) & BIT(31)) ? 2 : 0)59#define MT_DFS_EVENT_TIMESTAMP(x) ((x) & GENMASK(21, 0))60#define MT_DFS_EVENT_WIDTH(x) ((x) & GENMASK(11, 0))61struct mt76x02_dfs_event {62unsigned long fetch_ts;63u32 ts;64u16 width;65u8 engine;66};6768#define MT_DFS_EVENT_BUFLEN 25669struct mt76x02_dfs_event_rb {70struct mt76x02_dfs_event data[MT_DFS_EVENT_BUFLEN];71int h_rb, t_rb;72};7374struct mt76x02_dfs_sequence {75struct list_head head;76u32 first_ts;77u32 last_ts;78u32 pri;79u16 count;80u8 engine;81};8283struct mt76x02_dfs_hw_pulse {84u8 engine;85u32 period;86u32 w1;87u32 w2;88u32 burst;89};9091struct mt76x02_dfs_sw_detector_params {92u32 min_pri;93u32 max_pri;94u32 pri_margin;95};9697struct mt76x02_dfs_engine_stats {98u32 hw_pattern;99u32 hw_pulse_discarded;100u32 sw_pattern;101};102103struct mt76x02_dfs_seq_stats {104u32 seq_pool_len;105u32 seq_len;106};107108struct mt76x02_dfs_pattern_detector {109u8 chirp_pulse_cnt;110u32 chirp_pulse_ts;111112struct mt76x02_dfs_sw_detector_params sw_dpd_params;113struct mt76x02_dfs_event_rb event_rb[2];114115struct list_head sequences;116struct list_head seq_pool;117struct mt76x02_dfs_seq_stats seq_stats;118119unsigned long last_sw_check;120u32 last_event_ts;121122struct mt76x02_dfs_engine_stats stats[MT_DFS_NUM_ENGINES];123struct tasklet_struct dfs_tasklet;124};125126void mt76x02_dfs_init_params(struct mt76x02_dev *dev);127void mt76x02_dfs_init_detector(struct mt76x02_dev *dev);128void mt76x02_regd_notifier(struct wiphy *wiphy,129struct regulatory_request *request);130void mt76x02_phy_dfs_adjust_agc(struct mt76x02_dev *dev);131#endif /* __MT76x02_DFS_H */132133134