From patchwork Fri Apr 26 18:33:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13645256 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 9633F4687 for ; Fri, 26 Apr 2024 18:34:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714156450; cv=none; b=U/kuPMHrKDReZbBWtRju/jsQoO2l95s3/vbYw3mykVLbM2ea6vyp1LbOhou6rGpKPJKaNjKG6+zqMqSZgYGT06wzltPEjsoGT4/JPXPjKRqzKqeoxozLbCRfYcIb1hOQdq3cOUQlSkdVHmIposBb//IyZAyPfDQfB88bL5IRzV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714156450; c=relaxed/simple; bh=vHW1DL0lxBdtpusUhIuDr8YiecZhEDqf3QUX1YWqzBU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BB+qBQqqblGN/cxF8YtkqZQOsvCzXyRWTSzAgPQmf2dFj3S1zxAwzlB+j4LrA+UNyMmmlaAOl9ALYVMAYPEQcMhQgvKjmuYLTaPQ3boPHHmbc5XvhitKGlQmCFA6UztCI9JlOowr11wNCHmAt0gnQfS+tbqg7Y/I6wuiTG2EC5I= 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=SiRoxZi6; arc=none smtp.client-ip=209.85.214.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="SiRoxZi6" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1e3f17c6491so20382285ad.2 for ; Fri, 26 Apr 2024 11:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1714156448; x=1714761248; darn=vger.kernel.org; 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=aqaAQgdA856jvIs7dAW5ZIMPYVryl65URaMxVc//Sq0=; b=SiRoxZi6yDcS7xehwrjfxyCY3jGc6AAAdpeCGyiTmJmoT7ywIEGPo7WZ+YiSXnO1Nf SOHhjebIOgI4KiAdoB6ZlxyTP6SQKI4aBarpXaiOy7G986qTar+Hi0TpPtdFzLTZZyJ+ sGj5NWmI1QoHbMyyVsh2/RrSDh5dU0IsQn7Yk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714156448; x=1714761248; 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=aqaAQgdA856jvIs7dAW5ZIMPYVryl65URaMxVc//Sq0=; b=fmcTmdDZHFTdIlAkjYdHVZ9g5CIc8Sd6Yb66RwERZ/ZWJhUCG3jRLS+vVzOS+8py4u JxIBMwSI808OZWbKOFnC7X/3nwDmIH0i4hT7e5LXv19iigkqsdU0TG3rq8gVP64wlqLd 59wUa+wkNUYEcNdwPkaYuAJcLmHDuZCCIBRixL5h9Riao5p33BxJuxTSBppzgImsdKik w7nf/fLmoD3r8ZaUohR2nMRcpo0IM526GBXPI1zXdcjmFYVmdnh+PLaDNg27+SsJp/kN hcG231WhZgsfouURrFoQ0F8UKgQw1tLFS7u48deacDWD9ZnnHaK4m/r8nF6bh0xPIJn1 iKCw== X-Forwarded-Encrypted: i=1; AJvYcCVR1WuSLeNZBOp7ILbEwMAhHYLY6qLdRiVAmmVzfuGN6LTAawCFC5S+nsb/WqFgIAfWUov9rWk3cZlammdnFUkVSyj4nK3S X-Gm-Message-State: AOJu0YwGTlRFJI7BkyFJ3eAG+M6ySwbPV7FO03jxCRajqw8HxHt0CPlZ aLdnOxAJdKy2QmJvPBimlz6TkfjNTs/dRCdHtTjKvKSuqGnGqLZka4DX74YGMGo= X-Google-Smtp-Source: AGHT+IGmOBABSwmeCyrHpqNf6ZoNtezrLaurXRxgwMJaiE7lf1v3+4wY7GFcM3RlNtf1RT1PE1g6qw== X-Received: by 2002:a17:903:1205:b0:1e4:ccf6:209f with SMTP id l5-20020a170903120500b001e4ccf6209fmr4140136plh.28.1714156447894; Fri, 26 Apr 2024 11:34:07 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id j23-20020a170902759700b001deecb4f897sm15713152pll.100.2024.04.26.11.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 11:34:07 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, tariqt@nvidia.com, saeedm@nvidia.com Cc: mkarsten@uwaterloo.ca, gal@nvidia.com, nalramli@fastly.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX4 core VPI driver) Subject: [PATCH net-next v2 1/3] net/mlx4: Track RX allocation failures in a stat Date: Fri, 26 Apr 2024 18:33:53 +0000 Message-Id: <20240426183355.500364-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426183355.500364-1-jdamato@fastly.com> References: <20240426183355.500364-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org mlx4_en_alloc_frags currently returns -ENOMEM when mlx4_alloc_page fails but does not increment a stat field when this occurs. struct mlx4_en_rx_ring has a dropped field which is tabulated in mlx4_en_DUMP_ETH_STATS, but never incremented by the driver. This change modifies mlx4_en_alloc_frags to increment mlx4_en_rx_ring's dropped field for the -ENOMEM case. Signed-off-by: Joe Damato Tested-by: Martin Karsten --- drivers/net/ethernet/mellanox/mlx4/en_port.c | 5 ++++- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c index 532997eba698..47541f7666f2 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_port.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c @@ -151,7 +151,7 @@ void mlx4_en_fold_software_stats(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; - unsigned long packets, bytes; + unsigned long packets, bytes, dropped; int i; if (!priv->port_up || mlx4_is_master(mdev->dev)) @@ -159,14 +159,17 @@ void mlx4_en_fold_software_stats(struct net_device *dev) packets = 0; bytes = 0; + dropped = 0; for (i = 0; i < priv->rx_ring_num; i++) { const struct mlx4_en_rx_ring *ring = priv->rx_ring[i]; packets += READ_ONCE(ring->packets); bytes += READ_ONCE(ring->bytes); + dropped += READ_ONCE(ring->dropped); } dev->stats.rx_packets = packets; dev->stats.rx_bytes = bytes; + dev->stats.rx_missed_errors = dropped; packets = 0; bytes = 0; diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 8328df8645d5..573ae10300c7 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -82,8 +82,10 @@ static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv, for (i = 0; i < priv->num_frags; i++, frags++) { if (!frags->page) { - if (mlx4_alloc_page(priv, frags, gfp)) + if (mlx4_alloc_page(priv, frags, gfp)) { + ring->dropped++; return -ENOMEM; + } ring->rx_alloc_pages++; } rx_desc->data[i].addr = cpu_to_be64(frags->dma + From patchwork Fri Apr 26 18:33:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13645257 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 4815814A96 for ; Fri, 26 Apr 2024 18:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714156451; cv=none; b=U71qU4rnLKxFbT8kzuC76FfG1og9oOCZ2Sohnddc38ixkpyGOdtLX+ExI+9m6CwEfs9uf80+W/p4qhEbUJeZwBTiK/Vixspf9uzkjXzscjcLGJPHR/ATZdI3b+CKk+WDF6l+uKuPtvM2mM3tuKgpOujM0CXxS+mBVwEFebRLeTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714156451; c=relaxed/simple; bh=z7MYz1SqSvvk6nW/0aA7VzXJvv/C3aolR9fi0nj1t1s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Kqe58yf5nl8yNyDJYU3RWMHDtGjOM8ld4q7xr8iWkRXMwVOFMDioo/dbhu6H+bzN81qBjRcXYMzbrhiDmnLBjZs08ZbYfqR00zyIGoANVlNxhzDeYX07B5GFECaDhsO/VsVGj9Y9vO6pISdPyLcdwmFrMgf0+BYxP7uvtbzADA8= 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=KL+zdN+O; arc=none smtp.client-ip=209.85.214.178 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="KL+zdN+O" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1eb0e08bfd2so6376075ad.1 for ; Fri, 26 Apr 2024 11:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1714156450; x=1714761250; darn=vger.kernel.org; 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=Fnj34GfYIADDHYe9QxZ0tA9OymLxhmbsRufEPA1lFlk=; b=KL+zdN+OIMESqIa6bHCDBUP0MeSrePl/9WrD9dDeQyUV38WjUjwZVZkegN9eicu1n/ C5AlXmcUSk5/K+vhkRbKprDH9VKAUN18Rm5ObjKMNAU/jXidI+ZNCjk5daJjHc98tNbY CqDsu57b/mMsZ4aZPGRdRdfK+K8ijGo1FrVXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714156450; x=1714761250; 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=Fnj34GfYIADDHYe9QxZ0tA9OymLxhmbsRufEPA1lFlk=; b=TLGp6p/iRkZVrHlPoWE6tLcDrqoi1rpTAUhty3CfRDVhrYxmysvFEJMh/oPONw0E6P tLkAMU+mkumDa7uvOms2gTCIOzd/0ObHtlLcJy4KN6WHiSmlw8csRCgFGvKkWuzQ3o+g 9rKKPmWWcpV6IYfe/omtABuUMsRLZHYUDj+F2WgKQk2HFLTH+IL97u29czms6zKnafSn 2e4c89s3LbE1RGnu1mYqpUnvIPOXUZtoVst8b9UWPQRqqEe3yuwg+bQOF7orEmNSmP7R UTF7N0Zi2f5xmQ8iTbQaUcVuM5iFfCUbkObZnzVzQ9LJj8Q1YFcgxKXNx5fMWdlgv+RP O+AA== X-Forwarded-Encrypted: i=1; AJvYcCXHt3UqN+ajo53xugcQs8UaZI1QKcVhMl6+B6SXFomhJq/TeDuJTMdsU3l5bGG1JQBhfnoCoOHX7YhQ+++udalpZJAoXQuj X-Gm-Message-State: AOJu0YxdACyo0J3uX2rqRQ+RBwzP8BpnmcrMvBvSOoBgAUTb52gk0FI8 1nHsr/LAieX70UvNrINAmUKezSLU6i61NibQhtP+IuFIPvmvloFV/fKGoWTJ3+g= X-Google-Smtp-Source: AGHT+IGZIOzj2H8FqiVmmHXgMXRX0ZqydYegzeUCwj981ToCy0Qyjz0/sEw94VO7ZNVIcGwOrkdcCQ== X-Received: by 2002:a17:902:b20f:b0:1ea:fb65:a0c9 with SMTP id t15-20020a170902b20f00b001eafb65a0c9mr3018377plr.20.1714156449597; Fri, 26 Apr 2024 11:34:09 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id j23-20020a170902759700b001deecb4f897sm15713152pll.100.2024.04.26.11.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 11:34:09 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, tariqt@nvidia.com, saeedm@nvidia.com Cc: mkarsten@uwaterloo.ca, gal@nvidia.com, nalramli@fastly.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX4 core VPI driver) Subject: [PATCH net-next v2 2/3] net/mlx4: link NAPI instances to queues and IRQs Date: Fri, 26 Apr 2024 18:33:54 +0000 Message-Id: <20240426183355.500364-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426183355.500364-1-jdamato@fastly.com> References: <20240426183355.500364-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Make mlx4 compatible with the newly added netlink queue GET APIs. Signed-off-by: Joe Damato Tested-by: Martin Karsten Acked-by: Jakub Kicinski --- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 14 ++++++++++++++ drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c index 1184ac5751e1..461cc2c79c71 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c @@ -126,6 +126,7 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, cq_idx = cq_idx % priv->rx_ring_num; rx_cq = priv->rx_cq[cq_idx]; cq->vector = rx_cq->vector; + irq = mlx4_eq_get_irq(mdev->dev, cq->vector); } if (cq->type == RX) @@ -142,18 +143,23 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, if (err) goto free_eq; + cq->cq_idx = cq_idx; cq->mcq.event = mlx4_en_cq_event; switch (cq->type) { case TX: cq->mcq.comp = mlx4_en_tx_irq; netif_napi_add_tx(cq->dev, &cq->napi, mlx4_en_poll_tx_cq); + netif_napi_set_irq(&cq->napi, irq); napi_enable(&cq->napi); + netif_queue_set_napi(cq->dev, cq_idx, NETDEV_QUEUE_TYPE_TX, &cq->napi); break; case RX: cq->mcq.comp = mlx4_en_rx_irq; netif_napi_add(cq->dev, &cq->napi, mlx4_en_poll_rx_cq); + netif_napi_set_irq(&cq->napi, irq); napi_enable(&cq->napi); + netif_queue_set_napi(cq->dev, cq_idx, NETDEV_QUEUE_TYPE_RX, &cq->napi); break; case TX_XDP: /* nothing regarding napi, it's shared with rx ring */ @@ -189,6 +195,14 @@ void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq **pcq) void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) { if (cq->type != TX_XDP) { + enum netdev_queue_type qtype; + + if (cq->type == RX) + qtype = NETDEV_QUEUE_TYPE_RX; + else + qtype = NETDEV_QUEUE_TYPE_TX; + + netif_queue_set_napi(cq->dev, cq->cq_idx, qtype, NULL); napi_disable(&cq->napi); netif_napi_del(&cq->napi); } diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index efe3f97b874f..896f985549a4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -379,6 +379,7 @@ struct mlx4_en_cq { #define MLX4_EN_OPCODE_ERROR 0x1e const struct cpumask *aff_mask; + int cq_idx; }; struct mlx4_en_port_profile { From patchwork Fri Apr 26 18:33:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13645258 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 DB66E18C36 for ; Fri, 26 Apr 2024 18:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714156454; cv=none; b=dJUYHwWRdGdjsx32jQz+VMZPuCuRS/z8ygnh2TXHr48R98wvVBNmTI0geQhdZQ9PQPQenHOB+UljM4ulSatVFRR4V4aNJUbp5uDA5JbuHnTiEhtD2VEKvdL9+gmaYLblsmCdYoDgWZymQHb+bLyNSavJUj7WoVSbkvjdX2Gglvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714156454; c=relaxed/simple; bh=MLuvGJ/zA1iclcyHt/GxmXZCz5tS19mI8X3ZFBvh8do=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LfuOAdVwbq81JqaSjozGrnld9Oc15YZL9MHDqG03wOVU+FHW/Oot1Lvps17b57IGdsv6fwyfZtaLW0fsGQOFKCo2c5QQrT/fFnl0R2OrZKMg/GYuMkNGePFIEpHNuggC/gvc/6yJb012jSGPds9C2XM8dCEFUq2e5wz2t/Baodg= 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=PS19TAq3; arc=none smtp.client-ip=209.85.214.182 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="PS19TAq3" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1e8fce77bb2so19293215ad.0 for ; Fri, 26 Apr 2024 11:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1714156451; x=1714761251; darn=vger.kernel.org; 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=FvWkUDJTV88ioDILsOGCqcHdicMQ5/7lOhgwRuMptVU=; b=PS19TAq3fZDuOmElwvm4aY25ENEM+vR9XOJEbtlR79rMVLfExkKE6Uvdbv8KmpW09j a5ztdq/SlHm4DXkzwTnKWl3y3YmCri8fBi2T7vvAqqDM4TdiSTFKA8I83JMXcW4LBF3V tP9zfEduvPwtYPXBp1Ys7sj6odRVHm3eW4Qv8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714156451; x=1714761251; 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=FvWkUDJTV88ioDILsOGCqcHdicMQ5/7lOhgwRuMptVU=; b=W7ejlJUv0F1X05cxGCO0C/K9spY2c7uf2yniKPOQq23j/TmpYhCUQpV/V3nbuu8/e3 98u3eufg1b3gPaX4xPFvotCvsIymTnpRr6zcRGTwxw4qKehfOBw1HQhCZzCKJU9cWDE8 cYUihRZdyhN9GR6NSZOGLeeKB7xbxing6Q9rN8+bsUn1yGZo4n0u36/jVMIKZm8aYmRt bvzL/6Eb+LMG4c5eY7eYzLJiI8HGEf32QLB70ipbFFtlfteot5X/3P3cmh4xHG3avyEr Zjo9soV7fKmmyMBSwWNf1cQsEM33yz2IBWGGEN7NofhDhcCtQdFl4D9wrcJDonBSWlih J/aA== X-Forwarded-Encrypted: i=1; AJvYcCU77zIdfN0pbeDVLXPV9gElnllPD/gqDbvwqj17irrO/vUd57wBSV+651d5HthpG+Rui4QYBxDhvXgtXbZR5Q+HuJOtoNkU X-Gm-Message-State: AOJu0YyCii0+K9ycpIPQMWzXh+5aK33Eag+A+MCHI75fPp4vHNiUUVJm 2QIV0L2kajcLHnUhw95P+ioTXIQe2cBkjRdJLNv+q7qJsM0b2/yqmxprRF3wvP4= X-Google-Smtp-Source: AGHT+IEL2BH46uz5mSu+XJ6KKa6VNvwHhbLsO2C+ij6hWATE+1ghZzydX50iems5S/LvEF8wTN3Zjw== X-Received: by 2002:a17:902:c40f:b0:1e9:cf94:5bea with SMTP id k15-20020a170902c40f00b001e9cf945beamr4414909plk.35.1714156451222; Fri, 26 Apr 2024 11:34:11 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id j23-20020a170902759700b001deecb4f897sm15713152pll.100.2024.04.26.11.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 11:34:10 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, tariqt@nvidia.com, saeedm@nvidia.com Cc: mkarsten@uwaterloo.ca, gal@nvidia.com, nalramli@fastly.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX4 core VPI driver) Subject: [PATCH net-next v2 3/3] net/mlx4: support per-queue statistics via netlink Date: Fri, 26 Apr 2024 18:33:55 +0000 Message-Id: <20240426183355.500364-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426183355.500364-1-jdamato@fastly.com> References: <20240426183355.500364-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Make mlx4 compatible with the newly added netlink queue stats API. Signed-off-by: Joe Damato Tested-by: Martin Karsten Reviewed-by: Jakub Kicinski --- .../net/ethernet/mellanox/mlx4/en_netdev.c | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 5d3fde63b273..6875f8c5103a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -3099,6 +3100,83 @@ void mlx4_en_set_stats_bitmap(struct mlx4_dev *dev, last_i += NUM_PHY_STATS; } +static void mlx4_get_queue_stats_rx(struct net_device *dev, int i, + struct netdev_queue_stats_rx *stats) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + const struct mlx4_en_rx_ring *ring; + + spin_lock_bh(&priv->stats_lock); + + if (!priv->port_up || mlx4_is_master(priv->mdev->dev)) + goto out_unlock; + + if (i < 0 || i >= priv->rx_ring_num) + goto out_unlock; + + ring = priv->rx_ring[i]; + stats->packets = READ_ONCE(ring->packets); + stats->bytes = READ_ONCE(ring->bytes); + stats->alloc_fail = READ_ONCE(ring->dropped); + +out_unlock: + spin_unlock_bh(&priv->stats_lock); +} + +static void mlx4_get_queue_stats_tx(struct net_device *dev, int i, + struct netdev_queue_stats_tx *stats) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + const struct mlx4_en_tx_ring *ring; + + spin_lock_bh(&priv->stats_lock); + + if (!priv->port_up || mlx4_is_master(priv->mdev->dev)) + goto out_unlock; + + if (i < 0 || i >= priv->tx_ring_num[TX]) + goto out_unlock; + + ring = priv->tx_ring[TX][i]; + stats->packets = READ_ONCE(ring->packets); + stats->bytes = READ_ONCE(ring->bytes); + +out_unlock: + spin_unlock_bh(&priv->stats_lock); +} + +static void mlx4_get_base_stats(struct net_device *dev, + struct netdev_queue_stats_rx *rx, + struct netdev_queue_stats_tx *tx) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + + spin_lock_bh(&priv->stats_lock); + + if (!priv->port_up || mlx4_is_master(priv->mdev->dev)) + goto out_unlock; + + if (priv->rx_ring_num) { + rx->packets = 0; + rx->bytes = 0; + rx->alloc_fail = 0; + } + + if (priv->tx_ring_num[TX]) { + tx->packets = 0; + tx->bytes = 0; + } + +out_unlock: + spin_unlock_bh(&priv->stats_lock); +} + +static const struct netdev_stat_ops mlx4_stat_ops = { + .get_queue_stats_rx = mlx4_get_queue_stats_rx, + .get_queue_stats_tx = mlx4_get_queue_stats_tx, + .get_base_stats = mlx4_get_base_stats, +}; + int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, struct mlx4_en_port_profile *prof) { @@ -3262,6 +3340,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, netif_set_real_num_tx_queues(dev, priv->tx_ring_num[TX]); netif_set_real_num_rx_queues(dev, priv->rx_ring_num); + dev->stat_ops = &mlx4_stat_ops; dev->ethtool_ops = &mlx4_en_ethtool_ops; /*