From patchwork Sat Feb 4 23:29:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13128903 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0E2FC63797 for ; Sat, 4 Feb 2023 23:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232248AbjBDXaa (ORCPT ); Sat, 4 Feb 2023 18:30:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbjBDXa2 (ORCPT ); Sat, 4 Feb 2023 18:30:28 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E7520D3F; Sat, 4 Feb 2023 15:30:27 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id qw12so24904297ejc.2; Sat, 04 Feb 2023 15:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MjjMvrw5tJrb/cltfe+ZEhTawCPcDiUPZTdFHcpnzm4=; b=HoWYHrdvFCGhcXWlarOny3c24oMzEhjdRXQzdySqTnM05N23bR5f2jVD9zsYjkVqCH 58L1tKW0nY0NKLOYF+bXN/vQYRzR2Q5vC1204cwHXn7EzOVP7eNyqRirbDINCIJY4DDY NlrTjFCw9WdaVeQIIvQoDyrw1iQZ8oXhGklIoMycw9laFHAO4ex8NSZMu5rK1BiYKRyK FhUn3KRCOAztglGWcwpd1kh803RJ21Bp+8j57BAt7OH4HL7qfj6g5MGfHKNY3cAR/1jL OnQfc979MZmqPYEmO7wImiMW47EnyRBv6wAb0PqSKGhOBQXryLsFlwgRVS+42b5c19NR gk6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MjjMvrw5tJrb/cltfe+ZEhTawCPcDiUPZTdFHcpnzm4=; b=4KqxOHrnmp32mLkgakImFgyMy1bhSM/8/5Ik1/IZi+nSmZpn5gS1L8CA5fyY4TGfJA ucnr+hj6xND3+l/8tttEMGs+TV75SoWTKvru5CS7LnTx9QTc2VFDNHrzl+A5IwhCh6vY /CRbZwLG+3EplsNn0ErnNt6Nmx3jLQmRwzRl5nEa9Bu8UA1A0/po8kQEXU3KYFSycyc9 RXjYNAdFVSmeHmqXf6zdoWYWyJp5pn95F2x5mAcfbTTH3Ccacbpga0lokoFN4bhhEHC5 MKKtVJ0YmH2Qi+Vjb2aR0Bcy7veO0/X7liHdyUSes4ikhgSPCkxD71AwkEe8e0RPfu8I Ujhw== X-Gm-Message-State: AO0yUKVlIw4YTwPyjy2soxMzTrzWkV+S+LYHIdM50uAgx52Ind4z+DFa ChATKPoZ55ZMXRlIAwh7amXyhaBirIc= X-Google-Smtp-Source: AK7set92M3F5KuzFAmBymgQnZPqzD40IunbRn4HKzv/59C1RYG7NfpILQ+xwX9hFZy6oeSbIUTfraA== X-Received: by 2002:a17:906:199b:b0:878:6631:7fe with SMTP id g27-20020a170906199b00b00878663107femr16536254ejd.20.1675553425726; Sat, 04 Feb 2023 15:30:25 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7777-cc00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7777:cc00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id v5-20020a1709061dc500b0084d4e9a13cbsm3386658ejh.221.2023.02.04.15.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 15:30:25 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , pkshih@realtek.com, Martin Blumenstingl Subject: [PATCH v2 1/4] wifi: rtw88: pci: Use enum type for rtw_hw_queue_mapping() and ac_to_hwq Date: Sun, 5 Feb 2023 00:29:58 +0100 Message-Id: <20230204233001.1511643-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> References: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org rtw_hw_queue_mapping() and ac_to_hwq[] hold values of type enum rtw_tx_queue_type. Change their types to reflect this to make it easier to understand this part of the code. While here, also change the array to be static const as it is not supposed to be modified at runtime. Signed-off-by: Martin Blumenstingl Reviewed-by: Simon Horman Reviewed-by: Ping-Ke Shih --- Changes from v1 -> v2: - also make ac_to_hwq static const (instead of just static) - reword subject and include the "wifi" prefix drivers/net/wireless/realtek/rtw88/pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c index 0975d27240e4..45ce7e624c03 100644 --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c @@ -669,7 +669,7 @@ static void rtw_pci_deep_ps(struct rtw_dev *rtwdev, bool enter) spin_unlock_bh(&rtwpci->irq_lock); } -static u8 ac_to_hwq[] = { +static const enum rtw_tx_queue_type ac_to_hwq[] = { [IEEE80211_AC_VO] = RTW_TX_QUEUE_VO, [IEEE80211_AC_VI] = RTW_TX_QUEUE_VI, [IEEE80211_AC_BE] = RTW_TX_QUEUE_BE, @@ -678,12 +678,12 @@ static u8 ac_to_hwq[] = { static_assert(ARRAY_SIZE(ac_to_hwq) == IEEE80211_NUM_ACS); -static u8 rtw_hw_queue_mapping(struct sk_buff *skb) +static enum rtw_tx_queue_type rtw_hw_queue_mapping(struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; __le16 fc = hdr->frame_control; u8 q_mapping = skb_get_queue_mapping(skb); - u8 queue; + enum rtw_tx_queue_type queue; if (unlikely(ieee80211_is_beacon(fc))) queue = RTW_TX_QUEUE_BCN; From patchwork Sat Feb 4 23:29:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13128905 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DC32C636D6 for ; Sat, 4 Feb 2023 23:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232476AbjBDXad (ORCPT ); Sat, 4 Feb 2023 18:30:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbjBDXaa (ORCPT ); Sat, 4 Feb 2023 18:30:30 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1ACD22DF8; Sat, 4 Feb 2023 15:30:28 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id q19so8426130edd.2; Sat, 04 Feb 2023 15:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b6UgdhmqWocOBQz+eQ8ew5GqkBUQxNNwSV7ocstJJqs=; b=QQBddVqS2/y8BHJEpL0Gok9noxj5m3QC3aAsMRYvcruT3kqu6I7QgdsEb5eXypojuy ZT6cyhabERR3oMuv7M6SdHEzV+TIDlTElsLir4OtTd+ab+QCFxHV1tFlkJeusC6w3Fkv RitfAXmTN43OzfoHVaS7MC64eISy8OtyHy/+5dm2VjzUoteCMOJDSZZ9IF/B7Zy7AtDL 6g933RxqErpj9Z1pW7SmBegfkMLSbddY97GZWlxtzIA/cM3GrZUN89rhPdNR1qmLljua AzxxEPc4wG/kLgC5BlzBrV3hNTfEZ4efJLDMx9ZknTkFjiLZvxIeu4osLQNZ25Ys4LbN tA3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b6UgdhmqWocOBQz+eQ8ew5GqkBUQxNNwSV7ocstJJqs=; b=IDzLrAS9XGj3l6rlUmIv11oyBzmqYvYzgXo4arvjw8Z35AuA7ZqU6Np9LnyhlXkCYb MGHqQ5hQjyDVdg2ggWl5rCfkk7CqF40y+BwULXWfwiVeSC3H7K4X3p9yMf0c/z2xESxb BDyQixgSdcByVgwQ6wSLSnHcUvRTFgmS6EaG7SgHDDr164r0oDNaHStvLdnhtQpf0mcp GydMjTJeeuFUMLVpALAMoXndG7tHqY2416PSnDwDz5b9n2ZypFzcxkgsQgmD+8BtlsUE hi2zjXQGUhgGfppIebcAq1IemZmRJe27qz8BEcnJGqopkYizfDnw7Zwy/evIpTDA+yIP 1+Nw== X-Gm-Message-State: AO0yUKUKj9vVyMtQIv45VobRcKEsHgy9ghIcaz8Gcw2g8WbKplu6Vfeu WP1HFbU4IJbvzj8L1f9Mzj0l0pri6hE= X-Google-Smtp-Source: AK7set/xbtNPaYyRyrRexiTwkymptbgSjSZV1sYj7RCcoc7XJ42wiUlUuMpKaEL9+JLRL9OIbmo/+w== X-Received: by 2002:a50:9f4a:0:b0:4aa:a4f3:49cd with SMTP id b68-20020a509f4a000000b004aaa4f349cdmr1848814edf.19.1675553426583; Sat, 04 Feb 2023 15:30:26 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7777-cc00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7777:cc00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id v5-20020a1709061dc500b0084d4e9a13cbsm3386658ejh.221.2023.02.04.15.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 15:30:26 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , pkshih@realtek.com, Martin Blumenstingl Subject: [PATCH v2 2/4] wifi: rtw88: pci: Change queue datatype to enum rtw_tx_queue_type Date: Sun, 5 Feb 2023 00:29:59 +0100 Message-Id: <20230204233001.1511643-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> References: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes it easier to understand which values are allowed for the "queue" variable when using the enum instead of an u8. Acked-by: Ping-Ke Shih Signed-off-by: Martin Blumenstingl Reviewed-by: Simon Horman --- Changes from v1 -> v2: - reword subject and include the "wifi" prefix - add Ping-Ke's Acked-by drivers/net/wireless/realtek/rtw88/pci.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c index 45ce7e624c03..5492107fc85b 100644 --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c @@ -30,7 +30,8 @@ static u32 rtw_pci_tx_queue_idx_addr[] = { [RTW_TX_QUEUE_H2C] = RTK_PCI_TXBD_IDX_H2CQ, }; -static u8 rtw_pci_get_tx_qsel(struct sk_buff *skb, u8 queue) +static u8 rtw_pci_get_tx_qsel(struct sk_buff *skb, + enum rtw_tx_queue_type queue) { switch (queue) { case RTW_TX_QUEUE_BCN: @@ -542,7 +543,7 @@ static int rtw_pci_setup(struct rtw_dev *rtwdev) static void rtw_pci_dma_release(struct rtw_dev *rtwdev, struct rtw_pci *rtwpci) { struct rtw_pci_tx_ring *tx_ring; - u8 queue; + enum rtw_tx_queue_type queue; rtw_pci_reset_trx_ring(rtwdev); for (queue = 0; queue < RTK_MAX_TX_QUEUE_NUM; queue++) { @@ -608,8 +609,8 @@ static void rtw_pci_deep_ps_enter(struct rtw_dev *rtwdev) { struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; struct rtw_pci_tx_ring *tx_ring; + enum rtw_tx_queue_type queue; bool tx_empty = true; - u8 queue; if (rtw_fw_feature_check(&rtwdev->fw, FW_FEATURE_TX_WAKE)) goto enter_deep_ps; @@ -803,7 +804,8 @@ static void rtw_pci_flush_queues(struct rtw_dev *rtwdev, u32 queues, bool drop) __rtw_pci_flush_queues(rtwdev, pci_queues, drop); } -static void rtw_pci_tx_kick_off_queue(struct rtw_dev *rtwdev, u8 queue) +static void rtw_pci_tx_kick_off_queue(struct rtw_dev *rtwdev, + enum rtw_tx_queue_type queue) { struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; struct rtw_pci_tx_ring *ring; @@ -822,7 +824,7 @@ static void rtw_pci_tx_kick_off_queue(struct rtw_dev *rtwdev, u8 queue) static void rtw_pci_tx_kick_off(struct rtw_dev *rtwdev) { struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; - u8 queue; + enum rtw_tx_queue_type queue; for (queue = 0; queue < RTK_MAX_TX_QUEUE_NUM; queue++) if (test_and_clear_bit(queue, rtwpci->tx_queued)) @@ -831,7 +833,8 @@ static void rtw_pci_tx_kick_off(struct rtw_dev *rtwdev) static int rtw_pci_tx_write_data(struct rtw_dev *rtwdev, struct rtw_tx_pkt_info *pkt_info, - struct sk_buff *skb, u8 queue) + struct sk_buff *skb, + enum rtw_tx_queue_type queue) { struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; const struct rtw_chip_info *chip = rtwdev->chip; @@ -949,9 +952,9 @@ static int rtw_pci_tx_write(struct rtw_dev *rtwdev, struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb) { + enum rtw_tx_queue_type queue = rtw_hw_queue_mapping(skb); struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; struct rtw_pci_tx_ring *ring; - u8 queue = rtw_hw_queue_mapping(skb); int ret; ret = rtw_pci_tx_write_data(rtwdev, pkt_info, skb, queue); From patchwork Sat Feb 4 23:30:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13128904 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 938DFC61DA4 for ; Sat, 4 Feb 2023 23:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbjBDXab (ORCPT ); Sat, 4 Feb 2023 18:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbjBDXa3 (ORCPT ); Sat, 4 Feb 2023 18:30:29 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C790C148; Sat, 4 Feb 2023 15:30:28 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id lu11so24891157ejb.3; Sat, 04 Feb 2023 15:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HW/43DsO23wMM/PBvyHhtD5GvgJpDufOCANf4LVvWfk=; b=ne8x7rZxJOVDlM1J3JENOJsBo3jC9kh2eTD945pf7aIDfJHZR88Tl66rh2eVihwCqe bgNSmiPk61GbFRu4UlDuMEgHHiBvkOmjqD2YDxo5NvAKJqPSIqWpS3QLZ4r8WzKqLFJN vntBri+0K5kt9rdrzT0O60eci853AZd2B9JspCtudh7XuxULJvqPsqENuP3rgl2haETs zOuSrNWVf12o3aborjNpY8IfKWBxkVEnfMCBm7O3OR5Z97jjVrKNZ7nneO+epvWU/1mu XWfrgyPJimRTh+bQJtBRAyVDH4L8JXmXy2J4neH66J581FSXJUQA2y82m+m92iLs4ych wwvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HW/43DsO23wMM/PBvyHhtD5GvgJpDufOCANf4LVvWfk=; b=ySx7RHNkozobyIIO5IU9Kgg5O64/Zgnywn9Fjiq2qzaNgrR3WxftbO6ojq3Ra8cKuQ adNqOePr+ODN9/vQ/ZExIIj92Lw7ydyORpXroUWWnrrcyVNfcnoYULwHbs2V5o8WkkmM gbJvZPf81oUzmx1yfXPNw9aQUDfQs1qoY0aMr/RrrlwzY5+C8UsaoJgLDKFqsBREtUb7 sYok/Yacfbcam3wM3r17h5CFqLa4U9PljnJ8Smbd2sHRHKIZSqjEnqAaxrVPmCONNGj7 GpY9RUHEIIeCJwrfg+TEONaoY+0jrzQrXJBdWkoDTUqKJUw8V/IB03t7V1qT04YzQ8cU TeWA== X-Gm-Message-State: AO0yUKXxmr+kLSO4fai9QKDsg++DH1k8NvuIgmnFShYyGvvh7NLVhETt cVklaIWRAjA+IpRQgMcKGBJjuDYAbJ0= X-Google-Smtp-Source: AK7set8DVBdqBbGn9YF3tvA+eC3dh0t5o/yHbzl3VsJTEDQSg9yt4IMHlxrQzzxW1sS3qZ0CFYrkSw== X-Received: by 2002:a17:906:d7a7:b0:87b:d3e3:c23 with SMTP id pk7-20020a170906d7a700b0087bd3e30c23mr16435923ejb.54.1675553427469; Sat, 04 Feb 2023 15:30:27 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7777-cc00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7777:cc00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id v5-20020a1709061dc500b0084d4e9a13cbsm3386658ejh.221.2023.02.04.15.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 15:30:27 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , pkshih@realtek.com, Martin Blumenstingl Subject: [PATCH v2 3/4] wifi: rtw88: Move enum rtw_tx_queue_type mapping code to tx.{c,h} Date: Sun, 5 Feb 2023 00:30:00 +0100 Message-Id: <20230204233001.1511643-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> References: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This code is not specific to the PCIe bus type but can be re-used by USB and SDIO bus types. Move it to tx.{c,h} to avoid code-duplication in the future. While here, add checking of the ac argument in rtw_tx_ac_to_hwq() so we're not accessing entries beyond the end of the array. Signed-off-by: Martin Blumenstingl Reviewed-by: Simon Horman Reviewed-by: Ping-Ke Shih --- Changes from v1 -> v2: - add out of bounds check (with a fallback) in rtw_tx_queue_type() - reword subject and include the "wifi" prefix drivers/net/wireless/realtek/rtw88/pci.c | 35 ++------------------ drivers/net/wireless/realtek/rtw88/tx.c | 41 ++++++++++++++++++++++++ drivers/net/wireless/realtek/rtw88/tx.h | 3 ++ 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c index 5492107fc85b..b4bd831c9845 100644 --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c @@ -670,37 +670,6 @@ static void rtw_pci_deep_ps(struct rtw_dev *rtwdev, bool enter) spin_unlock_bh(&rtwpci->irq_lock); } -static const enum rtw_tx_queue_type ac_to_hwq[] = { - [IEEE80211_AC_VO] = RTW_TX_QUEUE_VO, - [IEEE80211_AC_VI] = RTW_TX_QUEUE_VI, - [IEEE80211_AC_BE] = RTW_TX_QUEUE_BE, - [IEEE80211_AC_BK] = RTW_TX_QUEUE_BK, -}; - -static_assert(ARRAY_SIZE(ac_to_hwq) == IEEE80211_NUM_ACS); - -static enum rtw_tx_queue_type rtw_hw_queue_mapping(struct sk_buff *skb) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - __le16 fc = hdr->frame_control; - u8 q_mapping = skb_get_queue_mapping(skb); - enum rtw_tx_queue_type queue; - - if (unlikely(ieee80211_is_beacon(fc))) - queue = RTW_TX_QUEUE_BCN; - else if (unlikely(ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc))) - queue = RTW_TX_QUEUE_MGMT; - else if (is_broadcast_ether_addr(hdr->addr1) || - is_multicast_ether_addr(hdr->addr1)) - queue = RTW_TX_QUEUE_HI0; - else if (WARN_ON_ONCE(q_mapping >= ARRAY_SIZE(ac_to_hwq))) - queue = ac_to_hwq[IEEE80211_AC_BE]; - else - queue = ac_to_hwq[q_mapping]; - - return queue; -} - static void rtw_pci_release_rsvd_page(struct rtw_pci *rtwpci, struct rtw_pci_tx_ring *ring) { @@ -798,7 +767,7 @@ static void rtw_pci_flush_queues(struct rtw_dev *rtwdev, u32 queues, bool drop) } else { for (i = 0; i < rtwdev->hw->queues; i++) if (queues & BIT(i)) - pci_queues |= BIT(ac_to_hwq[i]); + pci_queues |= BIT(rtw_tx_ac_to_hwq(i)); } __rtw_pci_flush_queues(rtwdev, pci_queues, drop); @@ -952,7 +921,7 @@ static int rtw_pci_tx_write(struct rtw_dev *rtwdev, struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb) { - enum rtw_tx_queue_type queue = rtw_hw_queue_mapping(skb); + enum rtw_tx_queue_type queue = rtw_tx_queue_mapping(skb); struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; struct rtw_pci_tx_ring *ring; int ret; diff --git a/drivers/net/wireless/realtek/rtw88/tx.c b/drivers/net/wireless/realtek/rtw88/tx.c index ab39245e9c2f..bb5c7492c98b 100644 --- a/drivers/net/wireless/realtek/rtw88/tx.c +++ b/drivers/net/wireless/realtek/rtw88/tx.c @@ -682,3 +682,44 @@ void rtw_txq_cleanup(struct rtw_dev *rtwdev, struct ieee80211_txq *txq) list_del_init(&rtwtxq->list); spin_unlock_bh(&rtwdev->txq_lock); } + +static const enum rtw_tx_queue_type ac_to_hwq[] = { + [IEEE80211_AC_VO] = RTW_TX_QUEUE_VO, + [IEEE80211_AC_VI] = RTW_TX_QUEUE_VI, + [IEEE80211_AC_BE] = RTW_TX_QUEUE_BE, + [IEEE80211_AC_BK] = RTW_TX_QUEUE_BK, +}; + +static_assert(ARRAY_SIZE(ac_to_hwq) == IEEE80211_NUM_ACS); + +enum rtw_tx_queue_type rtw_tx_ac_to_hwq(enum ieee80211_ac_numbers ac) +{ + if (WARN_ON(unlikely(ac >= IEEE80211_NUM_ACS))) + return RTW_TX_QUEUE_BE; + + return ac_to_hwq[ac]; +} +EXPORT_SYMBOL(rtw_tx_ac_to_hwq); + +enum rtw_tx_queue_type rtw_tx_queue_mapping(struct sk_buff *skb) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + __le16 fc = hdr->frame_control; + u8 q_mapping = skb_get_queue_mapping(skb); + enum rtw_tx_queue_type queue; + + if (unlikely(ieee80211_is_beacon(fc))) + queue = RTW_TX_QUEUE_BCN; + else if (unlikely(ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc))) + queue = RTW_TX_QUEUE_MGMT; + else if (is_broadcast_ether_addr(hdr->addr1) || + is_multicast_ether_addr(hdr->addr1)) + queue = RTW_TX_QUEUE_HI0; + else if (WARN_ON_ONCE(q_mapping >= ARRAY_SIZE(ac_to_hwq))) + queue = ac_to_hwq[IEEE80211_AC_BE]; + else + queue = ac_to_hwq[q_mapping]; + + return queue; +} +EXPORT_SYMBOL(rtw_tx_queue_mapping); diff --git a/drivers/net/wireless/realtek/rtw88/tx.h b/drivers/net/wireless/realtek/rtw88/tx.h index a2f3ac326041..197d5868c8ad 100644 --- a/drivers/net/wireless/realtek/rtw88/tx.h +++ b/drivers/net/wireless/realtek/rtw88/tx.h @@ -131,6 +131,9 @@ rtw_tx_write_data_h2c_get(struct rtw_dev *rtwdev, struct rtw_tx_pkt_info *pkt_info, u8 *buf, u32 size); +enum rtw_tx_queue_type rtw_tx_ac_to_hwq(enum ieee80211_ac_numbers ac); +enum rtw_tx_queue_type rtw_tx_queue_mapping(struct sk_buff *skb); + static inline void fill_txdesc_checksum_common(u8 *txdesc, size_t words) { From patchwork Sat Feb 4 23:30:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13128906 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF719C61DA4 for ; Sat, 4 Feb 2023 23:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232576AbjBDXae (ORCPT ); Sat, 4 Feb 2023 18:30:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbjBDXab (ORCPT ); Sat, 4 Feb 2023 18:30:31 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA3B20D3F; Sat, 4 Feb 2023 15:30:29 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id k4so24897643eje.1; Sat, 04 Feb 2023 15:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z2OOn9fRXNRi/D1wH37mZYRXmM0quMrDez5IgGiosfE=; b=SEpEv7LYUi6fgDWjw58MnVru5yw3PR4Nv9F5hz9BybL1VI5ncXJWDCa0A+RMTUDTW9 VS8x1Johk107INT5c6XKACchwDjsJ0wAKpkXTkITuGwAp5pzu2vO7jr7cKFksMJjXtcm zxSWaqoudv9upUL1uek3oEHUBglZUOozLKhCsV5nKOIoyGDfMO/UwmKMQTD3LSfYPtNj pt6rLNM19iVCnjUaRNrQQznFMYJAZ/IoIeHyUAbImG6dGVd9lvmPCZh9LAlwoyMqk0iN O4utBltvi7sqz6ohwpgxCXeHKzGKRzmcn4WWX6YlXNGKdGXM+bnL4jkzDBhW9LxcGsUn mcXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z2OOn9fRXNRi/D1wH37mZYRXmM0quMrDez5IgGiosfE=; b=sgMjfN1WG5x+ypSUh8sRoMbEB1MnJHaFPSUWAvvXwCmpFdNdgmuqeefrTLpgtcRYAd 2WfY8jYcO7wHxVfWbjc3BEVLFS4W21b5w9OzIvQ0BpR/5mX9/WNcNwpMb+NBNWttfNXA nWNlPFXEidOI1fk0QRRqaVE7an8RM6pdGa78uJuUkLbTeKC8v5c0iq4qDBGfpdvgH6hf gNlymxyBfz3GHTvjQXcq27EKzsdNd3Ep9WcCnSb3k44qNSX1zSaOqTjFmazfhxwAlFbz YQ7ppu265Nb7xPMgwOqZ7C5ktle3hzl0cWFqcoBCt62+QD6Uyt7Y2jmMGb2fO9TtR5Am gl5Q== X-Gm-Message-State: AO0yUKWkpZyKTdAdMrol7oOUk15ZCOeh1adnCgGjsOoanRcNeMMt964x LfKMspovPIsvfIdSuFBKk7j+8f8FQio= X-Google-Smtp-Source: AK7set9RFpSCBsOLZmbEz9QMqDpnQ3kXDdCfwx9PGfRzdBnIj20vsnMnQFO91WSbWBcbTxeHRtcGFg== X-Received: by 2002:a17:906:5658:b0:878:7b5c:3811 with SMTP id v24-20020a170906565800b008787b5c3811mr13627277ejr.42.1675553428265; Sat, 04 Feb 2023 15:30:28 -0800 (PST) Received: from localhost.localdomain (dynamic-2a01-0c22-7777-cc00-f22f-74ff-fe21-0725.c22.pool.telefonica.de. [2a01:c22:7777:cc00:f22f:74ff:fe21:725]) by smtp.googlemail.com with ESMTPSA id v5-20020a1709061dc500b0084d4e9a13cbsm3386658ejh.221.2023.02.04.15.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 15:30:27 -0800 (PST) From: Martin Blumenstingl To: linux-wireless@vger.kernel.org Cc: tony0620emma@gmail.com, kvalo@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Neo Jou , Jernej Skrabec , pkshih@realtek.com, Martin Blumenstingl Subject: [PATCH v2 4/4] wifi: rtw88: mac: Use existing macros in rtw_pwr_seq_parser() Date: Sun, 5 Feb 2023 00:30:01 +0100 Message-Id: <20230204233001.1511643-5-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> References: <20230204233001.1511643-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Replace the magic numbers for the intf_mask with their existing RTW_PWR_INTF_PCI_MSK and RTW_PWR_INTF_USB_MSK macros to make the code easier to understand. Acked-by: Ping-Ke Shih Signed-off-by: Martin Blumenstingl Reviewed-by: Simon Horman --- Changes from v1 -> v2: - reword subject and include the "wifi" prefix - add Ping-Ke's Acked-by drivers/net/wireless/realtek/rtw88/mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/mac.c b/drivers/net/wireless/realtek/rtw88/mac.c index 98777f294945..4e5c194aac29 100644 --- a/drivers/net/wireless/realtek/rtw88/mac.c +++ b/drivers/net/wireless/realtek/rtw88/mac.c @@ -217,10 +217,10 @@ static int rtw_pwr_seq_parser(struct rtw_dev *rtwdev, cut_mask = cut_version_to_mask(cut); switch (rtw_hci_type(rtwdev)) { case RTW_HCI_TYPE_PCIE: - intf_mask = BIT(2); + intf_mask = RTW_PWR_INTF_PCI_MSK; break; case RTW_HCI_TYPE_USB: - intf_mask = BIT(1); + intf_mask = RTW_PWR_INTF_USB_MSK; break; default: return -EINVAL;