Эх сурвалжийг харах

qcacmn: DFS componentization (Filter Tables)

Whenever the hardware detects a RADAR PHY error, it generates an interrupt
and the MAC layer provides the RSSI value, Pulse width, Timestamp on the
collected data,  and FFT data to Software.
There is an event queue associated with RADAR detection. The RSSI, pulse
width, and time stamp is stored in the queue by the interrupt handler.
There is a DFS timer task that reads the entries in the queue associated
with RADAR detection. It checks the time stamp, RSSI, and pulse width
value against the PRI, RSSI, and pulse width defined in the RADAR filter
table. If any entry of the table mactches then it announces RADAR is found.

Change-Id: I71bf88c77eb5baa4984bdc2181ca27008d641469
CRs-Fixed: 2001106
Abhijit Pradhan 8 жил өмнө
parent
commit
752ce0a9de

+ 209 - 0
umac/dfs/core/src/filtering/ar5212_radar.c

@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2011, 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2002-2005 Atheros Communications, Inc.
+ * Copyright (c) 2008-2010, Atheros Communications Inc.
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: This file has the radar table for AR5212 chipset and function to
+ * initialize the radar table.
+ */
+#include "../dfs.h"
+#include "../dfs_internal.h"
+#include "wlan_dfs_lmac_api.h"
+
+/* Default 5212/5312 radar phy parameters. */
+#define AR5212_DFS_FIRPWR -41
+#define AR5212_DFS_RRSSI  12
+#define AR5212_DFS_HEIGHT 20
+#define AR5212_DFS_PRSSI  22
+#define AR5212_DFS_INBAND 6
+
+/**
+ * struct dfs_pulse ar5212_etsi_radars - ETSI radar pulse table for
+ *                                       AR5212 chipset.
+ */
+struct dfs_pulse ar5212_etsi_radars[] = {
+	/* TYPE 1 */
+	{10, 2,   750,  0, 24, 50,  0,  2, 22,  0, 3, 0, 0},
+
+	/* TYPE 2 */
+	{7,  2,   200,  0, 24, 50,  0,  2, 22,  0, 3, 0, 1},
+	{7,  2,   300,  0, 24, 50,  0,  2, 22,  0, 3, 0, 2},
+	{7,  2,   500,  0, 24, 50,  0,  2, 22,  1, 3, 0, 3},
+	{7,  2,   800,  0, 24, 50,  0,  2, 22,  1, 3, 0, 4},
+	{7,  2,  1001,  0, 24, 50,  0,  2, 22,  0, 3, 0, 5},
+	{7,  8,   200,  0, 24, 50,  6,  9, 22,  8, 3, 0, 6},
+	{7,  8,   300,  0, 24, 50,  6,  9, 22,  8, 3, 0, 7},
+	{7,  8,   502,  0, 24, 50,  6,  9, 22,  0, 3, 0, 8},
+	{7,  8,   805,  0, 24, 50,  6,  9, 22,  0, 3, 0, 9},
+	{7,  8,  1008,  0, 24, 50,  6,  9, 22,  0, 3, 0, 10},
+
+	/* TYPE 3 */
+	{10, 14,  200,  0, 24, 50, 12, 15, 22, 14, 3, 0, 11},
+	{10, 14,  300,  0, 24, 50, 12, 15, 22, 14, 3, 0, 12},
+	{10, 14,  503,  0, 24, 50, 12, 15, 22,  2, 3, 0, 13},
+	{10, 14,  809,  0, 24, 50, 12, 15, 22,  0, 3, 0, 14},
+	{10, 14, 1014,  0, 24, 50, 12, 15, 22,  0, 3, 0, 15},
+	{10, 18,  200,  0, 24, 50, 15, 19, 22, 18, 3, 0, 16},
+	{10, 18,  301,  0, 24, 50, 15, 19, 22,  7, 3, 0, 17},
+	{10, 18,  504,  0, 24, 50, 15, 19, 22,  2, 3, 0, 18},
+	{10, 18,  811,  0, 24, 50, 15, 19, 22,  0, 3, 0, 19},
+	{10, 18, 1018,  0, 24, 50, 15, 19, 22,  0, 3, 0, 20},
+
+	/* TYPE 4 */
+	{10, 2,  1200,  0, 24, 50,  0,  2, 22,  0, 3, 0, 21},
+	{10, 2,  1500,  0, 24, 50,  0,  2, 22,  0, 3, 0, 22},
+	{10, 2,  1600,  0, 24, 50,  0,  2, 22,  0, 3, 0, 23},
+	{10, 8,  1212,  0, 24, 50,  6,  9, 22,  0, 3, 0, 24},
+	{10, 8,  1517,  0, 24, 50,  6,  9, 22,  0, 3, 0, 25},
+	{10, 8,  1620,  0, 24, 50,  6,  9, 22,  0, 3, 0, 26},
+	{10, 14, 1221,  0, 24, 50, 12, 15, 22,  0, 3, 0, 27},
+	{10, 14, 1531,  0, 24, 50, 12, 15, 22,  0, 3, 0, 28},
+	{10, 14, 1636,  0, 24, 50, 12, 15, 22,  0, 3, 0, 29},
+	{10, 18, 1226,  0, 24, 50, 15, 19, 22,  0, 3, 0, 30},
+	{10, 18, 1540,  0, 24, 50, 15, 19, 22,  0, 3, 0, 31},
+	{10, 18, 1647,  0, 24, 50, 15, 19, 22,  0, 3, 0, 32},
+
+	/* TYPE 5 */
+	{17, 2,  2305,  0, 24, 50,  0,  2, 22,  0, 3, 0, 33},
+	{17, 2,  3009,  0, 24, 50,  0,  2, 22,  0, 3, 0, 34},
+	{17, 2,  3512,  0, 24, 50,  0,  2, 22,  0, 3, 0, 35},
+	{17, 2,  4016,  0, 24, 50,  0,  2, 22,  0, 3, 0, 36},
+	{17, 8,  2343,  0, 24, 50,  6,  9, 22,  0, 3, 0, 37},
+	{17, 8,  3073,  0, 24, 50,  6,  9, 22,  0, 3, 0, 38},
+	{17, 8,  3601,  0, 24, 50,  6,  9, 22,  0, 3, 0, 39},
+	{17, 8,  4132,  0, 24, 50,  6,  9, 22,  0, 3, 0, 40},
+	{17, 14, 2376,  0, 24, 50, 12, 15, 22,  0, 3, 0, 41},
+	{17, 14, 3131,  0, 24, 50, 12, 15, 22,  0, 3, 0, 42},
+	{17, 14, 3680,  0, 24, 50, 12, 15, 22,  0, 3, 0, 43},
+	{17, 14, 4237,  0, 24, 50, 12, 15, 22,  0, 3, 0, 44},
+	{17, 18, 2399,  0, 24, 50, 15, 19, 22,  0, 3, 0, 45},
+	{17, 18, 3171,  0, 24, 50, 15, 19, 22,  0, 3, 0, 46},
+	{17, 18, 3735,  0, 24, 50, 15, 19, 22,  0, 3, 0, 47},
+	{17, 18, 4310,  0, 24, 50, 15, 19, 22,  0, 3, 0, 48},
+
+	/* TYPE 6 */
+	{14, 22, 2096,  0, 24, 50, 21, 24, 22,  0, 3, 0, 49},
+	{14, 22, 3222,  0, 24, 50, 21, 24, 22,  0, 3, 0, 50},
+	{14, 22, 4405,  0, 24, 50, 21, 24, 22,  0, 3, 0, 51},
+	{14, 32, 2146,  0, 24, 50, 30, 35, 22,  0, 3, 0, 52},
+	{14, 32, 3340,  0, 24, 50, 30, 35, 22,  0, 3, 0, 53},
+	{14, 32, 4629,  0, 24, 50, 30, 35, 22,  0, 3, 0, 54},
+};
+
+/**
+ * struct dfs_pulse ar5212_fcc_radars - FCC radar pulse table for
+ *                                       AR5212 chipset.
+ */
+struct dfs_pulse ar5212_fcc_radars[] = {
+	/* following two filters are specific to Japan/MKK4 */
+	{16,   2,  720,  6, 40,  0,  2, 18,  0, 3, 0, 30},
+	{16,   3,  260,  6, 40,  0,  5, 18,  0, 3, 0, 31},
+
+	/* following filters are common to both FCC and JAPAN */
+	{9,   2, 3003,   6, 50,  0,  2, 18,  0, 0, 0, 29},
+	{16,  2,  700,   6, 35,  0,  2, 18,  0, 3, 0, 28},
+
+	{10,  3, 6666,  10, 90,  2,  3, 22,  0, 3,  0, 0},
+	{10,  3, 5900,  10, 90,  2,  3, 22,  0, 3,  0, 1},
+	{10,  3, 5200,  10, 90,  2,  3, 22,  0, 3,  0, 2},
+	{10,  3, 4800,  10, 90,  2,  3, 22,  0, 3,  0, 3},
+	{10,  3, 4400,  10, 90,  2,  3, 22,  0, 3,  0, 4},
+	{10,  5, 6666,  50, 30,  3, 10, 22,  0, 3,  0, 5},
+	{10,  5, 5900,  70, 30,  3, 10, 22,  0, 3,  0, 6},
+	{10,  5, 5200,  70, 30,  3, 10, 22,  0, 3,  0, 7},
+	{10,  5, 4800,  70, 30,  3, 10, 22,  0, 3,  0, 8},
+	{10,  5, 4400,  50, 30,  3,  9, 22,  0, 3,  0, 9},
+
+	{8,  10, 5000, 100, 40,  7, 17, 22,  0, 3, 0, 10},
+	{8,  10, 3000, 100, 40,  7, 17, 22,  0, 3, 0, 11},
+	{8,  10, 2000,  40, 40,  9, 17, 22,  0, 3, 0, 12},
+	{8,  14, 5000, 100, 40, 13, 16, 22,  0, 3, 0, 13},
+	{8,  14, 3000, 100, 40, 13, 16, 22,  0, 3, 0, 14},
+	{8,  14, 2000,  40, 40, 13, 16, 22,  0, 3, 0, 15},
+
+	{6,  10, 5000,  80, 40, 10, 15, 22,  0, 3, 0, 16},
+	{6,  10, 3000,  80, 40, 10, 15, 22,  0, 3, 0, 17},
+	{6,  10, 2000,  40, 40, 10, 15, 22,  0, 3, 0, 18},
+	{6,  10, 5000,  80, 40, 10, 12, 22,  0, 3, 0, 19},
+	{6,  10, 3000,  80, 40, 10, 12, 22,  0, 3, 0, 20},
+	{6,  10, 2000,  40, 40, 10, 12, 22,  0, 3, 0, 21},
+
+	{6,  18, 5000,  80, 40, 16, 25, 22,  0, 3, 0, 22},
+	{6,  18, 3000,  80, 40, 16, 25, 22,  0, 3, 0, 23},
+	{6,  18, 2000,  40, 40, 16, 25, 22,  0, 3, 0, 24},
+
+	{6,  21, 5000,  80, 40, 12, 25, 22,  0, 3, 0, 25},
+	{6,  21, 3000,  80, 40, 12, 25, 22,  0, 3, 0, 26},
+	{6,  21, 2000,  40, 40, 12, 25, 22,  0, 3, 0, 27},
+};
+
+/**
+ * struct dfs_bin5pulse ar5212_bin5pulses - BIN5 pulse for AR5212 chipset.
+ */
+struct dfs_bin5pulse ar5212_bin5pulses[] = {
+	{5, 52, 100, 12, 22, 3},
+};
+
+void dfs_get_radars_for_ar5212(struct wlan_dfs *dfs)
+{
+	struct wlan_dfs_radar_tab_info rinfo;
+	int dfsdomain = DFS_FCC_DOMAIN;
+
+	qdf_mem_zero(&rinfo, sizeof(rinfo));
+	dfsdomain = lmac_get_dfsdomain(dfs->dfs_pdev_obj);
+
+	switch (dfsdomain) {
+	case DFS_FCC_DOMAIN:
+		DFS_PRINTK("%s: DFS_FCC_DOMAIN_5212\n", __func__);
+		rinfo.dfsdomain = DFS_FCC_DOMAIN;
+		rinfo.dfs_radars = &ar5212_fcc_radars[2];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar5212_fcc_radars)-2;
+		rinfo.b5pulses = &ar5212_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5212_bin5pulses);
+		break;
+	case DFS_ETSI_DOMAIN:
+		DFS_PRINTK("%s: DFS_ETSI_DOMAIN_5412\n", __func__);
+		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
+		rinfo.dfs_radars = &ar5212_etsi_radars[0];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar5212_etsi_radars);
+		rinfo.b5pulses = &ar5212_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5212_bin5pulses);
+		break;
+	case DFS_MKK4_DOMAIN:
+		DFS_PRINTK("%s: DFS_MKK4_DOMAIN_5412\n", __func__);
+		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
+		rinfo.dfs_radars = &ar5212_fcc_radars[0];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar5212_fcc_radars);
+		rinfo.b5pulses = &ar5212_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5212_bin5pulses);
+		break;
+	default:
+		DFS_PRINTK("%s: No domain\n", __func__);
+		return;
+	}
+
+	rinfo.dfs_defaultparams.pe_firpwr = AR5212_DFS_FIRPWR;
+	rinfo.dfs_defaultparams.pe_rrssi = AR5212_DFS_RRSSI;
+	rinfo.dfs_defaultparams.pe_height = AR5212_DFS_HEIGHT;
+	rinfo.dfs_defaultparams.pe_prssi = AR5212_DFS_PRSSI;
+	rinfo.dfs_defaultparams.pe_inband = AR5212_DFS_INBAND;
+
+	dfs_init_radar_filters(dfs, &rinfo);
+}

