linux/drivers/staging/ath6kl/include/common/regulatory/reg_dbschema.h
<<
>>
Prefs
   1//------------------------------------------------------------------------------
   2// Copyright (c) 2005-2010 Atheros Corporation.  All rights reserved.
   3// 
   4//
   5// Permission to use, copy, modify, and/or distribute this software for any
   6// purpose with or without fee is hereby granted, provided that the above
   7// copyright notice and this permission notice appear in all copies.
   8//
   9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16//
  17//
  18//------------------------------------------------------------------------------
  19//==============================================================================
  20// Author(s): ="Atheros"
  21//==============================================================================
  22
  23#ifndef __REG_DBSCHEMA_H__
  24#define __REG_DBSCHEMA_H__
  25
  26/*
  27 * This file describes the regulatory DB schema, which is common between the
  28 * 'generator' and 'parser'. The 'generator' runs on a host(typically a x86
  29 * Linux) and spits outs two binary files, which follow the DB file
  30 * format(described below). The resultant output "regulatoryData_AG.bin"
  31 * is binary file which has information regarding A and G regulatory
  32 * information, while the "regulatoryData_G.bin" consists of G-ONLY regulatory
  33 * information. This binary file is parsed in the target for extracting
  34 * regulatory information.
  35 * 
  36 * The DB values used to populate the regulatory DB are defined in
  37 * reg_dbvalues.h
  38 *
  39 */
  40
  41/* Binary data file - Representation of Regulatory DB*/
  42#define REG_DATA_FILE_AG    "./regulatoryData_AG.bin"
  43#define REG_DATA_FILE_G     "./regulatoryData_G.bin"
  44
  45
  46/* Table tags used to encode different tables in the database */
  47enum data_tags_t{
  48    REG_DMN_PAIR_MAPPING_TAG = 0,
  49    REG_COUNTRY_CODE_TO_ENUM_RD_TAG,
  50    REG_DMN_FREQ_BAND_regDmn5GhzFreq_TAG,
  51    REG_DMN_FREQ_BAND_regDmn2Ghz11_BG_Freq_TAG,
  52    REG_DOMAIN_TAG,
  53    MAX_DB_TABLE_TAGS
  54    };
  55
  56
  57
  58/*
  59 ****************************************************************************
  60 * Regulatory DB file format :
  61 * 4-bytes : "RGDB" (Magic Key)
  62 * 4-bytes : version (Default is 5379(my extn))
  63 * 4-bytes : length of file
  64 * dbType(4)
  65 * TAG(4)
  66 * Entries(1)entrySize(1)searchType(1)reserved[3]tableSize(2)"0xdeadbeef"(4)struct_data....
  67 * TAG(4)
  68 * Entries(1)entrySize(1)searchType(1)reserved[3]tableSize(2)"0xdeadbeef"(4)struct_data....
  69 * TAG(4)
  70 * Entries(1)entrySize(1)searchType(1)reserved[3]tableSize(2)"0xdeadbeef"(4)struct_data....
  71 * ...
  72 * ...
  73 ****************************************************************************
  74 *
  75 */
  76
  77/*
  78 * Length of the file would be filled in when the file is created and
  79 * it would include the header size.
  80 */
  81
  82#define REG_DB_KEY          "RGDB" /* Should be EXACTLY 4-bytes */
  83#define REG_DB_VER           7802  /* Between 0-9999 */
  84/*  REG_DB_VER history in reverse chronological order: 
  85 *  7802: 78 (ASCII code of N) + 02 (minor version number) - updated 10/21/09 
  86 *  7801: 78 (ASCII code of N) + 01 (minor version number, increment on further changes)
  87 *  1178: '11N' = 11 + ASCII code of N(78)
  88 *  5379: initial version, no 11N support
  89 */
  90#define MAGIC_KEY_OFFSET    0
  91#define VERSION_OFFSET      4
  92#define FILE_SZ_OFFSET      8
  93#define DB_TYPE_OFFSET      12
  94
  95#define MAGIC_KEY_SZ        4
  96#define VERSION_SZ          4
  97#define FILE_SZ_SZ          4
  98#define DB_TYPE_SZ          4
  99#define DB_TAG_SZ           4
 100
 101#define REGDB_GET_MAGICKEY(x)     ((char *)x + MAGIC_KEY_OFFSET) 
 102#define REGDB_GET_VERSION(x)      ((char *)x + VERSION_OFFSET)
 103#define REGDB_GET_FILESIZE(x)     *((unsigned int *)((char *)x + FILE_SZ_OFFSET))
 104#define REGDB_GET_DBTYPE(x)       *((char *)x + DB_TYPE_OFFSET)
 105
 106#define REGDB_SET_FILESIZE(x, sz_) *((unsigned int *)((char *)x + FILE_SZ_OFFSET)) = (sz_)
 107#define REGDB_IS_EOF(cur, begin)  ( REGDB_GET_FILESIZE(begin) > ((cur) - (begin)) )
 108
 109
 110/* A Table can be search based on key as a parameter or accessed directly
 111 * by giving its index in to the table.
 112 */
 113enum searchType {
 114    KEY_BASED_TABLE_SEARCH = 1,
 115    INDEX_BASED_TABLE_ACCESS
 116    };
 117
 118
 119/* Data is organised as different tables. There is a Master table, which
 120 * holds information regarding all the tables. It does not have any
 121 * knowledge about the attributes of the table it is holding
 122 * but has external view of the same(for ex, how many entries, record size,
 123 * how to search the table, total table size and reference to the data
 124 * instance of table).
 125 */
 126typedef PREPACK struct dbMasterTable_t {    /* Hold ptrs to Table data structures */
 127    A_UCHAR     numOfEntries;
 128    A_CHAR      entrySize;      /* Entry size per table row */
 129    A_CHAR      searchType;     /* Index based access or key based */
 130    A_CHAR      reserved[3];    /* for alignment */
 131    A_UINT16    tableSize;      /* Size of this table */
 132    A_CHAR      *dataPtr;       /* Ptr to the actual Table */
 133} POSTPACK dbMasterTable;    /* Master table - table of tables */
 134
 135
 136/* used to get the number of rows in a table */
 137#define REGDB_NUM_OF_ROWS(a)    (sizeof (a) / sizeof (a[0]))
 138
 139/* 
 140 * Used to set the RegDomain bitmask which chooses which frequency
 141 * band specs are used.
 142 */
 143
 144#define BMLEN 2         /* Use 2 32-bit uint for channel bitmask */
 145#define BMZERO {0,0}    /* BMLEN zeros */
 146
 147#define BM(_fa, _fb, _fc, _fd, _fe, _ff, _fg, _fh) \
 148      {((((_fa >= 0) && (_fa < 32)) ? (((A_UINT32) 1) << _fa) : 0) | \
 149    (((_fb >= 0) && (_fb < 32)) ? (((A_UINT32) 1) << _fb) : 0) | \
 150    (((_fc >= 0) && (_fc < 32)) ? (((A_UINT32) 1) << _fc) : 0) | \
 151    (((_fd >= 0) && (_fd < 32)) ? (((A_UINT32) 1) << _fd) : 0) | \
 152    (((_fe >= 0) && (_fe < 32)) ? (((A_UINT32) 1) << _fe) : 0) | \
 153    (((_ff >= 0) && (_ff < 32)) ? (((A_UINT32) 1) << _ff) : 0) | \
 154    (((_fg >= 0) && (_fg < 32)) ? (((A_UINT32) 1) << _fg) : 0) | \
 155    (((_fh >= 0) && (_fh < 32)) ? (((A_UINT32) 1) << _fh) : 0)), \
 156       ((((_fa > 31) && (_fa < 64)) ? (((A_UINT32) 1) << (_fa - 32)) : 0) | \
 157        (((_fb > 31) && (_fb < 64)) ? (((A_UINT32) 1) << (_fb - 32)) : 0) | \
 158        (((_fc > 31) && (_fc < 64)) ? (((A_UINT32) 1) << (_fc - 32)) : 0) | \
 159        (((_fd > 31) && (_fd < 64)) ? (((A_UINT32) 1) << (_fd - 32)) : 0) | \
 160        (((_fe > 31) && (_fe < 64)) ? (((A_UINT32) 1) << (_fe - 32)) : 0) | \
 161        (((_ff > 31) && (_ff < 64)) ? (((A_UINT32) 1) << (_ff - 32)) : 0) | \
 162        (((_fg > 31) && (_fg < 64)) ? (((A_UINT32) 1) << (_fg - 32)) : 0) | \
 163        (((_fh > 31) && (_fh < 64)) ? (((A_UINT32) 1) << (_fh - 32)) : 0))}
 164
 165
 166/*
 167 * THE following table is the mapping of regdomain pairs specified by
 168 * a regdomain value to the individual unitary reg domains
 169 */
 170
 171typedef PREPACK struct reg_dmn_pair_mapping {
 172    A_UINT16 regDmnEnum;    /* 16 bit reg domain pair */
 173    A_UINT16 regDmn5GHz;    /* 5GHz reg domain */
 174    A_UINT16 regDmn2GHz;    /* 2GHz reg domain */
 175    A_UINT8  flags5GHz;     /* Requirements flags (AdHoc disallow etc) */
 176    A_UINT8  flags2GHz;     /* Requirements flags (AdHoc disallow etc) */
 177    A_UINT32 pscanMask;     /* Passive Scan flags which can override unitary domain passive scan
 178                                   flags.  This value is used as a mask on the unitary flags*/
 179} POSTPACK REG_DMN_PAIR_MAPPING;
 180
 181#define OFDM_YES (1 << 0)
 182#define OFDM_NO  (0 << 0)
 183#define MCS_HT20_YES   (1 << 1)
 184#define MCS_HT20_NO    (0 << 1)
 185#define MCS_HT40_A_YES (1 << 2)
 186#define MCS_HT40_A_NO  (0 << 2)
 187#define MCS_HT40_G_YES (1 << 3)
 188#define MCS_HT40_G_NO  (0 << 3)
 189
 190typedef PREPACK struct {
 191    A_UINT16    countryCode;       
 192    A_UINT16    regDmnEnum;
 193    A_CHAR      isoName[3];
 194    A_CHAR      allowMode;  /* what mode is allowed - bit 0: OFDM; bit 1: MCS_HT20; bit 2: MCS_HT40_A; bit 3: MCS_HT40_G */
 195} POSTPACK COUNTRY_CODE_TO_ENUM_RD;
 196
 197/* lower 16 bits of ht40ChanMask */
 198#define NO_FREQ_HT40    0x0     /* no freq is HT40 capable */
 199#define F1_TO_F4_HT40   0xF     /* freq 1 to 4 in the block is ht40 capable */
 200#define F2_TO_F3_HT40   0x6     /* freq 2 to 3 in the block is ht40 capable */
 201#define F1_TO_F10_HT40  0x3FF   /* freq 1 to 10 in the block is ht40 capable */
 202#define F3_TO_F11_HT40  0x7FC   /* freq 3 to 11 in the block is ht40 capable */
 203#define F3_TO_F9_HT40   0x1FC   /* freq 3 to 9 in the block is ht40 capable */
 204#define F1_TO_F8_HT40   0xFF    /* freq 1 to 8 in the block is ht40 capable */
 205#define F1_TO_F4_F9_TO_F10_HT40   0x30F    /* freq 1 to 4, 9 to 10 in the block is ht40 capable */
 206
 207/* upper 16 bits of ht40ChanMask */
 208#define FREQ_HALF_RATE      0x10000
 209#define FREQ_QUARTER_RATE   0x20000
 210
 211typedef PREPACK struct RegDmnFreqBand {
 212    A_UINT16    lowChannel;     /* Low channel center in MHz */
 213    A_UINT16    highChannel;    /* High Channel center in MHz */
 214    A_UINT8     power;          /* Max power (dBm) for channel range */
 215    A_UINT8     channelSep;     /* Channel separation within the band */
 216    A_UINT8     useDfs;         /* Use DFS in the RegDomain if corresponding bit is set */
 217    A_UINT8     mode;           /* Mode of operation */
 218    A_UINT32    usePassScan;    /* Use Passive Scan in the RegDomain if corresponding bit is set */
 219    A_UINT32    ht40ChanMask;   /* lower 16 bits: indicate which frequencies in the block is HT40 capable 
 220                                   upper 16 bits: what rate (half/quarter) the channel is  */
 221} POSTPACK REG_DMN_FREQ_BAND;
 222
 223
 224
 225typedef PREPACK struct regDomain {
 226    A_UINT16    regDmnEnum;     /* value from EnumRd table */
 227    A_UINT8     rdCTL;
 228    A_UINT8     maxAntGain;
 229    A_UINT8     dfsMask;        /* DFS bitmask for 5Ghz tables */
 230    A_UINT8     flags;          /* Requirement flags (AdHoc disallow etc) */
 231    A_UINT16    reserved;       /* for alignment */
 232    A_UINT32    pscan;          /* Bitmask for passive scan */
 233    A_UINT32    chan11a[BMLEN]; /* 64 bit bitmask for channel/band selection */
 234    A_UINT32    chan11bg[BMLEN];/* 64 bit bitmask for channel/band selection */
 235} POSTPACK REG_DOMAIN;
 236
 237#endif /* __REG_DBSCHEMA_H__ */
 238