From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BF2BCD37AF for ; Sat, 9 May 2026 13:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Wfm1ebR8KpCb/3t1Wm4Vnh+N3lu+KDDPiciqDRZaEEI=; b=MNyb84Cc+elMcxko/bVHAH+F8J WJXe2o2gW3xRCmYsA5vfcdklkkSWh4f1YIB+Mvgyboqw1pp7GdmnFkCI53OX874gPaX0tKlu+04Gf V9qn+PvMSQtIm+S0dN6o6xfC9l13mRixZbqkHTFZqzWMtiiMqSoBn7NTItdjHs7bBO+2G8RrETW2z m90UimtE2XH7Bna5uYXvP0DXtIx9XkyEg9yzsW65gP3jjxvyiuMF3u2HMn/hklWY1jy/KjM1aILps 00pTA6vhmjTwNaXZdSt5rUx/mI9zBQdYMiOioYqfHgzzf6xSXClK+d5ER6Wzr9M2yv41TxlQPQBDM wTfk922Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wLhNl-00000008yXZ-3Oa5; Sat, 09 May 2026 13:06:13 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wLhNi-00000008yTJ-2GTo; Sat, 09 May 2026 13:06:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id F41236024D; Sat, 9 May 2026 13:06:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 186C0C2BCC7; Sat, 9 May 2026 13:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778331969; bh=JBu/pFDd+voohNzFYglle2gQXZmQlnyxgdMRxiXi4VY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lC4PVVPBLoeKcia8HT3X1Wmgn+bgat7xq+udY6tQZNmHCwHGl6XvN8U/wwFNLB19Q loiFIYxryxFT8ei6wvZRNKvBGVBjbKuYXJDeMgepBgrS0B2lj9B7/7wurqnWJ+nNvI NLtuNCgomv0D87iFVSSFQT1Fh8o92mLGx1a8mxJCm+Ahlr2RfUpd+NsquwzY7+HA2h fJ90sEjaAbyqfHwd4H342PsdTv6YMnCXU7Fhxd0BOuItBQyxLW4+UHxgsWP1Q8mExP q0iTV2Q8DSbwJ4lYaAf7r9EH4kWuz16t6ldXZdB/i5LD8DyKCwKV5geIEt3+tq5jlF njz0Jb9TysK1g== From: Lorenzo Bianconi Date: Sat, 09 May 2026 15:05:31 +0200 Subject: [PATCH net-next v5 06/12] net: airoha: Move qos_sq_bmap in airoha_gdm_dev struct MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260509-airoha-eth-multi-serdes-v5-6-805e38edc2aa@kernel.org> References: <20260509-airoha-eth-multi-serdes-v5-0-805e38edc2aa@kernel.org> In-Reply-To: <20260509-airoha-eth-multi-serdes-v5-0-805e38edc2aa@kernel.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lorenzo Bianconi Cc: Christian Marangi , Benjamin Larsson , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, devicetree@vger.kernel.org X-Mailer: b4 0.14.3 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since now multiple net_devices connected to different QDMA blocks can share the same GDM port, qos_sq_bmap field can be overwritten with the configuration obtained from a net_device connected to a different QDMA block. In order to fix the issue move qos_sq_bmap field from airoha_gdm_port struct to airoha_gdm_dev one. Add qos_channel_map bitmap in airoha_qdma struct to track if a shared QDMA channel is already in use by another net_device. Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/airoha/airoha_eth.c | 65 ++++++++++++++++++++++---------- drivers/net/ethernet/airoha/airoha_eth.h | 6 ++- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c index f9cb49f0529a..33a0f7b98d52 100644 --- a/drivers/net/ethernet/airoha/airoha_eth.c +++ b/drivers/net/ethernet/airoha/airoha_eth.c @@ -2606,19 +2606,28 @@ static int airoha_tc_htb_alloc_leaf_queue(struct net_device *netdev, u32 rate = div_u64(opt->rate, 1000) << 3; /* kbps */ int err, num_tx_queues = netdev->real_num_tx_queues; struct airoha_gdm_dev *dev = netdev_priv(netdev); - struct airoha_gdm_port *port = dev->port; + struct airoha_qdma *qdma = dev->qdma; if (opt->parent_classid != TC_HTB_CLASSID_ROOT) { NL_SET_ERR_MSG_MOD(opt->extack, "invalid parent classid"); return -EINVAL; } + /* Here we need to check the requested QDMA channel is not already + * in use by another net_device running on the same QDMA block. + */ + if (test_and_set_bit(channel, qdma->qos_channel_map)) { + NL_SET_ERR_MSG_MOD(opt->extack, + "qdma qos channel already in use"); + return -EBUSY; + } + err = airoha_qdma_set_tx_rate_limit(netdev, channel, rate, opt->quantum); if (err) { NL_SET_ERR_MSG_MOD(opt->extack, "failed configuring htb offload"); - return err; + goto error; } if (opt->command == TC_HTB_NODE_MODIFY) @@ -2630,13 +2639,17 @@ static int airoha_tc_htb_alloc_leaf_queue(struct net_device *netdev, opt->quantum); NL_SET_ERR_MSG_MOD(opt->extack, "failed setting real_num_tx_queues"); - return err; + goto error; } - set_bit(channel, port->qos_sq_bmap); + set_bit(channel, dev->qos_sq_bmap); opt->qid = AIROHA_NUM_TX_RING + channel; return 0; +error: + clear_bit(channel, qdma->qos_channel_map); + + return err; } static int airoha_qdma_set_rx_meter(struct airoha_gdm_dev *dev, @@ -2814,14 +2827,28 @@ static int airoha_dev_setup_tc_block(struct net_device *dev, } } -static void airoha_tc_remove_htb_queue(struct net_device *netdev, int queue) +static int airoha_tc_remove_htb_queue(struct net_device *netdev, int queue) { struct airoha_gdm_dev *dev = netdev_priv(netdev); - struct airoha_gdm_port *port = dev->port; + struct airoha_qdma *qdma = dev->qdma; + int err; - netif_set_real_num_tx_queues(netdev, netdev->real_num_tx_queues - 1); - airoha_qdma_set_tx_rate_limit(netdev, queue + 1, 0, 0); - clear_bit(queue, port->qos_sq_bmap); + err = netif_set_real_num_tx_queues(netdev, + netdev->real_num_tx_queues - 1); + if (err) + return err; + + err = airoha_qdma_set_tx_rate_limit(netdev, queue + 1, 0, 0); + if (err) { + netif_set_real_num_tx_queues(netdev, + netdev->real_num_tx_queues + 1); + return err; + } + + clear_bit(queue, qdma->qos_channel_map); + clear_bit(queue, dev->qos_sq_bmap); + + return 0; } static int airoha_tc_htb_delete_leaf_queue(struct net_device *netdev, @@ -2829,26 +2856,27 @@ static int airoha_tc_htb_delete_leaf_queue(struct net_device *netdev, { u32 channel = TC_H_MIN(opt->classid) % AIROHA_NUM_QOS_CHANNELS; struct airoha_gdm_dev *dev = netdev_priv(netdev); - struct airoha_gdm_port *port = dev->port; - if (!test_bit(channel, port->qos_sq_bmap)) { + if (!test_bit(channel, dev->qos_sq_bmap)) { NL_SET_ERR_MSG_MOD(opt->extack, "invalid queue id"); return -EINVAL; } - airoha_tc_remove_htb_queue(netdev, channel); - - return 0; + return airoha_tc_remove_htb_queue(netdev, channel); } static int airoha_tc_htb_destroy(struct net_device *netdev) { struct airoha_gdm_dev *dev = netdev_priv(netdev); - struct airoha_gdm_port *port = dev->port; int q; - for_each_set_bit(q, port->qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS) - airoha_tc_remove_htb_queue(netdev, q); + for_each_set_bit(q, dev->qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS) { + int err; + + err = airoha_tc_remove_htb_queue(netdev, q); + if (err) + return err; + } return 0; } @@ -2858,9 +2886,8 @@ static int airoha_tc_get_htb_get_leaf_queue(struct net_device *netdev, { u32 channel = TC_H_MIN(opt->classid) % AIROHA_NUM_QOS_CHANNELS; struct airoha_gdm_dev *dev = netdev_priv(netdev); - struct airoha_gdm_port *port = dev->port; - if (!test_bit(channel, port->qos_sq_bmap)) { + if (!test_bit(channel, dev->qos_sq_bmap)) { NL_SET_ERR_MSG_MOD(opt->extack, "invalid queue id"); return -EINVAL; } diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h index c038e722370e..475f5c64bfcb 100644 --- a/drivers/net/ethernet/airoha/airoha_eth.h +++ b/drivers/net/ethernet/airoha/airoha_eth.h @@ -532,6 +532,8 @@ struct airoha_qdma { struct airoha_queue q_tx[AIROHA_NUM_TX_RING]; struct airoha_queue q_rx[AIROHA_NUM_RX_RING]; + + DECLARE_BITMAP(qos_channel_map, AIROHA_NUM_QOS_CHANNELS); }; struct airoha_gdm_dev { @@ -539,6 +541,8 @@ struct airoha_gdm_dev { struct airoha_qdma *qdma; struct net_device *dev; struct airoha_eth *eth; + + DECLARE_BITMAP(qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS); }; struct airoha_gdm_port { @@ -548,8 +552,6 @@ struct airoha_gdm_port { struct airoha_hw_stats stats; - DECLARE_BITMAP(qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS); - /* qos stats counters */ u64 cpu_tx_packets; u64 fwd_tx_packets; -- 2.54.0