+ 155 - 0
umac/dfs/core/src/filtering/ar5416_radar.c

@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2011, 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2002-2005 Atheros Communications, Inc.
+ * Copyright (c) 2008-2010, Atheros Communications Inc.
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: This file has the radar table for AR5416 chipset and function to
+ * initialize the radar table.
+ */
+
+#include "../dfs.h"
+#include "../dfs_internal.h"
+#include "wlan_dfs_lmac_api.h"
+
+/* Default 5413/5416 radar phy parameters. */
+#define AR5416_DFS_FIRPWR  -33
+#define AR5416_DFS_RRSSI   20
+#define AR5416_DFS_HEIGHT  10
+#define AR5416_DFS_PRSSI   15
+#define AR5416_DFS_INBAND  15
+#define AR5416_DFS_RELPWR  8
+#define AR5416_DFS_RELSTEP 12
+#define AR5416_DFS_MAXLEN  255
+
+/**
+ * struct dfs_pulse ar5416_etsi_radars - ETSI radar pulse table for
+ *                                       AR5416 chipset.
+ */
+struct dfs_pulse ar5416_etsi_radars[] = {
+	/* TYPE staggered pulse */
+	/* 0.8-2us, 2-3 bursts,300-400 PRF, 10 pulses each */
+	{20,  2,  300,  400, 2, 30,  4,  0,  2, 15, 0,   0, 0, 31},
+	/* 0.8-2us, 2-3 bursts, 400-1200 PRF, 15 pulses each */
+	{30,  2,  400, 1200, 2, 30,  7,  0,  2, 15, 0,   0, 0, 32},
+
+	/* constant PRF based */
+	/* 0.8-5us, 200  300 PRF, 10 pulses */
+	{10, 5,   200,  400, 0, 24,  5,  0,  8, 18, 0,   0, 0, 33},
+	{10, 5,   400,  600, 0, 24,  5,  0,  8, 18, 0,   0, 0, 37},
+	{10, 5,   600,  800, 0, 24,  5,  0,  8, 18, 0,   0, 0, 38},
+	{10, 5,   800, 1000, 0, 24,  5,  0,  8, 18, 0,   0, 0, 39},
+
+	/* 0.8-15us, 200-1600 PRF, 15 pulses */
+	{15, 15,  200, 1600, 0, 24, 6,  0, 18, 15, 0,   0, 0, 34},
+
+	/* 0.8-15us, 2300-4000 PRF, 25 pulses*/
+	{25, 15, 2300, 4000,  0, 24, 8, 0, 18, 15, 0,   0, 0, 35},
+
+	/* 20-30us, 2000-4000 PRF, 20 pulses*/
+	{20, 30, 2000, 4000, 0, 24, 8, 19, 33, 15, 0,   0, 0, 36},
+};
+
+/**
+ * struct dfs_pulse ar5416_fcc_radars - FCC radar pulse table for
+ *                                       AR5416 chipset.
+ */
+struct dfs_pulse ar5416_fcc_radars[] = {
+	/* following two filters are specific to Japan/MKK4 */
+	/* 1389 +/- 6 us */
+	{18,  1,  720,  720, 0,  6,  6,  0,  1, 18,  0, 3, 0, 17},
+	/* 4000 +/- 6 us */
+	{18,  4,  250,  250, 0, 10,  5,  1,  6, 18,  0, 3, 0, 18},
+	/* 3846 +/- 7 us */
+	{18,  5,  260,  260, 0, 10,  6,  1,  6, 18,  0, 3, 0, 19},
+
+	/* following filters are common to both FCC and JAPAN */
+	/* FCC TYPE 1 */
+	{18,  1,  700, 700, 0,  6,  5,  0,  1, 18,  0, 3,  0, 0},
+	{18,  1,  350, 350, 0,  6,  5,  0,  1, 18,  0, 3,  0, 0},
+
+	/* FCC TYPE 6 */
+	{9,   1, 3003, 3003, 1,  7,  5,  0,  1, 18,  0, 0,  0, 1},
+
+	/* FCC TYPE 2 */
+	{23, 5, 4347, 6666, 0, 18, 11,  0,  7, 20,  0, 3,  0, 2},
+
+	/* FCC TYPE 3 */
+	{18, 10, 2000, 5000, 0, 23,  8,  6, 13, 20,  0, 3, 0, 5},
+
+	/* FCC TYPE 4 */
+	{16, 15, 2000, 5000, 0, 25,  7, 11, 23, 20,  0, 3, 0, 11},
+};
+
+/**
+ * struct dfs_bin5pulse ar5416_bin5pulses - BIN5 pulse for AR5416 chipset.
+ */
+struct dfs_bin5pulse ar5416_bin5pulses[] = {
+	{2, 28, 105, 12, 22, 5},
+};
+
+void dfs_get_radars_for_ar5416(struct wlan_dfs *dfs)
+{
+	struct wlan_dfs_radar_tab_info rinfo;
+	int dfsdomain = DFS_FCC_DOMAIN;
+
+	qdf_mem_zero(&rinfo, sizeof(rinfo));
+	dfsdomain = lmac_get_dfsdomain(dfs->dfs_pdev_obj);
+
+	switch (dfsdomain) {
+	case DFS_FCC_DOMAIN:
+		DFS_PRINTK("%s: DFS_FCC_DOMAIN_5416\n", __func__);
+		rinfo.dfsdomain = DFS_FCC_DOMAIN;
+		rinfo.dfs_radars = &ar5416_fcc_radars[3];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar5416_fcc_radars)-3;
+		rinfo.b5pulses = &ar5416_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5416_bin5pulses);
+		break;
+	case DFS_ETSI_DOMAIN:
+		DFS_PRINTK("%s: DFS_ETSI_DOMAIN_5416\n", __func__);
+		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
+		rinfo.dfs_radars = &ar5416_etsi_radars[0];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar5416_etsi_radars);
+		rinfo.b5pulses = &ar5416_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5416_bin5pulses);
+		break;
+	case DFS_MKK4_DOMAIN:
+		DFS_PRINTK("%s: DFS_MKK4_DOMAIN_5416\n", __func__);
+		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
+		rinfo.dfs_radars = &ar5416_fcc_radars[0];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar5416_fcc_radars);
+		rinfo.b5pulses = &ar5416_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5416_bin5pulses);
+		break;
+	default:
+		DFS_PRINTK("%s: no domain\n", __func__);
+		return;
+	}
+
+	rinfo.dfs_defaultparams.pe_firpwr = AR5416_DFS_FIRPWR;
+	rinfo.dfs_defaultparams.pe_rrssi = AR5416_DFS_RRSSI;
+	rinfo.dfs_defaultparams.pe_height = AR5416_DFS_HEIGHT;
+	rinfo.dfs_defaultparams.pe_prssi = AR5416_DFS_PRSSI;
+	rinfo.dfs_defaultparams.pe_inband = AR5416_DFS_INBAND;
+	rinfo.dfs_defaultparams.pe_relpwr = AR5416_DFS_RELPWR;
+	rinfo.dfs_defaultparams.pe_relstep = AR5416_DFS_RELSTEP;
+	rinfo.dfs_defaultparams.pe_maxlen = AR5416_DFS_MAXLEN;
+
+	dfs_init_radar_filters(dfs, &rinfo);
+}

