From patchwork Fri Feb 9 20:23:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 199083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1109835dyd; Fri, 9 Feb 2024 12:23:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVR/niEG+TuX8uvY4Q8xy+QLVpLEInSyhDIybEJzbzChzsYZpXRszaeEf1A5H1e7/ljGkfJ7zvcNOCQiVJBvd7peH5rVQ== X-Google-Smtp-Source: AGHT+IFXCayy6pNw+34Wu3NcwZfjjlFKCCZVkF506/FFPiObbzmSu6oUhkntuVHiDGn1izB0XPTo X-Received: by 2002:a17:906:ad8b:b0:a37:7ef6:7ffe with SMTP id la11-20020a170906ad8b00b00a377ef67ffemr133429ejb.3.1707510225735; Fri, 09 Feb 2024 12:23:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707510225; cv=pass; d=google.com; s=arc-20160816; b=fkX+nAK8ENVnci4O8kGPvUFun2uPw4HO/tVYwqPqyjrcSUKmXeEsyXWvyxGxhT7nFA lskgXsX/5kajbB9TO7BjFLrOXcg0drZEtrI5RZTVan0QQB1er6tgwV2IS1VJ7XlH4yrz cU54m/vsEZCkSnk+uMhhPjCV6sJ4koiqXfIt3r1zCA0ueA3ziAP1FmLQUaksaLIjWexW aNIYvqvY/EEmI9PWLupoEPMp7goY85SiCIFuvM4GGa4Eg88W6+v9dBovdkwq8MXEzJfY DVfovSBeIRNPSyI+2o6Sx3rPENvhhdLY3Qj9ezQeb/Ve8KAozhlmWbtynPpFjBVHVfng ZMEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=rDZ3Jmq4/nSFOD85T2yiUnizUyC/JrtpL4z0B/Jmq+Q=; fh=FNlOi1znteDX1YCwSIO98V3jm3UhtnReMpVw2CI/u3E=; b=gGcLoKtDWbnrHO4WbDQ5nr+tDL9FsXUVLt8ySXMytE97yfVq0VQJy58z2qgwG9m2JO vra5bNongFUCZCKqTiIFopGGH9u/hL7Y9dSAwl2T3JtdLvXj/0MWnwoh/ZKwKsqgEWtL XUPyJdFnO4aoPhzGAsKdEaodjK/CSQQPuSkCH0cPgZmNyqeSKJBiT4QQzSVO3lUzEhoB eC4RVQhfrlKVMYdBIBtB3OKxkbObhLdEhiLzv/J8WV/vnpU6XvsVQim0yQ8phA1HPV8H +fDR4RRKKZJ0SnKDDrmQNl+ma1+g+qUiDezBsu5Zac7ECwzq/d+thCaDT80/a0s2jDIH vHfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fastly.com header.s=google header.b="k/nFKFRo"; arc=pass (i=1 spf=pass spfdomain=fastly.com dkim=pass dkdomain=fastly.com dmarc=pass fromdomain=fastly.com); spf=pass (google.com: domain of linux-kernel+bounces-59932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59932-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fastly.com X-Forwarded-Encrypted: i=2; AJvYcCUzaXJGkiXNvs2X6UkCOpqhNSPTwqNtbywIEUYGHoEGBNCLRflfsOZfvCyx3uxeOU53Ai/kJVzPfjoWjDgSTtC/JVZmtA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g26-20020a170906395a00b00a3633ac23b9si1148129eje.550.2024.02.09.12.23.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 12:23:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@fastly.com header.s=google header.b="k/nFKFRo"; arc=pass (i=1 spf=pass spfdomain=fastly.com dkim=pass dkdomain=fastly.com dmarc=pass fromdomain=fastly.com); spf=pass (google.com: domain of linux-kernel+bounces-59932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59932-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fastly.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 am.mirrors.kernel.org (Postfix) with ESMTPS id DBEDA1F227DA for ; Fri, 9 Feb 2024 20:23:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 675E6127B41; Fri, 9 Feb 2024 20:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="k/nFKFRo" Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E26C126F09 for ; Fri, 9 Feb 2024 20:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707510201; cv=none; b=M80G9pXi4BHaeb72QO+LbWZDBZVDBaGcLSbTVGVKxF7LFHnIpCrsmBKX7tfjJ9ybpOS1QQI0DnnT/VpGtmvZQcdS07uLMhyeCNcTH6fGrM10dBcp48Qif8UNhGIE0jz8pjMCjcgqmV4tU+mQKCCgVLJ66qWFkVpj3414VSkOT3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707510201; c=relaxed/simple; bh=Qa7WBTIDQpNbeS/hiyhWQzSVHICDNi2Lqssf/YFEgRQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PIYu2RyrZhfDKgc4p8vD6JSzJM4mmzl67N6X4pkUFZ6W9ioW32XKb7SuaP+u/XV5oqUMZuWR1VPDCeSdILatPsSNLn73xWRqTLGYZDMZaATEcbAYmSe2m9pH59RavvKtzQCHrY9DymCrz2qzd5r6DefLjxUmlOv51bYEznpEp/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=k/nFKFRo; arc=none smtp.client-ip=209.85.161.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-599fc25071bso879389eaf.3 for ; Fri, 09 Feb 2024 12:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1707510198; x=1708114998; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rDZ3Jmq4/nSFOD85T2yiUnizUyC/JrtpL4z0B/Jmq+Q=; b=k/nFKFRoIeO5UyIXezOjU30+kbylY8X0rdH7lU4D4U22GLlP9xx/qMLNRMw9s1q/FM Y++AG17tiVa3nnrR2QkltW4NqiQThgQstzq7+7bDLlDz3+9Om3ShVOlg0nC1QZVZrmnj eMnmfmlf3uypwlMNZr0CbUzRHtjH1HSkfX4Qs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707510198; x=1708114998; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rDZ3Jmq4/nSFOD85T2yiUnizUyC/JrtpL4z0B/Jmq+Q=; b=EmT71DAZPRot8CNyv2o8u10t7fuimhBSspTbyqblQNGfAR0U89QDCs1OPKjOCd5Q3v uFB9JAZalcNxWpENs2SgY/Pe5nqKS8gqu7rllAh2V+lPiYlsxx0AdEyF5EEcfCIk9geP v3KBr0sWlsXNt1p18lXAxHKA/2OAhJjkc2mZWxCwXjWtd87XuBgBoDGBhX8ZUFFHv/nd 26CC1x0j63jcpXebSjNZWsUFRjhSugLUtgIsNOQ3jcJQKBwRFxq9a8L7C2rAbEaFfaHz OY/RYGXNUj6MxcofXH22NzclwIpNxVEiL1za7fRSvOGrxuuUhA4Fy+RVxNHKGCvmpoir r0QA== X-Gm-Message-State: AOJu0YwAC9S082ZzOojAKh9BRX+kUYaWUKl3nv/37tuPoxBUn36rRjZS 2I7bg//OoOrHAsl7GonpboDcjyJy4K2I34gj4EbyiXsjEn440T7lPW4CrHx5kbB4dK8X8PFXKIM Bov0d6xBKlX/dIXTsp25h8Evh5OnHf1aFu6ElUm+Jg3U0Ik3OGbHamA3UEndc0zUF7511tsmwud 2z5AyowLfWOgmxMJyjgIubNHWXyQ+igtpStR9AcoWJDeo= X-Received: by 2002:a05:6358:1212:b0:178:8ec9:a2f with SMTP id h18-20020a056358121200b001788ec90a2fmr602645rwi.5.1707510198038; Fri, 09 Feb 2024 12:23:18 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV9gYyDVJ/FTepbkZQWu3Aexv8qHVS0hrlr6yspf74pQaoAyp4jb/aaAEShwx8G0I0JF64bQF9DRoyw+vjK2VOuOd/N+ZjwRQnKTZ/0/RENVtV5Q9qXujjeJo+UJWx3Ku7z+XPP57RCd2F/wJDbaOZmySQTKUyv62JIUVVoj+Xo1xyLufeMnuDWwPxHpTkgJHDd8CTYykBE/gZ0LTgqmJ+kY1/t2ATggIS/IE9CnVm7C8wNXntCa6X94WvNdAakwC0eU8cZncggC3/Xqzdcso5l40SRE9WGdecCHd/8S+jbsfyfkokOvelVGw8otO96Ktlui4zilWlJjvOSNbGLTsrCQnY+nw+Mlh+jj8e95ovv6zuenZ7CrKyJjq5j8zy/4CCbU370DH0/vTnAWfqFZX7d2bwg9uulY0r3efo7usGizAXonVLf Received: from localhost.localdomain ([2620:11a:c018:0:ea8:be91:8d1:f59b]) by smtp.gmail.com with ESMTPSA id e25-20020a62aa19000000b006ddc71607a7sm933742pff.191.2024.02.09.12.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 12:23:17 -0800 (PST) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: tariqt@nvidia.com, rrameshbabu@nvidia.com, Joe Damato , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Gal Pressman , Vadim Fedorenko , linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver) Subject: [PATCH net-next v4] net/mlx5e: link NAPI instances to queues and IRQs Date: Fri, 9 Feb 2024 20:23:08 +0000 Message-Id: <20240209202312.30181-1-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790454242318692164 X-GMAIL-MSGID: 1790454242318692164 Make mlx5 compatible with the newly added netlink queue GET APIs. Signed-off-by: Joe Damato Reviewed-by: Tariq Toukan --- v3 -> v4: - Use sq->netdev and sq->cq.napi to get the netdev and NAPI structures in mlx5e_activate_txqsq and mlx5e_deactivate_txqsq as requested by Tariq Toukan [1] - Only set or unset NETDEV_QUEUE_TYPE_RX when the MLX5E_PTP_STATE_RX bit is on in mlx5e_ptp_activate_channel and mlx5e_ptp_deactivate_channel as requested by Rahul Rameshbabu [2] v2 -> v3: - Fix commit message subject - call netif_queue_set_napi in mlx5e_ptp_activate_channel and mlx5e_ptp_deactivate_channel to enable/disable NETDEV_QUEUE_TYPE_RX for the PTP channel. - Modify mlx5e_activate_txqsq and mlx5e_deactivate_txqsq to set NETDEV_QUEUE_TYPE_TX which should take care of all TX queues including QoS/HTB and PTP. - Rearrange mlx5e_activate_channel and mlx5e_deactivate_channel for better ordering when setting and unsetting NETDEV_QUEUE_TYPE_RX NAPI structs v1 -> v2: - Move netlink NULL code to mlx5e_deactivate_channel - Move netif_napi_set_irq to mlx5e_open_channel and avoid storing the irq, after netif_napi_add which itself sets the IRQ to -1 [1]: https://lore.kernel.org/all/8c083e6d-5fcd-4557-88dd-0f95acdbc747@gmail.com/ [2]: https://lore.kernel.org/all/871q9mz1a0.fsf@nvidia.com/ drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 5 ++++- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c index 078f56a3cbb2..fd4ef6431142 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c @@ -935,6 +935,7 @@ void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c) if (test_bit(MLX5E_PTP_STATE_RX, c->state)) { mlx5e_ptp_rx_set_fs(c->priv); mlx5e_activate_rq(&c->rq); + netif_queue_set_napi(c->netdev, c->rq.ix, NETDEV_QUEUE_TYPE_RX, &c->napi); } mlx5e_trigger_napi_sched(&c->napi); } @@ -943,8 +944,10 @@ void mlx5e_ptp_deactivate_channel(struct mlx5e_ptp *c) { int tc; - if (test_bit(MLX5E_PTP_STATE_RX, c->state)) + if (test_bit(MLX5E_PTP_STATE_RX, c->state)) { + netif_queue_set_napi(c->netdev, c->rq.ix, NETDEV_QUEUE_TYPE_RX, NULL); mlx5e_deactivate_rq(&c->rq); + } if (test_bit(MLX5E_PTP_STATE_TX, c->state)) { for (tc = 0; tc < c->num_tc; tc++) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index c8e8f512803e..be809556b2e1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -1806,6 +1806,7 @@ void mlx5e_activate_txqsq(struct mlx5e_txqsq *sq) set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state); netdev_tx_reset_queue(sq->txq); netif_tx_start_queue(sq->txq); + netif_queue_set_napi(sq->netdev, sq->txq_ix, NETDEV_QUEUE_TYPE_TX, sq->cq.napi); } void mlx5e_tx_disable_queue(struct netdev_queue *txq) @@ -1819,6 +1820,7 @@ void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq) { struct mlx5_wq_cyc *wq = &sq->wq; + netif_queue_set_napi(sq->netdev, sq->txq_ix, NETDEV_QUEUE_TYPE_TX, NULL); clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state); synchronize_net(); /* Sync with NAPI to prevent netif_tx_wake_queue. */ @@ -2560,6 +2562,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, c->lag_port = mlx5e_enumerate_lag_port(priv->mdev, ix); netif_napi_add(netdev, &c->napi, mlx5e_napi_poll); + netif_napi_set_irq(&c->napi, irq); err = mlx5e_open_queues(c, params, cparam); if (unlikely(err)) @@ -2602,12 +2605,16 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c) mlx5e_activate_xsk(c); else mlx5e_activate_rq(&c->rq); + + netif_queue_set_napi(c->netdev, c->ix, NETDEV_QUEUE_TYPE_RX, &c->napi); } static void mlx5e_deactivate_channel(struct mlx5e_channel *c) { int tc; + netif_queue_set_napi(c->netdev, c->ix, NETDEV_QUEUE_TYPE_RX, NULL); + if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state)) mlx5e_deactivate_xsk(c); else