Beispiel #1
0
static int prism2_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
			       enum nl80211_tx_power_setting type, int mbm)
{
	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
	struct wlandevice *wlandev = priv->wlandev;
	u32 data;
	int result;
	int err = 0;

	if (type == NL80211_TX_POWER_AUTOMATIC)
		data = 30;
	else
		data = MBM_TO_DBM(mbm);

	result = prism2_domibset_uint32(wlandev,
		DIDMIB_DOT11PHY_TXPOWERTABLE_CURRENTTXPOWERLEVEL,
		data);

	if (result) {
		err = -EFAULT;
		goto exit;
	}

exit:
	return err;
}
Beispiel #2
0
int prism2_set_tx_power(struct wiphy *wiphy, enum nl80211_tx_power_setting type,
			int mbm)
{
	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
	wlandevice_t *wlandev = priv->wlandev;
	u32 data;
	int result;
	int err = 0;

	if (type == NL80211_TX_POWER_AUTOMATIC)
		data = 30;
	else
		data = MBM_TO_DBM(mbm);

	result = prism2_domibset_uint32(wlandev,
		DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
		data);

	if (result) {
		err = -EFAULT;
		goto exit;
	}

exit:
	return err;
}
Beispiel #3
0
/*
 * CFG802.11 operation handler to set Tx power.
 */
static int
mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy,
			      enum nl80211_tx_power_setting type,
			      int mbm)
{
	struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
	struct mwifiex_power_cfg power_cfg;
	int dbm = MBM_TO_DBM(mbm);

	if (type == NL80211_TX_POWER_FIXED) {
		power_cfg.is_power_auto = 0;
		power_cfg.power_level = dbm;
	} else {
		power_cfg.is_power_auto = 1;
	}

	return mwifiex_set_tx_power(priv, &power_cfg);
}
/**
 * cds_process_regulatory_data() - process regulatory data
 * @wiphy: wiphy
 * @band_capability: band_capability
 *
 * Return: int
 */