+ 230 - 0
umac/dfs/core/src/filtering/ar9300_radar.c

@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2011, 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2008-2010, Atheros Communications Inc.
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: This file has the radar table for AR9300 chipset and function to
+ * initialize the radar table.
+ */
+
+#include "../dfs.h"
+#include "../dfs_internal.h"
+#include "wlan_dfs_lmac_api.h"
+
+/*
+ * Default 5413/9300 radar phy parameters
+ * Values adjusted to fix EV76432/EV76320
+ */
+#define AR9300_DFS_FIRPWR    -28
+#define AR9300_DFS_RRSSI     0
+#define AR9300_DFS_HEIGHT    10
+#define AR9300_DFS_PRSSI     6
+#define AR9300_DFS_INBAND    8
+#define AR9300_DFS_RELPWR    8
+#define AR9300_DFS_RELSTEP   12
+#define AR9300_DFS_MAXLEN    255
+#define AR9300_DFS_PRSSI_CAC 10
+
+/*
+ * Make sure that value matches value in ar9300_osprey_2p2_mac_core[][2] for
+ * register 0x1040 to 0x104c.
+ */
+#define AR9300_FCC_RADARS_FCC_OFFSET 4
+
+/**
+ * struct dfs_pulse ar9300_etsi_radars - ETSI radar pulse table for
+ *                                       AR9300 chipset.
+ *
+ * For short pulses, RSSI threshold should be smaller than Kquick-drop.
+ * The chip has only one chance to drop the gain which will be reported
+ * as the estimated RSSI.
+ */
+struct dfs_pulse ar9300_etsi_radars[] = {
+	/* TYPE staggered pulse */
+	/* Type 5*/
+	/* 0.8-2us, 2-3 bursts,300-400 PRF, 10 pulses each */
+	{30,  2,  300,  400, 2, 30,  3,  0,  5, 15, 0,   0, 1, 31},
+	/* Type 6 */
+	/* 0.8-2us, 2-3 bursts, 400-1200 PRF, 15 pulses each */
+	{30,  2,  400, 1200, 2, 30,  7,  0,  5, 15, 0,   0, 0, 32},
+
+	/* constant PRF based */
+	/* Type 1 */
+	/* 0.8-5us, 200  300 PRF, 10 pulses */
+	{10, 5,   200,  400, 0, 24,  5,  0,  8, 15, 0,   0, 2, 33},
+	{10, 5,   400,  600, 0, 24,  5,  0,  8, 15, 0,   0, 2, 37},
+	{10, 5,   600,  800, 0, 24,  5,  0,  8, 15, 0,   0, 2, 38},
+	{10, 5,   800, 1000, 0, 24,  5,  0,  8, 15, 0,   0, 2, 39},
+
+	/* Type 2 */
+	/* 0.8-15us, 200-1600 PRF, 15 pulses */
+	{15, 15,  200, 1600, 0, 24, 8,  0, 18, 24, 0,   0, 0, 34},
+
+	/* Type 3 */
+	/* 0.8-15us, 2300-4000 PRF, 25 pulses*/
+	{25, 15, 2300, 4000,  0, 24, 10, 0, 18, 24, 0,   0, 0, 35},
+
+	/* Type 4 */
+	/* 20-30us, 2000-4000 PRF, 20 pulses*/
+	{20, 30, 2000, 4000, 0, 24, 8, 19, 33, 24, 0,   0, 0, 36},
+};
+
+/**
+ * struct dfs_pulse ar9300_fcc_radars - FCC radar pulse table for
+ *                                       AR9300 chipset.
+ */
+struct dfs_pulse ar9300_fcc_radars[] = {
+	/*
+	 * Format is as following:
+	 * Numpulses pulsedur pulsefreq max_pulsefreq patterntype pulsevar
+	 * threshold mindur maxdur rssithresh meanoffset rssimargin pulseid.
+	 */
+
+	/* following two filters are specific to Japan/MKK4 */
+	/* 1389 +/- 6 us */
+	{18,  1,  720,  720, 0,  6,  6,  0,  1, 18,  0, 3, 0, 17},
+	/* 4000 +/- 6 us */
+	{18,  4,  250,  250, 0, 10,  5,  1,  6, 18,  0, 3, 0, 18},
+	/* 3846 +/- 7 us */
+	{18,  5,  260,  260, 0, 10,  6,  1,  6, 18,  0, 3, 1, 19},
+	/* 3846 +/- 7 us */
+	{18, 5, 260, 260, 1, 10, 6, 1, 6, 18, 0, 3, 1, 20},
+
+	/* following filters are common to both FCC and JAPAN */
+
+	/* FCC TYPE 1 */
+	{18,  1,  700, 700, 0,  6,  5,  0,  1, 18,  0, 3, 1, 8},
+	{18,  1,  350, 350, 0,  6,  5,  0,  1, 18,  0, 3, 0, 0},
+
+	/* FCC TYPE 6 */
+	{9,   1, 3003, 3003, 0,  7,  5,  0,  1, 18,  0, 0, 1, 1},
+
+	/* FCC TYPE 2 */
+	{23, 5, 4347, 6666, 0, 18, 11,  0,  7, 22,  0, 3, 0, 2},
+
+	/* FCC TYPE 3 */
+	{18, 10, 2000, 5000, 0, 23,  8,  6, 13, 22,  0, 3, 0, 5},
+
+	/* FCC TYPE 4 */
+	{16, 15, 2000, 5000, 0, 25,  7, 11, 23, 22,  0, 3, 0, 11},
+
+	/* FCC NEW TYPE 1 */
+	/* Search duration is numpulses*maxpri.
+	 * The last theshold can be increased if false detects happen
+	 */
+	/* 518us to 938us pulses (min 56 pulses) */
+	{57, 1, 1066, 1930, 0, 6, 20,  0,  1, 22,  0, 3, 0, 21},
+	/* 938us to 2000 pulses (min 26 pulses) */
+	{27, 1,  500, 1066, 0, 6, 13,  0,  1, 22,  0, 3, 0, 22},
+	/* 2000 to 3067us pulses (min 17 pulses)*/
+	{18, 1,  325,  500, 0, 6,  9,  0,  1, 22,  0, 3, 0, 23},
+
+};
+
+/**
+ * struct dfs_bin5pulse ar9300_bin5pulses - BIN5 pulse for AR9300 chipset.
+ */
+struct dfs_bin5pulse ar9300_bin5pulses[] = {
+	{2, 28, 105, 12, 22, 5},
+};
+
+/**
+ * struct dfs_pulse ar9300_korea_radars - DFS pulses for KOREA domain.
+ */
+struct dfs_pulse ar9300_korea_radars[] = {
+	/* Korea Type 1 */
+	{18,  1,  700, 700,  0, 6,  5,  0,  1, 18,  0, 3,  1, 40},
+	/* Korea Type 2 */
+	{10,  1, 1800, 1800, 0, 6,  4,  0,  1, 18,  0, 3,  1, 41},
+	/* Korea Type 3 */
+	{70,  1,  330, 330,  0, 6, 20,  0,  2, 18,  0, 3,  1, 42},
+	/* Korea Type 4 */
+	{3,   1, 3003, 3003, 1, 7,  2,  0,  1, 18,  0, 0, 1,  43},
+};
+
+void dfs_get_radars_for_ar9300(struct wlan_dfs *dfs)
+{
+	struct wlan_dfs_radar_tab_info rinfo;
+	int dfsdomain = DFS_FCC_DOMAIN;
+
+	qdf_mem_zero(&rinfo, sizeof(rinfo));
+	dfsdomain = lmac_get_dfsdomain(dfs->dfs_pdev_obj);
+
+	switch (dfsdomain) {
+	case DFS_FCC_DOMAIN:
+		DFS_PRINTK("%s: DFS_FCC_DOMAIN_9300\n", __func__);
+		rinfo.dfsdomain = DFS_FCC_DOMAIN;
+		rinfo.dfs_radars =
+			&ar9300_fcc_radars[AR9300_FCC_RADARS_FCC_OFFSET];
+		rinfo.numradars =
+			(QDF_ARRAY_SIZE(ar9300_fcc_radars) -
+			 AR9300_FCC_RADARS_FCC_OFFSET);
+		rinfo.b5pulses = &ar9300_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar9300_bin5pulses);
+		break;
+	case DFS_ETSI_DOMAIN:
+		DFS_PRINTK("%s: DFS_ETSI_DOMAIN_9300\n", __func__);
+		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
+		rinfo.dfs_radars = &ar9300_etsi_radars[0];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar9300_etsi_radars);
+		rinfo.b5pulses = &ar9300_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar9300_bin5pulses);
+
+		if (lmac_is_countryCode_KOREA_ROC3(dfs->dfs_pdev_obj)) {
+			DFS_PRINTK("%s: DFS_ETSI_DOMAIN_9300_Country_Korea\n",
+				__func__);
+			rinfo.dfs_radars = &ar9300_korea_radars[0];
+			rinfo.numradars = QDF_ARRAY_SIZE(ar9300_korea_radars);
+		}
+		break;
+	case DFS_MKK4_DOMAIN:
+		DFS_PRINTK("%s: DFS_MKK4_DOMAIN_9300\n", __func__);
+		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
+		rinfo.dfs_radars = &ar9300_fcc_radars[0];
+		rinfo.numradars = QDF_ARRAY_SIZE(ar9300_fcc_radars);
+		rinfo.b5pulses = &ar9300_bin5pulses[0];
+		rinfo.numb5radars = QDF_ARRAY_SIZE(ar9300_bin5pulses);
+		break;
+	default:
+		DFS_PRINTK("%s: no domain\n", __func__);
+		return;
+	}
+
+	lmac_set_use_cac_prssi(dfs->dfs_pdev_obj);
+
+	rinfo.dfs_defaultparams.pe_firpwr = AR9300_DFS_FIRPWR;
+	rinfo.dfs_defaultparams.pe_rrssi = AR9300_DFS_RRSSI;
+	rinfo.dfs_defaultparams.pe_height = AR9300_DFS_HEIGHT;
+	rinfo.dfs_defaultparams.pe_prssi = AR9300_DFS_PRSSI;
+
+	/*
+	 * We have an issue with PRSSI.
+	 * For normal operation we use AR9300_DFS_PRSSI, which is set to 6.
+	 * Please refer to EV91563, 94164.
+	 * However, this causes problem during CAC as no radar is detected
+	 * during that period with PRSSI=6. Only PRSSI= 10 seems to fix this.
+	 * We use this flag to keep track of change in PRSSI.
+	 */
+	rinfo.dfs_defaultparams.pe_inband = AR9300_DFS_INBAND;
+	rinfo.dfs_defaultparams.pe_relpwr = AR9300_DFS_RELPWR;
+	rinfo.dfs_defaultparams.pe_relstep = AR9300_DFS_RELSTEP;
+	rinfo.dfs_defaultparams.pe_maxlen = AR9300_DFS_MAXLEN;
+
+	dfs_init_radar_filters(dfs, &rinfo);
+}

