Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp82310lqo; Wed, 27 Mar 2024 07:31:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUU8JfN9YY+rJ1Wpz5S/w1vEQLx5yo5tQY/p0JkAFV0r7ry8efqwaTJLvBn7+ZLIhJlsJRapoqFl1DXmdHQTcoaTYOJfwy1kBrvqYgp4g== X-Google-Smtp-Source: AGHT+IEm0+uVW+V6uwd0ajyJEUUdocRQLc267kC0XjQVdClKCM/1FVq/9hJeuPgL5hkUlefQHL+k X-Received: by 2002:a05:6358:8083:b0:17e:69a1:a797 with SMTP id a3-20020a056358808300b0017e69a1a797mr5941453rwk.30.1711549901715; Wed, 27 Mar 2024 07:31:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711549901; cv=pass; d=google.com; s=arc-20160816; b=Z4HmKCtMH3MoNxXw3mfKUEAEphgswrkeWN6RfJ7bzxFTNJeQa4uceZVO1jKOh3Ci7b x+emy4P+mgc7k9aGYsGWcgc54mi9x+mk+MGho96jUjv8lvwRcZrpc+6Wy6h2AxdCtx6b e22USarQc3hIY0vOjbIC/PUpstZ9YIoHLG4Qnk5J0PXAx7gl4mddObdBan+PTYr/GbXH 5p/1XIhCmTjSxagDhLS+1Z1g694b9hsAtPi6gkzlW8xgdzh49kEhYGtUpejsQe48S8Ey kMKtyFHL6UDCvN5RP2cnnjzm5GIvvHgnTDwyM0vjSqSPv33kmJktHIaGGbbrBKQqw9Bl rarQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=FrQzsn87xaPozpOsr6mrbRGEBewC/DvcdWCLtE3LggY=; fh=xv7jQgBDBjvi4NFA/N8aQ6Tr+8v7/D+2rQx2ydw2/5M=; b=SMQJ2Gizd9CRXm2G/x+i5mjfih3zrxASvYHxYTK+NxT/tTn439evlsod55Os7S11Z2 kcJFBY++MfibBvbbJp1Bg7A5DftjmMPWvALCj5o/BWTKbPKIrH8AhupTHbxGQetANnN6 /s/PZGZSXyLkcCSJkouUIBWZhymqrv6MYh2PwLctpanyl27zUeTmq/B7SyzES78KkAHr cXO4bp9f2AobkmC29M2d0V8EA6T1ILSRIqt2yr7jFYfZ+5f60AxYw0NIQxNToLLB1Ape V0GZBUw5EQ/NsahViVIxlH6/k2g/VNZTQdwb+OwCjN/T2gV79+EE81Y8mynBpSYH9OUg XKkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jh7i9jbn; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-5351-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5351-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y62-20020a636441000000b005dbcf14be2bsi12077457pgb.800.2024.03.27.07.31.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 07:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5351-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jh7i9jbn; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-5351-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5351-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C434B2A3A16 for ; Wed, 27 Mar 2024 14:30:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30A9C12DD91; Wed, 27 Mar 2024 12:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="jh7i9jbn" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 823DB12F38C for ; Wed, 27 Mar 2024 12:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711544102; cv=none; b=cTa+v6ZOokFu2EXq5gQqdx15ncwqVDvaeXQUBDNlHrw4hDR7Z6rZqDRbbb3/JkKoPH8di5bOJ3JIOmfupUA4EolqQelQQ8la+e/aqHklZ9BeFhSrvdffzj281loAUMSGMl140qgYqyaT+UZxRla0/pEGt9KUm/g/T/CphWcIsjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711544102; c=relaxed/simple; bh=gTFmeIWaWZYZbC0gTxXCf8i+5T6huZtTwmnbY15DArY=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=uStn9UUf9M6lOqaXCLebp7sDkqa+EDFiiifsrLqj8xFIop/7oVtih7GFuHGhYpk83Uf32UyHZ5YZ9Y4JCHUYDHZV6i0Cr2AKX/cW7Ksqugax7mH1ig2cvekGxso0pvyRbe7OrDvRqgd2a2MMCltQzGqGwTYvCOh7j1XuGdCY1lQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=jh7i9jbn; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42RAZfX5023903; Wed, 27 Mar 2024 12:54:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=FrQzsn87xaPozpOsr6mrbRGEBewC/DvcdWCLtE3LggY=; b=jh 7i9jbnTPz+T+4WRdYruqZu7uz7IAMT1bGRQMebdLoFvQQQu3nOU3Xwyn5ocwnwkT 8NyKLgPWXc2RvW7ps2I0MHnmqika9sLj3t0d06izLbgxHESWs1HrX75k3BM+eFgX an67XaQHW7o80tdbNXYIvWwCIti1YE19d4NHCSum29py8BUQZQrRtLSbbJYp66Fl 6GSTtADgjvv64wzzs54NSMsJWabvD6FY0hqfudD5SWj3crA1F7UJ1AwoQNgLcaM4 7D2MptpW6NkLa0ryapcXD2hqRMsHgP0ZRnyCMaOBLAoLnFu8R3/VSeazql5RQL+W rS9yLn1h97YGgChkxuNA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4hu2rb8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 12:54:46 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42RCskt1011989 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 12:54:46 GMT Received: from [10.110.105.230] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 27 Mar 2024 05:54:45 -0700 Message-ID: <3f5b9e74-d898-416b-9b08-d008883c7e58@quicinc.com> Date: Wed, 27 Mar 2024 20:54:42 +0800 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] wifi: ath12k: report signal for iw dev xxx station dump To: Kalle Valo CC: , References: <20240219111417.1185-1-quic_lingbok@quicinc.com> <87o7b8amcn.fsf@kernel.org> Content-Language: en-US From: Lingbo Kong In-Reply-To: <87o7b8amcn.fsf@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: EyqYlXtp9seqaVCzx4qFOCmnhiwXSEkO X-Proofpoint-GUID: EyqYlXtp9seqaVCzx4qFOCmnhiwXSEkO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-27_08,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403270088 On 2024/3/21 0:39, Kalle Valo wrote: > Lingbo Kong writes: > >> The signal of "iw dev xxx station dump" always show 0 dBm. This is because >> currently signal is only set in ath12k_mgmt_rx_event function, and not set >> for rx data packet. So, change to get signal from firmware and report to >> mac80211. > >> /* TODO: Use real NF instead of default one. */ >> - sinfo->signal = arsta->rssi_comb + ATH12K_DEFAULT_NOISE_FLOOR; >> - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); >> + signal = arsta->rssi_comb; >> + >> + if (!signal && >> + arsta->arvif->vdev_type == WMI_VDEV_TYPE_STA && >> + ar->ab->hw_params->supports_rssi_stats && >> + !(ath12k_mac_get_fw_stats(ar, ar->pdev->pdev_id, 0, >> + WMI_REQUEST_VDEV_STAT))) >> + signal = arsta->rssi_beacon; >> + >> + if (signal) { >> + sinfo->signal = signal; >> + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); >> + } >> } > > If I'm reading the patch correctly this is the sequence: > > 1. ath12k_mac_op_sta_statistics() is called > > 2. WMI_REQUEST_STATS_CMDID is sent to the firmware > > 3. ath12k_mac_op_sta_statistics() returns > > 4. firmware sends WMI_UPDATE_STATS_EVENTID to host > > 5. ath12k_wmi_tlv_fw_stats_data_parse() stores signal to arsta->rssi_beacon > > So doesn't this mean that ath12k_mac_op_sta_statistics() actually uses > the previous value? And if ath12k_mac_op_sta_statistics() is called very > seldom, like once an hour, the signal value can be one hour wrong? > Hi, kalle, you're right. Thanks you for pointing this out. I should add a struct completion to make up the synchronization mechanism. So, i add a struct completion in struct ath12k, then modify the ath12k_mac_get_fw_stats() function: +static int ath12k_mac_get_fw_stats(struct ath12k *ar, u32 pdev_id, + u32 vdev_id, u32 stats_id) +{ + struct ath12k_base *ab = ar->ab; + int ret, left; + + mutex_lock(&ar->conf_mutex); + + if (ar->state != ATH12K_STATE_ON) { + ret = -ENETDOWN; + goto err_unlock; + } + + reinit_completion(&ar->fw_stats_complete); + + ret = ath12k_wmi_send_stats_request_cmd(ar, stats_id, vdev_id, pdev_id); + + if (ret) { + ath12k_warn(ab, "failed to request fw stats: %d\n", ret); + goto err_unlock; + } + + ath12k_dbg(ab, ATH12K_DBG_WMI, + "get fw stat pdev id %d vdev id %d stats id 0x%x\n", + pdev_id, vdev_id, stats_id); + + left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ); + + if (!left) + ath12k_warn(ab, "time out while waiting for get fw stats\n"); +err_unlock: + + mutex_unlock(&ar->conf_mutex); + return ret; +} then add "complete(&ar->fw_stats_complete);" at the end of ath12k_wmi_tlv_fw_stats_data_parse() function. what do you think of this? > Also I don't see any protection when accessing arsta->rssi_beacon. > i think add protection is unnecessary when accessing arsta->rssi_beacon in ath12k_mac_op_sta_statistics() function, because we just take its value and don't change it. Best regards Lingbo Kong