From patchwork Tue May 28 18:11:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13677060 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 4E52B482C1 for ; Tue, 28 May 2024 18:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716919911; cv=none; b=E0wxnT5rmglHnwZjkaEErC61k31pYf+ww7h240dpV6DDsaRrgehfvLY8YSFWRKjkEj1yOM5p9o5nnvQyRUc7bHDbE0ewyk/HvuAjfRTSGBqObMOSDvecvBzoB4R2jvk4E+ydJHlTuND3wLRKBh8hkXkZA0GmOp6YgMMZe030Gg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716919911; c=relaxed/simple; bh=At1AhuB6bMioug31oBJZbuGGBQlkqzmenZ/4OhCkf/M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PR6NBOppALQA3XsRpgfuXAfuDxpjYvSAcKawepaf5ZAiXTZ8kz2M/BvuL0G8Ld1/KX/F6DnMkLZDDTqthMvszBTiz5UEUJw5MUk7uMT31A0SzqNylc1eWNCgc9K32387eZbprEq3fJCfAZtMTuQ6v3V3avwhFu/hp6r1rdtKsCU= 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=iqFWdEzZ; arc=none smtp.client-ip=209.85.210.173 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="iqFWdEzZ" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6f6911d16b4so946213b3a.3 for ; Tue, 28 May 2024 11:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1716919908; x=1717524708; 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=XMwDaG0C8XGkjNqWFyY43ZulaM5n6/Kpuxg3CcMZavU=; b=iqFWdEzZEidSACaumrywtSVK9nVLmfhHtI747HVUSw/7ILOlffuVF3lxILWG7wElQm 0HfJ9PhDxhOdenBBJXWtFNKWXKj+0g3QQGGMmtaIhqe0UXMAQe98mpUASdcY/6B6HCoR HOcYj5mau8tC3YZLSzh0cZ5cWYypA+BftlCAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716919908; x=1717524708; 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=XMwDaG0C8XGkjNqWFyY43ZulaM5n6/Kpuxg3CcMZavU=; b=vJqhdbU7ceeTWZr/I+jiva2j2FRPBTIALxfTxFC4qZYJAS9G5WLyxILvat1sNK72i3 ts00tqKjGyZdc0m3NfxGtkBE8SZ7kjNEV/CXk57IfYod3gV1gVfPNV42Jz2UTz9cccPa iMgL+rL10r3spgNphmFK3TwMzMY3YlsihMuZK2K9DcIZAE52ONIpq403PP9PA8o3Acff k/I9gQaej7eEPQuJsUp8GcC2QQ3HwnotwYmfuMADEU0/cDwSoiF312OplaAlaqpTZtKg hw094cxxIaEMTimPcdyad5P3Thvqd4dzaHAJcFlngVLLzpwc5KnLbQ5CDSjHy0T5CV1S 68Yg== X-Forwarded-Encrypted: i=1; AJvYcCU3z5ntsifyfR+4KDFqBEF1gB6gTGU+P+LSw9fgyxIpu0aPygrKZ4/1z5dtXgtdljMKP8GT9oPmnCcKcq++qRLEbz5giMKP X-Gm-Message-State: AOJu0YwxRxFVsuhcJN1qw/X7vsye5KhNSAt4MNVgLCxj15sMUDb9lyab 1LARi6rkOkdoEP6th+CMN9ukxvn0qctopO4MyU4DiqrQq87w8r5JS/1yu0j9iq4= X-Google-Smtp-Source: AGHT+IHXeid6bB3qbISuL1ms2RtSB9UuPU79/g2JxlCBPKxlRIA2qVwPU06XmMZ0xegX72n80AJblQ== X-Received: by 2002:a05:6a00:1c83:b0:6f4:d079:bb2b with SMTP id d2e1a72fcca58-6f8f3186614mr13750541b3a.9.1716919907646; Tue, 28 May 2024 11:11:47 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fcdebf54sm6718849b3a.112.2024.05.28.11.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 11:11:47 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: nalramli@fastly.com, mkarsten@uwaterloo.ca, 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 v6 1/3] net/mlx4: Track RX allocation failures in a stat Date: Tue, 28 May 2024 18:11:36 +0000 Message-Id: <20240528181139.515070-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240528181139.515070-1-jdamato@fastly.com> References: <20240528181139.515070-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 Reviewed-by: Tariq Toukan Reviewed-by: Jacob Keller --- 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 Tue May 28 18:11:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13677061 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 01C0016D4F6 for ; Tue, 28 May 2024 18:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716919911; cv=none; b=oWfTQbLQBSwJJoGSI26dPPPlEFtI/071zYF7gF5Fgn828JfCTU6g/mD+jgcx9TQJHuo6tm8DxCmXc07UPg2jBysHE/+YQn1OQ7ySfkI35Wc+hypv2nz9KqeJjKO5UTXLluIrdP5h/zo7sTx67qp7oeU27W9P+FTzY+jf3mNwrF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716919911; c=relaxed/simple; bh=iyTG7Cq3pocgTQck4D1YrQGNjvMiY2USz0q4p8QPPAA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V+QENeb6F9jcMLEj7SG2tSkWCOobAFMTIHlyGYu/6dcJkrGWbZhFYawU4p48x38Bcyp+t/Ki+L+ID/W5DKeTRsKIsHiB8e807tKDPR4U1n641+kLZt96LTnJnKQw8D1aM3H4hhdJr9mfuWRCnVFJpIM39Yw7D5QOhfV9VFRBCbc= 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=GPidMOJ/; arc=none smtp.client-ip=209.85.210.169 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="GPidMOJ/" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6f8e98784b3so843133b3a.1 for ; Tue, 28 May 2024 11:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1716919909; x=1717524709; 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=F53AvWwbOsFwRRf3aqw2FPbWvEDA36PwlFhpoQmzPfo=; b=GPidMOJ/QeQX5bdzPglDYi+muygwhtYj+hhInjsSFIcu/z7FrmEVkS49OiASOuhIKq X/pwWl0JK2J0skIldRgXngbVGuq8rzkuWaaPEpuHAM1Y0b3Yq6CQ/0TQt8BTxPkrBWdl DlOSoJiXfQ7Bmp/tHUeyD7jTW5asZQ+oumU3M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716919909; x=1717524709; 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=F53AvWwbOsFwRRf3aqw2FPbWvEDA36PwlFhpoQmzPfo=; b=sQpi8BF0nON5TMeCCzpA1hm/7idkExOSu+0YzrVB5Gsyi2eSxL2jVc8SmvOrzg+lvI dEXArFLsgCrbWPSsq8YyAuXmKwk1zDK+T4mY8X7tJroBlV44YeG1ZOXTqLh+fH1tk5Rh P3XZ4ehPPEOph1tMMBSQwSzrQiZH/2SxDikXZ3fttjqb9vhUEtO06bsRs36Cb34Hn2qU tI3QIVzdDSV/t9g9tbg7WT7+YkBbo6JAuP7pnWZykKeKlHMT74OF6UloRuL5SPYCgkJY cmpVdb1ABmtyNakZn2R/+Ad+SDIxZaiRAatmYJtfoo7eQCdZg36PFRTsOgmVC6WQu2vC kAsw== X-Forwarded-Encrypted: i=1; AJvYcCUmqs9S3yH9S6ivJaTT0jtITuvfFuqoL7HhJvqKQFPETVOErqWRDcL5Zy0WmuPXDRr1Jy18Nbby4HHhrxVToAQwJjJv6XT2 X-Gm-Message-State: AOJu0YzgZRRxp4jtmoBLxUxerBDBfk/1yJdG2HRFg8evap19KMeuIklR HEvMOLlzUG9cQ7wlTFxBLcp7i3rvJwSrwBjYqUADXkv34HQjjBxV2Ag76AaPm2o= X-Google-Smtp-Source: AGHT+IH526oPfXwlVZihlIMLiUTTnTItfT1UqLFzZfgiSTPeVbqfEm6VgxczQEfX/RxXPYLbuae5nA== X-Received: by 2002:a05:6a20:9783:b0:1af:d9a3:f399 with SMTP id adf61e73a8af0-1b212dfe3e3mr12049996637.29.1716919909260; Tue, 28 May 2024 11:11:49 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fcdebf54sm6718849b3a.112.2024.05.28.11.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 11:11:48 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: nalramli@fastly.com, mkarsten@uwaterloo.ca, 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 v6 2/3] net/mlx4: link NAPI instances to queues and IRQs Date: Tue, 28 May 2024 18:11:37 +0000 Message-Id: <20240528181139.515070-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240528181139.515070-1-jdamato@fastly.com> References: <20240528181139.515070-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 Reviewed-by: Tariq Toukan Reviewed-by: Jacob Keller --- 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 Tue May 28 18:11:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13677062 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 4EA10171069 for ; Tue, 28 May 2024 18:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716919912; cv=none; b=EkpJM1Yrrk8vdfAaVOq3tqJns+TcpEG1nFeZ9NcWRLiTUQnXMpuq3AfWAyIvfv/O5sZ6vGJaNiyhtfYWvZwfNaSevUMtzop9X3v0f3HeUBKBl5beBsogxTGBo6o5b5e9ZYRtsHR7Vli4i9onFHQBSGCSFDe+JG+jtAaC0vNBVvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716919912; c=relaxed/simple; bh=HLbaFyoM4QCM6qCh0lmKblqHhUr5Yb1xPECeS8JhKwQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DTlfG7aMb9izZsP9YTT8EFuXplYEitNHdAomdPD2pL3tcMx42ws/eh7a6p74OGSidZik27XNpefa98PPBTmya6igWMC++QavaqQVitMDUh2EN4Q4Rxk7UcX2zMkSrIrZG5uWHm470sa+Or3B56VaO4y208qB1dKM9XdQ7bUL2cU= 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=PDRSplIZ; arc=none smtp.client-ip=209.85.210.177 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="PDRSplIZ" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6fcbd812b33so990877b3a.3 for ; Tue, 28 May 2024 11:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1716919911; x=1717524711; 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=ziTBsOU+7FApePULAU8xAxlPyi/hAcaPSqVXZZ7lGPw=; b=PDRSplIZ6oL84i9Tb25O5OnAg29PlP1c1qa9KqWyb0pnw4kOgXrEYj7dd/a8Ww1zhN JZfL3n4WoBLjvjs0QdBBiS6vpbN6AMxBGb8EnF2ExRTMO5MuTbpL1P3pPj7ZkNij1AtC vTN5GXpiG7lTGQU0SM9ckbEJcgtI2tPmVMD4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716919911; x=1717524711; 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=ziTBsOU+7FApePULAU8xAxlPyi/hAcaPSqVXZZ7lGPw=; b=sZEKfMIYsZE5Ti2M6F75APe0g2y/t7bxUN9vQOLxnXEsu2DADGAWXxaHlcF51WtveJ 1FUdJ16kBz5rF14EgIFgXf19rSii6LoX56lir+6yM4Clb+qsxDmcUaT4GVXJ/RDw7e3F lfKW9k9Srf2AYCl3mH2pWsXWcKiEcQtzQpaNqyW6bog5e4UAsFQQqEYZ3hMXuziLlV/i aDfzfQxx85YvT3nc/hNXi2WASZUDGKhiMufISnCwIeC0130ciYXDQha29wSPZ5rMk1TW Lpakj010cIdWuRFoQXFAZP8Y8GOzv201OR2Nkk27qERQfYrWpGq5aQJVluTixsguZoL+ 8cPw== X-Forwarded-Encrypted: i=1; AJvYcCV8YY7p2QLWNMV2w2+jB5hYBg3kjTspQO7b7jwZ+c2D3xr7mmbDSOXJca9ap+REs6zVHQ3HICIZ1GlR4lCNKgC1wlL1bwPR X-Gm-Message-State: AOJu0YzC3ByL0vOLNqqOaEwkJMG7bPglfnqa6MW8IdcSAWUw2UoQiZn+ x5/BDNXFyNBEaN8pnDPK7Nba2DyWB005BG0+eX3s4qTyLWt9pSod47KFvj9A6IA= X-Google-Smtp-Source: AGHT+IHMsPYMffQSLrHqovP+ORt+JmtPfbEq9itNJo7BWLkpZrL7fRfZti1HbUVDab+SRTYzmrd5+A== X-Received: by 2002:a05:6a00:1f0f:b0:6f8:d4b8:b200 with SMTP id d2e1a72fcca58-6f8f2c60956mr14567299b3a.1.1716919910707; Tue, 28 May 2024 11:11:50 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fcdebf54sm6718849b3a.112.2024.05.28.11.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 11:11:50 -0700 (PDT) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: nalramli@fastly.com, mkarsten@uwaterloo.ca, 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 v6 3/3] net/mlx4: support per-queue statistics via netlink Date: Tue, 28 May 2024 18:11:38 +0000 Message-Id: <20240528181139.515070-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240528181139.515070-1-jdamato@fastly.com> References: <20240528181139.515070-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: Tariq Toukan Reviewed-by: Jacob Keller --- .../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; /*