+ 571 - 0
umac/dfs/core/src/filtering/dfs_radar.c

@@ -0,0 +1,571 @@
+/*
+ * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011, Atheros Communications Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: This file has radar table and initialization function for Beeliner
+ * family of chipsets.
+ */
+
+#include "../dfs.h"
+#include "wlan_dfs_mlme_api.h"
+#include "wlan_dfs_lmac_api.h"
+#include "wlan_dfs_mlme_api.h"
+#include "../dfs_internal.h"
+
+/**
+ * struct dfs_pulse dfs_fcc_radars - FCC radar table for Offload chipsets.
+ */
+struct dfs_pulse dfs_fcc_radars[] = {
+	/* FCC TYPE 1 */
+	{18,  1,  700, 700, 0,  6,  5,  0,  1, 18,  0, 3,  1, 0},
+	{18,  1,  350, 350, 0,  6,  5,  0,  1, 18,  0, 3,  0, 0},
+
+	/* FCC TYPE 6 */
+	{9,   1, 3003, 3003, 1,  7,  5,  0,  1, 18,  0, 0,  1, 1},
+
+	/* FCC TYPE 2 */
+	{23, 5, 4347, 6666, 0, 18, 11,  0,  7, 22,  0, 3,  0, 2},
+
+	/* FCC TYPE 3 */
+	{18, 10, 2000, 5000, 0, 23,  8,  6, 13, 22,  0, 3, 0, 5},
+
+	/* FCC TYPE 4 */
+	{16, 15, 2000, 5000, 0, 25,  7, 11, 23, 22,  0, 3, 0, 11},
+
+	/* FCC NEW TYPE 1 */
+	/* 518us to 938us pulses (min 56 pulses) */
+	{57, 1, 1066, 1930, 0, 6, 20,  0,  1, 22,  0, 3,  0, 21},
+
+	/* 938us to 2000 pulses (min 26 pulses) */
+	{27, 1,  500, 1066, 0, 6, 13,  0,  1, 22,  0, 3,  0, 22},
+
+	/* 2000 to 3067us pulses (min 17 pulses) */
+	{18, 1,  325,  500, 0, 6,  9,  0,  1, 22,  0, 3,  0, 23},
+};
+
+/**
+ * struct dfs_pulse dfs_mkk4_radars - MKK4 radar table for Offload chipsets.
+ */
+struct dfs_pulse dfs_mkk4_radars[] = {
+
+	/* following two filters are specific to Japan/MKK4 */
+	/* 1389 +/- 6 us */
+	{18,  1,  720,  720, 0,  6,  6,  0,  1, 18,  0, 3, 0, 17},
+
+	/* 4000 +/- 6 us */
+	{18,  4,  250,  250, 0, 10,  5,  1,  6, 18,  0, 3, 0, 18},
+
+	/* 3846 +/- 7 us */
+	{18,  5,  260,  260, 0, 10,  6,  1,  6, 18,  0, 3, 1, 19},
+
+	/* following filters are common to both FCC and JAPAN */
+
+	/* FCC TYPE 1 */
+	{18,  1,  700, 700, 0,  6,  5,  0,  1, 18,  0, 3,  1, 0},
+	{18,  1,  350, 350, 0,  6,  5,  0,  1, 18,  0, 3,  0, 0},
+
+	/* FCC TYPE 6 */
+	{9,   1, 3003, 3003, 1,  7,  5,  0,  1, 18,  0, 0, 1,  1},
+
+	/* FCC TYPE 2 */
+	{23, 5, 4347, 6666, 0, 18, 11,  0,  7, 22,  0, 3,  0, 2},
+
+	/* FCC TYPE 3 */
+	{18, 10, 2000, 5000, 0, 23,  8,  6, 13, 22,  0, 3, 0, 5},
+
+	/* FCC TYPE 4 */
+	{16, 15, 2000, 5000, 0, 25,  7, 11, 23, 22,  0, 3, 0, 11},
+};
+
+/**
+ * struct dfs_bin5pulse dfs_fcc_bin5pulses - FCC BIN5 pulses for Offload
+ *                                           chipsets.
+ */
+struct dfs_bin5pulse dfs_fcc_bin5pulses[] = {
+	{4, 28, 105, 12, 22, 5},
+};
+
+/**
+ * struct dfs_bin5pulse dfs_jpn_bin5pulses - JAPAN BIN5 pulses for Offload
+ *                                           chipsets.
+ */
+struct dfs_bin5pulse dfs_jpn_bin5pulses[] = {
+	{5, 28, 105, 12, 22, 5},
+};
+
+/**
+ * dfs_bin5pulse dfs_fcc_bin5pulses_ar900b - FCC BIN5 pulses for AR9300
+ *                                           chipsets.
+ *
+ * WAR : IR 42631
+ * Beeliner 2 is tested at -65dbm as opposed to -62 dbm.
+ * For FCC/JPN chirping pulses, HW reports RSSI value that is lower by 2dbm
+ * when we enable noise floor claibration. This is specially true for
+ * frequencies that are greater than center frequency and in VHT80 mode.
+ */
+
+struct dfs_bin5pulse dfs_fcc_bin5pulses_ar900b[] = {
+	{4, 28, 105, 12, 20, 5},
+};
+
+/**
+ * dfs_bin5pulse dfs_jpn_bin5pulses_ar900b - JAPAN BIN5 pulses for AR9300
+ *                                           chipsets.
+ */
+struct dfs_bin5pulse dfs_jpn_bin5pulses_ar900b[] = {
+	{5, 28, 105, 12, 20, 5},
+};
+
+/**
+ * dfs_bin5pulse dfs_fcc_bin5pulses_qca9984 - FCC BIN5 pulses for QCA9984
+ *                                            chipsets.
+ * WAR : IR-83400
+ * Cascade is tested at -65dbm as opposed to -62 dbm.
+ * For FCC/JPN chirping pulses, HW reports RSSI value that is significantly
+ * lower at left edge especially in HT80_80 mode. Also, duration may be
+ * significantly low. This can result in false detection and we may have to
+ * raise the threshold.
+ */
+struct dfs_bin5pulse dfs_fcc_bin5pulses_qca9984[] = {
+	{4, 20, 105, 12, 20, 0},
+};
+
+/**
+ * dfs_bin5pulse dfs_jpn_bin5pulses_qca9984 - JAPAN BIN5 pulses for QCA9984
+ *                                            chipsets.
+ */
+struct dfs_bin5pulse dfs_jpn_bin5pulses_qca9984[] = {
+	{5, 20, 105, 12, 20, 0},
+};
+
+/**
+ * dfs_pulse dfs_etsi_radars - ETSI radar table.
+ */
+struct dfs_pulse dfs_etsi_radars[] = {
+
+	/* TYPE staggered pulse */
+	/* Type 5*/
+	/* 0.8-2us, 2-3 bursts,300-400 PRF, 10 pulses each */
+	{30,  2,  300,  400, 2, 30,  3,  0,  5, 15, 0,   0, 1, 31},
+	/* Type 6 */
+	/* 0.8-2us, 2-3 bursts, 400-1200 PRF, 15 pulses each */
+	{30,  2,  400, 1200, 2, 30,  7,  0,  5, 15, 0,   0, 0, 32},
+
+	/* constant PRF based */
+	/* Type 1 */
+	/* 0.8-5us, 200  300 PRF, 10 pulses */
+	{10, 5,   200,  400, 0, 24,  5,  0,  8, 15, 0,   0, 2, 33},
+	{10, 5,   400,  600, 0, 24,  5,  0,  8, 15, 0,   0, 2, 37},
+	{10, 5,   600,  800, 0, 24,  5,  0,  8, 15, 0,   0, 2, 38},
+	{10, 5,   800, 1000, 0, 24,  5,  0,  8, 15, 0,   0, 2, 39},
+
+	/* Type 2 */
+	/* 0.8-15us, 200-1600 PRF, 15 pulses */
+	{15, 15,  200, 1600, 0, 24, 8,  0, 18, 24, 0,   0, 0, 34},
+
+	/* Type 3 */
+	/* 0.8-15us, 2300-4000 PRF, 25 pulses*/
+	{25, 15, 2300, 4000,  0, 24, 10, 0, 18, 24, 0,   0, 0, 35},
+
+	/* Type 4 */
+	/* 20-30us, 2000-4000 PRF, 20 pulses*/
+	{20, 30, 2000, 4000, 0, 24, 6, 19, 33, 24, 0,   0, 0, 36},
+};
+
+/**
+ * dfs_pulse dfs_china_radars - CHINA radar table.
+ */
+struct dfs_pulse dfs_china_radars[] = {
+
+	/* TYPE staggered pulse */
+	/* Type 5*/
+	/* 0.8-2us, 2-3 bursts,300-400 PRF, 12 pulses each */
+	{36,  2,  300,  400, 2, 30,  3,  0,  5, 15, 0,   0, 1, 51},
+	/* Type 6 */
+	/* 0.8-2us, 2-3 bursts, 400-1200 PRF, 16 pulses each */
+	{48,  2,  400, 1200, 2, 30,  7,  0,  5, 15, 0,   0, 0, 52},
+
+	/* constant PRF based */
+	/* Type 1 */
+	/* 0.5-5us, 200  1000 PRF, 12 pulses */
+	{12, 5,   200,  400, 0, 24,  5,  0,  8, 15, 0,   0, 2, 53},
+	{12, 5,   400,  600, 0, 24,  5,  0,  8, 15, 0,   0, 2, 57},
+	{12, 5,   600,  800, 0, 24,  5,  0,  8, 15, 0,   0, 2, 58},
+	{12, 5,   800, 1000, 0, 24,  5,  0,  8, 15, 0,   0, 2, 59},
+
+	/* Type 2 */
+	/* 0.5-15us, 200-1600 PRF, 16 pulses */
+	{16, 15,  200, 1600, 0, 24, 8,  0, 18, 24, 0,   0, 0, 54},
+
+	/* Type 3 */
+	/* 0.5-30us, 2300-4000 PRF, 24 pulses*/
+	{24, 15, 2300, 4000,  0, 24, 10, 0, 33, 24, 0,   0, 0, 55},
+
+	/* Type 4 */
+	/* 20-30us, 2000-4000 PRF, 20 pulses*/
+	{20, 30, 2000, 4000, 0, 24, 6, 19, 33, 24, 0,   0, 0, 56},
+
+	/* 1us, 1000 PRF, 20 pulses */
+	/* 1000 us PRI */
+	{20,  1, 1000, 1000, 0,  6,  6,  0,  1, 18,  0, 3, 0, 50},
+};
+
+/**
+ * dfs_pulse dfs_korea_radars - KOREA radar table.
+ */
+struct dfs_pulse dfs_korea_radars[] = {
+	/* Korea Type 1 */
+	{18,  1,  700, 700,  0, 6,  5,  0,  1, 18,  0, 3,  1, 40},
+
+	/* Korea Type 2 */
+	{10,  1, 1800, 1800, 0, 6,  4,  0,  1, 18,  0, 3,  1, 41},
+
+	/* Korea Type 3 */
+	{70,  1,  330, 330,  0, 6, 20,  0,  2, 18,  0, 3,  1, 42},
+
+	/* Korea Type 4 */
+	{3,   1, 3003, 3003, 1, 7,  2,  0,  1, 18,  0, 0, 1,  43},
+};
+
+#define TARGET_TYPE_AR900B    9
+#define TARGET_TYPE_QCA9984   10
+#define TARGET_TYPE_IPQ4019   11
+#define TARGET_TYPE_QCA9888   12
+#define RSSI_THERSH_AR900B    15
+
+void ol_if_dfs_configure(struct wlan_dfs *dfs)
+{
+	struct wlan_dfs_radar_tab_info rinfo;
+	int i;
+	uint32_t target_type;
+	int dfsdomain = DFS_FCC_DOMAIN;
+
+	DFS_PRINTK(KERN_DEBUG"%s: called\n", __func__);
+
+	/* Fetch current radar patterns from the lmac */
+	qdf_mem_zero(&rinfo, sizeof(rinfo));
+
+	/*
+	 * Look up the current DFS regulatory domain and decide
+	 * which radar pulses to use.
+	 */
+	dfsdomain = lmac_get_dfsdomain(dfs->dfs_pdev_obj);
+	target_type = lmac_get_target_type(dfs->dfs_pdev_obj);
+
+	switch (dfsdomain) {
+	case DFS_FCC_DOMAIN:
+		DFS_PRINTK("%s: FCC domain\n", __func__);
+		rinfo.dfsdomain = DFS_FCC_DOMAIN;
+		/*
+		 * China uses a radar pattern that is similar to ETSI but it
+		 * follows FCC in all other respect like transmit power, CCA
+		 * threshold etc.
+		 */
+		if (lmac_is_countryCode_CHINA(dfs->dfs_pdev_obj)) {
+			DFS_PRINTK(
+					"%s: FCC domain -- Country China(156) override FCC radar pattern\n",
+					__func__);
+			rinfo.dfs_radars = dfs_china_radars;
+			rinfo.numradars = QDF_ARRAY_SIZE(dfs_china_radars);
+			rinfo.b5pulses = NULL;
+			rinfo.numb5radars = 0;
+		} else {
+			rinfo.dfs_radars = dfs_fcc_radars;
+			rinfo.numradars = QDF_ARRAY_SIZE(dfs_fcc_radars);
+
+			if (target_type == TARGET_TYPE_AR900B ||
+					target_type == TARGET_TYPE_IPQ4019) {
+				rinfo.b5pulses = dfs_fcc_bin5pulses_ar900b;
+				rinfo.numb5radars = QDF_ARRAY_SIZE(
+						dfs_fcc_bin5pulses_ar900b);
+			} else if (target_type == TARGET_TYPE_QCA9984 ||
+					target_type == TARGET_TYPE_QCA9888) {
+				rinfo.b5pulses = dfs_fcc_bin5pulses_qca9984;
+				rinfo.numb5radars = QDF_ARRAY_SIZE(
+						dfs_fcc_bin5pulses_qca9984);
+			} else {
+				rinfo.b5pulses = dfs_fcc_bin5pulses;
+				rinfo.numb5radars =
+					QDF_ARRAY_SIZE(dfs_fcc_bin5pulses);
+			}
+		}
+
+		break;
+	case DFS_ETSI_DOMAIN:
+		DFS_PRINTK("%s: ETSI domain\n", __func__);
+		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
+		rinfo.dfs_radars = dfs_etsi_radars;
+		rinfo.numradars = QDF_ARRAY_SIZE(dfs_etsi_radars);
+
+		/*
+		 * So far we have treated Korea as part of ETSI and did not
+		 * support any radar patters specific to Korea other than
+		 * standard ETSI radar patterns. Ideally we would want to
+		 * treat Korea as a different domain. This is something that
+		 * we will address in the future. However, for now override
+		 * ETSI tables for Korea.
+		 */
+
+		if (lmac_is_countryCode_KOREA_ROC3(dfs->dfs_pdev_obj)) {
+			DFS_PRINTK(
+					"%s: ETSI domain -- Korea(412)\n",
+					__func__);
+			rinfo.dfs_radars = dfs_korea_radars;
+			rinfo.numradars = QDF_ARRAY_SIZE(dfs_korea_radars);
+		}
+
+		rinfo.b5pulses = NULL;
+		rinfo.numb5radars = 0;
+		break;
+	case DFS_MKK4_DOMAIN:
+		DFS_PRINTK("%s: MKK4 domain\n", __func__);
+		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
+		rinfo.dfs_radars = dfs_mkk4_radars;
+		rinfo.numradars = QDF_ARRAY_SIZE(dfs_mkk4_radars);
+
+		if (target_type == TARGET_TYPE_AR900B ||
+				target_type == TARGET_TYPE_IPQ4019) {
+			rinfo.b5pulses = dfs_jpn_bin5pulses_ar900b;
+			rinfo.numb5radars = QDF_ARRAY_SIZE(
+					dfs_jpn_bin5pulses_ar900b);
+		} else if (target_type == TARGET_TYPE_QCA9984 ||
+				target_type == TARGET_TYPE_QCA9888) {
+			rinfo.b5pulses = dfs_jpn_bin5pulses_qca9984;
+			rinfo.numb5radars = QDF_ARRAY_SIZE
+				(dfs_jpn_bin5pulses_qca9984);
+		} else {
+			rinfo.b5pulses = dfs_jpn_bin5pulses;
+			rinfo.numb5radars = QDF_ARRAY_SIZE(
+					dfs_jpn_bin5pulses);
+		}
+		break;
+	default:
+		DFS_PRINTK("%s: UNINIT domain\n", __func__);
+		rinfo.dfsdomain = DFS_UNINIT_DOMAIN;
+		rinfo.dfs_radars = NULL;
+		rinfo.numradars = 0;
+		rinfo.b5pulses = NULL;
+		rinfo.numb5radars = 0;
+		break;
+	}
+
+	if (target_type == TARGET_TYPE_AR900B ||
+			target_type == TARGET_TYPE_IPQ4019 ||
+			target_type == TARGET_TYPE_QCA9984 ||
+			target_type == TARGET_TYPE_QCA9888) {
+		/* Beeliner WAR: lower RSSI threshold to improve detection of
+		 * certian radar types
+		 */
+		/* Cascade WAR:
+		 * Cascade can report lower RSSI near the channel boundary then
+		 * expected. It can also report significantly low RSSI at center
+		 * (as low as 16) at center. So we are lowering threshold for
+		 * all types of radar for * Cascade.
+		 * This may increase the possibility of false radar detection.
+		 * IR -- 083703, 083398, 083387
+		 */
+
+		for (i = 0; i < rinfo.numradars; i++)
+			rinfo.dfs_radars[i].rp_rssithresh = RSSI_THERSH_AR900B;
+	}
+
+	dfs_init_radar_filters(dfs, &rinfo);
+}
+
+void dfs_get_radars(struct wlan_dfs *dfs)
+{
+#define AR5212_DEVID_IBM            0x1014 /* IBM minipci ID */
+#define AR5212_AR2413               0x001a /* AR2413 aka Griffin-lite */
+#define AR5212_AR2413               0x001a /* AR2413 aka Griffin-lite */
+#define AR5212_AR5413               0x001b /* Eagle */
+#define AR5212_AR5424               0x001c /* Condor (PCI express) */
+#define AR5212_DEVID_FF19           0xff19 /* PCI express */
+#define AR5212_AR2417               0x001d /* Nala, PCI */
+#define AR5212_DEVID                0x0013 /* Final ar5212 devid */
+#define AR5212_FPGA                 0xf013 /* Emulation board */
+#define AR5212_DEFAULT              0x1113 /* No eeprom HW default */
+
+#define AR5416_DEVID_PCI            0x0023 /* AR5416 PCI (CB/MB) (Owl)*/
+#define AR5416_DEVID_PCIE           0x0024 /* AR5416 PCI-E (XB) (Owl) */
+#define AR5416_DEVID_AR9160_PCI     0x0027 /* AR9160 PCI (Sowl) */
+#define AR5416_AR9100_DEVID         0x000b /* AR9100 (Howl)    */
+#define AR5416_DEVID_AR9280_PCI     0x0029 /* PCI (Merlin) */
+#define AR5416_DEVID_AR9280_PCIE    0x002a /* PCIE (Merlin) */
+#define AR5416_DEVID_AR9285_PCIE    0x002b /* PCIE (Kite) */
+#define AR5416_DEVID_AR9285G_PCIE   0x002c /* PCIE (Kite G only) */
+#define AR5416_DEVID_AR9287_PCI     0x002d /* PCI (Kiwi) */
+#define AR5416_DEVID_AR9287_PCIE    0x002e /* PCIE (Kiwi) */
+
+#define AR9300_DEVID_AR9380_PCIE    0x0030 /* PCIE (Osprey) */
+#define AR9300_DEVID_AR9340         0x0031 /* Wasp */
+#define AR9300_DEVID_AR9485_PCIE    0x0032 /* Poseidon */
+#define AR9300_DEVID_AR9580_PCIE    0x0033 /* Peacock */
+#define AR9300_DEVID_AR1111_PCIE    0x0037 /* AR1111 */
+#define AR9300_DEVID_AR946X_PCIE    0x0034 /* Jupiter: 2x2 DB + BT - AR9462 */
+#define AR9300_DEVID_AR955X         0x0039 /* Scorpion */
+#define AR9300_DEVID_AR953X         0x003d /* Honey Bee */
+#define AR9300_DEVID_AR956X         0x003f /* Dragonfly */
+#define AR9300_DEVID_AR956X_PCIE    0x0036 /* Aphrodite: 1x1 DB + BT - AR9564 */
+#define AR9300_DEVID_EMU_PCIE       0xabcd
+
+	if (dfs == NULL) {
+		DFS_PRINTK("%s: dfs is NULL\n", __func__);
+		return;
+	}
+
+	if (lmac_is_mode_offload(dfs->dfs_pdev_obj)) {
+		/* For offload */
+		ol_if_dfs_configure(dfs);
+	} else {
+		uint16_t devid = lmac_get_ah_devid(dfs->dfs_pdev_obj);
+		/* For DA */
+
+		switch (devid) {
+		case AR5212_DEVID_IBM:
+		case AR5212_AR2413:
+		case AR5212_AR5413:
+		case AR5212_AR5424:
+		case AR5212_DEVID_FF19:
+			devid = AR5212_DEVID;
+		case AR5212_AR2417:
+		case AR5212_DEVID:
+		case AR5212_FPGA:
+		case AR5212_DEFAULT:
+			dfs_get_radars_for_ar5212(dfs);
+			break;
+		case AR5416_DEVID_PCI:
+		case AR5416_DEVID_PCIE:
+		case AR5416_DEVID_AR9160_PCI:
+		case AR5416_AR9100_DEVID:
+		case AR5416_DEVID_AR9280_PCI:
+		case AR5416_DEVID_AR9280_PCIE:
+		case AR5416_DEVID_AR9285_PCIE:
+		case AR5416_DEVID_AR9285G_PCIE:
+		case AR5416_DEVID_AR9287_PCI:
+		case AR5416_DEVID_AR9287_PCIE:
+			dfs_get_radars_for_ar5416(dfs);
+			break;
+		case AR9300_DEVID_AR9380_PCIE:
+		case AR9300_DEVID_AR9340:
+		case AR9300_DEVID_AR9485_PCIE:
+		case AR9300_DEVID_AR9580_PCIE:
+		case AR9300_DEVID_AR1111_PCIE:
+		case AR9300_DEVID_AR946X_PCIE:
+		case AR9300_DEVID_AR955X:
+		case AR9300_DEVID_AR953X:
+		case AR9300_DEVID_AR956X:
+		case AR9300_DEVID_AR956X_PCIE:
+		case AR9300_DEVID_EMU_PCIE:
+			dfs_get_radars_for_ar9300(dfs);
+			break;
+		}
+	}
+}
+
+void dfs_radar_found_action(struct wlan_dfs *dfs)
+{
+	if (dfs->dfs_rinfo.rn_use_nol == 1) {
+		/*
+		 * If precac is running and the radar found in secondary
+		 * VHT80 mark the channel as radar and add to NOL list.
+		 * Otherwise random channel selection can choose this
+		 * channel.
+		 */
+		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
+				"%s : found_on_second = %d is_pre = %d\n",
+				__func__,
+				dfs->is_radar_found_on_secondary_seg,
+				dfs_is_precac_timer_running(dfs));
+
+		if (dfs->is_radar_found_on_secondary_seg &&
+				dfs_is_precac_timer_running(dfs)) {
+			/* Get a VHT80 channel and mark it */
+			struct dfs_ieee80211_channel *ichan;
+
+			dfs_find_precac_secondary_vht80_chan(dfs, &ichan);
+			dfs_mlme_channel_mark_radar(dfs->dfs_pdev_obj,
+					ichan->ic_freq,
+					ichan->ic_vhtop_ch_freq_seg2,
+					ichan->ic_flags);
+		} else {
+			dfs_mlme_channel_mark_radar(dfs->dfs_pdev_obj,
+					dfs->dfs_curchan->ic_freq,
+					dfs->dfs_curchan->ic_vhtop_ch_freq_seg2,
+					dfs->dfs_curchan->ic_flags);
+		}
+	}
+
+	/*
+	 * Even if radar found on primary, we need to move the channel
+	 * from precac-required-list and precac-done-list to
+	 * precac-nol-list.
+	 */
+	if (dfs->dfs_rinfo.rn_use_nol == 1) {
+		dfs_mark_precac_dfs(dfs,
+				dfs->is_radar_found_on_secondary_seg);
+	}
+
+	if (dfs->is_radar_found_on_secondary_seg) {
+		dfs_second_segment_radar_disable(dfs);
+		dfs->is_radar_found_on_secondary_seg = 0;
+		if (dfs->is_radar_during_precac) {
+			dfs->is_radar_during_precac = 0;
+			goto radar_process_end;
+		}
+	}
+
+	/*
+	 * This calls into the umac DFS code, which sets the umac
+	 * related radar flags and begins the channel change
+	 * machinery.
+	 * XXX TODO: the umac NOL code isn't used, but
+	 * IEEE80211_CHAN_DFS_RADAR still gets set. Since the umac
+	 * NOL code isn't used, that flag is never cleared. This
+	 * needs to be fixed. See EV 105776.
+	 */
+	if (dfs->dfs_rinfo.rn_use_nol == 1)  {
+		dfs_mlme_start_rcsa(dfs->dfs_pdev_obj);
+		dfs_mlme_mark_dfs(dfs->dfs_pdev_obj,
+				dfs->dfs_curchan->ic_ieee,
+				dfs->dfs_curchan->ic_freq,
+				dfs->dfs_curchan->ic_vhtop_ch_freq_seg2,
+				dfs->dfs_curchan->ic_flags);
+		/*
+		 * EV 129487 : We have detected radar in the channel,
+		 * stop processing PHY error data as this can cause
+		 * false detect in the new channel while channel
+		 * change is in progress.
+		 */
+		dfs_radar_disable(dfs);
+		dfs_second_segment_radar_disable(dfs);
+	} else if (dfs->dfs_rinfo.rn_use_nol == 0) {
+		/*
+		 * For the test mode, don't do a CSA here; but setup
+		 * the test timer so we get a CSA _back_ to the
+		 * original channel.
+		 */
+		qdf_timer_stop(&dfs->wlan_dfstesttimer);
+		dfs->wlan_dfstest = 1;
+		dfs->wlan_dfstest_ieeechan = dfs->dfs_curchan->ic_ieee;
+		dfs->wlan_dfstesttime = 1;   /* 1ms */
+		OS_SET_TIMER(&dfs->wlan_dfstesttimer,
+				dfs->wlan_dfstesttime);
+	}
+
+radar_process_end:
+	return;
+}