Linux Audio

Check our new training course

Loading...
v3.1
  1#ifndef __NET_REGULATORY_H
  2#define __NET_REGULATORY_H
  3/*
  4 * regulatory support structures
  5 *
  6 * Copyright 2008-2009	Luis R. Rodriguez <lrodriguez@atheros.com>
  7 *
  8 * This program is free software; you can redistribute it and/or modify
  9 * it under the terms of the GNU General Public License version 2 as
 10 * published by the Free Software Foundation.
 
 
 
 
 
 
 
 
 11 */
 12
 13
 14/**
 15 * enum environment_cap - Environment parsed from country IE
 16 * @ENVIRON_ANY: indicates country IE applies to both indoor and
 17 *	outdoor operation.
 18 * @ENVIRON_INDOOR: indicates country IE applies only to indoor operation
 19 * @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation
 20 */
 21enum environment_cap {
 22	ENVIRON_ANY,
 23	ENVIRON_INDOOR,
 24	ENVIRON_OUTDOOR,
 25};
 26
 27/**
 28 * struct regulatory_request - used to keep track of regulatory requests
 29 *
 30 * @wiphy_idx: this is set if this request's initiator is
 31 * 	%REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This
 32 * 	can be used by the wireless core to deal with conflicts
 33 * 	and potentially inform users of which devices specifically
 34 * 	cased the conflicts.
 35 * @initiator: indicates who sent this request, could be any of
 36 * 	of those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*)
 37 * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested
 38 * 	regulatory domain. We have a few special codes:
 39 * 	00 - World regulatory domain
 40 * 	99 - built by driver but a specific alpha2 cannot be determined
 41 * 	98 - result of an intersection between two regulatory domains
 42 *	97 - regulatory domain has not yet been configured
 
 
 
 
 43 * @intersect: indicates whether the wireless core should intersect
 44 * 	the requested regulatory domain with the presently set regulatory
 45 * 	domain.
 46 * @processed: indicates whether or not this requests has already been
 47 *	processed. When the last request is processed it means that the
 48 *	currently regulatory domain set on cfg80211 is updated from
 49 *	CRDA and can be used by other regulatory requests. When a
 50 *	the last request is not yet processed we must yield until it
 51 *	is processed before processing any new requests.
 52 * @country_ie_checksum: checksum of the last processed and accepted
 53 * 	country IE
 54 * @country_ie_env: lets us know if the AP is telling us we are outdoor,
 55 * 	indoor, or if it doesn't matter
 56 * @list: used to insert into the reg_requests_list linked list
 57 */
 58struct regulatory_request {
 59	int wiphy_idx;
 60	enum nl80211_reg_initiator initiator;
 61	char alpha2[2];
 
 62	bool intersect;
 63	bool processed;
 64	enum environment_cap country_ie_env;
 65	struct list_head list;
 66};
 67
 68struct ieee80211_freq_range {
 69	u32 start_freq_khz;
 70	u32 end_freq_khz;
 71	u32 max_bandwidth_khz;
 72};
 73
 74struct ieee80211_power_rule {
 75	u32 max_antenna_gain;
 76	u32 max_eirp;
 77};
 78
 79struct ieee80211_reg_rule {
 80	struct ieee80211_freq_range freq_range;
 81	struct ieee80211_power_rule power_rule;
 82	u32 flags;
 83};
 84
 85struct ieee80211_regdomain {
 86	u32 n_reg_rules;
 87	char alpha2[2];
 
 88	struct ieee80211_reg_rule reg_rules[];
 89};
 90
 91#define MHZ_TO_KHZ(freq) ((freq) * 1000)
 92#define KHZ_TO_MHZ(freq) ((freq) / 1000)
 93#define DBI_TO_MBI(gain) ((gain) * 100)
 94#define MBI_TO_DBI(gain) ((gain) / 100)
 95#define DBM_TO_MBM(gain) ((gain) * 100)
 96#define MBM_TO_DBM(gain) ((gain) / 100)
 97
 98#define REG_RULE(start, end, bw, gain, eirp, reg_flags) \
 99{							\
100	.freq_range.start_freq_khz = MHZ_TO_KHZ(start),	\
101	.freq_range.end_freq_khz = MHZ_TO_KHZ(end),	\
102	.freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw),	\
103	.power_rule.max_antenna_gain = DBI_TO_MBI(gain),\
104	.power_rule.max_eirp = DBM_TO_MBM(eirp),	\
105	.flags = reg_flags,				\
106}
107
108#endif
v3.5.6
  1#ifndef __NET_REGULATORY_H
  2#define __NET_REGULATORY_H
  3/*
  4 * regulatory support structures
  5 *
  6 * Copyright 2008-2009	Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
  7 *
  8 * Permission to use, copy, modify, and/or distribute this software for any
  9 * purpose with or without fee is hereby granted, provided that the above
 10 * copyright notice and this permission notice appear in all copies.
 11 *
 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 19 */
 20
 21
 22/**
 23 * enum environment_cap - Environment parsed from country IE
 24 * @ENVIRON_ANY: indicates country IE applies to both indoor and
 25 *	outdoor operation.
 26 * @ENVIRON_INDOOR: indicates country IE applies only to indoor operation
 27 * @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation
 28 */
 29enum environment_cap {
 30	ENVIRON_ANY,
 31	ENVIRON_INDOOR,
 32	ENVIRON_OUTDOOR,
 33};
 34
 35/**
 36 * struct regulatory_request - used to keep track of regulatory requests
 37 *
 38 * @wiphy_idx: this is set if this request's initiator is
 39 * 	%REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This
 40 * 	can be used by the wireless core to deal with conflicts
 41 * 	and potentially inform users of which devices specifically
 42 * 	cased the conflicts.
 43 * @initiator: indicates who sent this request, could be any of
 44 * 	of those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*)
 45 * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested
 46 * 	regulatory domain. We have a few special codes:
 47 * 	00 - World regulatory domain
 48 * 	99 - built by driver but a specific alpha2 cannot be determined
 49 * 	98 - result of an intersection between two regulatory domains
 50 *	97 - regulatory domain has not yet been configured
 51 * @dfs_region: If CRDA responded with a regulatory domain that requires
 52 *	DFS master operation on a known DFS region (NL80211_DFS_*),
 53 *	dfs_region represents that region. Drivers can use this and the
 54 *	@alpha2 to adjust their device's DFS parameters as required.
 55 * @intersect: indicates whether the wireless core should intersect
 56 * 	the requested regulatory domain with the presently set regulatory
 57 * 	domain.
 58 * @processed: indicates whether or not this requests has already been
 59 *	processed. When the last request is processed it means that the
 60 *	currently regulatory domain set on cfg80211 is updated from
 61 *	CRDA and can be used by other regulatory requests. When a
 62 *	the last request is not yet processed we must yield until it
 63 *	is processed before processing any new requests.
 64 * @country_ie_checksum: checksum of the last processed and accepted
 65 * 	country IE
 66 * @country_ie_env: lets us know if the AP is telling us we are outdoor,
 67 * 	indoor, or if it doesn't matter
 68 * @list: used to insert into the reg_requests_list linked list
 69 */
 70struct regulatory_request {
 71	int wiphy_idx;
 72	enum nl80211_reg_initiator initiator;
 73	char alpha2[2];
 74	u8 dfs_region;
 75	bool intersect;
 76	bool processed;
 77	enum environment_cap country_ie_env;
 78	struct list_head list;
 79};
 80
 81struct ieee80211_freq_range {
 82	u32 start_freq_khz;
 83	u32 end_freq_khz;
 84	u32 max_bandwidth_khz;
 85};
 86
 87struct ieee80211_power_rule {
 88	u32 max_antenna_gain;
 89	u32 max_eirp;
 90};
 91
 92struct ieee80211_reg_rule {
 93	struct ieee80211_freq_range freq_range;
 94	struct ieee80211_power_rule power_rule;
 95	u32 flags;
 96};
 97
 98struct ieee80211_regdomain {
 99	u32 n_reg_rules;
100	char alpha2[2];
101	u8 dfs_region;
102	struct ieee80211_reg_rule reg_rules[];
103};
104
105#define MHZ_TO_KHZ(freq) ((freq) * 1000)
106#define KHZ_TO_MHZ(freq) ((freq) / 1000)
107#define DBI_TO_MBI(gain) ((gain) * 100)
108#define MBI_TO_DBI(gain) ((gain) / 100)
109#define DBM_TO_MBM(gain) ((gain) * 100)
110#define MBM_TO_DBM(gain) ((gain) / 100)
111
112#define REG_RULE(start, end, bw, gain, eirp, reg_flags) \
113{							\
114	.freq_range.start_freq_khz = MHZ_TO_KHZ(start),	\
115	.freq_range.end_freq_khz = MHZ_TO_KHZ(end),	\
116	.freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw),	\
117	.power_rule.max_antenna_gain = DBI_TO_MBI(gain),\
118	.power_rule.max_eirp = DBM_TO_MBM(eirp),	\
119	.flags = reg_flags,				\
120}
121
122#endif