From patchwork Tue Mar 1 10:32:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 8464031 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 07A51C0553 for ; Tue, 1 Mar 2016 10:32:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 188C020295 for ; Tue, 1 Mar 2016 10:32:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 078952012D for ; Tue, 1 Mar 2016 10:32:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aahbZ-0000e4-Rn; Tue, 01 Mar 2016 10:32:37 +0000 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aahbW-0000R5-SC for ath10k@lists.infradead.org; Tue, 01 Mar 2016 10:32:35 +0000 Received: by mail-lf0-x22d.google.com with SMTP id l83so62920030lfd.3 for ; Tue, 01 Mar 2016 02:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3BNfYO3zMRZPODFNug0V/unTZyQzUoh31KJmXfW32R0=; b=22C5eaFZtCUMJYLK+wCrcfxyGO3JwOfoUM4/ai4rRtJCZv7k7tzZAjdeOqGPa829h8 8snq7QCcZciNKEPOFcvnFVSMtVxvM0l93FniT6yDVsX9uyfSZjgBC9sqRP+WGWovLevO zKUDFzIJOLmeKfTlt/saUwJbDLz1BY1uATmDY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3BNfYO3zMRZPODFNug0V/unTZyQzUoh31KJmXfW32R0=; b=X4kXCQNsjoNzquGExVG+21qiWahzact3xZAaNUG5Q0tkn/ku4pwtJahOmyyy1jtXVA GFRE72DGFEexSOCQPG+M/y6noXZO++g8y0YJvQHhlnr5LhTqPWNf0b2P4rtHB9TxfE98 P9NbbsX2sZQ8tTT82TTywF33BzZnsq240kcFthBDTy2IOQxXG0THiFWC+JvpP9XJLCbs ZG1GlLjQ+EWA9o7flv+6C5inZd/yx/kw1t/G52uywwVWnhd53WhGdwAliepYQUa3Rp4E 89UlTd1UVfRQpaGxomnmnFjCjiezQdNp5ZHcklh5XFvHsnTonB8BfIHi6xvKKgweippe 18Bg== X-Gm-Message-State: AD7BkJKeKxFv3+jGgvO2JjveXvtstUmZ7fuIMrfOg5kJNyQ6vexkVFleKSDXO9rHBzmmu6ZQMk+10UsLvn+/0fImtTecnB9IkpNnlkbFvVBrPTcdpTnCyWNU6eu6XoipnTfMBc41KIxgaRauk8DGV/cC6a4xfikcLOj3uPhARtel01v0bRIbUQlDcSzm7KQdUg== X-Received: by 10.25.136.84 with SMTP id k81mr8061205lfd.78.1456828332865; Tue, 01 Mar 2016 02:32:12 -0800 (PST) Received: from localhost.localdomain ([91.198.246.10]) by smtp.gmail.com with ESMTPSA id i2sm4644857lfd.43.2016.03.01.02.32.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 02:32:11 -0800 (PST) From: Michal Kazior To: ath10k@lists.infradead.org Subject: [PATCH v2 04/11] ath10k: maintain peer_id for each sta and vif Date: Tue, 1 Mar 2016 11:32:49 +0100 Message-Id: <1456828376-2795-5-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456828376-2795-1-git-send-email-michal.kazior@tieto.com> References: <1453384006-31907-1-git-send-email-michal.kazior@tieto.com> <1456828376-2795-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160301_023235_140959_5812F766 X-CRM114-Status: GOOD ( 12.35 ) X-Spam-Score: -2.7 (--) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, Michal Kazior MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 10.4.3 firmware with congestion control guarantees that each peer has only a single peer_id mapping. The 1:1 mapping isn't the case for older firmwares (e.g. 10.4.1, 10.2, 10.1) but it should not matter. This 1:1 mapping is going to be only used by future code which inherently (flow-wise) is for 10.4.3. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/core.h | 2 ++ drivers/net/wireless/ath/ath10k/mac.c | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index a62b62a62266..523585e85f35 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -313,6 +313,7 @@ struct ath10k_sta { u32 bw; u32 nss; u32 smps; + u16 peer_id; struct work_struct update_wk; @@ -335,6 +336,7 @@ struct ath10k_vif { struct list_head list; u32 vdev_id; + u16 peer_id; enum wmi_vdev_type vdev_type; enum wmi_vdev_subtype vdev_subtype; u32 beacon_interval; diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 140ad250ea69..72b8f177445d 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -4421,6 +4421,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, { struct ath10k *ar = hw->priv; struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); + struct ath10k_peer *peer; enum wmi_sta_powersave_param param; int ret = 0; u32 value; @@ -4620,6 +4621,24 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, arvif->vdev_id, ret); goto err_vdev_delete; } + + spin_lock_bh(&ar->data_lock); + + peer = ath10k_peer_find(ar, arvif->vdev_id, vif->addr); + if (!peer) { + ath10k_warn(ar, "failed to lookup peer %pM on vdev %i\n", + vif->addr, arvif->vdev_id); + spin_unlock_bh(&ar->data_lock); + ret = -ENOENT; + goto err_peer_delete; + } + + arvif->peer_id = find_first_bit(peer->peer_ids, + ATH10K_MAX_NUM_PEER_IDS); + + spin_unlock_bh(&ar->data_lock); + } else { + arvif->peer_id = HTT_INVALID_PEERID; } if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { @@ -5501,6 +5520,7 @@ static int ath10k_sta_state(struct ieee80211_hw *hw, struct ath10k *ar = hw->priv; struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; + struct ath10k_peer *peer; int ret = 0; if (old_state == IEEE80211_STA_NOTEXIST && @@ -5551,6 +5571,24 @@ static int ath10k_sta_state(struct ieee80211_hw *hw, goto exit; } + spin_lock_bh(&ar->data_lock); + + peer = ath10k_peer_find(ar, arvif->vdev_id, sta->addr); + if (!peer) { + ath10k_warn(ar, "failed to lookup peer %pM on vdev %i\n", + vif->addr, arvif->vdev_id); + spin_unlock_bh(&ar->data_lock); + ath10k_peer_delete(ar, arvif->vdev_id, sta->addr); + ath10k_mac_dec_num_stations(arvif, sta); + ret = -ENOENT; + goto exit; + } + + arsta->peer_id = find_first_bit(peer->peer_ids, + ATH10K_MAX_NUM_PEER_IDS); + + spin_unlock_bh(&ar->data_lock); + if (!sta->tdls) goto exit;