From patchwork Thu May 9 20:50: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: 13660416 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.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 672EE82871 for ; Thu, 9 May 2024 20:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287868; cv=none; b=iqLbYG52Mf0apXPcaekwW0ceZg+th6VLc5DANr+9cfls8msvmG0iwN7iAoF5QItPjAZJF6P0+nyDYLdhagjb9/OpYNWn36pAYAVytSTCkOjaT7V1bA1Iiqm9ruFF2nFEAZN0n+XcSMGw6wd2nypKGowKHHRUqguw+riDMAn2AeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287868; c=relaxed/simple; bh=AO4ibM0f40u0LST8xsBvynBO/brqWCLwYZxK5Wpm0nw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mzoS4slwISFbaZj8uD+1AWDgxRxNJBOEupnt1XbVJyIF5Iu0+1Sf0gVdgCwoPgqXFU9lU6AnxgjBwri/FpWJTotepmxZOudGd6phtGf2/NyPSibZeRab4YBbL8nt4qKCOGvyLWa8a27xQWT5yNprn8A0N1nJtyemoSGuAKiQna4= 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=Ed67/4tf; arc=none smtp.client-ip=209.85.210.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="Ed67/4tf" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6f44ed6e82fso1220782b3a.3 for ; Thu, 09 May 2024 13:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1715287866; x=1715892666; 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=mK9jRCqJy/IAjt4V55hSSH/H3KvUaHNlqx/4tUOcg/w=; b=Ed67/4tfRKob+rHwqlGfFIl6bqdWmz9So+IxPDc4LHg5gndY/4YzTkAYeIdM4Tp9Yk OrrehrbByqoUzvelU3q/x5TzL98DIlmdYARhEYkZnbXNhud9tvOvxMhnphWq5Taxcb7P tzRfNG/9JxVKihzIGfjBgX1vUmbScnaNzEhuE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715287866; x=1715892666; 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=mK9jRCqJy/IAjt4V55hSSH/H3KvUaHNlqx/4tUOcg/w=; b=ecUqW7CutgMzezTK9eAdW+CSw3DqTDYZ22anUFSDY7zc2ScYhovxUKckNqKeEosfxK bklWZPyZoGaGzGTgQiwdmimFetmhU3EYpQ3QWFMd1fTh2tBWolyk95V+IbkYRpK2e73V RQqtkP/EmxX3BdDl6U94UYs+R8sbKVS2F8Ls554gPD53gp1G6UBg8pqvTu+TbBvBcrk2 aNVMYF8IXF9IldQJekProJupMYPXp1z5bkDHMItjMSzVXGZ4S5xO8OsRi0zqs4cxT160 s8b2ZhglvYnt1kNbxstWD/pPl+yVBaiYETnpRqAZrZeU4gmrXt8Nhr2TRf5ChlxT5KWy ITtA== X-Forwarded-Encrypted: i=1; AJvYcCVzUjRKRrtTVe4EO8FORR7WO80pn1QLCGL6uycYPHhtN/HFr/QiZKnvjpx9aw63uRKmVlPaNwxbYjJPfCSzM0rgCj6goKGE X-Gm-Message-State: AOJu0YywC/haD4/X5xO2eVPpmOKAE2nDJyq01sdlhan3sSpw6sujdefT wonJDdEycxphu2nIyEpjLm8Jo6VmcLRH1JU32d+6Y0h+N1mQhIXMOvyq7QVvBpc= X-Google-Smtp-Source: AGHT+IHla1dQrim4j3USXrIXGvmfovYHjmRSCd80Xn+OwNzfQ8XNKU71RDvgr85iegLA1EQwUc2zpw== X-Received: by 2002:a05:6a21:99aa:b0:1af:7180:494f with SMTP id adf61e73a8af0-1afde1b6f3dmr1283476637.41.1715287865782; Thu, 09 May 2024 13:51:05 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0badb959sm18677365ad.85.2024.05.09.13.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 13:51:05 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, nalramli@fastly.com, Joe Damato , Tariq Toukan , "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 v4 1/3] net/mlx4: Track RX allocation failures in a stat Date: Thu, 9 May 2024 20:50:54 +0000 Message-Id: <20240509205057.246191-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240509205057.246191-1-jdamato@fastly.com> References: <20240509205057.246191-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. A new field called alloc_fail has been added to struct mlx4_en_rx_ring which is now incremented in mlx4_en_rx_ring when -ENOMEM occurs. Signed-off-by: Joe Damato Tested-by: Martin Karsten --- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 4 +++- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 8328df8645d5..15c57e9517e9 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->alloc_fail++; return -ENOMEM; + } ring->rx_alloc_pages++; } rx_desc->data[i].addr = cpu_to_be64(frags->dma + diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index efe3f97b874f..cd70df22724b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -355,6 +355,7 @@ struct mlx4_en_rx_ring { unsigned long xdp_tx; unsigned long xdp_tx_full; unsigned long dropped; + unsigned long alloc_fail; int hwtstamp_rx_filter; cpumask_var_t affinity_mask; struct xdp_rxq_info xdp_rxq; From patchwork Thu May 9 20:50: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: 13660417 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 75AA384FB1 for ; Thu, 9 May 2024 20:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287870; cv=none; b=CjizIWDvktH/nNHgIRF6AjyKl9TtpKVI5cEsvIwbLQWCmFQRgwdSSVlxBG10OQ0W2cMvUXKmPvn6iI9KZpWAdAsMlLg9AlPYnbG24eBPNIPui9LQ0sBsc44hQNi9/4INGVYH4o0giz2BLDTAoSYz8IFqmyNyxBqxPiv/cwEtCXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287870; c=relaxed/simple; bh=gCbabcQaR8Ix1K97TkMliO2FSC7RBAC3W9/BPXaCzC8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MCvOfGaAXYq/Wnom/JV8QVAilIJ/Q9k9hgYbm5B+S+Hm0ymz/fwTfNyq8H5+ru9I2UjmZsvshFGroHvSfqUcJFSMZ5V7IyVfuPr7agxp38KRKKv5zwBoisjTeDne4e5BD4dvnkZHH+bFvlzPeVCopDCxlELaM9nBwLpVJ/346Hk= 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=hYC9Rgdp; arc=none smtp.client-ip=209.85.214.179 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="hYC9Rgdp" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1ed835f3c3cso11423455ad.3 for ; Thu, 09 May 2024 13:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1715287867; x=1715892667; 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=KmgZyGJ6WZhyygeOTuBznvTKrsssXOFJdYN+KnXDyKU=; b=hYC9RgdpmNvwLSFloxHwGaw+e7pmgNtitqyJHDDhUem8n+0hxCP/5WnD2hcd471I5L hdLXA9w08eZ/nZl7irhqC1khRlPK20SDefVorcL9Tg5w1l3B4Sci7mEaz8qtnXXGMPSR axYI2Otl+5r57V7yt9QZldcrzAIRP++r7mPfE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715287867; x=1715892667; 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=KmgZyGJ6WZhyygeOTuBznvTKrsssXOFJdYN+KnXDyKU=; b=NaTCSoRtH3VTZks/CSYBevjUcz0WSokn+IAOUC3ZuCXXMgIWAWl4J+/x5N7bic4JcP /Frq+9xqSxC8fUchWsD7AEijv6Fex7dhUHmuH1W0KEuskTxQ3vjVim0Dn4Z9IjVYMyBm 8jNUPeqc47Cxkg64LEWJ92Ji0BRFYdg6B7RyXWcT9mQqQJEVEj6iE1ypIdBUKSeBMCBx BLY7FijqfKHyoMixcYjPnEokBBckDu25RMdX3TwslX5K66FX6S9qktN6zsMOQMMgHxY2 syQpdaqXhWPIdkx1jz+fbjX/a/EMaY3R5kJHuIjiWw3T8uCd1+TFbssrRDeSLgX4FifF XoHg== X-Forwarded-Encrypted: i=1; AJvYcCVenbd9qC4tcUMiQikEyiSzFqeGQGUGEDfngnz6rBBZCnURusBve+7LxsOytCZ/vAM/jl2TbFzdSzct8ALxyV/OGV4iio2M X-Gm-Message-State: AOJu0Yyg7mSzRXTVB3buLCYPYlkDuHkIuBajuuRTsFdF9X6rF4cQTInx 1oHVPcDBbGUyOt6+M0vTwQFJX5HHRl57rTpL2MH8RBYEaXKkWwJDMmXBkEZlD6Q= X-Google-Smtp-Source: AGHT+IFAC02y7XWbzyZ9poYznCRhteDMrS6y/6vnrp3VuOJIRuyyMgREUL36urHGU3CvlHCx24DmMQ== X-Received: by 2002:a17:902:d4c2:b0:1ec:ad62:fe87 with SMTP id d9443c01a7336-1ef44059628mr10146585ad.56.1715287867290; Thu, 09 May 2024 13:51:07 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0badb959sm18677365ad.85.2024.05.09.13.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 13:51:06 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, nalramli@fastly.com, Joe Damato , Jakub Kicinski , Tariq Toukan , "David S. Miller" , Eric Dumazet , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX4 core VPI driver) Subject: [PATCH net-next v4 2/3] net/mlx4: link NAPI instances to queues and IRQs Date: Thu, 9 May 2024 20:50:55 +0000 Message-Id: <20240509205057.246191-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240509205057.246191-1-jdamato@fastly.com> References: <20240509205057.246191-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 cd70df22724b..28b70dcc652e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -380,6 +380,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 Thu May 9 20:50:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13660418 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 96EAC85620 for ; Thu, 9 May 2024 20:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287871; cv=none; b=gRJM2FAdmU5zlAsLqX7n9nsi0/LVgR5aXU5un1HU7i/5rsDdOkCntrGMmzEII1BTPzTSXHZfPYMbPbLguGDYoo6+ZnfFajPmBomrldtgYKzcvHYupbTD7CzH9Jx4oGKY4YVAl3kJUEURKPlRO9vy88ZyJVSWdldsIlzIuigMicA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715287871; c=relaxed/simple; bh=jh0q0ulQ5LcPy3XQUg0Ue3n4pGfewvXGaX+N3ICGH+Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TIUlCYBTIPTgNleRdGU4QhQDfidnfNN+E5H21vYl+09KqrB3AtE0UANLLurUmezuWiGL4/0ZV8QF9EAcJysCCOV+RtgttJ2GIYvVnQVsAfLgZiFz0doil/tH5UNZPoiP7gGrltfA7SnH0cWX7ZvTRRxcWf+jlQDIG8Gr6thMInI= 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=jXh2kqeU; arc=none smtp.client-ip=209.85.214.175 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="jXh2kqeU" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1ec69e3dbcfso10708685ad.0 for ; Thu, 09 May 2024 13:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1715287869; x=1715892669; 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=No8/jmvB2lIMy6tK61c0Wm+y+Z2VaVEhQDXdDb8ENDg=; b=jXh2kqeUaVQ0nhfXGHTIL23aws5KMCR8Yscd7r1sehBwfSwQRHDjCnXqcnG0IRr0oH 3a+hKH2nHUvzXiXJA9/y/H35CGqSW2LAh6Wx5h13meATPrwl3nalSImdxrrhXHWILNuv 4JPlAyjSq+MMJEmRPYcZXa80RgNMRcWQWZ1i8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715287869; x=1715892669; 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=No8/jmvB2lIMy6tK61c0Wm+y+Z2VaVEhQDXdDb8ENDg=; b=VaZCNJvRWBT2YqlJDOoQYTht097FqnsCuEhCKKt3TdG5It2is1FvpSME5TSgqh7Ilj eX4ZNoIQ5Pvz6He69A+50ID+U3kJzzq6tEi9n4Do+dhniAuZl2BuY5FQXjFXVqphR+xN +wSeTPlD+J0b/PaiDzvCgwIncVDHOeLUIzoh5JAsGWPNm2XKKEnQvJJlqqLc1HBPT65R lRBfqN7ym55P7OfTffYK4ufokPQhUMd9FBrAnPMGBLlS7JqxBjODEkDSNTUQAgta6fVm uSogrZpYpzmg0lGy0Gu1Ed+opCNsbpWzbLuRt0cMgM3tajlTw0UzbWLKTJ6OeUIvKlyq OpKA== X-Forwarded-Encrypted: i=1; AJvYcCVPHOI8DX3LFmWHrtgo8bGa2MlZJoKXDBHKrBbKU1yZ6dKcbbChIJW6Y36bNbMfFPT+Mok1dfcPS8QX9HhSvATuKFCciIaX X-Gm-Message-State: AOJu0Yxnwi6e/VW4He4EmffnK2JqNsykhaWlHJcwvtq2pZkpKXLNBCLI v/C30QXl4ZRGwjFeQ9kA5Lbw1DS+6XXxiNwLbUMoiUzsELDl/JrK145YzJgBaHI= X-Google-Smtp-Source: AGHT+IFdJzoOlK3+2PZn0yWAVQ5SUDkUUcQQGgjCs9iyqPeiJ5XXgMJqnpVya2oFF/6RdwbW0XGY1w== X-Received: by 2002:a17:902:f812:b0:1eb:1474:5ef5 with SMTP id d9443c01a7336-1ef43d2ea72mr6154495ad.33.1715287868873; Thu, 09 May 2024 13:51:08 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0badb959sm18677365ad.85.2024.05.09.13.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 13:51:08 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, nalramli@fastly.com, Joe Damato , Tariq Toukan , "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 v4 3/3] net/mlx4: support per-queue statistics via netlink Date: Thu, 9 May 2024 20:50:56 +0000 Message-Id: <20240509205057.246191-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240509205057.246191-1-jdamato@fastly.com> References: <20240509205057.246191-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 --- .../net/ethernet/mellanox/mlx4/en_netdev.c | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 4c089cfa027a..fd79e957b5d8 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,77 @@ 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; + + ring = priv->rx_ring[i]; + stats->packets = READ_ONCE(ring->packets); + stats->bytes = READ_ONCE(ring->bytes); + stats->alloc_fail = READ_ONCE(ring->alloc_fail); + +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; + + 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 +3334,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; /*