Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a519311 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

cfg80211/nl80211: scanning (and mac80211 update to use it)



This patch adds basic scan capability to cfg80211/nl80211 and
changes mac80211 to use it. The BSS list that cfg80211 maintains
is made driver-accessible with a private area in each BSS struct,
but mac80211 doesn't yet use it. That's another large project.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 849b7967
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -2678,11 +2678,19 @@ static void iwl_bss_info_changed(struct ieee80211_hw *hw,

}

static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
static int iwl_mac_hw_scan(struct ieee80211_hw *hw,
			   struct cfg80211_scan_request *req)
{
	unsigned long flags;
	struct iwl_priv *priv = hw->priv;
	int ret;
	u8 *ssid = NULL;
	size_t ssid_len = 0;

	if (req->n_ssids) {
		ssid = req->ssids[0].ssid;
		ssid_len = req->ssids[0].ssid_len;
	}

	IWL_DEBUG_MAC80211(priv, "enter\n");

@@ -2718,7 +2726,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)

	if (ssid_len) {
		priv->one_direct_scan = 1;
		priv->direct_ssid_len =  min_t(u8, ssid_len, IW_ESSID_MAX_SIZE);
		priv->direct_ssid_len = ssid_len;
		memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len);
	} else {
		priv->one_direct_scan = 0;
+1 −0
Original line number Diff line number Diff line
@@ -1271,6 +1271,7 @@ int iwl_setup_mac(struct iwl_priv *priv)
		BIT(NL80211_IFTYPE_ADHOC);

	hw->wiphy->custom_regulatory = true;
	hw->wiphy->max_scan_ssids = 1;

	/* Default value; 4 EDCA QOS priorities */
	hw->queues = 4;
+1 −1
Original line number Diff line number Diff line
@@ -860,7 +860,7 @@ void iwl_bg_scan_completed(struct work_struct *work)
	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

	ieee80211_scan_completed(priv->hw);
	ieee80211_scan_completed(priv->hw, false);

	/* Since setting the TXPOWER may have been deferred while
	 * performing the scan, fire one off */
+13 −4
Original line number Diff line number Diff line
@@ -4442,15 +4442,23 @@ static void iwl3945_bss_info_changed(struct ieee80211_hw *hw,

}

static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw,
			       struct cfg80211_scan_request *req)
{
	int rc = 0;
	unsigned long flags;
	struct iwl_priv *priv = hw->priv;
	size_t len = 0;
	u8 *ssid = NULL;
	DECLARE_SSID_BUF(ssid_buf);

	IWL_DEBUG_MAC80211(priv, "enter\n");

	if (req->n_ssids) {
		ssid = req->ssids[0].ssid;
		len = req->ssids[0].ssid_len;
	}

	mutex_lock(&priv->mutex);
	spin_lock_irqsave(&priv->lock, flags);

@@ -4478,9 +4486,8 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
			       print_ssid(ssid_buf, ssid, len), len);

		priv->one_direct_scan = 1;
		priv->direct_ssid_len = (u8)
		    min((u8) len, (u8) IW_ESSID_MAX_SIZE);
		memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len);
		priv->direct_ssid_len = len;
		memcpy(priv->direct_ssid, ssid, len);
	} else
		priv->one_direct_scan = 0;

@@ -5412,6 +5419,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e

	hw->wiphy->custom_regulatory = true;

	hw->wiphy->max_scan_ssids = 1;

	/* 4 EDCA QOS priorities */
	hw->queues = 4;

+65 −0
Original line number Diff line number Diff line
@@ -143,6 +143,13 @@
 *	added to all specified management frames generated by
 *	kernel/firmware/driver.
 *
 * @NL80211_CMD_GET_SCAN: get scan results
 * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
 * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
 *	NL80211_CMD_GET_SCAN and on the "scan" multicast group)
 * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
 *	partial scan results may be available
 *
 * @NL80211_CMD_MAX: highest used command number
 * @__NL80211_CMD_AFTER_LAST: internal use
 */
@@ -192,6 +199,11 @@ enum nl80211_commands {

	NL80211_CMD_GET_REG,

	NL80211_CMD_GET_SCAN,
	NL80211_CMD_TRIGGER_SCAN,
	NL80211_CMD_NEW_SCAN_RESULTS,
	NL80211_CMD_SCAN_ABORTED,

	/* add new commands above here */

	/* used to define NL80211_CMD_MAX below */
@@ -305,6 +317,18 @@ enum nl80211_commands {
 * @NL80211_ATTR_IE: Information element(s) data (used, e.g., with
 *	%NL80211_CMD_SET_MGMT_EXTRA_IE).
 *
 * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
 *	a single scan request, a wiphy attribute.
 *
 * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
 * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
 *	scanning and include a zero-length SSID (wildcard) for wildcard scan
 * @NL80211_ATTR_SCAN_GENERATION: the scan generation increases whenever the
 *	scan result list changes (BSS expired or added) so that applications
 *	can verify that they got a single, consistent snapshot (when all dump
 *	messages carried the same generation number)
 * @NL80211_ATTR_BSS: scan result BSS
 *
 * @NL80211_ATTR_MAX: highest attribute number currently defined
 * @__NL80211_ATTR_AFTER_LAST: internal use
 */
@@ -372,6 +396,13 @@ enum nl80211_attrs {
	NL80211_ATTR_MGMT_SUBTYPE,
	NL80211_ATTR_IE,

	NL80211_ATTR_MAX_NUM_SCAN_SSIDS,

	NL80211_ATTR_SCAN_FREQUENCIES,
	NL80211_ATTR_SCAN_SSIDS,
	NL80211_ATTR_SCAN_GENERATION,
	NL80211_ATTR_BSS,

	/* add attributes here, update the policy in nl80211.c */

	__NL80211_ATTR_AFTER_LAST,
@@ -841,4 +872,38 @@ enum nl80211_channel_type {
	NL80211_CHAN_HT40MINUS,
	NL80211_CHAN_HT40PLUS
};

/**
 * enum nl80211_bss - netlink attributes for a BSS
 *
 * @__NL80211_BSS_INVALID: invalid
 * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
 * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
 * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
 * @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
 * @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
 *	raw information elements from the probe response/beacon (bin)
 * @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
 *	in mBm (100 * dBm) (s32)
 * @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
 *	in unspecified units, scaled to 0..100 (u8)
 * @__NL80211_BSS_AFTER_LAST: internal
 * @NL80211_BSS_MAX: highest BSS attribute
 */
enum nl80211_bss {
	__NL80211_BSS_INVALID,
	NL80211_BSS_BSSID,
	NL80211_BSS_FREQUENCY,
	NL80211_BSS_TSF,
	NL80211_BSS_BEACON_INTERVAL,
	NL80211_BSS_CAPABILITY,
	NL80211_BSS_INFORMATION_ELEMENTS,
	NL80211_BSS_SIGNAL_MBM,
	NL80211_BSS_SIGNAL_UNSPEC,

	/* keep last */
	__NL80211_BSS_AFTER_LAST,
	NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
};

#endif /* __LINUX_NL80211_H */
Loading