Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1003263pxb; Tue, 8 Feb 2022 07:15:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxT3YZ3ACAm7LqTo5PKWUbcBrnyBlqHmxaM4zSLZTudULG6EfRmQc9rGInYszdar7hIMrj4 X-Received: by 2002:a17:90b:4a12:: with SMTP id kk18mr1875632pjb.227.1644333343672; Tue, 08 Feb 2022 07:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644333343; cv=none; d=google.com; s=arc-20160816; b=b0uTenuKknNMK4tl9zbllKH2s8LAmWIJ71PnFIHoPIBv/rFGk68ZWD5zf+XtsFSTm9 z5Z1f8SE6c0IiKtBAsnC3SsLpufH7n5m4DCbdRPtKpJ7gbRbuwStfO7eKGFCRQqa3efH I+ER+PgEftqTXyR4nUIJfI0PosAJTZwHUpGddUCRok9+Z7GsZthagmqYByXH7nu/DHhg f7cMjoZGGwJ47+VR7+t73Msk8UXWqHEXlvRkoK7ZJLZKXxRkRbNt3Q3+/xtx4JPCTNKp vowyfdpYDZlmh5LWqKhean61GLUzUEap8X0M5OwlCA5X5lCUuMGJaR99dOPz1n7FHA64 NTvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fH/qgj+dDtRFV8WcMxMiKcWypVJq2rw8EsBnqMfnxbE=; b=g1AldPzIXKhG8AsB3BGz3/YJrRrpRLuH6AOKpJhHquHwn3iaT/LCnLidIXcfru4qW3 y6pP2GCkUV5kATRhlElJF1vOKar4lmiQ/Jrxtg8tUk6uotHY4vFlTtb8EHlWCcjSrlI1 Vn826ljGxr2Sitf/3LfR/VVtbe9uVSE5/9/qi4ZWaGLxZLnXK4R+NTXkr+5vbGGjL0Ke 8Ytcj0CsujTo+jo0TzbEy41Yr8BRFUucAy+Qn6uSO1KJT8xZ+Sy6KAArW+wApfNAcx85 P39/Jm9nmr2/Z5ul6U0zRHJ1/SKG3KyC2c8ODCuwe2ccDTVqqDKC3YZ7HvOTAR7I6XTq g4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=faki3e9a; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8si11020900plg.178.2022.02.08.07.15.28; Tue, 08 Feb 2022 07:15:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=faki3e9a; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348987AbiBHIQA (ORCPT + 72 others); Tue, 8 Feb 2022 03:16:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349108AbiBHIPp (ORCPT ); Tue, 8 Feb 2022 03:15:45 -0500 X-Greylist: delayed 122 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 08 Feb 2022 00:15:44 PST Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7FAFC03FEC0 for ; Tue, 8 Feb 2022 00:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1644308145; x=1675844145; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=fH/qgj+dDtRFV8WcMxMiKcWypVJq2rw8EsBnqMfnxbE=; b=faki3e9aaWDWf7sJOg581tI7dpGitFYXSkmaxbUadgYKU1fufnDv/olp 5kfDsQdo34bR5oVuuasA3ZLh6Z8IUjBj+Aw2TRg03/HCLB6G7UaRF1gmk c4g/VaUTDFeDLkqzoUsINPZt4TZCBQH4kPGlBWxXyQD8OfIEY3RFEVReW o=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 08 Feb 2022 00:13:41 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2022 00:13:41 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 8 Feb 2022 00:13:41 -0800 Received: from cjhuang2-gv.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 8 Feb 2022 00:13:39 -0800 From: Carl Huang To: CC: Subject: [PATCH v3 3/6] ath11k: implement hardware data filter Date: Tue, 8 Feb 2022 16:13:23 +0800 Message-ID: <1644308006-22784-4-git-send-email-quic_cjhuang@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1644308006-22784-1-git-send-email-quic_cjhuang@quicinc.com> References: <1644308006-22784-1-git-send-email-quic_cjhuang@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Host needs to set hardware data filter before entering WoW to let firmware drop needless broadcast/mulitcast frames to avoid frequent wakeup. Host clears hardware data filter when leaving WoW. Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1 Signed-off-by: Carl Huang --- drivers/net/wireless/ath/ath11k/wmi.c | 32 ++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.h | 15 ++++++++ drivers/net/wireless/ath/ath11k/wow.c | 55 +++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 9ff170493dd0..6fa9659f9c61 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -8165,6 +8165,38 @@ void ath11k_wmi_detach(struct ath11k_base *ab) ath11k_wmi_free_dbring_caps(ab); } +int ath11k_wmi_send_hw_data_filter_cmd(struct ath11k *ar, u32 vdev_id, + u32 filter_bitmap, bool enable) +{ + struct wmi_hw_data_filter_cmd *cmd; + struct sk_buff *skb; + int len; + + len = sizeof(*cmd); + skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); + + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_hw_data_filter_cmd *)skb->data; + cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_HW_DATA_FILTER_CMD) | + FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); + + cmd->vdev_id = vdev_id; + cmd->enable = enable; + /* Set all modes in case of disable */ + if (cmd->enable) + cmd->hw_filter_bitmap = filter_bitmap; + else + cmd->hw_filter_bitmap = ((u32)~0U); + + ath11k_dbg(ar->ab, ATH11K_DBG_WMI, + "wmi set hw filter enable %d, filter_bitmap:0x%x\n", + enable, filter_bitmap); + + return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_HW_DATA_FILTER_CMDID); +} + int ath11k_wmi_wow_host_wakeup_ind(struct ath11k *ar) { struct wmi_wow_host_wakeup_ind *cmd; diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h index 9150e0555c6d..4ef1b4f4a743 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.h +++ b/drivers/net/wireless/ath/ath11k/wmi.h @@ -5390,6 +5390,19 @@ struct ath11k_wmi_base { struct ath11k_targ_cap *targ_cap; }; +/* Definition of HW data filtering */ +enum hw_data_filter_type { + WMI_HW_DATA_FILTER_DROP_NON_ARP_BC = BIT(0), + WMI_HW_DATA_FILTER_DROP_NON_ICMPV6_MC = BIT(1), +}; + +struct wmi_hw_data_filter_cmd { + u32 tlv_header; + u32 vdev_id; + u32 enable; + u32 hw_filter_bitmap; +} __packed; + /* WOW structures */ enum wmi_wow_wakeup_event { WOW_BMISS_EVENT = 0, @@ -5953,4 +5966,6 @@ int ath11k_wmi_wow_add_pattern(struct ath11k *ar, u32 vdev_id, u32 pattern_id, int ath11k_wmi_wow_add_wakeup_event(struct ath11k *ar, u32 vdev_id, enum wmi_wow_wakeup_event event, u32 enable); +int ath11k_wmi_send_hw_data_filter_cmd(struct ath11k *ar, u32 vdev_id, + u32 filter_bitmap, bool enable); #endif diff --git a/drivers/net/wireless/ath/ath11k/wow.c b/drivers/net/wireless/ath/ath11k/wow.c index bef36b244a9f..63577e018518 100644 --- a/drivers/net/wireless/ath/ath11k/wow.c +++ b/drivers/net/wireless/ath/ath11k/wow.c @@ -512,6 +512,48 @@ static int ath11k_wow_nlo_cleanup(struct ath11k *ar) return 0; } +static int ath11k_wow_set_hw_filter(struct ath11k *ar) +{ + struct ath11k_vif *arvif; + int ret; + + lockdep_assert_held(&ar->conf_mutex); + + list_for_each_entry(arvif, &ar->arvifs, list) { + ret = ath11k_wmi_send_hw_data_filter_cmd(ar, arvif->vdev_id, + WMI_HW_DATA_FILTER_DROP_NON_ICMPV6_MC | + WMI_HW_DATA_FILTER_DROP_NON_ARP_BC, + true); + if (ret) { + ath11k_warn(ar->ab, "failed to set hw data filter on vdev %i: %d\n", + arvif->vdev_id, ret); + return ret; + } + } + + return 0; +} + +static int ath11k_wow_clear_hw_filter(struct ath11k *ar) +{ + struct ath11k_vif *arvif; + int ret; + + lockdep_assert_held(&ar->conf_mutex); + + list_for_each_entry(arvif, &ar->arvifs, list) { + ret = ath11k_wmi_send_hw_data_filter_cmd(ar, arvif->vdev_id, 0, false); + + if (ret) { + ath11k_warn(ar->ab, "failed to clear hw data filter on vdev %i: %d\n", + arvif->vdev_id, ret); + return ret; + } + } + + return 0; +} + int ath11k_wow_op_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) { @@ -540,6 +582,13 @@ int ath11k_wow_op_suspend(struct ieee80211_hw *hw, goto cleanup; } + ret = ath11k_wow_set_hw_filter(ar); + if (ret) { + ath11k_warn(ar->ab, "failed to set hw filter: %d\n", + ret); + goto cleanup; + } + ret = ath11k_wow_enable(ar->ab); if (ret) { ath11k_warn(ar->ab, "failed to start wow: %d\n", ret); @@ -608,6 +657,12 @@ int ath11k_wow_op_resume(struct ieee80211_hw *hw) goto exit; } + ret = ath11k_wow_clear_hw_filter(ar); + if (ret) { + ath11k_warn(ar->ab, "failed to clear hw filter: %d\n", ret); + goto exit; + } + exit: if (ret) { switch (ar->state) { -- 2.32.0