From patchwork Thu Apr 10 07:08:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohsin Bashir X-Patchwork-Id: 14045977 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 BD8E1204C1E for ; Thu, 10 Apr 2025 07:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268975; cv=none; b=W9iuc7W+1Y/kvrKK65pcVd0GcBMQeRs6vQsP3JZ4YM8M+qGx9/cJgV6TrFeVVN6xYYtpPsV8BLJTi74rf7GxG+okyxDPBB4/MgYmsg2FaCAE9WrOiIrUWM7QblxpIEy793JxNKYjRe3kh4cwSlI5p4lUVxiO74hidGaGdpotJsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268975; c=relaxed/simple; bh=ZdRabb18Zu0sC4OY0YF4GbVOmmdmxft6odqkRX7ZvMc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WJy12NG453KYEpR67PzBXYxMGIpAt8hkptZaU71JTH3GQ36vtxLlAYUvIpgCHYQKx0/KdRoeVMKAArS07THRNQOc4su0XNbpTdGzAqzjZP0BaR7lboF63v81wm6kJFhx6IeM1v40+Ygg+hV7xU7+Ub/0pzHrlbJxGzo/lXKmZjM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UgZBvtQZ; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UgZBvtQZ" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43d0618746bso3204535e9.2 for ; Thu, 10 Apr 2025 00:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744268972; x=1744873772; 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=hTTpOJ0JhdYbtpWXm6RJBf4irZrdnE+cHphQPXX0dN8=; b=UgZBvtQZPagwVy7lbx0dhO3Uv+siVtHylegC2D7Z/p+L6TYONsDxEz3AdZWu3wEUDg 2YtqXsYCXJ3Ta7RCg0B2adAbk/yWMUHQSXPmx6fhfPYv4ob43uGl0Sums1maFAdUwF0i ZgjwuIexSMNuQUOPuDp1GZQuhic7huizreRPuvRcUSckGX0DlEOTB4XMU0qNCtYS1Sul QHPF0LQxpVNwEhXCC/9Sesh1pwRBnKrTM8/Is9901Hs5OBxcvIECkUcL5hCpbxPnEjbS OSBmLASIrpqJ9fe4MQptLG+YNJ08I6L+SKOKJ0+7ke/68GYCW6OwQKSM5RBiwBPj42st gGIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744268972; x=1744873772; 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=hTTpOJ0JhdYbtpWXm6RJBf4irZrdnE+cHphQPXX0dN8=; b=wpvQDWBiczaec4oPEXvKqMa++GMjNaceG11Kr+XPTnF/i9spbhWFRK2SEn8/CWqCC4 EhDPKgJ45e//R3ci+Yfx8NJRXtD220KgT/4aTDba8bFqbBs05CG+zgrNGWHAYpCbAp6a BQi35MrcP1eZ06bmyb377UDQZoguM3A8RWXs8uyNYAnwmbjYMDWDNUi1MBYuDfRN6X13 wGTY0CQ2gEQLWLuKaeGPlfc5EQosN0p126fetuVgbMDLm2WhuSb70anJfhIjVn8IKJBO 6baZw7e+aX5IcGUUWc/xDyOV7Ac7TVr5bCa20M+fxKXKUmCPkN773HNnxGmMWyQf/qlh zT3A== X-Gm-Message-State: AOJu0YwX0I0MkkuljrWhRE3V+26VPpqoWAxYiOKuFKEkANTFe8FYO9VD e1BXID6i1CGTYWK5QwACy+/Xk7vysFcyUZ0RkQcvewOlKY00c/orRfYkm8jq X-Gm-Gg: ASbGncvEPGEcBpkdRKGDqo3vjXXgSwWlmOju0gGH3Gz4PJ5uhnkAyKNbDqXJ2ejQZEG Qg2MbnGljFOgFUuvwczFPjNkjp5vZkbjNSDoJJYdmkvd7ecFgLee0kRySHnU6NrBwk7LOhefBbD 05/b2zPoJ/5UgFfX+lBeY4N8m9fJ5EDwpaiVYvxXVh733bJPHV1k35bvbP/2uILR+B/oq7/4pX9 xItiaL6iEvhHXbZSoFFu4m4P5Yv4r9JrnbCb2wbjf2YeiULj5ZzDEzhET1aKDekO0+fcfHmF6UZ 1n/p3j7KnPGkwv3GmUROG35nv/HQ1kC3y35lWsg= X-Google-Smtp-Source: AGHT+IG+jlhHrf+5d8lGRA0eBSAkUQXXizElCUxr3HM352KIzxjzNZ9Pu+SS4vatJ5e2Cw4OxkDvfA== X-Received: by 2002:a05:600c:b90:b0:43d:9d5:474d with SMTP id 5b1f17b1804b1-43f2d688b3cmr18947315e9.0.1744268971559; Thu, 10 Apr 2025 00:09:31 -0700 (PDT) Received: from localhost ([2a03:2880:31ff:44::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43f2075fc99sm44959255e9.29.2025.04.10.00.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 00:09:30 -0700 (PDT) From: Mohsin Bashir To: netdev@vger.kernel.org Cc: alexanderduyck@fb.com, kuba@kernel.org, andrew+netdev@lunn.ch, corbet@lwn.net, davem@davemloft.net, edumazet@google.com, horms@kernel.org, jdamato@fastly.com, kalesh-anakkur.purayil@broadcom.com, kernel-team@meta.com, mohsin.bashr@gmail.com, pabeni@redhat.com, richardcochran@gmail.com, sanman.p211993@gmail.com, sdf@fomichev.me, vadim.fedorenko@linux.dev Subject: [PATCH net-next 1/5 V2] eth: fbnic: add locking support for hw stats Date: Thu, 10 Apr 2025 00:08:55 -0700 Message-ID: <20250410070859.4160768-2-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250410070859.4160768-1-mohsin.bashr@gmail.com> References: <20250410070859.4160768-1-mohsin.bashr@gmail.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 This patch adds lock protection for the hardware statistics for fbnic. The hardware statistics access via ndo_get_stats64 is not protected by the rtnl_lock(). Since these stats can be accessed from different places in the code such as service task, ethtool, Q-API, and net_device_ops, a lock-less approach can lead to races. Note that this patch is not a fix rather, just a prep for the subsequent changes in this series. Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir Reviewed-by: Simon Horman --- drivers/net/ethernet/meta/fbnic/fbnic.h | 3 +++ drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c | 16 +++++++++++++--- drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic.h b/drivers/net/ethernet/meta/fbnic/fbnic.h index 4ca7b99ef131..80d54edaac55 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic.h @@ -81,6 +81,9 @@ struct fbnic_dev { /* Local copy of hardware statistics */ struct fbnic_hw_stats hw_stats; + + /* Lock protecting access to hw_stats */ + spinlock_t hw_stats_lock; }; /* Reserve entry 0 in the MSI-X "others" array until we have filled all diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c index 89ac6bc8c7fc..957138cb841e 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c @@ -203,18 +203,28 @@ static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd, void fbnic_reset_hw_stats(struct fbnic_dev *fbd) { + spin_lock(&fbd->hw_stats_lock); fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc); fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie); + spin_unlock(&fbd->hw_stats_lock); } -void fbnic_get_hw_stats32(struct fbnic_dev *fbd) +static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd) { fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc); } -void fbnic_get_hw_stats(struct fbnic_dev *fbd) +void fbnic_get_hw_stats32(struct fbnic_dev *fbd) { - fbnic_get_hw_stats32(fbd); + spin_lock(&fbd->hw_stats_lock); + __fbnic_get_hw_stats32(fbd); + spin_unlock(&fbd->hw_stats_lock); +} +void fbnic_get_hw_stats(struct fbnic_dev *fbd) +{ + spin_lock(&fbd->hw_stats_lock); + __fbnic_get_hw_stats32(fbd); fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie); + spin_unlock(&fbd->hw_stats_lock); } diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c index 6cbbc2ee3e1f..1f76ebdd6ad1 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c @@ -292,6 +292,7 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fbnic_devlink_register(fbd); fbnic_dbg_fbd_init(fbd); + spin_lock_init(&fbd->hw_stats_lock); /* Capture snapshot of hardware stats so netdev can calculate delta */ fbnic_reset_hw_stats(fbd); From patchwork Thu Apr 10 07:08:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohsin Bashir X-Patchwork-Id: 14045978 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 8A8DD204C3C for ; Thu, 10 Apr 2025 07:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268978; cv=none; b=u/vxuatB7k0r4GiOY6en8K6Li8Rzq5d1V9QQD95fFUt4i0jY90sfswi21mYkqvH114+M3bmllBqersuCVgTnmxvntHEBPOThhurjs8ZZkK7Rzl2W9NaGTIWRitW0J3kWWzS3fVk5HtXoJc82DVwKwl7aKImTwc0JveeW/xeWv9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268978; c=relaxed/simple; bh=9GMUF7pImvxqFvl08svPq8C6bS8tO6DYtxfWRztQdVo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tt7aC+saN85H8SR/JC+9kg1GBo4sHFM5rVUDrWkNcT/RlzBgWhazNDeQC2rAakUfD85F4nZicq05kfgUwHEAwmhqyqU2pESznHdyWDXH2vX9gkHVo+DYf+OtsoLtxSKIKKUo7NXBt7aju02xIAoGSCL4dIVkWHMZ8scNHkDIgw4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=huFZfTt7; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="huFZfTt7" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-43cec5cd73bso3164675e9.3 for ; Thu, 10 Apr 2025 00:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744268974; x=1744873774; 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=3G9ba1OytrE2JGvhMaAIXzjR+cA1mRYn7afZCz4Plgs=; b=huFZfTt7CYAVtKVFNJHW+EHl9wYsVLS2IfjOBPIZFWcNqlarsRIwheez2IDixA3Mr5 ELOxDF545kMU85hNsFUlcrMVGz53JGyW8yybod1dC/KFioO0e05HQLxd1New3k/vX7uN T1eTkPrw6yJ2CFnJfRVxiP3bNgHm8R0eQJ9b5ktYx/QnvyF9S3Lh2yQmZggRW6lww85f LLxq5uejb1M572G6+HgKqZdwr0S1z0+HyYmnFBzYlqlhH3khRseEE0WipGa6HO4zMYJ7 1w+NTAnNE9l5tUY43FhQbeu/vZqHTBRETK8eF5gmCbp9bJo/MisY7mneti8BiM33UlAp cHXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744268974; x=1744873774; 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=3G9ba1OytrE2JGvhMaAIXzjR+cA1mRYn7afZCz4Plgs=; b=IajfNvZyYjfWVjNzJxBNHpPf/xEibpmGuD8CcOyPjRvHN4iMR6fpJwHpOzsSkr6haa C7OcPK3ZBO38pV6bXOuwgW8lFHqtDxcoqEDECE/TYTj2LC6wf1N0pETc9kHLpy4QoWko i60ZlOWWQ/iJmrMudPBbPmAhod8UWlFKHMGo2qXGJRTSLIWxv9oMJcbGP6rmV+Wgoa3E BjDKdCKP8A61Wn+1GTWZCWxVWjfQAh7O4BkcTPOqB1t++wEdJmPk74yUpj/M/+PI8FDD rZPshSqQOkNSuN2ej97+R7PkgAXs/Nypxefv4Pk4CY1/kSL4daoO2AUkZNowk2VlVjk1 TSqQ== X-Gm-Message-State: AOJu0YxKjjAt+OFH1KuMJLHpFdIpAjRm8Io6/4tcdPTDBW4MDOE8T3BE zA8zPsyYzDh1kkulz5Q27vfdRHlz0GItsDXP+9Ca9IqHbKSsCtX9I7wx2orI X-Gm-Gg: ASbGncu7WcYMfarEqiI2ebtUiGi2zu7l51w4zvJC5qb7+/ekweSlynMYLkp3w0lA8mj 45aGg9mc49cRErwxJ4aNxVPGedLSQoHHVTJigRoyGfF69JMxsKAKI9U43hJ82AHa6K0e8nuFnUU XIQWxWeyMNU7OwprWg2xpiL3+n6as5oS/DnK41c6KeZUI7J9KE5gwhJirWS+IVeAzd7bTlAoN/q 2m68wjP0Oc31A7NZtlR4hsnnsJ0yz2QzSTpZ/REKD7/2BDtzPruiP6CV4rzn0xhvYzTotFlHCwr a/J5rsJJnQyIkzYPrEdiSvnt15/v1pMcAFJlFTYgCtTvfwluEw== X-Google-Smtp-Source: AGHT+IHAAZ8J8TkPeuwn7TsS4z1Hl0AOohE+/o/1sJAQ0bjNbg1NK0ojHhJ8ijyVCCWAdy8Y9zRR0Q== X-Received: by 2002:a05:600c:1546:b0:43c:e2dd:98ea with SMTP id 5b1f17b1804b1-43f2d95990dmr14095085e9.22.1744268973935; Thu, 10 Apr 2025 00:09:33 -0700 (PDT) Received: from localhost ([2a03:2880:31ff:72::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43f233c7a68sm40611115e9.19.2025.04.10.00.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 00:09:33 -0700 (PDT) From: Mohsin Bashir To: netdev@vger.kernel.org Cc: alexanderduyck@fb.com, kuba@kernel.org, andrew+netdev@lunn.ch, corbet@lwn.net, davem@davemloft.net, edumazet@google.com, horms@kernel.org, jdamato@fastly.com, kalesh-anakkur.purayil@broadcom.com, kernel-team@meta.com, mohsin.bashr@gmail.com, pabeni@redhat.com, richardcochran@gmail.com, sanman.p211993@gmail.com, sdf@fomichev.me, vadim.fedorenko@linux.dev Subject: [PATCH net-next 2/5 V2] eth: fbnic: add coverage for hw queue stats Date: Thu, 10 Apr 2025 00:08:56 -0700 Message-ID: <20250410070859.4160768-3-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250410070859.4160768-1-mohsin.bashr@gmail.com> References: <20250410070859.4160768-1-mohsin.bashr@gmail.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 This patch provides support for hardware queue stats and covers packet errors for RX-DMA engine, RCQ drops and BDQ drops. The packet errors are also aggregated with the `rx_errors` stats in the `rtnl_link_stats` as well as with the `hw_drops` in the queue API. The RCQ and BDQ drops are aggregated with `rx_over_errors` in the `rtnl_link_stats` as well as with the `hw_drop_overruns` in the queue API. ethtool -S eth0 | grep -E 'rde' rde_0_pkt_err: 0 rde_0_pkt_cq_drop: 0 rde_0_pkt_bdq_drop: 0 --- --- rde_127_pkt_err: 0 rde_127_pkt_cq_drop: 0 rde_127_pkt_bdq_drop: 0 Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir Reviewed-by: Simon Horman --- V2: Add lock protection while reading the `fbd->hw_stats` to ensure snapshot consistency. --- .../device_drivers/ethernet/meta/fbnic.rst | 9 +++ drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 12 ++++ .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 55 ++++++++++++++++--- .../net/ethernet/meta/fbnic/fbnic_hw_stats.c | 50 +++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_hw_stats.h | 9 +++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 29 +++++++++- 6 files changed, 156 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst index 04e0595bb0a7..bc7f2fef2875 100644 --- a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +++ b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst @@ -44,6 +44,15 @@ RPC (Rx parser) - ``rpc_out_of_hdr_err``: frames where header was larger than parsable region - ``ovr_size_err``: oversized frames +Hardware Queues +~~~~~~~~~~~~~~~ + +1. RX DMA Engine: + + - ``rde_[i]_pkt_err``: packets with MAC EOP, RPC parser, RXB truncation, or RDE frame truncation errors. These error are flagged in the packet metadata because of cut-through support but the actual drop happens once PCIE/RDE is reached. + - ``rde_[i]_pkt_cq_drop``: packets dropped because RCQ is full + - ``rde_[i]_pkt_bdq_drop``: packets dropped because HPQ or PPQ ran out of host buffer + PCIe ~~~~ diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h index 3b12a0ab5906..ff5f68c7e73d 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h @@ -864,6 +864,12 @@ enum { #define FBNIC_QUEUE_TWQ1_BAL 0x022 /* 0x088 */ #define FBNIC_QUEUE_TWQ1_BAH 0x023 /* 0x08c */ +/* Tx Work Queue Statistics Registers */ +#define FBNIC_QUEUE_TWQ0_PKT_CNT 0x062 /* 0x188 */ +#define FBNIC_QUEUE_TWQ0_ERR_CNT 0x063 /* 0x18c */ +#define FBNIC_QUEUE_TWQ1_PKT_CNT 0x072 /* 0x1c8 */ +#define FBNIC_QUEUE_TWQ1_ERR_CNT 0x073 /* 0x1cc */ + /* Tx Completion Queue Registers */ #define FBNIC_QUEUE_TCQ_CTL 0x080 /* 0x200 */ #define FBNIC_QUEUE_TCQ_CTL_RESET CSR_BIT(0) @@ -953,6 +959,12 @@ enum { FBNIC_QUEUE_RDE_CTL1_PAYLD_PACK_RSS = 2, }; +/* Rx Per CQ Statistics Counters */ +#define FBNIC_QUEUE_RDE_PKT_CNT 0x2a2 /* 0xa88 */ +#define FBNIC_QUEUE_RDE_PKT_ERR_CNT 0x2a3 /* 0xa8c */ +#define FBNIC_QUEUE_RDE_CQ_DROP_CNT 0x2a4 /* 0xa90 */ +#define FBNIC_QUEUE_RDE_BDQ_DROP_CNT 0x2a5 /* 0xa94 */ + /* Rx Interrupt Manager Registers */ #define FBNIC_QUEUE_RIM_CTL 0x2c0 /* 0xb00 */ #define FBNIC_QUEUE_RIM_CTL_MSIX_MASK CSR_GENMASK(7, 0) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c index 0a751a2aaf73..038e969f5ba3 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -39,7 +39,20 @@ static const struct fbnic_stat fbnic_gstrings_hw_stats[] = { }; #define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats) -#define FBNIC_HW_STATS_LEN FBNIC_HW_FIXED_STATS_LEN + +#define FBNIC_HW_Q_STAT(name, stat) \ + FBNIC_STAT_FIELDS(fbnic_hw_q_stats, name, stat.value) + +static const struct fbnic_stat fbnic_gstrings_hw_q_stats[] = { + FBNIC_HW_Q_STAT("rde_%u_pkt_err", rde_pkt_err), + FBNIC_HW_Q_STAT("rde_%u_pkt_cq_drop", rde_pkt_cq_drop), + FBNIC_HW_Q_STAT("rde_%u_pkt_bdq_drop", rde_pkt_bdq_drop), +}; + +#define FBNIC_HW_Q_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_q_stats) +#define FBNIC_HW_STATS_LEN \ + (FBNIC_HW_FIXED_STATS_LEN + \ + FBNIC_HW_Q_STATS_LEN * FBNIC_MAX_QUEUES) static void fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) @@ -300,29 +313,57 @@ fbnic_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data) { - int i; + const struct fbnic_stat *stat; + int i, idx; switch (sset) { case ETH_SS_STATS: - for (i = 0; i < FBNIC_HW_STATS_LEN; i++) + for (i = 0; i < FBNIC_HW_FIXED_STATS_LEN; i++) ethtool_puts(&data, fbnic_gstrings_hw_stats[i].string); + + for (idx = 0; idx < FBNIC_MAX_QUEUES; idx++) { + stat = fbnic_gstrings_hw_q_stats; + + for (i = 0; i < FBNIC_HW_Q_STATS_LEN; i++, stat++) + ethtool_sprintf(&data, stat->string, idx); + } break; } } +static void fbnic_report_hw_stats(const struct fbnic_stat *stat, + const void *base, int len, u64 **data) +{ + while (len--) { + u8 *curr = (u8 *)base + stat->offset; + + **data = *(u64 *)curr; + + stat++; + (*data)++; + } +} + static void fbnic_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data) { struct fbnic_net *fbn = netdev_priv(dev); - const struct fbnic_stat *stat; + struct fbnic_dev *fbd = fbn->fbd; int i; fbnic_get_hw_stats(fbn->fbd); - for (i = 0; i < FBNIC_HW_STATS_LEN; i++) { - stat = &fbnic_gstrings_hw_stats[i]; - data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset); + spin_lock(&fbd->hw_stats_lock); + fbnic_report_hw_stats(fbnic_gstrings_hw_stats, &fbd->hw_stats, + FBNIC_HW_FIXED_STATS_LEN, &data); + + for (i = 0; i < FBNIC_MAX_QUEUES; i++) { + const struct fbnic_hw_q_stats *hw_q = &fbd->hw_stats.hw_q[i]; + + fbnic_report_hw_stats(fbnic_gstrings_hw_q_stats, hw_q, + FBNIC_HW_Q_STATS_LEN, &data); } + spin_unlock(&fbd->hw_stats_lock); } static int fbnic_get_sset_count(struct net_device *dev, int sset) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c index 957138cb841e..c8faedc2ec44 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c @@ -117,6 +117,54 @@ static void fbnic_get_rpc_stats32(struct fbnic_dev *fbd, &rpc->ovr_size_err); } +static void fbnic_reset_hw_rxq_stats(struct fbnic_dev *fbd, + struct fbnic_hw_q_stats *hw_q) +{ + int i; + + for (i = 0; i < fbd->max_num_queues; i++, hw_q++) { + u32 base = FBNIC_QUEUE(i); + + fbnic_hw_stat_rst32(fbd, + base + FBNIC_QUEUE_RDE_PKT_ERR_CNT, + &hw_q->rde_pkt_err); + fbnic_hw_stat_rst32(fbd, + base + FBNIC_QUEUE_RDE_CQ_DROP_CNT, + &hw_q->rde_pkt_cq_drop); + fbnic_hw_stat_rst32(fbd, + base + FBNIC_QUEUE_RDE_BDQ_DROP_CNT, + &hw_q->rde_pkt_bdq_drop); + } +} + +static void fbnic_get_hw_rxq_stats32(struct fbnic_dev *fbd, + struct fbnic_hw_q_stats *hw_q) +{ + int i; + + for (i = 0; i < fbd->max_num_queues; i++, hw_q++) { + u32 base = FBNIC_QUEUE(i); + + fbnic_hw_stat_rd32(fbd, + base + FBNIC_QUEUE_RDE_PKT_ERR_CNT, + &hw_q->rde_pkt_err); + fbnic_hw_stat_rd32(fbd, + base + FBNIC_QUEUE_RDE_CQ_DROP_CNT, + &hw_q->rde_pkt_cq_drop); + fbnic_hw_stat_rd32(fbd, + base + FBNIC_QUEUE_RDE_BDQ_DROP_CNT, + &hw_q->rde_pkt_bdq_drop); + } +} + +void fbnic_get_hw_q_stats(struct fbnic_dev *fbd, + struct fbnic_hw_q_stats *hw_q) +{ + spin_lock(&fbd->hw_stats_lock); + fbnic_get_hw_rxq_stats32(fbd, hw_q); + spin_unlock(&fbd->hw_stats_lock); +} + static void fbnic_reset_pcie_stats_asic(struct fbnic_dev *fbd, struct fbnic_pcie_stats *pcie) { @@ -205,6 +253,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd) { spin_lock(&fbd->hw_stats_lock); fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc); + fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q); fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie); spin_unlock(&fbd->hw_stats_lock); } @@ -212,6 +261,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd) static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd) { fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc); + fbnic_get_hw_rxq_stats32(fbd, fbd->hw_stats.hw_q); } void fbnic_get_hw_stats32(struct fbnic_dev *fbd) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h index 78df56b87745..81efa8dc8381 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h @@ -43,6 +43,12 @@ struct fbnic_rpc_stats { struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err; }; +struct fbnic_hw_q_stats { + struct fbnic_stat_counter rde_pkt_err; + struct fbnic_stat_counter rde_pkt_cq_drop; + struct fbnic_stat_counter rde_pkt_bdq_drop; +}; + struct fbnic_pcie_stats { struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword; struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword; @@ -56,12 +62,15 @@ struct fbnic_pcie_stats { struct fbnic_hw_stats { struct fbnic_mac_stats mac; struct fbnic_rpc_stats rpc; + struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES]; struct fbnic_pcie_stats pcie; }; u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset); void fbnic_reset_hw_stats(struct fbnic_dev *fbd); +void fbnic_get_hw_q_stats(struct fbnic_dev *fbd, + struct fbnic_hw_q_stats *hw_q); void fbnic_get_hw_stats32(struct fbnic_dev *fbd); void fbnic_get_hw_stats(struct fbnic_dev *fbd); diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c index 79a01fdd1dd1..e19284d4b91d 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c @@ -403,11 +403,15 @@ static int fbnic_hwtstamp_set(struct net_device *netdev, static void fbnic_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats64) { + u64 rx_bytes, rx_packets, rx_dropped = 0, rx_errors = 0; u64 tx_bytes, tx_packets, tx_dropped = 0; - u64 rx_bytes, rx_packets, rx_dropped = 0; struct fbnic_net *fbn = netdev_priv(dev); + struct fbnic_dev *fbd = fbn->fbd; struct fbnic_queue_stats *stats; unsigned int start, i; + u64 rx_over = 0; + + fbnic_get_hw_stats(fbd); stats = &fbn->tx_stats; @@ -444,9 +448,22 @@ static void fbnic_get_stats64(struct net_device *dev, rx_packets = stats->packets; rx_dropped = stats->dropped; + spin_lock(&fbd->hw_stats_lock); + for (i = 0; i < fbd->max_num_queues; i++) { + /* Report packets dropped due to CQ/BDQ being full/empty */ + rx_over += fbd->hw_stats.hw_q[i].rde_pkt_cq_drop.value; + rx_over += fbd->hw_stats.hw_q[i].rde_pkt_bdq_drop.value; + + /* Report packets with errors */ + rx_errors += fbd->hw_stats.hw_q[i].rde_pkt_err.value; + } + spin_unlock(&fbd->hw_stats_lock); + stats64->rx_bytes = rx_bytes; stats64->rx_packets = rx_packets; stats64->rx_dropped = rx_dropped; + stats64->rx_over_errors = rx_over; + stats64->rx_errors = rx_errors; for (i = 0; i < fbn->num_rx_queues; i++) { struct fbnic_ring *rxr = fbn->rx[i]; @@ -486,6 +503,7 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx, { struct fbnic_net *fbn = netdev_priv(dev); struct fbnic_ring *rxr = fbn->rx[idx]; + struct fbnic_dev *fbd = fbn->fbd; struct fbnic_queue_stats *stats; u64 bytes, packets, alloc_fail; u64 csum_complete, csum_none; @@ -509,6 +527,15 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx, rx->alloc_fail = alloc_fail; rx->csum_complete = csum_complete; rx->csum_none = csum_none; + + fbnic_get_hw_q_stats(fbd, fbd->hw_stats.hw_q); + + spin_lock(&fbd->hw_stats_lock); + rx->hw_drop_overruns = fbd->hw_stats.hw_q[idx].rde_pkt_cq_drop.value + + fbd->hw_stats.hw_q[idx].rde_pkt_bdq_drop.value; + rx->hw_drops = fbd->hw_stats.hw_q[idx].rde_pkt_err.value + + rx->hw_drop_overruns; + spin_unlock(&fbd->hw_stats_lock); } static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx, From patchwork Thu Apr 10 07:08:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohsin Bashir X-Patchwork-Id: 14045979 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 DFFBD204C14 for ; Thu, 10 Apr 2025 07:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268981; cv=none; b=BV+RjuNSpfqmAq8RPh0Pw/Q+MHxdE0gQ6dgoGAGfpk7DPoG7Q5cNSQqhxoVHRYnwPBGLH0w7i7EEF1vVl3z3gnqJ5Uyr9VDXpXxD6YaYoqrJ4/0wAKI4Mw/E+hhH8OzwgTSBCuAPFUWTy4gzwFYsKv/ZKVP/2N/fNpfYxgT876Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268981; c=relaxed/simple; bh=twmxLOniMqpJYiahMn2vTkQH09dQjxfCm2AdhMBW1sU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dxjyIhyDPyrtVO9LBeDVm9WU7oTUOjAIhUN57+XsMtxsFNhjvdW/QYhbPOLgI/bMYFaIKf6ff9w3Xu8PC0Jibxygft2fEXVNm2u6vOgbQ5trokkrxsaaiS2NWpvJw7byCWBPaNm2aNdO2JuUnF7p1jApw8DLFfe5eA/2BH7PfG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VjAQj7TR; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VjAQj7TR" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-39c31e4c3e5so225277f8f.0 for ; Thu, 10 Apr 2025 00:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744268976; x=1744873776; 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=hxMMLXa3xZFAJENCUVmYSmi8zhnkjZvyHs2Cc3FojUA=; b=VjAQj7TRWiHEL6oE3cx7tIHGQomSaz0X2PgWkVzpwUDWKTEnwLRzIApo8acGvSXpRk i3k/AsIJtofqySSMhBawU2rB0hRdQrv/StTSKWOc1a7XW90J+4ijBAW6dEeL/zfAwf8e 2KFYYSL2Zok2QPX5BEY5VtCHIaSgpwk03pDvxvSiGkM9KrBE2Qtjr16VsqPJ50cs2kF6 de/g7dszmtSPMjDQ/F8jVAGYTc2Rqua8ByW573Y+saRp2AwuBpEzneLIuRh0J0iC/Z7+ lm46ub50xbsqtTrJpdZ6yLO8PLQc/Z1oYOAWxxV2yh+8GWqTatYZvUxTtZCU50pZQr6B at+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744268976; x=1744873776; 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=hxMMLXa3xZFAJENCUVmYSmi8zhnkjZvyHs2Cc3FojUA=; b=P5JE3axmVXKA3pWZqKf7sjZeVzgoA/Gw+ZgaP158K22ba1WAiiXJ0fc/6/TDvi6Oz1 VBnHHoosBOCe+CPuGZDx6mRFabQpNm3L3ktzIjQOl4jfZScdCN5OKpBCOP/nzinaxBrv 4eCEaN1fi8QeCeKQnV9uqwHZPRywYj3nmjbxNZ0WGSDz8EIzZD1m/kYc4woWyV4a7omZ oLEk/MuJn64brU4CIJ9EgKVq5bQN1sKhllc/+Ir52de0XMRtOa0pyNbMMx5+oVlxy23b ZacSpU27GUKN5mjAGUqhYbNzT8A+C/hzMJYPN2MxB786pRtwvW4ex5oS1dhGvia4uqTm usBg== X-Gm-Message-State: AOJu0Yy6UDLbONUHYQSqpBfCpxtQqzaOOwDvwb3T5qpQ7kvdkmzZ5SI7 SorDe3zzedyHdPWGFf/BE7Nzd1GPL4vKIPkQ0S2GC6sEEzMZWaRd5TtmEZOU X-Gm-Gg: ASbGncvsPMoeV81/NxGI5K7Z6PfjRnt6tIuqNESVNRre8u4JasJdHp9h2VNgQ8zReRf 9fxoWd8grWohDtniL6UGw8X9z0jAuwYwCyTjfFMDAQWZc4xbtgLDJn7vJVc0dtGpKoV+lIXzE+H 9LhFNHJB5bjS0qqm/2f54R1p7W/4GQ9b4uMotJJ76HX8JijVXICrxf3BJjN+Soh20/JiYglbuHz rTEWzakwXBsBIopxFO3j0hhlnw5iHRwEyGqjvlHVNQccQqpvz6SC34mozBLNIzVFHB7iZHhaJdJ tbv5YGJqePSztEuKXs0SmXjAdSeafsxw42I= X-Google-Smtp-Source: AGHT+IGWo1fdfveid8WFBs862TFUgCyLpAJyuhLA7UEvBCb8GA7cg1NvmRhnkyokGaUSsMZKjdotJQ== X-Received: by 2002:a5d:584d:0:b0:39c:1257:c7a2 with SMTP id ffacd0b85a97d-39d8f4fa815mr1089441f8f.58.1744268976210; Thu, 10 Apr 2025 00:09:36 -0700 (PDT) Received: from localhost ([2a03:2880:31ff::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39d8938a4dasm3813512f8f.48.2025.04.10.00.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 00:09:35 -0700 (PDT) From: Mohsin Bashir To: netdev@vger.kernel.org Cc: alexanderduyck@fb.com, kuba@kernel.org, andrew+netdev@lunn.ch, corbet@lwn.net, davem@davemloft.net, edumazet@google.com, horms@kernel.org, jdamato@fastly.com, kalesh-anakkur.purayil@broadcom.com, kernel-team@meta.com, mohsin.bashr@gmail.com, pabeni@redhat.com, richardcochran@gmail.com, sanman.p211993@gmail.com, sdf@fomichev.me, vadim.fedorenko@linux.dev Subject: [PATCH net-next 3/5 V2] eth: fbnic: add coverage for RXB stats Date: Thu, 10 Apr 2025 00:08:57 -0700 Message-ID: <20250410070859.4160768-4-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250410070859.4160768-1-mohsin.bashr@gmail.com> References: <20250410070859.4160768-1-mohsin.bashr@gmail.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 This patch provides coverage to the RXB (RX Buffer) stats. RXB stats are divided into 3 sections: RXB enqueue, RXB FIFO, and RXB dequeue stats. The RXB enqueue/dequeue stats are indexed from 0-3 and cater for the input/output counters whereas, the RXB fifo stats are indexed from 0-7. The RXB also supports pause frame stats counters which we are leaving for a later patch. ethtool -S eth0 | grep rxb rxb_integrity_err0: 0 rxb_mac_err0: 0 rxb_parser_err0: 0 rxb_frm_err0: 0 rxb_drbo0_frames: 1433543 rxb_drbo0_bytes: 775949081 --- --- rxb_intf3_frames: 1195711 rxb_intf3_bytes: 739650210 rxb_pbuf3_frames: 1195711 rxb_pbuf3_bytes: 765948092 Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir Reviewed-by: Simon Horman --- .../device_drivers/ethernet/meta/fbnic.rst | 26 +++ drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 8 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 110 +++++++++++ .../net/ethernet/meta/fbnic/fbnic_hw_stats.c | 171 ++++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_hw_stats.h | 28 +++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 14 +- 6 files changed, 356 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst index bc7f2fef2875..8ba94ae95db9 100644 --- a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +++ b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst @@ -31,6 +31,32 @@ separate entry. Statistics ---------- +RXB (RX Buffer) Enqueue +~~~~~~~~~~~~~~~~~~~~~~~ + + - ``rxb_integrity_err[i]``: frames enqueued with integrity errors (e.g., multi-bit ECC errors) on RXB input i + - ``rxb_mac_err[i]``: frames enqueued with MAC end-of-frame errors (e.g., bad FCS) on RXB input i + - ``rxb_parser_err[i]``: frames experienced RPC parser errors + - ``rxb_frm_err[i]``: frames experienced signaling errors (e.g., missing end-of-packet/start-of-packet) on RXB input i + - ``rxb_drbo[i]_frames``: frames received at RXB input i + - ``rxb_drbo[i]_bytes``: bytes received at RXB input i + +RXB (RX Buffer) FIFO +~~~~~~~~~~~~~~~~~~~~ + + - ``rxb_fifo[i]_drop``: transitions into the drop state on RXB pool i + - ``rxb_fifo[i]_dropped_frames``: frames dropped on RXB pool i + - ``rxb_fifo[i]_ecn``: transitions into the ECN mark state on RXB pool i + - ``rxb_fifo[i]_level``: current occupancy of RXB pool i + +RXB (RX Buffer) Dequeue +~~~~~~~~~~~~~~~~~~~~~~~ + + - ``rxb_intf[i]_frames``: frames sent to the output i + - ``rxb_intf[i]_bytes``: bytes sent to the output i + - ``rxb_pbuf[i]_frames``: frames sent to output i from the perspective of internal packet buffer + - ``rxb_pbuf[i]_bytes``: bytes sent to output i from the perspective of internal packet buffer + RPC (Rx parser) ~~~~~~~~~~~~~~~ diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h index ff5f68c7e73d..a554e0b2cfff 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h @@ -485,6 +485,14 @@ enum { FBNIC_RXB_FIFO_INDICES = 8 }; +enum { + FBNIC_RXB_INTF_NET = 0, + FBNIC_RXB_INTF_RBT = 1, + /* Unused */ + /* Unused */ + FBNIC_RXB_INTF_INDICES = 4 +}; + #define FBNIC_RXB_CT_SIZE(n) (0x08000 + (n)) /* 0x20000 + 4*n */ #define FBNIC_RXB_CT_SIZE_CNT 8 #define FBNIC_RXB_CT_SIZE_HEADER CSR_GENMASK(5, 0) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c index 038e969f5ba3..816af96a5d5f 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -40,6 +40,47 @@ static const struct fbnic_stat fbnic_gstrings_hw_stats[] = { #define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats) +#define FBNIC_RXB_ENQUEUE_STAT(name, stat) \ + FBNIC_STAT_FIELDS(fbnic_rxb_enqueue_stats, name, stat) + +static const struct fbnic_stat fbnic_gstrings_rxb_enqueue_stats[] = { + FBNIC_RXB_ENQUEUE_STAT("rxb_integrity_err%u", integrity_err), + FBNIC_RXB_ENQUEUE_STAT("rxb_mac_err%u", mac_err), + FBNIC_RXB_ENQUEUE_STAT("rxb_parser_err%u", parser_err), + FBNIC_RXB_ENQUEUE_STAT("rxb_frm_err%u", frm_err), + + FBNIC_RXB_ENQUEUE_STAT("rxb_drbo%u_frames", drbo.frames), + FBNIC_RXB_ENQUEUE_STAT("rxb_drbo%u_bytes", drbo.bytes), +}; + +#define FBNIC_HW_RXB_ENQUEUE_STATS_LEN \ + ARRAY_SIZE(fbnic_gstrings_rxb_enqueue_stats) + +#define FBNIC_RXB_FIFO_STAT(name, stat) \ + FBNIC_STAT_FIELDS(fbnic_rxb_fifo_stats, name, stat) + +static const struct fbnic_stat fbnic_gstrings_rxb_fifo_stats[] = { + FBNIC_RXB_FIFO_STAT("rxb_fifo%u_drop", trans_drop), + FBNIC_RXB_FIFO_STAT("rxb_fifo%u_dropped_frames", drop.frames), + FBNIC_RXB_FIFO_STAT("rxb_fifo%u_ecn", trans_ecn), + FBNIC_RXB_FIFO_STAT("rxb_fifo%u_level", level), +}; + +#define FBNIC_HW_RXB_FIFO_STATS_LEN ARRAY_SIZE(fbnic_gstrings_rxb_fifo_stats) + +#define FBNIC_RXB_DEQUEUE_STAT(name, stat) \ + FBNIC_STAT_FIELDS(fbnic_rxb_dequeue_stats, name, stat) + +static const struct fbnic_stat fbnic_gstrings_rxb_dequeue_stats[] = { + FBNIC_RXB_DEQUEUE_STAT("rxb_intf%u_frames", intf.frames), + FBNIC_RXB_DEQUEUE_STAT("rxb_intf%u_bytes", intf.bytes), + FBNIC_RXB_DEQUEUE_STAT("rxb_pbuf%u_frames", pbuf.frames), + FBNIC_RXB_DEQUEUE_STAT("rxb_pbuf%u_bytes", pbuf.bytes), +}; + +#define FBNIC_HW_RXB_DEQUEUE_STATS_LEN \ + ARRAY_SIZE(fbnic_gstrings_rxb_dequeue_stats) + #define FBNIC_HW_Q_STAT(name, stat) \ FBNIC_STAT_FIELDS(fbnic_hw_q_stats, name, stat.value) @@ -52,6 +93,9 @@ static const struct fbnic_stat fbnic_gstrings_hw_q_stats[] = { #define FBNIC_HW_Q_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_q_stats) #define FBNIC_HW_STATS_LEN \ (FBNIC_HW_FIXED_STATS_LEN + \ + FBNIC_HW_RXB_ENQUEUE_STATS_LEN * FBNIC_RXB_ENQUEUE_INDICES + \ + FBNIC_HW_RXB_FIFO_STATS_LEN * FBNIC_RXB_FIFO_INDICES + \ + FBNIC_HW_RXB_DEQUEUE_STATS_LEN * FBNIC_RXB_DEQUEUE_INDICES + \ FBNIC_HW_Q_STATS_LEN * FBNIC_MAX_QUEUES) static void @@ -311,6 +355,36 @@ fbnic_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, return err; } +static void fbnic_get_rxb_enqueue_strings(u8 **data, unsigned int idx) +{ + const struct fbnic_stat *stat; + int i; + + stat = fbnic_gstrings_rxb_enqueue_stats; + for (i = 0; i < FBNIC_HW_RXB_ENQUEUE_STATS_LEN; i++, stat++) + ethtool_sprintf(data, stat->string, idx); +} + +static void fbnic_get_rxb_fifo_strings(u8 **data, unsigned int idx) +{ + const struct fbnic_stat *stat; + int i; + + stat = fbnic_gstrings_rxb_fifo_stats; + for (i = 0; i < FBNIC_HW_RXB_FIFO_STATS_LEN; i++, stat++) + ethtool_sprintf(data, stat->string, idx); +} + +static void fbnic_get_rxb_dequeue_strings(u8 **data, unsigned int idx) +{ + const struct fbnic_stat *stat; + int i; + + stat = fbnic_gstrings_rxb_dequeue_stats; + for (i = 0; i < FBNIC_HW_RXB_DEQUEUE_STATS_LEN; i++, stat++) + ethtool_sprintf(data, stat->string, idx); +} + static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data) { const struct fbnic_stat *stat; @@ -321,6 +395,15 @@ static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data) for (i = 0; i < FBNIC_HW_FIXED_STATS_LEN; i++) ethtool_puts(&data, fbnic_gstrings_hw_stats[i].string); + for (i = 0; i < FBNIC_RXB_ENQUEUE_INDICES; i++) + fbnic_get_rxb_enqueue_strings(&data, i); + + for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++) + fbnic_get_rxb_fifo_strings(&data, i); + + for (i = 0; i < FBNIC_RXB_DEQUEUE_INDICES; i++) + fbnic_get_rxb_dequeue_strings(&data, i); + for (idx = 0; idx < FBNIC_MAX_QUEUES; idx++) { stat = fbnic_gstrings_hw_q_stats; @@ -357,6 +440,33 @@ static void fbnic_get_ethtool_stats(struct net_device *dev, fbnic_report_hw_stats(fbnic_gstrings_hw_stats, &fbd->hw_stats, FBNIC_HW_FIXED_STATS_LEN, &data); + for (i = 0; i < FBNIC_RXB_ENQUEUE_INDICES; i++) { + const struct fbnic_rxb_enqueue_stats *enq; + + enq = &fbd->hw_stats.rxb.enq[i]; + fbnic_report_hw_stats(fbnic_gstrings_rxb_enqueue_stats, + enq, FBNIC_HW_RXB_ENQUEUE_STATS_LEN, + &data); + } + + for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++) { + const struct fbnic_rxb_fifo_stats *fifo; + + fifo = &fbd->hw_stats.rxb.fifo[i]; + fbnic_report_hw_stats(fbnic_gstrings_rxb_fifo_stats, + fifo, FBNIC_HW_RXB_FIFO_STATS_LEN, + &data); + } + + for (i = 0; i < FBNIC_RXB_DEQUEUE_INDICES; i++) { + const struct fbnic_rxb_dequeue_stats *deq; + + deq = &fbd->hw_stats.rxb.deq[i]; + fbnic_report_hw_stats(fbnic_gstrings_rxb_dequeue_stats, + deq, FBNIC_HW_RXB_DEQUEUE_STATS_LEN, + &data); + } + for (i = 0; i < FBNIC_MAX_QUEUES; i++) { const struct fbnic_hw_q_stats *hw_q = &fbd->hw_stats.hw_q[i]; diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c index c8faedc2ec44..1c5ccaf39727 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c @@ -117,6 +117,173 @@ static void fbnic_get_rpc_stats32(struct fbnic_dev *fbd, &rpc->ovr_size_err); } +static void fbnic_reset_rxb_fifo_stats(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_fifo_stats *fifo) +{ + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_DROP_FRMS_STS(i), + &fifo->drop.frames); + fbnic_hw_stat_rst64(fbd, FBNIC_RXB_DROP_BYTES_STS_L(i), 1, + &fifo->drop.bytes); + + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_TRUN_FRMS_STS(i), + &fifo->trunc.frames); + fbnic_hw_stat_rst64(fbd, FBNIC_RXB_TRUN_BYTES_STS_L(i), 1, + &fifo->trunc.bytes); + + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_TRANS_DROP_STS(i), + &fifo->trans_drop); + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_TRANS_ECN_STS(i), + &fifo->trans_ecn); + + fifo->level.u.old_reg_value_32 = 0; +} + +static void fbnic_reset_rxb_enq_stats(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_enqueue_stats *enq) +{ + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_DRBO_FRM_CNT_SRC(i), + &enq->drbo.frames); + fbnic_hw_stat_rst64(fbd, FBNIC_RXB_DRBO_BYTE_CNT_SRC_L(i), 4, + &enq->drbo.bytes); + + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_INTEGRITY_ERR(i), + &enq->integrity_err); + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_MAC_ERR(i), + &enq->mac_err); + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_PARSER_ERR(i), + &enq->parser_err); + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_FRM_ERR(i), + &enq->frm_err); +} + +static void fbnic_reset_rxb_deq_stats(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_dequeue_stats *deq) +{ + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_INTF_FRM_CNT_DST(i), + &deq->intf.frames); + fbnic_hw_stat_rst64(fbd, FBNIC_RXB_INTF_BYTE_CNT_DST_L(i), 4, + &deq->intf.bytes); + + fbnic_hw_stat_rst32(fbd, FBNIC_RXB_PBUF_FRM_CNT_DST(i), + &deq->pbuf.frames); + fbnic_hw_stat_rst64(fbd, FBNIC_RXB_PBUF_BYTE_CNT_DST_L(i), 4, + &deq->pbuf.bytes); +} + +static void fbnic_reset_rxb_stats(struct fbnic_dev *fbd, + struct fbnic_rxb_stats *rxb) +{ + int i; + + for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++) + fbnic_reset_rxb_fifo_stats(fbd, i, &rxb->fifo[i]); + + for (i = 0; i < FBNIC_RXB_INTF_INDICES; i++) { + fbnic_reset_rxb_enq_stats(fbd, i, &rxb->enq[i]); + fbnic_reset_rxb_deq_stats(fbd, i, &rxb->deq[i]); + } +} + +static void fbnic_get_rxb_fifo_stats32(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_fifo_stats *fifo) +{ + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_DROP_FRMS_STS(i), + &fifo->drop.frames); + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_TRUN_FRMS_STS(i), + &fifo->trunc.frames); + + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_TRANS_DROP_STS(i), + &fifo->trans_drop); + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_TRANS_ECN_STS(i), + &fifo->trans_ecn); + + fifo->level.value = rd32(fbd, FBNIC_RXB_PBUF_FIFO_LEVEL(i)); +} + +static void fbnic_get_rxb_fifo_stats(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_fifo_stats *fifo) +{ + fbnic_hw_stat_rd64(fbd, FBNIC_RXB_DROP_BYTES_STS_L(i), 1, + &fifo->drop.bytes); + fbnic_hw_stat_rd64(fbd, FBNIC_RXB_TRUN_BYTES_STS_L(i), 1, + &fifo->trunc.bytes); + + fbnic_get_rxb_fifo_stats32(fbd, i, fifo); +} + +static void fbnic_get_rxb_enq_stats32(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_enqueue_stats *enq) +{ + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_DRBO_FRM_CNT_SRC(i), + &enq->drbo.frames); + + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_INTEGRITY_ERR(i), + &enq->integrity_err); + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_MAC_ERR(i), + &enq->mac_err); + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_PARSER_ERR(i), + &enq->parser_err); + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_FRM_ERR(i), + &enq->frm_err); +} + +static void fbnic_get_rxb_enq_stats(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_enqueue_stats *enq) +{ + fbnic_hw_stat_rd64(fbd, FBNIC_RXB_DRBO_BYTE_CNT_SRC_L(i), 4, + &enq->drbo.bytes); + + fbnic_get_rxb_enq_stats32(fbd, i, enq); +} + +static void fbnic_get_rxb_deq_stats32(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_dequeue_stats *deq) +{ + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_INTF_FRM_CNT_DST(i), + &deq->intf.frames); + fbnic_hw_stat_rd32(fbd, FBNIC_RXB_PBUF_FRM_CNT_DST(i), + &deq->pbuf.frames); +} + +static void fbnic_get_rxb_deq_stats(struct fbnic_dev *fbd, int i, + struct fbnic_rxb_dequeue_stats *deq) +{ + fbnic_hw_stat_rd64(fbd, FBNIC_RXB_INTF_BYTE_CNT_DST_L(i), 4, + &deq->intf.bytes); + fbnic_hw_stat_rd64(fbd, FBNIC_RXB_PBUF_BYTE_CNT_DST_L(i), 4, + &deq->pbuf.bytes); + + fbnic_get_rxb_deq_stats32(fbd, i, deq); +} + +static void fbnic_get_rxb_stats32(struct fbnic_dev *fbd, + struct fbnic_rxb_stats *rxb) +{ + int i; + + for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++) + fbnic_get_rxb_fifo_stats32(fbd, i, &rxb->fifo[i]); + + for (i = 0; i < FBNIC_RXB_INTF_INDICES; i++) { + fbnic_get_rxb_enq_stats32(fbd, i, &rxb->enq[i]); + fbnic_get_rxb_deq_stats32(fbd, i, &rxb->deq[i]); + } +} + +static void fbnic_get_rxb_stats(struct fbnic_dev *fbd, + struct fbnic_rxb_stats *rxb) +{ + int i; + + for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++) + fbnic_get_rxb_fifo_stats(fbd, i, &rxb->fifo[i]); + + for (i = 0; i < FBNIC_RXB_INTF_INDICES; i++) { + fbnic_get_rxb_enq_stats(fbd, i, &rxb->enq[i]); + fbnic_get_rxb_deq_stats(fbd, i, &rxb->deq[i]); + } +} + static void fbnic_reset_hw_rxq_stats(struct fbnic_dev *fbd, struct fbnic_hw_q_stats *hw_q) { @@ -253,6 +420,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd) { spin_lock(&fbd->hw_stats_lock); fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc); + fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb); fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q); fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie); spin_unlock(&fbd->hw_stats_lock); @@ -261,6 +429,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd) static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd) { fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc); + fbnic_get_rxb_stats32(fbd, &fbd->hw_stats.rxb); fbnic_get_hw_rxq_stats32(fbd, fbd->hw_stats.hw_q); } @@ -275,6 +444,8 @@ void fbnic_get_hw_stats(struct fbnic_dev *fbd) { spin_lock(&fbd->hw_stats_lock); __fbnic_get_hw_stats32(fbd); + + fbnic_get_rxb_stats(fbd, &fbd->hw_stats.rxb); fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie); spin_unlock(&fbd->hw_stats_lock); } diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h index 81efa8dc8381..ec03e6253ba5 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h @@ -17,6 +17,11 @@ struct fbnic_stat_counter { bool reported; }; +struct fbnic_hw_stat { + struct fbnic_stat_counter frames; + struct fbnic_stat_counter bytes; +}; + struct fbnic_eth_mac_stats { struct fbnic_stat_counter FramesTransmittedOK; struct fbnic_stat_counter FramesReceivedOK; @@ -43,6 +48,28 @@ struct fbnic_rpc_stats { struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err; }; +struct fbnic_rxb_enqueue_stats { + struct fbnic_hw_stat drbo; + struct fbnic_stat_counter integrity_err, mac_err; + struct fbnic_stat_counter parser_err, frm_err; +}; + +struct fbnic_rxb_fifo_stats { + struct fbnic_hw_stat drop, trunc; + struct fbnic_stat_counter trans_drop, trans_ecn; + struct fbnic_stat_counter level; +}; + +struct fbnic_rxb_dequeue_stats { + struct fbnic_hw_stat intf, pbuf; +}; + +struct fbnic_rxb_stats { + struct fbnic_rxb_enqueue_stats enq[FBNIC_RXB_ENQUEUE_INDICES]; + struct fbnic_rxb_fifo_stats fifo[FBNIC_RXB_FIFO_INDICES]; + struct fbnic_rxb_dequeue_stats deq[FBNIC_RXB_DEQUEUE_INDICES]; +}; + struct fbnic_hw_q_stats { struct fbnic_stat_counter rde_pkt_err; struct fbnic_stat_counter rde_pkt_cq_drop; @@ -62,6 +89,7 @@ struct fbnic_pcie_stats { struct fbnic_hw_stats { struct fbnic_mac_stats mac; struct fbnic_rpc_stats rpc; + struct fbnic_rxb_stats rxb; struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES]; struct fbnic_pcie_stats pcie; }; diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c index e19284d4b91d..dff485511301 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c @@ -408,8 +408,8 @@ static void fbnic_get_stats64(struct net_device *dev, struct fbnic_net *fbn = netdev_priv(dev); struct fbnic_dev *fbd = fbn->fbd; struct fbnic_queue_stats *stats; + u64 rx_over = 0, rx_missed = 0; unsigned int start, i; - u64 rx_over = 0; fbnic_get_hw_stats(fbd); @@ -449,6 +449,17 @@ static void fbnic_get_stats64(struct net_device *dev, rx_dropped = stats->dropped; spin_lock(&fbd->hw_stats_lock); + /* Record drops for the host FIFOs. + * 4: network to Host, 6: BMC to Host + * Exclude the BMC and MC FIFOs as those stats may contain drops + * due to unrelated items such as TCAM misses. They are still + * accessible through the ethtool stats. + */ + i = FBNIC_RXB_FIFO_HOST; + rx_missed += fbd->hw_stats.rxb.fifo[i].drop.frames.value; + i = FBNIC_RXB_FIFO_BMC_TO_HOST; + rx_missed += fbd->hw_stats.rxb.fifo[i].drop.frames.value; + for (i = 0; i < fbd->max_num_queues; i++) { /* Report packets dropped due to CQ/BDQ being full/empty */ rx_over += fbd->hw_stats.hw_q[i].rde_pkt_cq_drop.value; @@ -464,6 +475,7 @@ static void fbnic_get_stats64(struct net_device *dev, stats64->rx_dropped = rx_dropped; stats64->rx_over_errors = rx_over; stats64->rx_errors = rx_errors; + stats64->rx_missed_errors = rx_missed; for (i = 0; i < fbn->num_rx_queues; i++) { struct fbnic_ring *rxr = fbn->rx[i]; From patchwork Thu Apr 10 07:08:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohsin Bashir X-Patchwork-Id: 14045980 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 C6643204C3C for ; Thu, 10 Apr 2025 07:09:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268983; cv=none; b=jAl1W9Ut0Olk73olF9yVugssOrOhcwf5iD78BzhyHWeWvWpprwaerUzpXcy7fjRP2FbEir+7mQNhvUoxiWWyxIgamNIQNa6jeaMPthr9IdkGUHdiBYW+fsRQtlyQvrS/YWRW76Xe5XNno+IfJUwpf8JJPcAJLrG8uVhzKdF36/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268983; c=relaxed/simple; bh=8vzmveTwXWZn4nZaYw5YL6CNieBIdBrZO1rG66Nexe4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BlGS+c3a1qEaLS7kHV4GK3TazAPvLBpYnuLbII8dfe0cyHrfOGerELZqO0UR/0wQ4QMA1KQDtLIc5184fd9Oz/XAcx8JEd2zxKIZwdXrFkwdv3CwYn8sKw4Q9l8qONvat3f9iQgU90lQo5MgF0xPAw7uLdSGvvuT2f8rqx6/QPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CPow/a5P; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CPow/a5P" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-43edecbfb94so5356525e9.1 for ; Thu, 10 Apr 2025 00:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744268979; x=1744873779; 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=m+FdyvwWte9fQ+zlYmpZxgQpsgup+t9GWDZcE3v6yyA=; b=CPow/a5PJzAr4yoA6PaRy0V59Sj9M/ABJ/4AXgIURSXvC46CSTCCUVozOLYuskmtpj XBmyeMwLcbWb8+0M0mzCbupOl7SlvG9i9AAVchZNsYFmORMm1PUA5aKmMT7YcVvbeFIs t0X/eL/Sem0L9EIkzPGYxNVd9UxnrUSI4wIXlHIjW4JAx/zNCKPpyQHVL9QFN5PUdRx5 e4okiqFBvCerhNzGWwH209RjWzK2Bj/IE+0/gK5PHbG87cn/Xm7dQBPRSp+YISXCo5zK mX+ZeKCOAcG5WzORamub6X4Q5WMj1qxDV8GQOMN0+TrxgVWuixAAtyqFWpOqq42dCeb7 kEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744268979; x=1744873779; 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=m+FdyvwWte9fQ+zlYmpZxgQpsgup+t9GWDZcE3v6yyA=; b=XbyrMnEIt/xnt4KIFuaCLmBHcIzU/LHVXmJDxW2MCUmfZit6fTlzJ2S5Or7XybubsJ yT33SnGhybyPg1E4KXG5l5RdVTDU0LNW037C54So1L7cdISrdNLTYGlyvnWY7V5Adobk D++tTV/+VMn0buurC55hrg1a2cB05Fx2mOgiQfSlWETBdBiG81obKG7osr4kWemoTUMm AuTIbsl5ulC1X6lu1r83I+OPZKyS1f1zjQXsSebGnTB8YhhrosHdWH6yj87f5UcZgA4O XltFy/PtoQy+Grgrd9ZTrVnvraEqj3YH1FS1kbCc+75y3Q1wMIhvzGq6kGpeMWzE4D66 toIw== X-Gm-Message-State: AOJu0YyOCqqPuwQkMhDYXx/ZmGV3EO1neQTPzTOyK8SN2huI5uymdQFF mCMODvd/HTtaQxDdlEvjS9npRpZkIVgUmxcMT8vnlgnzh0nMVbJBu5AlHXRo X-Gm-Gg: ASbGncuTgSo8VEjRWOekUsMJoUjaXjmRHTlr7dOglL3Vdxxh6CCXafuhbHlA+te8ven a3Qj4O6bjiKC8CBtKrV3fqdc/dsXOkZp7pBUpwQVyhfHtqHKqYGxVDFJbqd/umn8axnTKkkvDy5 Wn2Tj4jCM2gsp6N3UGU1CSndVctIH82sUetMkCCZkuitYSudEna/WeZg8a9b3ZVnZxCF2/0ipZx MvKFXmS9u2Ocm4pwbDOvOztQmtk8KMkl9BGY1m0OBUR5Pr3LnvzXW/tppXj5k1uPQjDEp7ZDrll 8Q0VFOIDREzP/zt3uU0C8W2hfVY/bd56ITQ= X-Google-Smtp-Source: AGHT+IHIcbe00HafuxTiVPPwEiqqMpejOZYmCvn5ftTXFvSQzYxJh7cq6AFUwTa5+M2dd4+RxX1Tsw== X-Received: by 2002:a05:600c:a08d:b0:43c:f513:9585 with SMTP id 5b1f17b1804b1-43f2fedc717mr11162305e9.13.1744268978590; Thu, 10 Apr 2025 00:09:38 -0700 (PDT) Received: from localhost ([2a03:2880:31ff::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43f235a5ec3sm41314255e9.39.2025.04.10.00.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 00:09:37 -0700 (PDT) From: Mohsin Bashir To: netdev@vger.kernel.org Cc: alexanderduyck@fb.com, kuba@kernel.org, andrew+netdev@lunn.ch, corbet@lwn.net, davem@davemloft.net, edumazet@google.com, horms@kernel.org, jdamato@fastly.com, kalesh-anakkur.purayil@broadcom.com, kernel-team@meta.com, mohsin.bashr@gmail.com, pabeni@redhat.com, richardcochran@gmail.com, sanman.p211993@gmail.com, sdf@fomichev.me, vadim.fedorenko@linux.dev Subject: [PATCH net-next 4/5 V2] eth: fbnic: add support for TMI stats Date: Thu, 10 Apr 2025 00:08:58 -0700 Message-ID: <20250410070859.4160768-5-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250410070859.4160768-1-mohsin.bashr@gmail.com> References: <20250410070859.4160768-1-mohsin.bashr@gmail.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 This patch add coverage for TMI stats including PTP stats and drop stats. PTP stats include illegal requests, bad timestamp and good timestamps. The bad timestamp and illegal request counters are reported under as `error` via `ethtool -T` Both these counters are individually being reported via `ethtool -S` The good timestamp stats are being reported as `pkts` via `ethtool -T` ethtool -S eth0 | grep "ptp" ptp_illegal_req: 0 ptp_good_ts: 0 ptp_bad_ts: 0 Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir Reviewed-by: Simon Horman --- .../device_drivers/ethernet/meta/fbnic.rst | 7 ++++ drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 5 +++ .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 5 +++ .../net/ethernet/meta/fbnic/fbnic_hw_stats.c | 34 +++++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_hw_stats.h | 6 ++++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 3 ++ 6 files changed, 60 insertions(+) diff --git a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst index 8ba94ae95db9..02339818cb8d 100644 --- a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +++ b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst @@ -31,6 +31,13 @@ separate entry. Statistics ---------- +TX MAC Interface +~~~~~~~~~~~~~~~~ + + - ``ptp_illegal_req``: packets sent to the NIC with PTP request bit set but routed to BMC/FW + - ``ptp_good_ts``: packets successfully routed to MAC with PTP request bit set + - ``ptp_bad_ts``: packets destined for MAC with PTP request bit set but aborted because of some error (e.g., DMA read error) + RXB (RX Buffer) Enqueue ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h index a554e0b2cfff..9426f7f2e611 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h @@ -432,6 +432,11 @@ enum { #define FBNIC_TMI_SOP_PROT_CTRL 0x04400 /* 0x11000 */ #define FBNIC_TMI_DROP_CTRL 0x04401 /* 0x11004 */ #define FBNIC_TMI_DROP_CTRL_EN CSR_BIT(0) +#define FBNIC_TMI_DROP_PKTS 0x04402 /* 0x11008 */ +#define FBNIC_TMI_DROP_BYTE_L 0x04403 /* 0x1100c */ +#define FBNIC_TMI_ILLEGAL_PTP_REQS 0x04409 /* 0x11024 */ +#define FBNIC_TMI_GOOD_PTP_TS 0x0440a /* 0x11028 */ +#define FBNIC_TMI_BAD_PTP_TS 0x0440b /* 0x1102c */ #define FBNIC_CSR_END_TMI 0x0443f /* CSR section delimiter */ /* Precision Time Protocol Registers */ diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c index 816af96a5d5f..7d421791033e 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -27,6 +27,11 @@ struct fbnic_stat { FBNIC_STAT_FIELDS(fbnic_hw_stats, name, stat) static const struct fbnic_stat fbnic_gstrings_hw_stats[] = { + /* TMI */ + FBNIC_HW_STAT("ptp_illegal_req", tmi.ptp_illegal_req), + FBNIC_HW_STAT("ptp_good_ts", tmi.ptp_good_ts), + FBNIC_HW_STAT("ptp_bad_ts", tmi.ptp_bad_ts), + /* RPC */ FBNIC_HW_STAT("rpc_unkn_etype", rpc.unkn_etype), FBNIC_HW_STAT("rpc_unkn_ext_hdr", rpc.unkn_ext_hdr), diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c index 1c5ccaf39727..80157f389975 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c @@ -70,6 +70,37 @@ static void fbnic_hw_stat_rd64(struct fbnic_dev *fbd, u32 reg, s32 offset, stat->u.old_reg_value_64 = new_reg_value; } +static void fbnic_reset_tmi_stats(struct fbnic_dev *fbd, + struct fbnic_tmi_stats *tmi) +{ + fbnic_hw_stat_rst32(fbd, FBNIC_TMI_DROP_PKTS, &tmi->drop.frames); + fbnic_hw_stat_rst64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes); + + fbnic_hw_stat_rst32(fbd, + FBNIC_TMI_ILLEGAL_PTP_REQS, + &tmi->ptp_illegal_req); + fbnic_hw_stat_rst32(fbd, FBNIC_TMI_GOOD_PTP_TS, &tmi->ptp_good_ts); + fbnic_hw_stat_rst32(fbd, FBNIC_TMI_BAD_PTP_TS, &tmi->ptp_bad_ts); +} + +static void fbnic_get_tmi_stats32(struct fbnic_dev *fbd, + struct fbnic_tmi_stats *tmi) +{ + fbnic_hw_stat_rd32(fbd, FBNIC_TMI_DROP_PKTS, &tmi->drop.frames); + + fbnic_hw_stat_rd32(fbd, + FBNIC_TMI_ILLEGAL_PTP_REQS, + &tmi->ptp_illegal_req); + fbnic_hw_stat_rd32(fbd, FBNIC_TMI_GOOD_PTP_TS, &tmi->ptp_good_ts); + fbnic_hw_stat_rd32(fbd, FBNIC_TMI_BAD_PTP_TS, &tmi->ptp_bad_ts); +} + +static void fbnic_get_tmi_stats(struct fbnic_dev *fbd, + struct fbnic_tmi_stats *tmi) +{ + fbnic_hw_stat_rd64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes); +} + static void fbnic_reset_rpc_stats(struct fbnic_dev *fbd, struct fbnic_rpc_stats *rpc) { @@ -419,6 +450,7 @@ static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd, void fbnic_reset_hw_stats(struct fbnic_dev *fbd) { spin_lock(&fbd->hw_stats_lock); + fbnic_reset_tmi_stats(fbd, &fbd->hw_stats.tmi); fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc); fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb); fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q); @@ -428,6 +460,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd) static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd) { + fbnic_get_tmi_stats32(fbd, &fbd->hw_stats.tmi); fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc); fbnic_get_rxb_stats32(fbd, &fbd->hw_stats.rxb); fbnic_get_hw_rxq_stats32(fbd, fbd->hw_stats.hw_q); @@ -445,6 +478,7 @@ void fbnic_get_hw_stats(struct fbnic_dev *fbd) spin_lock(&fbd->hw_stats_lock); __fbnic_get_hw_stats32(fbd); + fbnic_get_tmi_stats(fbd, &fbd->hw_stats.tmi); fbnic_get_rxb_stats(fbd, &fbd->hw_stats.rxb); fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie); spin_unlock(&fbd->hw_stats_lock); diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h index ec03e6253ba5..abb0957a5ac0 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h @@ -42,6 +42,11 @@ struct fbnic_mac_stats { struct fbnic_eth_mac_stats eth_mac; }; +struct fbnic_tmi_stats { + struct fbnic_hw_stat drop; + struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts; +}; + struct fbnic_rpc_stats { struct fbnic_stat_counter unkn_etype, unkn_ext_hdr; struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp; @@ -88,6 +93,7 @@ struct fbnic_pcie_stats { struct fbnic_hw_stats { struct fbnic_mac_stats mac; + struct fbnic_tmi_stats tmi; struct fbnic_rpc_stats rpc; struct fbnic_rxb_stats rxb; struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES]; diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c index dff485511301..a0f93bd27113 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c @@ -423,6 +423,9 @@ static void fbnic_get_stats64(struct net_device *dev, stats64->tx_packets = tx_packets; stats64->tx_dropped = tx_dropped; + /* Record drops from Tx HW Datapath */ + tx_dropped += fbd->hw_stats.tmi.drop.frames.value; + for (i = 0; i < fbn->num_tx_queues; i++) { struct fbnic_ring *txr = fbn->tx[i]; From patchwork Thu Apr 10 07:08:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohsin Bashir X-Patchwork-Id: 14045981 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 504B61DFDE for ; Thu, 10 Apr 2025 07:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268986; cv=none; b=iZJj0G1tdenp+dEioRoGPj1IVWrSHP3si3e8PiW1LDucxH//b0LV25y9BhiRQtCJL7xlx8QnnxwkA+v/sEcvpap0YGA0oOqal7TOb7liZpKuNBoBkRf+jGe0MbKh+JyHLxbLCnfh1cXfV2In7cHZLmvVtZ3OLt/Z46CubKKqQNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744268986; c=relaxed/simple; bh=zumvnT4RkTGQuq5rPHV8umYXVTGpW/B+zSu8kqD+hl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FpoxVVSWN0tJg4TGlioTkrM9IZOvALmm0OEL7pI017Pi7LZquvhnM33ETlPIs/rA9B2PRZFCYUXbbXnsLQ8nBfLaNvcbCnF5R3bjpK+5TPpCHH+f6rTCnoysjaQL7d/PHdxdpzaeluMMVn+4j4raxlMD0rS6Jv2FwvVr5Z7zuQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=juR//tfu; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="juR//tfu" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-39d83782ef6so978237f8f.0 for ; Thu, 10 Apr 2025 00:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744268981; x=1744873781; 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=koDuUtZSzdwmAZeQ+8NiUzPArIkaBe59rnqzlp7f0Qo=; b=juR//tfuJbZ6zUKkGE2ISRVqvok5ZYb8RnVeXprS4z6OtHWiUdToHfVByJXooTaCEd ORGvQohagvcrZE99Jk62CSffQGai1N/RZDTTfqVVB2qpARsGiE4IWh/rUUDmbJn3QpN9 cFWYE6HBCFLl5Fk2kwrr4l7XOZPACDxkeJlkRDnK8I0zOXd8a4ENEFuGWEt+FtoyI38l +Z2JWBnosMU0a2TvkEghtFGHi3XX3W0LKwkHB+7OYrUc1HT/C1IKav1ULfuVhczEz2aI agj/PQTwBsWsjJNDTej2YQFJLnzN4V5DlMc7zUyoa/245iXMYJcDQJvwaajIvy6acsOi DYng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744268981; x=1744873781; 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=koDuUtZSzdwmAZeQ+8NiUzPArIkaBe59rnqzlp7f0Qo=; b=MjySGLfscBnYMClpZVVtuKCoEu+4xjsLhreK2alloaQEDM7KpVAqpV1dylyUz0yAJ7 eGq/GDnaFDiBcj25+0R4VSXpOvf0AozsaF53GYFJLA87wm79Dl6gx3Kk0SrpSl5OityA BlIWhaj9YbP0bjsnQE3BJbM55rgHSZ0TVv28tAN+2FpXoEAREHMptFU09P2IYXBU3x/t jpkHTbHgjUin1cZEQbeGjso3mxa7rVeC9WyG8wnr8Wd0Pw3lGxTxOUup8IC5AKoiG3hb Iqe1PeWWYs0eXOJcLcTzYMdPzfsQUIiCogawQxLRrUtfZQ6sdEDunu+DiXIh+SZmdmCZ gUiw== X-Gm-Message-State: AOJu0YyU8MRTJSbDC1gvi6XC5GtQhOcUinFQbjMjfSU6Hkc8F+o9APFI 5tP0JG0uEjvanhRz0b8l//lt86WmOVetKlULZjOIzhiPNr5LK6SOkvD5hbMn X-Gm-Gg: ASbGncvwmSejwv6GHpqnbD5K2yYNKqye6stwYRpFcguwbH5u7vLYcnzOJCE/PDRw9WK vWC1aZLLAYsiID4IQ3k/1eEoL2TXZARrDQSwapzOrOKpdLiqe8MoCwvdf7PTHV8YNpo3ncvoDeV eXB0gLG8LqhBTBXxMeTUutfUYHI6boGABdwHG+wP9letp6gCUlfZh3dcqKgngdJuj/s7VQ8XcNz gVezyu8/3nUne8AYvcZ15khPYUZDISF/KJvhH0b77Yo8q71VkAp5Kqa0oUDUUawlYkx9N3V1sI6 ek0KzES5rzBt2TTOjRqDp6lsUSkjxgUqpSu4CJM= X-Google-Smtp-Source: AGHT+IFWoYcqrL+wudr/QKCdgY1favnxe2+wsJVT6ImPOw1UIZ942lCVFnASeC8GrxzmsHTAWzzwEA== X-Received: by 2002:a05:6000:188f:b0:391:3207:2e68 with SMTP id ffacd0b85a97d-39d8f27628cmr1067209f8f.9.1744268980918; Thu, 10 Apr 2025 00:09:40 -0700 (PDT) Received: from localhost ([2a03:2880:31ff:4b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39d893fc88dsm3814042f8f.81.2025.04.10.00.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 00:09:40 -0700 (PDT) From: Mohsin Bashir To: netdev@vger.kernel.org Cc: alexanderduyck@fb.com, kuba@kernel.org, andrew+netdev@lunn.ch, corbet@lwn.net, davem@davemloft.net, edumazet@google.com, horms@kernel.org, jdamato@fastly.com, kalesh-anakkur.purayil@broadcom.com, kernel-team@meta.com, mohsin.bashr@gmail.com, pabeni@redhat.com, richardcochran@gmail.com, sanman.p211993@gmail.com, sdf@fomichev.me, vadim.fedorenko@linux.dev Subject: [PATCH net-next 5/5 V2] eth: fbnic: add support for TTI HW stats Date: Thu, 10 Apr 2025 00:08:59 -0700 Message-ID: <20250410070859.4160768-6-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250410070859.4160768-1-mohsin.bashr@gmail.com> References: <20250410070859.4160768-1-mohsin.bashr@gmail.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 Add coverage for the TX Extension (TEI) Interface (TTI) stats. We are tracking packets and control message drops because of credit exhaustion on the TX interface. Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir Reviewed-by: Simon Horman --- .../device_drivers/ethernet/meta/fbnic.rst | 7 ++ drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 9 +++ .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 8 +++ .../net/ethernet/meta/fbnic/fbnic_hw_stats.c | 66 +++++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_hw_stats.h | 5 ++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 5 +- 6 files changed, 99 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst index 02339818cb8d..3483e498c08e 100644 --- a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +++ b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst @@ -38,6 +38,13 @@ TX MAC Interface - ``ptp_good_ts``: packets successfully routed to MAC with PTP request bit set - ``ptp_bad_ts``: packets destined for MAC with PTP request bit set but aborted because of some error (e.g., DMA read error) +TX Extension (TEI) Interface (TTI) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + - ``tti_cm_drop``: control messages dropped at the TX Extension (TEI) Interface because of credit starvation + - ``tti_frame_drop``: packets dropped at the TX Extension (TEI) Interface because of credit starvation + - ``tti_tbi_drop``: packets dropped at the TX BMC Interface (TBI) because of credit starvation + RXB (RX Buffer) Enqueue ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h index 9426f7f2e611..0c217c195c6a 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h @@ -397,6 +397,15 @@ enum { #define FBNIC_TCE_DROP_CTRL_TTI_FRM_DROP_EN CSR_BIT(1) #define FBNIC_TCE_DROP_CTRL_TTI_TBI_DROP_EN CSR_BIT(2) +#define FBNIC_TCE_TTI_CM_DROP_PKTS 0x0403e /* 0x100f8 */ +#define FBNIC_TCE_TTI_CM_DROP_BYTE_L 0x0403f /* 0x100fc */ +#define FBNIC_TCE_TTI_CM_DROP_BYTE_H 0x04040 /* 0x10100 */ +#define FBNIC_TCE_TTI_FRAME_DROP_PKTS 0x04041 /* 0x10104 */ +#define FBNIC_TCE_TTI_FRAME_DROP_BYTE_L 0x04042 /* 0x10108 */ +#define FBNIC_TCE_TTI_FRAME_DROP_BYTE_H 0x04043 /* 0x1010c */ +#define FBNIC_TCE_TBI_DROP_PKTS 0x04044 /* 0x10110 */ +#define FBNIC_TCE_TBI_DROP_BYTE_L 0x04045 /* 0x10114 */ + #define FBNIC_TCE_TCAM_IDX2DEST_MAP 0x0404A /* 0x10128 */ #define FBNIC_TCE_TCAM_IDX2DEST_MAP_DEST_ID_0 CSR_GENMASK(3, 0) enum { diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c index 7d421791033e..5c7556c8c4c5 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -27,6 +27,14 @@ struct fbnic_stat { FBNIC_STAT_FIELDS(fbnic_hw_stats, name, stat) static const struct fbnic_stat fbnic_gstrings_hw_stats[] = { + /* TTI */ + FBNIC_HW_STAT("tti_cm_drop_frames", tti.cm_drop.frames), + FBNIC_HW_STAT("tti_cm_drop_bytes", tti.cm_drop.bytes), + FBNIC_HW_STAT("tti_frame_drop_frames", tti.frame_drop.frames), + FBNIC_HW_STAT("tti_frame_drop_bytes", tti.frame_drop.bytes), + FBNIC_HW_STAT("tti_tbi_drop_frames", tti.tbi_drop.frames), + FBNIC_HW_STAT("tti_tbi_drop_bytes", tti.tbi_drop.bytes), + /* TMI */ FBNIC_HW_STAT("ptp_illegal_req", tmi.ptp_illegal_req), FBNIC_HW_STAT("ptp_good_ts", tmi.ptp_good_ts), diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c index 80157f389975..4223d8100e64 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c @@ -101,6 +101,69 @@ static void fbnic_get_tmi_stats(struct fbnic_dev *fbd, fbnic_hw_stat_rd64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes); } +static void fbnic_reset_tti_stats(struct fbnic_dev *fbd, + struct fbnic_tti_stats *tti) +{ + fbnic_hw_stat_rst32(fbd, + FBNIC_TCE_TTI_CM_DROP_PKTS, + &tti->cm_drop.frames); + fbnic_hw_stat_rst64(fbd, + FBNIC_TCE_TTI_CM_DROP_BYTE_L, + 1, + &tti->cm_drop.bytes); + + fbnic_hw_stat_rst32(fbd, + FBNIC_TCE_TTI_FRAME_DROP_PKTS, + &tti->frame_drop.frames); + fbnic_hw_stat_rst64(fbd, + FBNIC_TCE_TTI_FRAME_DROP_BYTE_L, + 1, + &tti->frame_drop.bytes); + + fbnic_hw_stat_rst32(fbd, + FBNIC_TCE_TBI_DROP_PKTS, + &tti->tbi_drop.frames); + fbnic_hw_stat_rst64(fbd, + FBNIC_TCE_TBI_DROP_BYTE_L, + 1, + &tti->tbi_drop.bytes); +} + +static void fbnic_get_tti_stats32(struct fbnic_dev *fbd, + struct fbnic_tti_stats *tti) +{ + fbnic_hw_stat_rd32(fbd, + FBNIC_TCE_TTI_CM_DROP_PKTS, + &tti->cm_drop.frames); + + fbnic_hw_stat_rd32(fbd, + FBNIC_TCE_TTI_FRAME_DROP_PKTS, + &tti->frame_drop.frames); + + fbnic_hw_stat_rd32(fbd, + FBNIC_TCE_TBI_DROP_PKTS, + &tti->tbi_drop.frames); +} + +static void fbnic_get_tti_stats(struct fbnic_dev *fbd, + struct fbnic_tti_stats *tti) +{ + fbnic_hw_stat_rd64(fbd, + FBNIC_TCE_TTI_CM_DROP_BYTE_L, + 1, + &tti->cm_drop.bytes); + + fbnic_hw_stat_rd64(fbd, + FBNIC_TCE_TTI_FRAME_DROP_BYTE_L, + 1, + &tti->frame_drop.bytes); + + fbnic_hw_stat_rd64(fbd, + FBNIC_TCE_TBI_DROP_BYTE_L, + 1, + &tti->tbi_drop.bytes); +} + static void fbnic_reset_rpc_stats(struct fbnic_dev *fbd, struct fbnic_rpc_stats *rpc) { @@ -451,6 +514,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd) { spin_lock(&fbd->hw_stats_lock); fbnic_reset_tmi_stats(fbd, &fbd->hw_stats.tmi); + fbnic_reset_tti_stats(fbd, &fbd->hw_stats.tti); fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc); fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb); fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q); @@ -461,6 +525,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd) static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd) { fbnic_get_tmi_stats32(fbd, &fbd->hw_stats.tmi); + fbnic_get_tti_stats32(fbd, &fbd->hw_stats.tti); fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc); fbnic_get_rxb_stats32(fbd, &fbd->hw_stats.rxb); fbnic_get_hw_rxq_stats32(fbd, fbd->hw_stats.hw_q); @@ -479,6 +544,7 @@ void fbnic_get_hw_stats(struct fbnic_dev *fbd) __fbnic_get_hw_stats32(fbd); fbnic_get_tmi_stats(fbd, &fbd->hw_stats.tmi); + fbnic_get_tti_stats(fbd, &fbd->hw_stats.tti); fbnic_get_rxb_stats(fbd, &fbd->hw_stats.rxb); fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie); spin_unlock(&fbd->hw_stats_lock); diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h index abb0957a5ac0..07e54bb75bf3 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h @@ -47,6 +47,10 @@ struct fbnic_tmi_stats { struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts; }; +struct fbnic_tti_stats { + struct fbnic_hw_stat cm_drop, frame_drop, tbi_drop; +}; + struct fbnic_rpc_stats { struct fbnic_stat_counter unkn_etype, unkn_ext_hdr; struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp; @@ -94,6 +98,7 @@ struct fbnic_pcie_stats { struct fbnic_hw_stats { struct fbnic_mac_stats mac; struct fbnic_tmi_stats tmi; + struct fbnic_tti_stats tti; struct fbnic_rpc_stats rpc; struct fbnic_rxb_stats rxb; struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES]; diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c index a0f93bd27113..d699f58dda21 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c @@ -424,7 +424,10 @@ static void fbnic_get_stats64(struct net_device *dev, stats64->tx_dropped = tx_dropped; /* Record drops from Tx HW Datapath */ - tx_dropped += fbd->hw_stats.tmi.drop.frames.value; + tx_dropped += fbd->hw_stats.tmi.drop.frames.value + + fbd->hw_stats.tti.frame_drop.frames.value + + fbd->hw_stats.tti.tbi_drop.frames.value + + fbd->hw_stats.tmi.drop.frames.value; for (i = 0; i < fbn->num_tx_queues; i++) { struct fbnic_ring *txr = fbn->tx[i];