static int cds_process_regulatory_data(struct wiphy *wiphy,
				       uint8_t band_capability, bool reset)
{
	int i, j, m;
	int k = 0, n = 0;
	hdd_context_t *hdd_ctx;
	const struct ieee80211_reg_rule *reg_rule;
	struct ieee80211_channel *chan;
	sRegulatoryChannel *temp_chan_k;
	sRegulatoryChannel *temp_chan_n;
	sRegulatoryChannel *temp_chan;

	hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD);
	if (NULL == hdd_ctx) {
		CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR,
			  "invalid hdd_ctx pointer");
		return CDF_STATUS_E_FAULT;
	}

	hdd_ctx->isVHT80Allowed = 0;

	if (band_capability == eCSR_BAND_24)
		CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_INFO,
			  "band capability is set to 2G only");

	for (i = 0, m = 0; i < IEEE80211_NUM_BANDS; i++) {

		if (i == IEEE80211_BAND_2GHZ && band_capability == eCSR_BAND_5G)
			continue;

		else if (i == IEEE80211_BAND_5GHZ
			 && band_capability == eCSR_BAND_24)
			continue;

		if (wiphy->bands[i] == NULL)
			continue;

		if (i == 0)
			m = 0;
		else
			m = wiphy->bands[i-1]->n_channels + m;

		for (j = 0; j < wiphy->bands[i]->n_channels; j++) {

			k = m + j;
			n = cds_bw20_ch_index_to_bw40_ch_index(k);

			chan = &(wiphy->bands[i]->channels[j]);
			temp_chan_k =
				&(reg_table.regDomains[temp_reg_domain].
				  channels[k]);

			temp_chan_n =
				&(reg_table.regDomains[temp_reg_domain].
				  channels[n]);

			if ((!reset) &&
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
			    (wiphy->regulatory_flags &
			     REGULATORY_CUSTOM_REG)) {
#else
				(wiphy->flags &
				 WIPHY_FLAG_CUSTOM_REGULATORY)) {
#endif
				reg_rule = freq_reg_info(wiphy,
							 MHZ_TO_KHZ(chan->
								 center_freq));

				if (!IS_ERR(reg_rule)) {
					chan->flags &=
						~IEEE80211_CHAN_DISABLED;

					if (!(reg_rule->flags &
					      NL80211_RRF_DFS)) {
						CDF_TRACE(CDF_MODULE_ID_CDF,
							  CDF_TRACE_LEVEL_INFO,
							  "%s: Remove passive scan restriction for %u",
							  __func__,
							  chan->center_freq);
						chan->flags &=
							~IEEE80211_CHAN_RADAR;
					}

					if (!(reg_rule->flags &
					      NL80211_RRF_PASSIVE_SCAN)) {
						CDF_TRACE(CDF_MODULE_ID_CDF,
							  CDF_TRACE_LEVEL_INFO,
							  "%s: Remove passive scan restriction for %u",
							  __func__,
							  chan->center_freq);
						chan->flags &=
						   ~IEEE80211_CHAN_PASSIVE_SCAN;
					}

					if (!(reg_rule->flags &
					      NL80211_RRF_NO_IBSS)) {
						CDF_TRACE(CDF_MODULE_ID_CDF,
							  CDF_TRACE_LEVEL_INFO,
							  "%s: Remove no ibss restriction for %u",
							  __func__,
							  chan->center_freq);
						chan->flags &=
							~IEEE80211_CHAN_NO_IBSS;
					}

					chan->max_power = MBM_TO_DBM(reg_rule->
								     power_rule.
								     max_eirp);
				}
			}

#ifdef FEATURE_STATICALLY_ADD_11P_CHANNELS
			if (is_dsrc_channel(chan->center_freq)) {
				temp_chan_k->enabled =
					CHANNEL_STATE_ENABLE;
				temp_chan_k->pwrLimit =
					DEFAULT_11P_POWER;
				temp_chan_k->flags = chan->flags;
			} else
#endif
			if (chan->flags & IEEE80211_CHAN_DISABLED) {
				temp_chan_k->enabled =
					CHANNEL_STATE_DISABLE;
				temp_chan_k->flags = chan->flags;
				if (n != -1) {
					temp_chan_n->enabled =
						CHANNEL_STATE_DISABLE;
					temp_chan_n->flags = chan->flags;
				}
			} else if (chan->flags &
				   (IEEE80211_CHAN_RADAR |
				    IEEE80211_CHAN_PASSIVE_SCAN
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
					|
					IEEE80211_CHAN_INDOOR_ONLY
#endif
				)) {

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
				if (chan->flags &
				    IEEE80211_CHAN_INDOOR_ONLY)
					chan->flags |=
						IEEE80211_CHAN_PASSIVE_SCAN;
#endif
				temp_chan_k->enabled = CHANNEL_STATE_DFS;
				temp_chan_k->pwrLimit =
					chan->max_power;
				temp_chan_k->flags = chan->flags;

				if (n != -1) {
					if ((chan->flags &
					     IEEE80211_CHAN_NO_HT40) ==
					    IEEE80211_CHAN_NO_HT40) {
						temp_chan_n->enabled =
							CHANNEL_STATE_DISABLE;
					} else {
						temp_chan_n->enabled =
							CHANNEL_STATE_DFS;
						temp_chan_n->pwrLimit =
							 chan->max_power-3;
					}
					temp_chan_n->flags = chan->flags;
				}
				if ((chan->flags &
				     IEEE80211_CHAN_NO_80MHZ) == 0)
					hdd_ctx->isVHT80Allowed = 1;
			} else {
				temp_chan_k->enabled = CHANNEL_STATE_ENABLE;
				temp_chan_k->pwrLimit = chan->max_power;
				temp_chan_k->flags = chan->flags;
				if (n != -1) {
					if ((chan->flags &
					     IEEE80211_CHAN_NO_HT40) ==
					    IEEE80211_CHAN_NO_HT40) {
						temp_chan_n->enabled =
							CHANNEL_STATE_DISABLE;
					} else {
						temp_chan_n->enabled =
							CHANNEL_STATE_ENABLE;
						temp_chan_n->pwrLimit =
							chan->max_power - 3;
					}
					temp_chan_n->flags = chan->flags;
				}
				if ((chan->flags &
				     IEEE80211_CHAN_NO_80MHZ) == 0)
					hdd_ctx->isVHT80Allowed = 1;
			}
		}
	}

	if (0 == (hdd_ctx->reg.eeprom_rd_ext &
		  (1 << WHAL_REG_EXT_FCC_CH_144))) {
		temp_chan = &(reg_table.regDomains[temp_reg_domain].
			      channels[RF_CHAN_144]);
		temp_chan->enabled =
			CHANNEL_STATE_DISABLE;
	}

	if (k == 0)
		return -1;

	return 0;
}