From patchwork Tue Apr 23 19:49:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13640603 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.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 3CE7C1420C9 for ; Tue, 23 Apr 2024 19:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713901779; cv=none; b=kJRxQ7MleI75HJr1MbfbbgQIoEzje4Dh/sTBRc2iEWeuZxdTRTeYsk/1ispGlYbASahh+87n5rtGq0hzr11KkdjpsxMoWpYtxitvdk/s/oITDMHgp9PjS45naV2co/RcI3knPlb2HbzLTW+mUmV6/tWCOmbUQMVKhqyT6VBxx+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713901779; c=relaxed/simple; bh=NAmZBz9KaDewSEn6UsfuFlFlWSCv9ZwDJZlG72i5LnE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qfO7KNwkSEe2p58lAOoBf7Q6NH1P1XqqLVsdLJ6mT+y2k2hddehotZe6KLjtybjubqQQBHS2fwHoVfmR1x17bUkzb0LFf2F4TOnvH9IgiQlKRdaqk77wUajXlaHD90tCj4gxaugMmdpcoOLxRP61Emn91FhvTRuWHD5Mg21nLQE= 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=H79s4Q/R; arc=none smtp.client-ip=209.85.210.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="H79s4Q/R" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6f28bb6d747so2561150b3a.3 for ; Tue, 23 Apr 2024 12:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1713901777; x=1714506577; 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=9XSEsaXMnYKVqcTHOSxPSgntkBLCcmZ9J5ASUc0dakk=; b=H79s4Q/RBaNSw0rrpw6Qp6qd61iAjvVhd9VStu1LP40yRnj4je7Q/QYbgcjlaHqLs7 /gFTUuskAhWmlJe3FU5pLj+wKY+bMQWXdIDg8HgppiesxQl6RPLWyN9ntPvdjWJ/QwgI t6BcbuP5psZuSXsrByIgBQszexyRjR9oZ73W4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713901777; x=1714506577; 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=9XSEsaXMnYKVqcTHOSxPSgntkBLCcmZ9J5ASUc0dakk=; b=wK/qvNxIcQfgIboQJb/5+IEThlT5ME1mNm/s4m3A68txtULtVd52N7IHFo1T1KWjZd yWY1MB2oqASKYQyTqPfyKnRtbfF1vJbQzEplQffb5U38U4cCDM8p+epU8m8xXcPQ3sQ9 x3ObtBmpy0E4In/qHT851AIqPuseU+b0NMxtpXogseI0OUfp1nim/QuS6nZkTZFd9VY6 fIddiOWKIm6aMYP/Dd4vZiRv20TaH8mTtdWzJ/I4Wbue4+VfCSl0DX5TE2rGCgqahY2D mFrHwdTkG+vrwl52GVgzeDq/MO2ejvtqwPkZpV+PnRM7LD3QkrUtQQouCXWd44pMHk9U VGjA== X-Forwarded-Encrypted: i=1; AJvYcCX7SoaxT3FKYFrV10OiQrU4rrrso49jkWlCdTNfIqpKM1HK0ksPoloKN/oGgUZ3s66R3JEw/EQKRV6wt3/8J4JI3d+xro8R6FCucw== X-Gm-Message-State: AOJu0YxjF88xHf+88ZHPNCGLVJxXYCYFTBC3MrBfgaeMQ5iUWFrsZ0Zc dmhcA6jyoNSPEn61N9lAOlmix99Z/6fwHJSVHLZ6ibZNFKE2luYMob+qNx0XzM4= X-Google-Smtp-Source: AGHT+IG6XovYKWAkwGpJrOjAuxe2PGxzyt0cRlqmXFkcgQRTJ+XKwTbwxnJkl3VTUBPWj80xsE85hw== X-Received: by 2002:a05:6a00:8c4:b0:6ed:41f3:431d with SMTP id s4-20020a056a0008c400b006ed41f3431dmr779855pfu.0.1713901777469; Tue, 23 Apr 2024 12:49:37 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id q3-20020a056a00084300b006ecc6c1c67asm9995672pfk.215.2024.04.23.12.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 12:49:37 -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 1/3] net/mlx4: Track RX allocation failures in a stat Date: Tue, 23 Apr 2024 19:49:28 +0000 Message-Id: <20240423194931.97013-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240423194931.97013-1-jdamato@fastly.com> References: <20240423194931.97013-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 4 +++- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 4 +++- 2 files changed, 6 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..c4b1062158e1 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)) @@ -164,9 +164,11 @@ void mlx4_en_fold_software_stats(struct net_device *dev) 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 Tue Apr 23 19:49:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13640604 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 B6CAC1422D5 for ; Tue, 23 Apr 2024 19:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713901781; cv=none; b=JHP1eU+PZBrxLosGWZm0FucY296EWwnHd4AQvZpeS5g8jOp3+DkwHJZPrMFwutYtLGjgwkfyBSY5CcVBfCOLxKucHLVN6AQEajrB8tUbSqhMwkRL9iSrfUvf1gtT8VKzlkH+i4hWqpjnsdZw8vaXmLv+7jTIS38vSZM+KUApZzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713901781; c=relaxed/simple; bh=74FTgsNpDoGFaJwtMp1SRuD1D9Y0+Vbu/uFyRIKGcj0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jTVLMIX5c9yJfRpao6s0st9dFqfRMVKuOOGfNekp9I8Pxwlmtovs3kQEAZzX2cWN8R4ZbW1AEzvm8Qeioj44yoIDNx/lQk5drMzvufRfnTuyZy8nWbFvxaNilrb7zPYhnj8FjG0LwMIqCdLiGZHqYASIxmIqsyWiTfGc7xubaGw= 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=la4dsS6g; arc=none smtp.client-ip=209.85.210.170 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="la4dsS6g" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6f0b9f943cbso4109369b3a.0 for ; Tue, 23 Apr 2024 12:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1713901779; x=1714506579; 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=K3hn5TsRaFYOkcNTzS8vHf8VfDIP6F4sJqKqR0K4LTA=; b=la4dsS6gqn5SLEuThfDMJKmc7s1xtZMSnV8Ry3BKJ4KFvaGAqpd++96pseiKvwB9PO Nw5Zx8uEjp8I7ehigEplq+DAhc24MPHcg0XezJySlfiA+ZD6guZAgAoaoIIjKVq1Es5S ZzHpQzHxCIXvsrnj4dujLx0OefZme43bHod+M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713901779; x=1714506579; 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=K3hn5TsRaFYOkcNTzS8vHf8VfDIP6F4sJqKqR0K4LTA=; b=Z6+ErkwkwoGMJ179TVubYuyILsN10TLQXlaNxDhNoFnx1anG31LL+mmMim6+Fx8IEG epbe16Gv6+BD7wbtARQ4dKsDHC12oaz72ovXkzROr8yGfXZvnILVjEGkrBOPo/ywnqiW E3cYMSoU2cmNWdAyruIvuiiWEXs+3drw5+uWgQjCYNKng5wEJwOBjyVhpeuREA7h5g1e x1FiMvWfbK9wLKhg8qgpZjJiTSXp6i3TNJWm2O6w8TWZWlp7wRpQ/NtbZ/xZkIEo7ipf aHA7xlqI3gZTyZHXJ5cDRlbFUkE2LHpBO+hbegj4tgh3V0H1ELd1Q0wAUWu683VZEhBZ iv2Q== X-Forwarded-Encrypted: i=1; AJvYcCVH4I0YvFWE7Tl+BzsZwyafktaFb9AFyiqFU25PXS1HFr//lNW2r9bWkS+4f0paWl8wAVqGBeUxp/bhqvJO1OnfJY+MRm8TvQsy4Q== X-Gm-Message-State: AOJu0Yxe/PJFdjfyUT+5sTzCCffWMmOICgNzTSaWVRAhp+T7MgZpLXKS Dls5gyH9l/RIbc9bj+EqV+rmIX6BJGzdOJhDsK5+tHyYW6yb/pOajXVKh1Zx6Jg= X-Google-Smtp-Source: AGHT+IHRM/pFIOlUTo0+zFZNp0G8QYV3sN9KVCAYc9wfXWxCwKDFXcp+V6Y3SzqZ5aixKJt4Z5OtRg== X-Received: by 2002:a05:6a21:348b:b0:1a7:aecd:9785 with SMTP id yo11-20020a056a21348b00b001a7aecd9785mr386439pzb.25.1713901779138; Tue, 23 Apr 2024 12:49:39 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id q3-20020a056a00084300b006ecc6c1c67asm9995672pfk.215.2024.04.23.12.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 12:49:38 -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 2/3] net/mlx4: link NAPI instances to queues and IRQs Date: Tue, 23 Apr 2024 19:49:29 +0000 Message-Id: <20240423194931.97013-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240423194931.97013-1-jdamato@fastly.com> References: <20240423194931.97013-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make mlx4 compatible with the newly added netlink queue GET APIs. Signed-off-by: Joe Damato Tested-by: Martin Karsten --- 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..d212ed9bfd60 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 */ @@ -188,7 +194,15 @@ 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) { + enum netdev_queue_type qtype; + if (cq->type != TX_XDP) { + if (cq->type == RX) + qtype = NETDEV_QUEUE_TYPE_RX; + else if (cq->type == TX) + 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 Tue Apr 23 19:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13640605 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 8DD0C14290F for ; Tue, 23 Apr 2024 19:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713901783; cv=none; b=JE4kvdFym0/eCZ/sqhGVfznANUkBF1e1s9/Q9XCgSrJOOTKxEhFQEH/DpLLV1T/2Lt47GaAkyi950mt6mHxa+g419ruPZ1yp3O+LOrU2g143drhamFqmiUASHaXZ/CaJezQTgqRDgexYp0hBXvBd/Ex74Z1fiz6HNZIN++m14/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713901783; c=relaxed/simple; bh=Ia0r0BSwe8QIUJufAJclFiQc0GFm4DiTWN09Y106Hm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i9FQF1iOgjhCc4M6BMCrExcoOZD/OBD3YEg7bpwk2t/A4AQXVH04zqR+FRRvWt88ja04Plb1HiP5xwss1WiftwwCO0Na/Tboa1QEjr23bKC7Qq6OjnCwSP70+PoJ2HWZCA/wQyLkyZmPuC2nHkrU/UJN56vwwYFvPyN8DecNQMY= 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=CN2stkCg; arc=none smtp.client-ip=209.85.215.180 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="CN2stkCg" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5ce6b5e3c4eso3461943a12.2 for ; Tue, 23 Apr 2024 12:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1713901781; x=1714506581; 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=xVn2/16u03FLjFZk8aJRPJceLU2TpVvTdEBl2UjSyh4=; b=CN2stkCgehZlulLdHqvj4QacpGOOalxpFaExf6HABiOhoqahuJ8NZIgWGYxRpWhL0E P2XMn1Pf11viDCxJ3SC222bNo9qeAfphBqcbqucYlwivRd/+RQLb0/R1vMVR0k4E6Bpe M8/UbE/xbCWBgnC8dL6OjZw+eNODMo9P/utfQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713901781; x=1714506581; 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=xVn2/16u03FLjFZk8aJRPJceLU2TpVvTdEBl2UjSyh4=; b=txtkBIbMnCYCAHVIORJDSsShTxPbXgNWS8AW+qgPhN0Zce5zhwvtSve09CQhIA3PWO p7WeJtH0an/2GIM8qhOrUj8jZKfnhtnyhc6DWJD1TOt9utSVXHxdz26Iz5JIu6cM4k25 jB7c0/35wdLGyRR2LzAMApmGfFCeqSVZ+soJeBSuTYR1uLaa7Uj3W5Vpw6fEeVUGDLZF JAm/f0GBdiVMHkylG3AKdtOEjf3/sr2thUjLS/VaKUPcRSVZ4PfsMVQtW+b4wdiuY04s x4ZGe8IFUrVHRIirhrGF/T0f4t45DhHU38eiEZ9hWe+K11/taw33Bovb1W3WMg9+MOak VQGw== X-Forwarded-Encrypted: i=1; AJvYcCUuOMuANxhkiTua9dGCkn+4WKaY2kQMawbcWH/1s6HNEfn+rUk9twbhViBoB/fU4vhWQqxH2POgL0yw3bcSV48pCB92Jig585x4Vg== X-Gm-Message-State: AOJu0YxwdW05qdOC9QJh0Zz/xUsF27mXkDXzh6NROy+OMxvIO0+7d/qo 99KWD7FMp3c2c2VEGjnoc63H2I9ZmrWooTrXUlD+oLJdF4/m5QoH+Eog9VsYE7JN2snajwtGcJ3 g X-Google-Smtp-Source: AGHT+IEdHVRIc38qxCA1mIyeOG1MZrMmyYzSbB685Hg3GGC/hMJZ8mGeFWAIK08zuqTSfXkJb1ZZRw== X-Received: by 2002:a05:6a20:974a:b0:1ad:746:b15a with SMTP id hs10-20020a056a20974a00b001ad0746b15amr349392pzc.47.1713901780830; Tue, 23 Apr 2024 12:49:40 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id q3-20020a056a00084300b006ecc6c1c67asm9995672pfk.215.2024.04.23.12.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 12:49:40 -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 3/3] net/mlx4: support per-queue statistics via netlink Date: Tue, 23 Apr 2024 19:49:30 +0000 Message-Id: <20240423194931.97013-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240423194931.97013-1-jdamato@fastly.com> References: <20240423194931.97013-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 5d3fde63b273..c7f04d4820c6 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,95 @@ 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; + + stats->packets = 0xff; + stats->bytes = 0xff; + stats->alloc_fail = 0xff; + + 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->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; + + stats->packets = 0xff; + stats->bytes = 0xff; + + 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); + int i; + + rx->packets = 0xff; + rx->bytes = 0xff; + rx->alloc_fail = 0xff; + tx->packets = 0xff; + tx->bytes = 0xff; + + spin_lock_bh(&priv->stats_lock); + + if (!priv->port_up || mlx4_is_master(priv->mdev->dev)) + goto out_unlock; + + for (i = 0; i < priv->rx_ring_num; i++) { + const struct mlx4_en_rx_ring *ring = priv->rx_ring[i]; + + rx->packets += READ_ONCE(ring->packets); + rx->bytes += READ_ONCE(ring->bytes); + rx->alloc_fail += READ_ONCE(ring->dropped); + } + + for (i = 0; i < priv->tx_ring_num[TX]; i++) { + const struct mlx4_en_tx_ring *ring = priv->tx_ring[TX][i]; + + tx->packets += READ_ONCE(ring->packets); + tx->bytes += READ_ONCE(ring->bytes); + } + +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 +3352,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; /*