Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp751946pxb; Thu, 30 Sep 2021 16:54:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZUxrMDO6YGzxrI7b76WVez4ACzQEwW6O4Ia6y0B+VWej9DI01FQNddKNbzM6gsw69pzDK X-Received: by 2002:a17:907:7703:: with SMTP id kw3mr2468714ejc.34.1633046076626; Thu, 30 Sep 2021 16:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633046076; cv=none; d=google.com; s=arc-20160816; b=fpjWYfgrJfJQ1JgHpj/cvMcZ6YlQ9WyMP5evBJNQLDWQ5dZJI8+JyKqgbo5qIM159Y +TKFWxKQBxG16GaMZb8oA7twfSX+Widec8ZYMo9PTDfPOvwF66OOm3hVxsEwppgxfp7W kTS/YnRYadv8s7Fs+fguHm6fuk+f5Xxv3Iopqbjqg3G6H5RhdzWqzLfL5Hbvg9AW9tn9 ztHnmeqziZvngem81JB31sXsngVEm05XbNs2Jth3ChruopktDxFpg+vTBYgNMVi/3L3k iqT0EXZa74wyMchkINU3nHGR4hE4jNmD99CaSZdtj9GYtu/+md0RHGq4h7Tq98yzRk5x F/1Q== 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; bh=eDdZSuqwrMRsztschC0Z0hjvJbfMVmQgqDMsBMIKIqk=; b=ikLkVOCIETjkBIFEUbwEzczIvYLvfFV2EYAogkw454eF3YJChSj2Swh9eEld9hMmvz XfJdm3m80sWPsjoRBTZq4dagyYLC1waUYp+wm95qpK1pSnoifJPiEeiZcAQYJECkH5Rx R/I+AzUlfsfxKHKQGfdIaXaackV5P5/5GChOe0cYLaTNjfHrVLZJ1nm1bXjEk577ASfA 1TvtrF7FY8NJOqis4w1W37NBntNS20pOGdEm43SNsgiismZ39G5oLif6+qBXw9GnkBgf 9eSXKU7dd86ufsUTfod4s2FB1y87Vb+6jgphaCeMBkln6M0HZ5mMOaXm6bSVPvMyArH6 qlww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd42si6879347ejc.627.2021.09.30.16.54.16; Thu, 30 Sep 2021 16:54:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350541AbhI3Xvw (ORCPT + 78 others); Thu, 30 Sep 2021 19:51:52 -0400 Received: from mailgw01.mediatek.com ([216.200.240.184]:33710 "EHLO mailgw01.mediatek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230218AbhI3Xvv (ORCPT ); Thu, 30 Sep 2021 19:51:51 -0400 X-UUID: e0e37426d16d4f9e85a0a965eb0bebb3-20210930 X-UUID: e0e37426d16d4f9e85a0a965eb0bebb3-20210930 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 634395843; Thu, 30 Sep 2021 16:50:06 -0700 Received: from mtkcas11.mediatek.inc (172.21.101.40) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 30 Sep 2021 16:48:57 -0700 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 1 Oct 2021 07:48:56 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 12/16] mt76: connac: extend mcu_get_nic_capability Date: Fri, 1 Oct 2021 07:47:59 +0800 Message-ID: <861f6162e2e5188d31f5b37ae5f5b7e9ae1f8a9f.1632961096.git.objelf@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Extend mcu_get_nic_capability to obtain tx resource for SDIO device, MAC address, and PHY capability. Tested-by: Deren Wu Acked-by: Lorenzo Bianconi Signed-off-by: Sean Wang --- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + .../wireless/mediatek/mt76/mt76_connac_mcu.c | 66 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 55c5642740de..50743a2bb6a2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -512,6 +512,7 @@ struct mt76_sdio { int pse_data_quota; int ple_data_quota; int pse_mcu_quota; + int pse_page_size; int deficit; } sched; }; diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index a53f6344a184..cee17b48b296 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -1716,6 +1716,61 @@ void mt76_connac_mcu_coredump_event(struct mt76_dev *dev, struct sk_buff *skb, } EXPORT_SYMBOL_GPL(mt76_connac_mcu_coredump_event); +static void mt76_connac_mcu_parse_tx_resource(struct mt76_dev *dev, + struct sk_buff *skb) +{ + struct mt76_sdio *sdio = &dev->sdio; + struct mt76_connac_tx_resource { + __le32 version; + __le32 pse_data_quota; + __le32 pse_mcu_quota; + __le32 ple_data_quota; + __le32 ple_mcu_quota; + __le16 pse_page_size; + __le16 ple_page_size; + u8 pp_padding; + u8 pad[3]; + } __packed * tx_res; + + tx_res = (struct mt76_connac_tx_resource *)skb->data; + sdio->sched.pse_data_quota = le32_to_cpu(tx_res->pse_data_quota); + sdio->sched.pse_mcu_quota = le32_to_cpu(tx_res->pse_mcu_quota); + sdio->sched.ple_data_quota = le32_to_cpu(tx_res->ple_data_quota); + sdio->sched.pse_page_size = le32_to_cpu(tx_res->pse_page_size); + sdio->sched.deficit = tx_res->pp_padding; +} + +static void mt76_connac_mcu_parse_phy_cap(struct mt76_dev *dev, + struct sk_buff *skb) +{ + struct mt76_connac_phy_cap { + u8 ht; + u8 vht; + u8 _5g; + u8 max_bw; + u8 nss; + u8 dbdc; + u8 tx_ldpc; + u8 rx_ldpc; + u8 tx_stbc; + u8 rx_stbc; + u8 hw_path; + u8 he; + } __packed * cap; + + enum { + WF0_24G, + WF0_5G + }; + + cap = (struct mt76_connac_phy_cap *)skb->data; + + dev->phy.antenna_mask = BIT(cap->nss) - 1; + dev->phy.chainmask = dev->phy.antenna_mask; + dev->phy.cap.has_2ghz = cap->hw_path & BIT(WF0_24G); + dev->phy.cap.has_5ghz = cap->hw_path & BIT(WF0_5G); +} + int mt76_connac_mcu_get_nic_capability(struct mt76_phy *phy) { struct mt76_connac_cap_hdr { @@ -1758,6 +1813,17 @@ int mt76_connac_mcu_get_nic_capability(struct mt76_phy *phy) case MT_NIC_CAP_6G: phy->cap.has_6ghz = skb->data[0]; break; + case MT_NIC_CAP_MAC_ADDR: + memcpy(phy->macaddr, (void *)skb->data, ETH_ALEN); + break; + case MT_NIC_CAP_PHY: + mt76_connac_mcu_parse_phy_cap(phy->dev, skb); + break; + case MT_NIC_CAP_TX_RESOURCE: + if (mt76_is_sdio(phy->dev)) + mt76_connac_mcu_parse_tx_resource(phy->dev, + skb); + break; default: break; } -- 2.25.1