From patchwork Mon May 13 17:29:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13663566 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 F194320DF7 for ; Mon, 13 May 2024 17:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621359; cv=none; b=e98yK7KWM6iFb7Xu2F5xWVj7wei93DeLiKsWLiuP91Ejm2dM5kpR9tBUtHS6tk4gimPBlsGNe9/Zb7ORW5fQlq0BANCYPOrcXjB0H7HbYnQkJ0Km9y2e9ZxuyoTWHc/+CoF80V5hVC0wtyb9RWcnn2c6ol51/5AAldqSibp/2Uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621359; c=relaxed/simple; bh=WG61YN2Nk7u7U7P0fO8v+PMiI3q/l4RfJSzMoJVrZSs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o3tPVagf7io3Z6Bt8u1h3gRLTi1Nsf4IQXsKXBM10ZoQ031HI9eP2AvjZ/bCxWEAKPgj/HdMle6zeCTG33TmHeukACQGKY0/PTdWx8LUDwDMonH7iDBK6OEO76j1DNTGc8TMfCJje67P7UhvBP090HGLAO9zGDAAyBpIsL0IgAE= 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=krpBOLQM; arc=none smtp.client-ip=209.85.214.174 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="krpBOLQM" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1edfc57ac0cso36743145ad.3 for ; Mon, 13 May 2024 10:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1715621357; x=1716226157; 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=prTLobfW9EKFUcdfFKM6P4Zgx11iA1pn2v87YJC+EGA=; b=krpBOLQMp5px5k53sqHorpJOHLfWSh6/oD7If8Tu30EBtb4KUFYs02xap1vgsry/dZ yWy9nBqzTE9uTf298ET05OKpS7OzAfPI4ndC8KxfihllDzOCs740GK2fzWean1fQpsHs 1JDsPYljok6wfS2EMgOO02ZvW0Q5LFKb9WIqU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715621357; x=1716226157; 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=prTLobfW9EKFUcdfFKM6P4Zgx11iA1pn2v87YJC+EGA=; b=Ds6i08fxSeGzfnWurRbVP3lLcQqnpwrgxV5av3rbYWrBp8nW7uQIKGniV68dVT+LAo 8Cx/vkw6BHSaXdQy/3EsyQagt6chSjh755zii016abNALoc/ML5Emg7sRxEyi61+HQ0W /51JHRbkZtsf8uIdU7JJEsLmwJDydtPhJo44w5kfbBDiEXx34YJzveVfr8wlmlQ0vcQD +6edhtOaGJWTlFljOpW8JmozHtC9YEcAufonOyhJw3oN7OIFqdMaCt4axZFpDaU392mn dzfDXRpje6mRepURp11P5c4OT7/MKZjpfINBwTJkwMthpWGeiMnU8oeTLqu8dJDZLY7v IANg== X-Forwarded-Encrypted: i=1; AJvYcCXvIPmZNO5Fh4iW6dZU9cX4JqPZrdL7BbkF3k3oFC85QCkSu/0A538l7Nu2QGhdDhIIU8CSS4YOGuAkjYcZa5kr+Y8F0ax6W6YjeA== X-Gm-Message-State: AOJu0YwOlJ2BTTc9HYQ9ufVWYXe9KEGDNW6/n9LuaBWOh8E9yYhAsv67 ZLDq5J/LmI97e7WluUN3+8BLDAG3AboaiGeDnCoGW3Y+wNBmUwCcW61E8QqgfJc= X-Google-Smtp-Source: AGHT+IF46wCZ1KQeIgtuYfMcqauDYMnMH2aXWUlfUF/ZIORIOH/ffVUgIGrqxIkotET62+M6MUa2bg== X-Received: by 2002:a17:902:eb8b:b0:1e5:5ccd:30e1 with SMTP id d9443c01a7336-1ef4404b81dmr120238405ad.65.1715621357397; Mon, 13 May 2024 10:29:17 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0b9d1663sm81948995ad.6.2024.05.13.10.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 10:29:17 -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 v5 1/3] net/mlx4: Track RX allocation failures in a stat Date: Mon, 13 May 2024 17:29:06 +0000 Message-Id: <20240513172909.473066-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240513172909.473066-1-jdamato@fastly.com> References: <20240513172909.473066-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. 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 Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 + drivers/net/ethernet/mellanox/mlx4/en_rx.c | 4 +++- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 4c089cfa027a..4d2f8c458346 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2073,6 +2073,7 @@ static void mlx4_en_clear_stats(struct net_device *dev) priv->rx_ring[i]->csum_ok = 0; priv->rx_ring[i]->csum_none = 0; priv->rx_ring[i]->csum_complete = 0; + priv->rx_ring[i]->alloc_fail = 0; } } 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 Mon May 13 17:29:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13663567 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 A30B723768 for ; Mon, 13 May 2024 17:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621361; cv=none; b=dBhQ8xxIjddW0xRU1Wg4miG2Lud0NpK7NbXoIL7//y+vvD3j3mp5mfgPNXTA8p/CyNkYzBNHHK5cibAraY7thY9KC1c/r/JRmAEWEPRWAc8ae3oZXzNcq0o/m6c7Aw8Zq0rDI+Q6VORY7UEswFlZFWLxfmxZpZcoSG1QkW6uR7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621361; c=relaxed/simple; bh=gCbabcQaR8Ix1K97TkMliO2FSC7RBAC3W9/BPXaCzC8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sMNiRaN/RYMle3xYSG1qlTO7u9iFT41MzzX55YDX9sQHHagIz7A6DVIcLRZ/kC1rsgDcsmZKi3me97UxF3u+aaHghPBqSk6i4wGOWui3LWGqBZQEKdy1gs7cdksT8snIgYlosLyYcbB/htp3dyJvY42K0Usxr11FObNMNqTqDak= 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=eLNUbDU3; arc=none smtp.client-ip=209.85.214.174 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="eLNUbDU3" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1ee0132a6f3so33149355ad.0 for ; Mon, 13 May 2024 10:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1715621359; x=1716226159; 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=eLNUbDU3Yot1/LExXUhEBigzYXXARnPWhj0JeNXOZVU9YSKkPwZuBKjukVp5IZ2ZFv ORwVo6dEWws21LAOv6ntTJ1Ap16deVyK99tSzEOMalIHX5bjzBfq1Jom4bhT2E+hf0K9 nCbRe9Ca5d+wAxfZTLSlG96+kDXzxhgTvnIbM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715621359; x=1716226159; 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=H/90MnFZsRoIlk0vgkR/Vet8c0/mI6XkCSe/KMHrPyVIuySkfzzG/sgxWx3XDUwVLW KssYo8c2ucXHS1OWeXnbdu6FiBsHWZCJpCzH7yN1jJqLe1skM2iSV/CTXayHlDA5XIIW vM98JDNV3zOREfKzD+9hmB70ywiwrNEJIa+FZBJett5d9xd2zgx/MgEj4QYQAjnXRMei aSYMU/yFucFnlP/nAENCC+pWyWc/Yz950VOxLPVRc6971Trw8yZ9dawxTH6F9cbgE4Jq 9YGbP+1Q6u1XjH2dyfjVVXgbM8uOhDqomzZQrMTVpG6oL60nkw38cn2/CgwrvV0qyB4R SYfw== X-Forwarded-Encrypted: i=1; AJvYcCUmHA1s0FSgK68rjLUqjhZcscNO8tsHcsyyZLcVmoao8m4ykoVbatHuV16njQYZTsTpGOwyNlTX7w/Z+mPAUOTztAxjRxizJtAYLg== X-Gm-Message-State: AOJu0Ywg5l+3gPtwuhYtsTmBIwgPGTe1frvmIjiIEJ7II9MMdU/FU0Mv IlJnsDLIxLCrqiy/T3hOycpiRwgtOL1maN1VKXhpYfqe5C1Qb5Xc9MDoTRv9wC0= X-Google-Smtp-Source: AGHT+IE2rxb2pPIKH8S7FxU35hdeFvoMaGhTcH1N3h9juaMagb8UpgyIIgNSFKB0+A0A1wmImOTmlw== X-Received: by 2002:a17:902:cf0b:b0:1e4:6253:75db with SMTP id d9443c01a7336-1ef43d1707emr120273805ad.17.1715621358954; Mon, 13 May 2024 10:29:18 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0b9d1663sm81948995ad.6.2024.05.13.10.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 10:29:18 -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 v5 2/3] net/mlx4: link NAPI instances to queues and IRQs Date: Mon, 13 May 2024 17:29:07 +0000 Message-Id: <20240513172909.473066-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240513172909.473066-1-jdamato@fastly.com> References: <20240513172909.473066-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 Acked-by: Jakub Kicinski Reviewed-by: Tariq Toukan --- 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 Mon May 13 17:29: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: 13663568 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 5D0E43398B for ; Mon, 13 May 2024 17:29:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621362; cv=none; b=JIbKR04PnYDcpgKO7lY/r1X4b8ZiR1ddZEd6NaHbqBEQaFBohHEHHWmwftJfkZpsWPi138Z30RLCSvXUHVZTNHS/7UCQzHTQ1ZfsuWyYg0S/hlnkNMC0OQir2at8Tpf6YXBDks9l7+t17HX5QVsaMPY0qFOTazpzetLB1sRX9a4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621362; c=relaxed/simple; bh=P7eM0Il1uySKTqVfADVyGJUrm+o+/vV/0DIs7BEq9P4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WE3W/M0Be7lHP/JoUCQVqI2ufRAnfUkeAg/gMCKcV8K87yMrvSbqTAsbU4xviBKpS1kOVLTF+e2EDZ/kXVsa3EjklbXNmJhg2NSafC3VFZDq/bjoj5fxcgOh5pUjOwywCqOvwyK4HKycJVNxv9VWTMNEsXxIk4IIIISMEXYq53M= 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=kceS75IP; arc=none smtp.client-ip=209.85.210.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="kceS75IP" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6f4f2b1c997so1726451b3a.0 for ; Mon, 13 May 2024 10:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1715621360; x=1716226160; 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=0fiSNLoSRkIwD2QvYCFkUQj2s7HVJ7QWOwVftlDtmBo=; b=kceS75IPicTgOLjCgRQghOqaFadwqxEbiC60Kt5VPsF6QJuvZInA5V7qXLYt6StlsQ vGEv//xuTwhoZDJBwCnQb5yoiweatO/KAC0XNsJvl2kCoCd7ovi5m9+u5vDqX1G3hQ3o Od+q9P5+DhhGH6cQg/XKMRFedlqL6NVPQJ16k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715621360; x=1716226160; 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=0fiSNLoSRkIwD2QvYCFkUQj2s7HVJ7QWOwVftlDtmBo=; b=w6hk+9ta4ltvNk1/eXsZ3nRSwb9QiHeaIgRgwbxj6KZ3sQdYeI4ObHNzHsa2hNVg85 mdhFqhCyJMCcICU+gM1DUwrhkPwpFg4Tn5RDxxjFMrI07D9Wvw4nxb23W+mLiSFm5pTN AZW4mZWBS1T9psKWiTC6nwJKzBd4rZRX1F5UekYVMi+AclnpZ+E31r/IAV3yDidXtHjz mPz1E0cLMJmt8rWUd0xOjjVXOfDL1keDcRJI7VXdo6AaH1feOaB2eSP5zMo3MUjt2Ij2 g2wkbfE+MpU3y5Yx/XShsqzvUp706N9O9mAck6OnhoOYQ7z2bzHsip8X5zWEvwOMXdq8 MHLQ== X-Forwarded-Encrypted: i=1; AJvYcCVMqDZa9mVbeb0qJN7kvr8UYH/w0Y02kyAfp0sSJcTAcb83XrbaDSBbUFdGWoqrUOuN/cZuj4AuLfy8J6uVJuzoL2YlTtBfFCrexg== X-Gm-Message-State: AOJu0Yy8Lln+N8VHBoD5JgXemycgCBkF/B9gWQq26Avg9xEmIzJj+urL bIyi5qiag3W8f3FdPTy77U8pdl6PbTV7Tt13Us+bDHoeSZ8oI7oyBgjxXEXW3qY= X-Google-Smtp-Source: AGHT+IEga2eM2fy1tMh/mmDwNfv6n9tZBFsKCOIzoHkybl2XuIfRafqS4ONAbNjcK/B8CXawfDm29A== X-Received: by 2002:a05:6a21:601:b0:1af:cbd3:ab48 with SMTP id adf61e73a8af0-1afde0af528mr8764530637.3.1715621360718; Mon, 13 May 2024 10:29:20 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0b9d1663sm81948995ad.6.2024.05.13.10.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 10:29:20 -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 v5 3/3] net/mlx4: support per-queue statistics via netlink Date: Mon, 13 May 2024 17:29:08 +0000 Message-Id: <20240513172909.473066-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240513172909.473066-1-jdamato@fastly.com> References: <20240513172909.473066-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 Reviewed-by: Tariq Toukan --- .../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 4d2f8c458346..281b34af0bb4 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 @@ -3100,6 +3101,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) { @@ -3263,6 +3335,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; /*