* [pull request][net-next 00/14] mlx5 updates 2023-11-13
@ 2023-11-13 23:00 Saeed Mahameed
2023-11-13 23:00 ` [net-next 01/14] net/mlx5: print change on SW reset semaphore returns busy Saeed Mahameed
` (13 more replies)
0 siblings, 14 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan
From: Saeed Mahameed <saeedm@nvidia.com>
This series adds misc updates to mlx5 driver.
For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
The following changes since commit 89cdf9d556016a54ff6ddd62324aa5ec790c05cc:
Merge tag 'net-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2023-11-09 17:09:35 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2023-11-13
for you to fetch changes up to 5e6d046ed27608f66dda31c2937dc923f15dddaf:
net/mlx5e: Remove early assignment to netdev->features (2023-11-13 14:58:57 -0800)
----------------------------------------------------------------
mlx5-updates-2023-11-13
1) Cleanup patches, leftovers from previous cycle
2) Allow sync reset flow when BF MGT interface device is present
3) Trivial ptp refactorings and improvements
4) Add local loopback counter to vport rep stats
----------------------------------------------------------------
Amir Tzin (1):
net/mlx5e: Some cleanup in mlx5e_tc_stats_matchall()
Gal Pressman (1):
net/mlx5e: Access array with enum values instead of magic numbers
Justin Stitt (1):
net/mlx5: simplify mlx5_set_driver_version string assignments
Kees Cook (2):
net/mlx5: Annotate struct mlx5_fc_bulk with __counted_by
net/mlx5: Annotate struct mlx5_flow_handle with __counted_by
Moshe Shemesh (2):
net/mlx5: print change on SW reset semaphore returns busy
net/mlx5: Allow sync reset flow when BF MGT interface device is present
Or Har-Toov (1):
net/mlx5e: Add local loopback counter to vport rep stats
Rahul Rameshbabu (5):
net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ
net/mlx5: Refactor real time clock operation checks for PHC
net/mlx5: Initialize clock->ptp_info inside mlx5_init_timer_clock
net/mlx5: Convert scaled ppm values outside the s32 range for PHC frequency adjustments
net/mlx5: Query maximum frequency adjustment of the PTP hardware clock
Tariq Toukan (1):
net/mlx5e: Remove early assignment to netdev->features
.../ethernet/mellanox/mlx5/counters.rst | 6 ++
.../net/ethernet/mellanox/mlx5/core/diag/crdump.c | 5 +-
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 1 +
.../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 14 ++++
.../ethernet/mellanox/mlx5/core/en/tc/act/pedit.c | 3 +-
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 -
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 26 +++++++-
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 1 +
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 3 +
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 24 ++-----
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 -
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 2 +-
.../net/ethernet/mellanox/mlx5/core/fs_counters.c | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 32 +++++++--
.../net/ethernet/mellanox/mlx5/core/lib/clock.c | 78 ++++++++++++++--------
drivers/net/ethernet/mellanox/mlx5/core/main.c | 20 +-----
include/linux/mlx5/mlx5_ifc.h | 5 +-
17 files changed, 148 insertions(+), 77 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [net-next 01/14] net/mlx5: print change on SW reset semaphore returns busy
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 02/14] net/mlx5: Allow sync reset flow when BF MGT interface device is present Saeed Mahameed
` (12 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Moshe Shemesh, Shay Drory
From: Moshe Shemesh <moshe@nvidia.com>
While collecting crdump as part of fw_fatal health reporter dump the PF
may fail to lock the SW reset semaphore. Change the print to indicate if
it was due to another PF locked the semaphore already and so trying to
lock the semaphore returned -EBUSY.
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/diag/crdump.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/crdump.c b/drivers/net/ethernet/mellanox/mlx5/core/diag/crdump.c
index 28d02749d3c4..7659ad21e6e5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/diag/crdump.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/diag/crdump.c
@@ -55,7 +55,10 @@ int mlx5_crdump_collect(struct mlx5_core_dev *dev, u32 *cr_data)
ret = mlx5_vsc_sem_set_space(dev, MLX5_SEMAPHORE_SW_RESET,
MLX5_VSC_LOCK);
if (ret) {
- mlx5_core_warn(dev, "Failed to lock SW reset semaphore\n");
+ if (ret == -EBUSY)
+ mlx5_core_info(dev, "SW reset semaphore is already in use\n");
+ else
+ mlx5_core_warn(dev, "Failed to lock SW reset semaphore\n");
goto unlock_gw;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 02/14] net/mlx5: Allow sync reset flow when BF MGT interface device is present
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
2023-11-13 23:00 ` [net-next 01/14] net/mlx5: print change on SW reset semaphore returns busy Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 03/14] net/mlx5e: Some cleanup in mlx5e_tc_stats_matchall() Saeed Mahameed
` (11 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Moshe Shemesh
From: Moshe Shemesh <moshe@nvidia.com>
In sync reset flow, PF is checking that only devices of same device ID
as itself present on the PCIe bridge, otherwise it will NACK the reset.
Since the PCIe bridge connection to NIC card has to be 1 to 1, this is
valid.
However, the BlueField device may also expose another sub-device to the
PCI called management interface, which only provides an ethernet channel
between the host and the smart NIC.
Allow sync reset flow also when management interface sub-device present
when checking devices on the PCIe bridge.
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../ethernet/mellanox/mlx5/core/fw_reset.c | 32 ++++++++++++++++---
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
index b568988e92e3..4b8cb120362b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
@@ -325,6 +325,25 @@ static void mlx5_fw_live_patch_event(struct work_struct *work)
mlx5_core_err(dev, "Failed to reload FW tracer\n");
}
+static const struct pci_device_id mgt_ifc_device_ids[] = {
+ { PCI_VDEVICE(MELLANOX, 0xc2d2) }, /* BlueField1 MGT interface device ID */
+ { PCI_VDEVICE(MELLANOX, 0xc2d3) }, /* BlueField2 MGT interface device ID */
+ { PCI_VDEVICE(MELLANOX, 0xc2d4) }, /* BlueField3-Lx MGT interface device ID */
+ { PCI_VDEVICE(MELLANOX, 0xc2d5) }, /* BlueField3 MGT interface device ID */
+ { PCI_VDEVICE(MELLANOX, 0xc2d6) }, /* BlueField4 MGT interface device ID */
+};
+
+static bool mlx5_is_mgt_ifc_pci_device(struct mlx5_core_dev *dev, u16 dev_id)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(mgt_ifc_device_ids); ++i)
+ if (mgt_ifc_device_ids[i].device == dev_id)
+ return true;
+
+ return false;
+}
+
static int mlx5_check_dev_ids(struct mlx5_core_dev *dev, u16 dev_id)
{
struct pci_bus *bridge_bus = dev->pdev->bus;
@@ -339,10 +358,15 @@ static int mlx5_check_dev_ids(struct mlx5_core_dev *dev, u16 dev_id)
err = pci_read_config_word(sdev, PCI_DEVICE_ID, &sdev_id);
if (err)
return pcibios_err_to_errno(err);
- if (sdev_id != dev_id) {
- mlx5_core_warn(dev, "unrecognized dev_id (0x%x)\n", sdev_id);
- return -EPERM;
- }
+
+ if (sdev_id == dev_id)
+ continue;
+
+ if (mlx5_is_mgt_ifc_pci_device(dev, sdev_id))
+ continue;
+
+ mlx5_core_warn(dev, "unrecognized dev_id (0x%x)\n", sdev_id);
+ return -EPERM;
}
return 0;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 03/14] net/mlx5e: Some cleanup in mlx5e_tc_stats_matchall()
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
2023-11-13 23:00 ` [net-next 01/14] net/mlx5: print change on SW reset semaphore returns busy Saeed Mahameed
2023-11-13 23:00 ` [net-next 02/14] net/mlx5: Allow sync reset flow when BF MGT interface device is present Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 04/14] net/mlx5: Annotate struct mlx5_fc_bulk with __counted_by Saeed Mahameed
` (10 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Amir Tzin,
Patrisious Haddad
From: Amir Tzin <amirtz@nvidia.com>
Function mlx5e_tc_stats_matchall() is only called from one file:
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
Move it there and make it static as exposing it is unnecessary. Also
variable cur_stats is redundant. Remove it and avoid superfluous copy.
This patch does not change functionality.
Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Amir Tzin <amirtz@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 14 ++++++++++++++
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 16 ----------------
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 --
3 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
index b12fe3c5a258..a55452c69f06 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
@@ -147,6 +147,20 @@ mlx5e_rep_setup_tc_cls_flower(struct mlx5e_priv *priv,
}
}
+static void mlx5e_tc_stats_matchall(struct mlx5e_priv *priv,
+ struct tc_cls_matchall_offload *ma)
+{
+ struct mlx5e_rep_priv *rpriv = priv->ppriv;
+ u64 dbytes;
+ u64 dpkts;
+
+ dpkts = priv->stats.rep_stats.vport_rx_packets - rpriv->prev_vf_vport_stats.rx_packets;
+ dbytes = priv->stats.rep_stats.vport_rx_bytes - rpriv->prev_vf_vport_stats.rx_bytes;
+ mlx5e_stats_copy_rep_stats(&rpriv->prev_vf_vport_stats, &priv->stats.rep_stats);
+ flow_stats_update(&ma->stats, dbytes, dpkts, 0, jiffies,
+ FLOW_ACTION_HW_STATS_DELAYED);
+}
+
static
int mlx5e_rep_setup_tc_cls_matchall(struct mlx5e_priv *priv,
struct tc_cls_matchall_offload *ma)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 9a5a5c2c7da9..25743a7eda26 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -5007,22 +5007,6 @@ int mlx5e_tc_delete_matchall(struct mlx5e_priv *priv,
return apply_police_params(priv, 0, extack);
}
-void mlx5e_tc_stats_matchall(struct mlx5e_priv *priv,
- struct tc_cls_matchall_offload *ma)
-{
- struct mlx5e_rep_priv *rpriv = priv->ppriv;
- struct rtnl_link_stats64 cur_stats;
- u64 dbytes;
- u64 dpkts;
-
- mlx5e_stats_copy_rep_stats(&cur_stats, &priv->stats.rep_stats);
- dpkts = cur_stats.rx_packets - rpriv->prev_vf_vport_stats.rx_packets;
- dbytes = cur_stats.rx_bytes - rpriv->prev_vf_vport_stats.rx_bytes;
- rpriv->prev_vf_vport_stats = cur_stats;
- flow_stats_update(&ma->stats, dbytes, dpkts, 0, jiffies,
- FLOW_ACTION_HW_STATS_DELAYED);
-}
-
static void mlx5e_tc_hairpin_update_dead_peer(struct mlx5e_priv *priv,
struct mlx5e_priv *peer_priv)
{
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
index adb39e30f90f..c24bda56b2b5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
@@ -203,8 +203,6 @@ int mlx5e_tc_configure_matchall(struct mlx5e_priv *priv,
struct tc_cls_matchall_offload *f);
int mlx5e_tc_delete_matchall(struct mlx5e_priv *priv,
struct tc_cls_matchall_offload *f);
-void mlx5e_tc_stats_matchall(struct mlx5e_priv *priv,
- struct tc_cls_matchall_offload *ma);
struct mlx5e_encap_entry;
void mlx5e_tc_encap_flows_add(struct mlx5e_priv *priv,
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 04/14] net/mlx5: Annotate struct mlx5_fc_bulk with __counted_by
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (2 preceding siblings ...)
2023-11-13 23:00 ` [net-next 03/14] net/mlx5e: Some cleanup in mlx5e_tc_stats_matchall() Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 05/14] net/mlx5: Annotate struct mlx5_flow_handle " Saeed Mahameed
` (9 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Kees Cook, Leon Romanovsky,
linux-rdma, Justin Stitt, Gustavo A . R . Silva, Leon Romanovsky
From: Kees Cook <keescook@chromium.org>
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct mlx5_fc_bulk.
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1]
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
index 17fe30a4c06c..0c26d707eed2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
@@ -539,7 +539,7 @@ struct mlx5_fc_bulk {
u32 base_id;
int bulk_len;
unsigned long *bitmask;
- struct mlx5_fc fcs[];
+ struct mlx5_fc fcs[] __counted_by(bulk_len);
};
static void mlx5_fc_init(struct mlx5_fc *counter, struct mlx5_fc_bulk *bulk,
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 05/14] net/mlx5: Annotate struct mlx5_flow_handle with __counted_by
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (3 preceding siblings ...)
2023-11-13 23:00 ` [net-next 04/14] net/mlx5: Annotate struct mlx5_fc_bulk with __counted_by Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 06/14] net/mlx5: simplify mlx5_set_driver_version string assignments Saeed Mahameed
` (8 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Kees Cook, Leon Romanovsky,
linux-rdma, Justin Stitt, Gustavo A . R . Silva, Leon Romanovsky
From: Kees Cook <keescook@chromium.org>
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct mlx5_flow_handle.
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1]
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
index 4aed1768b85f..78eb6b7097e1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
@@ -181,7 +181,7 @@ struct mlx5_flow_rule {
struct mlx5_flow_handle {
int num_rules;
- struct mlx5_flow_rule *rule[];
+ struct mlx5_flow_rule *rule[] __counted_by(num_rules);
};
/* Type of children is mlx5_flow_group */
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 06/14] net/mlx5: simplify mlx5_set_driver_version string assignments
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (4 preceding siblings ...)
2023-11-13 23:00 ` [net-next 05/14] net/mlx5: Annotate struct mlx5_flow_handle " Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 07/14] net/mlx5e: Access array with enum values instead of magic numbers Saeed Mahameed
` (7 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Justin Stitt,
linux-hardening, Kees Cook
From: Justin Stitt <justinstitt@google.com>
In total, just assigning this version string takes:
(1) strncpy()'s
(5) strlen()'s
(3) strncat()'s
(1) snprintf()'s
(4) max_t()'s
Moreover, `strncpy` is deprecated [1] and `strncat` really shouldn't be
used either [2]. With this in mind, let's simply use a single
`snprintf`.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://elixir.bootlin.com/linux/v6.6-rc5/source/include/linux/fortify-string.h#L448 [2]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/main.c | 20 +++----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index a17152c1cbb2..bccf6e53556c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -219,7 +219,6 @@ static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
int driver_ver_sz = MLX5_FLD_SZ_BYTES(set_driver_version_in,
driver_version);
u8 in[MLX5_ST_SZ_BYTES(set_driver_version_in)] = {};
- int remaining_size = driver_ver_sz;
char *string;
if (!MLX5_CAP_GEN(dev, driver_version))
@@ -227,22 +226,9 @@ static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
string = MLX5_ADDR_OF(set_driver_version_in, in, driver_version);
- strncpy(string, "Linux", remaining_size);
-
- remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
- strncat(string, ",", remaining_size);
-
- remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
- strncat(string, KBUILD_MODNAME, remaining_size);
-
- remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
- strncat(string, ",", remaining_size);
-
- remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
-
- snprintf(string + strlen(string), remaining_size, "%u.%u.%u",
- LINUX_VERSION_MAJOR, LINUX_VERSION_PATCHLEVEL,
- LINUX_VERSION_SUBLEVEL);
+ snprintf(string, driver_ver_sz, "Linux,%s,%u.%u.%u",
+ KBUILD_MODNAME, LINUX_VERSION_MAJOR,
+ LINUX_VERSION_PATCHLEVEL, LINUX_VERSION_SUBLEVEL);
/*Send the command*/
MLX5_SET(set_driver_version_in, in, opcode,
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 07/14] net/mlx5e: Access array with enum values instead of magic numbers
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (5 preceding siblings ...)
2023-11-13 23:00 ` [net-next 06/14] net/mlx5: simplify mlx5_set_driver_version string assignments Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ Saeed Mahameed
` (6 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Gal Pressman, Vlad Buslov
From: Gal Pressman <gal@nvidia.com>
Access the headers array using pedit_cmd enum values, and don't assume
anything about their values.
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c | 3 ++-
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 8 ++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c
index 368a95fa77d3..b14cd62edffc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c
@@ -48,7 +48,8 @@ mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv,
struct pedit_headers_action *hdrs,
struct netlink_ext_ack *extack)
{
- u8 cmd = (act->id == FLOW_ACTION_MANGLE) ? 0 : 1;
+ u8 cmd = (act->id == FLOW_ACTION_MANGLE) ? TCA_PEDIT_KEY_EX_CMD_SET :
+ TCA_PEDIT_KEY_EX_CMD_ADD;
u8 htype = act->mangle.htype;
int err = -EOPNOTSUPP;
u32 mask, val, offset;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 25743a7eda26..4e1f339e381f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -3195,10 +3195,10 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,
headers_c = mlx5e_get_match_headers_criteria(*action_flags, &parse_attr->spec);
headers_v = mlx5e_get_match_headers_value(*action_flags, &parse_attr->spec);
- set_masks = &hdrs[0].masks;
- add_masks = &hdrs[1].masks;
- set_vals = &hdrs[0].vals;
- add_vals = &hdrs[1].vals;
+ set_masks = &hdrs[TCA_PEDIT_KEY_EX_CMD_SET].masks;
+ add_masks = &hdrs[TCA_PEDIT_KEY_EX_CMD_ADD].masks;
+ set_vals = &hdrs[TCA_PEDIT_KEY_EX_CMD_SET].vals;
+ add_vals = &hdrs[TCA_PEDIT_KEY_EX_CMD_ADD].vals;
for (i = 0; i < ARRAY_SIZE(fields); i++) {
bool skip;
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (6 preceding siblings ...)
2023-11-13 23:00 ` [net-next 07/14] net/mlx5e: Access array with enum values instead of magic numbers Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-14 15:22 ` Vadim Fedorenko
2023-11-13 23:00 ` [net-next 09/14] net/mlx5: Refactor real time clock operation checks for PHC Saeed Mahameed
` (5 subsequent siblings)
13 siblings, 1 reply; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Rahul Rameshbabu
From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Track the number of times the a CQE was expected to not be delivered on PTP
Tx port timestamping CQ. A CQE is expected to not be delivered of a certain
amount of time passes since the corresponding CQE containing the DMA
timestamp information has arrived. Increment the late_cqe counter when such
a CQE does manage to be delivered to the CQ.
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../device_drivers/ethernet/mellanox/mlx5/counters.rst | 6 ++++++
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 1 +
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 1 +
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 1 +
4 files changed, 9 insertions(+)
diff --git a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst
index f69ee1ebee01..5464cd9e2694 100644
--- a/Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst
+++ b/Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst
@@ -702,6 +702,12 @@ the software port.
the device typically ensures not posting the CQE.
- Error
+ * - `ptp_cq[i]_lost_cqe`
+ - Number of times a CQE is expected to not be delivered on the PTP
+ timestamping CQE by the device due to a time delta elapsing. If such a
+ CQE is somehow delivered, `ptp_cq[i]_late_cqe` is incremented.
+ - Error
+
.. [#ring_global] The corresponding ring and global counters do not share the
same name (i.e. do not follow the common naming scheme).
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
index bb11e644d24f..a81f9c672b69 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
@@ -169,6 +169,7 @@ static void mlx5e_ptpsq_mark_ts_cqes_undelivered(struct mlx5e_ptpsq *ptpsq,
WARN_ON_ONCE(!pos->inuse);
pos->inuse = false;
list_del(&pos->entry);
+ ptpsq->cq_stats->lost_cqe++;
}
spin_unlock(&cqe_list->tracker_list_lock);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index 4b96ad657145..7e63d7c88894 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -2158,6 +2158,7 @@ static const struct counter_desc ptp_cq_stats_desc[] = {
{ MLX5E_DECLARE_PTP_CQ_STAT(struct mlx5e_ptp_cq_stats, abort) },
{ MLX5E_DECLARE_PTP_CQ_STAT(struct mlx5e_ptp_cq_stats, abort_abs_diff_ns) },
{ MLX5E_DECLARE_PTP_CQ_STAT(struct mlx5e_ptp_cq_stats, late_cqe) },
+ { MLX5E_DECLARE_PTP_CQ_STAT(struct mlx5e_ptp_cq_stats, lost_cqe) },
};
static const struct counter_desc ptp_rq_stats_desc[] = {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 477c547dcc04..2584f049ec53 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -461,6 +461,7 @@ struct mlx5e_ptp_cq_stats {
u64 abort;
u64 abort_abs_diff_ns;
u64 late_cqe;
+ u64 lost_cqe;
};
struct mlx5e_rep_stats {
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 09/14] net/mlx5: Refactor real time clock operation checks for PHC
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (7 preceding siblings ...)
2023-11-13 23:00 ` [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 10/14] net/mlx5: Initialize clock->ptp_info inside mlx5_init_timer_clock Saeed Mahameed
` (4 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Rahul Rameshbabu
From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Check if the MTUTC register of the NIC can be modified before attempting to
execute a real-time clock operation. Previous implementation aborted the
real-time clock operation pre-emptively when the MTUTC register used to
control the real-time clock was not modifiable, indicating real-time clock
mode was not enabled on the NIC. The original control flow was confusing
since the noop-if-RTC-disabled branch looked similar to an error handling
guard clause. The purpose of this patch is purely for improving readability
and should lead to no functional change.
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../ethernet/mellanox/mlx5/core/lib/clock.c | 41 +++++++++----------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index aa29f09e8356..c4f4d1c63463 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -266,9 +266,6 @@ static int mlx5_ptp_settime_real_time(struct mlx5_core_dev *mdev,
{
u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
- if (!mlx5_modify_mtutc_allowed(mdev))
- return 0;
-
if (ts->tv_sec < 0 || ts->tv_sec > U32_MAX ||
ts->tv_nsec < 0 || ts->tv_nsec > NSEC_PER_SEC)
return -EINVAL;
@@ -286,12 +283,15 @@ static int mlx5_ptp_settime(struct ptp_clock_info *ptp, const struct timespec64
struct mlx5_timer *timer = &clock->timer;
struct mlx5_core_dev *mdev;
unsigned long flags;
- int err;
mdev = container_of(clock, struct mlx5_core_dev, clock);
- err = mlx5_ptp_settime_real_time(mdev, ts);
- if (err)
- return err;
+
+ if (mlx5_modify_mtutc_allowed(mdev)) {
+ int err = mlx5_ptp_settime_real_time(mdev, ts);
+
+ if (err)
+ return err;
+ }
write_seqlock_irqsave(&clock->lock, flags);
timecounter_init(&timer->tc, &timer->cycles, timespec64_to_ns(ts));
@@ -341,9 +341,6 @@ static int mlx5_ptp_adjtime_real_time(struct mlx5_core_dev *mdev, s64 delta)
{
u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
- if (!mlx5_modify_mtutc_allowed(mdev))
- return 0;
-
/* HW time adjustment range is checked. If out of range, settime instead */
if (!mlx5_is_mtutc_time_adj_cap(mdev, delta)) {
struct timespec64 ts;
@@ -367,13 +364,16 @@ static int mlx5_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
struct mlx5_timer *timer = &clock->timer;
struct mlx5_core_dev *mdev;
unsigned long flags;
- int err;
mdev = container_of(clock, struct mlx5_core_dev, clock);
- err = mlx5_ptp_adjtime_real_time(mdev, delta);
- if (err)
- return err;
+ if (mlx5_modify_mtutc_allowed(mdev)) {
+ int err = mlx5_ptp_adjtime_real_time(mdev, delta);
+
+ if (err)
+ return err;
+ }
+
write_seqlock_irqsave(&clock->lock, flags);
timecounter_adjtime(&timer->tc, delta);
mlx5_update_clock_info_page(mdev);
@@ -391,9 +391,6 @@ static int mlx5_ptp_freq_adj_real_time(struct mlx5_core_dev *mdev, long scaled_p
{
u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
- if (!mlx5_modify_mtutc_allowed(mdev))
- return 0;
-
MLX5_SET(mtutc_reg, in, operation, MLX5_MTUTC_OPERATION_ADJUST_FREQ_UTC);
if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units)) {
@@ -415,13 +412,15 @@ static int mlx5_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
struct mlx5_core_dev *mdev;
unsigned long flags;
u32 mult;
- int err;
mdev = container_of(clock, struct mlx5_core_dev, clock);
- err = mlx5_ptp_freq_adj_real_time(mdev, scaled_ppm);
- if (err)
- return err;
+ if (mlx5_modify_mtutc_allowed(mdev)) {
+ int err = mlx5_ptp_freq_adj_real_time(mdev, scaled_ppm);
+
+ if (err)
+ return err;
+ }
mult = (u32)adjust_by_scaled_ppm(timer->nominal_c_mult, scaled_ppm);
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 10/14] net/mlx5: Initialize clock->ptp_info inside mlx5_init_timer_clock
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (8 preceding siblings ...)
2023-11-13 23:00 ` [net-next 09/14] net/mlx5: Refactor real time clock operation checks for PHC Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 11/14] net/mlx5: Convert scaled ppm values outside the s32 range for PHC frequency adjustments Saeed Mahameed
` (3 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Rahul Rameshbabu
From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Configure the PHC inside mlx5_init_timer_clock for calling mlx5_ptp_settime
later in the function. Would previously use mlx5_ptp_clock_info instance to
invoke mlx5_ptp_settime to set the NIC real-time clock to be synchronized
with the host system clock.
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index c4f4d1c63463..ca7691930f6b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -1002,10 +1002,12 @@ static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
{
struct mlx5_clock *clock = &mdev->clock;
+ /* Configure the PHC */
+ clock->ptp_info = mlx5_ptp_clock_info;
+
mlx5_timecounter_init(mdev);
mlx5_init_clock_info(mdev);
mlx5_init_overflow_period(clock);
- clock->ptp_info = mlx5_ptp_clock_info;
if (mlx5_real_time_mode(mdev)) {
struct timespec64 ts;
@@ -1036,11 +1038,10 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev)
}
seqlock_init(&clock->lock);
- mlx5_init_timer_clock(mdev);
INIT_WORK(&clock->pps_info.out_work, mlx5_pps_out);
- /* Configure the PHC */
- clock->ptp_info = mlx5_ptp_clock_info;
+ /* Initialize the device clock */
+ mlx5_init_timer_clock(mdev);
/* Initialize 1PPS data structures */
mlx5_init_pps(mdev);
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 11/14] net/mlx5: Convert scaled ppm values outside the s32 range for PHC frequency adjustments
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (9 preceding siblings ...)
2023-11-13 23:00 ` [net-next 10/14] net/mlx5: Initialize clock->ptp_info inside mlx5_init_timer_clock Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 12/14] net/mlx5: Query maximum frequency adjustment of the PTP hardware clock Saeed Mahameed
` (2 subsequent siblings)
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Rahul Rameshbabu
From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Represent scaled ppm as ppb to the device when the value in scaled ppm is
not representable as a 32-bit signed integer. mlx5 devices only support a
32-bit field for the frequency adjustment value in units of either scaled
ppm or ppb.
Since mlx5 devices only support a 32-bit field for the frequency adjustment
value independent of unit used, limit the maximum frequency adjustment to
S32_MAX ppb.
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index ca7691930f6b..1daa4b019513 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -393,10 +393,12 @@ static int mlx5_ptp_freq_adj_real_time(struct mlx5_core_dev *mdev, long scaled_p
MLX5_SET(mtutc_reg, in, operation, MLX5_MTUTC_OPERATION_ADJUST_FREQ_UTC);
- if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units)) {
+ if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units) &&
+ scaled_ppm <= S32_MAX && scaled_ppm >= S32_MIN) {
+ /* HW scaled_ppm support on mlx5 devices only supports a 32-bit value */
MLX5_SET(mtutc_reg, in, freq_adj_units,
MLX5_MTUTC_FREQ_ADJ_UNITS_SCALED_PPM);
- MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm);
+ MLX5_SET(mtutc_reg, in, freq_adjustment, (s32)scaled_ppm);
} else {
MLX5_SET(mtutc_reg, in, freq_adj_units, MLX5_MTUTC_FREQ_ADJ_UNITS_PPB);
MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm_to_ppb(scaled_ppm));
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 12/14] net/mlx5: Query maximum frequency adjustment of the PTP hardware clock
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (10 preceding siblings ...)
2023-11-13 23:00 ` [net-next 11/14] net/mlx5: Convert scaled ppm values outside the s32 range for PHC frequency adjustments Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 13/14] net/mlx5e: Add local loopback counter to vport rep stats Saeed Mahameed
2023-11-13 23:00 ` [net-next 14/14] net/mlx5e: Remove early assignment to netdev->features Saeed Mahameed
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Rahul Rameshbabu
From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Some mlx5 devices do not support the default advertised maximum frequency
adjustment value for the PTP hardware clock that is set by the driver.
These devices need to be queried when initializing the clock functionality
in order to get the maximum supported frequency adjustment value. This
value can be greater than the minimum supported frequency adjustment across
mlx5 devices (50 million ppb).
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../ethernet/mellanox/mlx5/core/lib/clock.c | 22 +++++++++++++++++++
include/linux/mlx5/mlx5_ifc.h | 5 ++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index 1daa4b019513..cac60a841e1d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -1000,6 +1000,25 @@ static void mlx5_init_clock_info(struct mlx5_core_dev *mdev)
info->frac = timer->tc.frac;
}
+static void mlx5_init_timer_max_freq_adjustment(struct mlx5_core_dev *mdev)
+{
+ struct mlx5_clock *clock = &mdev->clock;
+ u32 out[MLX5_ST_SZ_DW(mtutc_reg)] = {};
+ u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
+ u8 log_max_freq_adjustment = 0;
+ int err;
+
+ err = mlx5_core_access_reg(mdev, in, sizeof(in), out, sizeof(out),
+ MLX5_REG_MTUTC, 0, 0);
+ if (!err)
+ log_max_freq_adjustment =
+ MLX5_GET(mtutc_reg, out, log_max_freq_adjustment);
+
+ if (log_max_freq_adjustment)
+ clock->ptp_info.max_adj =
+ min(S32_MAX, 1 << log_max_freq_adjustment);
+}
+
static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
{
struct mlx5_clock *clock = &mdev->clock;
@@ -1007,6 +1026,9 @@ static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
/* Configure the PHC */
clock->ptp_info = mlx5_ptp_clock_info;
+ if (MLX5_CAP_MCAM_REG(mdev, mtutc))
+ mlx5_init_timer_max_freq_adjustment(mdev);
+
mlx5_timecounter_init(mdev);
mlx5_init_clock_info(mdev);
mlx5_init_overflow_period(clock);
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 6f3631425f38..ce2e71cd6d2a 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -10103,7 +10103,10 @@ enum {
struct mlx5_ifc_mtutc_reg_bits {
u8 reserved_at_0[0x5];
u8 freq_adj_units[0x3];
- u8 reserved_at_8[0x14];
+ u8 reserved_at_8[0x3];
+ u8 log_max_freq_adjustment[0x5];
+
+ u8 reserved_at_10[0xc];
u8 operation[0x4];
u8 freq_adjustment[0x20];
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 13/14] net/mlx5e: Add local loopback counter to vport rep stats
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (11 preceding siblings ...)
2023-11-13 23:00 ` [net-next 12/14] net/mlx5: Query maximum frequency adjustment of the PTP hardware clock Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
2023-11-13 23:00 ` [net-next 14/14] net/mlx5e: Remove early assignment to netdev->features Saeed Mahameed
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Or Har-Toov,
Patrisious Haddad
From: Or Har-Toov <ohartoov@nvidia.com>
Add counter for number of unicast, multicast and broadcast packets/
octets that were loopback.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_rep.c | 26 ++++++++++++++++++-
.../ethernet/mellanox/mlx5/core/en_stats.h | 2 ++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 693e55b010d9..2fd96471554b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -108,8 +108,18 @@ static const struct counter_desc vport_rep_stats_desc[] = {
tx_vport_rdma_multicast_bytes) },
};
+static const struct counter_desc vport_rep_loopback_stats_desc[] = {
+ { MLX5E_DECLARE_STAT(struct mlx5e_rep_stats,
+ vport_loopback_packets) },
+ { MLX5E_DECLARE_STAT(struct mlx5e_rep_stats,
+ vport_loopback_bytes) },
+};
+
#define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
#define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc)
+#define NUM_VPORT_REP_LOOPBACK_COUNTERS(dev) \
+ (MLX5_CAP_GEN(dev, vport_counter_local_loopback) ? \
+ ARRAY_SIZE(vport_rep_loopback_stats_desc) : 0)
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(sw_rep)
{
@@ -153,7 +163,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw_rep)
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(vport_rep)
{
- return NUM_VPORT_REP_HW_COUNTERS;
+ return NUM_VPORT_REP_HW_COUNTERS +
+ NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev);
}
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
@@ -162,6 +173,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_rep_stats_desc[i].format);
+ for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++)
+ strcpy(data + (idx++) * ETH_GSTRING_LEN,
+ vport_rep_loopback_stats_desc[i].format);
return idx;
}
@@ -172,6 +186,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport_rep)
for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.rep_stats,
vport_rep_stats_desc, i);
+ for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++)
+ data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.rep_stats,
+ vport_rep_loopback_stats_desc, i);
return idx;
}
@@ -243,6 +260,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep)
rep_stats->tx_vport_rdma_multicast_bytes =
MLX5_GET_CTR(out, received_ib_multicast.octets);
+ if (MLX5_CAP_GEN(priv->mdev, vport_counter_local_loopback)) {
+ rep_stats->vport_loopback_packets =
+ MLX5_GET_CTR(out, local_loopback.packets);
+ rep_stats->vport_loopback_bytes =
+ MLX5_GET_CTR(out, local_loopback.octets);
+ }
+
out:
kvfree(out);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 2584f049ec53..03f6265d3ed5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -477,6 +477,8 @@ struct mlx5e_rep_stats {
u64 tx_vport_rdma_multicast_packets;
u64 rx_vport_rdma_multicast_bytes;
u64 tx_vport_rdma_multicast_bytes;
+ u64 vport_loopback_packets;
+ u64 vport_loopback_bytes;
};
struct mlx5e_stats {
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [net-next 14/14] net/mlx5e: Remove early assignment to netdev->features
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
` (12 preceding siblings ...)
2023-11-13 23:00 ` [net-next 13/14] net/mlx5e: Add local loopback counter to vport rep stats Saeed Mahameed
@ 2023-11-13 23:00 ` Saeed Mahameed
13 siblings, 0 replies; 18+ messages in thread
From: Saeed Mahameed @ 2023-11-13 23:00 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Gal Pressman
From: Tariq Toukan <tariqt@nvidia.com>
The netdev->features is initialized to netdev->hw_features at a later
point in the flow. Remove any redundant earlier assignment.
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index ea58c6917433..3aecdf099a2f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5244,7 +5244,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->gso_partial_features |= NETIF_F_GSO_UDP_L4;
netdev->hw_features |= NETIF_F_GSO_UDP_L4;
- netdev->features |= NETIF_F_GSO_UDP_L4;
mlx5_query_port_fcs(mdev, &fcs_supported, &fcs_enabled);
--
2.41.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ
2023-11-13 23:00 ` [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ Saeed Mahameed
@ 2023-11-14 15:22 ` Vadim Fedorenko
2023-11-16 19:51 ` Rahul Rameshbabu
0 siblings, 1 reply; 18+ messages in thread
From: Vadim Fedorenko @ 2023-11-14 15:22 UTC (permalink / raw)
To: Saeed Mahameed, David S. Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: Saeed Mahameed, netdev, Tariq Toukan, Rahul Rameshbabu
On 13/11/2023 15:00, Saeed Mahameed wrote:
> From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
>
> Track the number of times the a CQE was expected to not be delivered on PTP
> Tx port timestamping CQ. A CQE is expected to not be delivered of a certain
> amount of time passes since the corresponding CQE containing the DMA
> timestamp information has arrived. Increment the late_cqe counter when such
> a CQE does manage to be delivered to the CQ.
>
It looks like missed/late timestamps is common problem for NICs. What do
you think about creating common counters in ethtool to have general
interface to provide timestamps counters? It may simplify things a lot.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ
2023-11-14 15:22 ` Vadim Fedorenko
@ 2023-11-16 19:51 ` Rahul Rameshbabu
2023-11-18 19:00 ` Vadim Fedorenko
0 siblings, 1 reply; 18+ messages in thread
From: Rahul Rameshbabu @ 2023-11-16 19:51 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Saeed Mahameed, David S. Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet, Saeed Mahameed, netdev, Tariq Toukan, Gal Pressman
On Tue, 14 Nov, 2023 10:22:43 -0500 Vadim Fedorenko <vadim.fedorenko@linux.dev> wrote:
> On 13/11/2023 15:00, Saeed Mahameed wrote:
>> From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
>> Track the number of times the a CQE was expected to not be delivered on PTP
>> Tx port timestamping CQ. A CQE is expected to not be delivered of a certain
>> amount of time passes since the corresponding CQE containing the DMA
>> timestamp information has arrived. Increment the late_cqe counter when such
>> a CQE does manage to be delivered to the CQ.
>>
>
> It looks like missed/late timestamps is common problem for NICs. What do
> you think about creating common counters in ethtool to have general
> interface to provide timestamps counters? It may simplify things a lot.
Hi Vadim,
I just took a look at the tree and believe devices supported by the
following drivers have missed/late timestamps.
- mlx5
- i40e
- ice
- stmicro
The above is from a very precursory grep through the netdev tree and
maybe inaccurate/incomplete.
You probably saw that Saeed already pulled out our vendor specific stat
counters from his v2 submission. Lets discuss the more appropriate
common counters in ethtool.
Similar to fec-stat in Documentation/netlink/specs/ethtool.yaml, should
we make a new statistics group for these timestamp related counters
(timestamp-stat) as follows?
1. Implement an ethtool_timestamp_stats struct in ethtool.h
2. Add the relevant callback support in ethtool
3. Add the correct spec changes in the ynl spec.
4. Implement the callback in the appropriate drivers
5. Separately prepare relevant userspace changes for ethtool.
If this seems reasonable, I can start preparing an RFC to send out to
the mailing list.
--
Thanks,
Rahul Rameshbabu
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ
2023-11-16 19:51 ` Rahul Rameshbabu
@ 2023-11-18 19:00 ` Vadim Fedorenko
0 siblings, 0 replies; 18+ messages in thread
From: Vadim Fedorenko @ 2023-11-18 19:00 UTC (permalink / raw)
To: Rahul Rameshbabu
Cc: Saeed Mahameed, David S. Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet, Saeed Mahameed, netdev, Tariq Toukan, Gal Pressman
On 16/11/2023 14:51, Rahul Rameshbabu wrote:
> On Tue, 14 Nov, 2023 10:22:43 -0500 Vadim Fedorenko <vadim.fedorenko@linux.dev> wrote:
>> On 13/11/2023 15:00, Saeed Mahameed wrote:
>>> From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
>>> Track the number of times the a CQE was expected to not be delivered on PTP
>>> Tx port timestamping CQ. A CQE is expected to not be delivered of a certain
>>> amount of time passes since the corresponding CQE containing the DMA
>>> timestamp information has arrived. Increment the late_cqe counter when such
>>> a CQE does manage to be delivered to the CQ.
>>>
>>
>> It looks like missed/late timestamps is common problem for NICs. What do
>> you think about creating common counters in ethtool to have general
>> interface to provide timestamps counters? It may simplify things a lot.
>
> Hi Vadim,
>
> I just took a look at the tree and believe devices supported by the
> following drivers have missed/late timestamps.
>
> - mlx5
> - i40e
> - ice
> - stmicro
>
> The above is from a very precursory grep through the netdev tree and
> maybe inaccurate/incomplete.
>
> You probably saw that Saeed already pulled out our vendor specific stat
> counters from his v2 submission. Lets discuss the more appropriate
> common counters in ethtool.
>
> Similar to fec-stat in Documentation/netlink/specs/ethtool.yaml, should
> we make a new statistics group for these timestamp related counters
> (timestamp-stat) as follows?
>
> 1. Implement an ethtool_timestamp_stats struct in ethtool.h
> 2. Add the relevant callback support in ethtool
> 3. Add the correct spec changes in the ynl spec.
> 4. Implement the callback in the appropriate drivers
> 5. Separately prepare relevant userspace changes for ethtool.
>
> If this seems reasonable, I can start preparing an RFC to send out to
> the mailing list.
Hi Rahul!
Thanks for taking care of this. The list of drivers seems reasonable at
the first look. But I believe more vendors will jump into it once the
spec is ready.
The new group in the ethtool yml spec seams reasonable. The steps
provided look good, I'll be happy to review your RFC patches.
Thanks,
Vadim
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2023-11-18 19:00 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-13 23:00 [pull request][net-next 00/14] mlx5 updates 2023-11-13 Saeed Mahameed
2023-11-13 23:00 ` [net-next 01/14] net/mlx5: print change on SW reset semaphore returns busy Saeed Mahameed
2023-11-13 23:00 ` [net-next 02/14] net/mlx5: Allow sync reset flow when BF MGT interface device is present Saeed Mahameed
2023-11-13 23:00 ` [net-next 03/14] net/mlx5e: Some cleanup in mlx5e_tc_stats_matchall() Saeed Mahameed
2023-11-13 23:00 ` [net-next 04/14] net/mlx5: Annotate struct mlx5_fc_bulk with __counted_by Saeed Mahameed
2023-11-13 23:00 ` [net-next 05/14] net/mlx5: Annotate struct mlx5_flow_handle " Saeed Mahameed
2023-11-13 23:00 ` [net-next 06/14] net/mlx5: simplify mlx5_set_driver_version string assignments Saeed Mahameed
2023-11-13 23:00 ` [net-next 07/14] net/mlx5e: Access array with enum values instead of magic numbers Saeed Mahameed
2023-11-13 23:00 ` [net-next 08/14] net/mlx5e: Introduce lost_cqe statistic counter for PTP Tx port timestamping CQ Saeed Mahameed
2023-11-14 15:22 ` Vadim Fedorenko
2023-11-16 19:51 ` Rahul Rameshbabu
2023-11-18 19:00 ` Vadim Fedorenko
2023-11-13 23:00 ` [net-next 09/14] net/mlx5: Refactor real time clock operation checks for PHC Saeed Mahameed
2023-11-13 23:00 ` [net-next 10/14] net/mlx5: Initialize clock->ptp_info inside mlx5_init_timer_clock Saeed Mahameed
2023-11-13 23:00 ` [net-next 11/14] net/mlx5: Convert scaled ppm values outside the s32 range for PHC frequency adjustments Saeed Mahameed
2023-11-13 23:00 ` [net-next 12/14] net/mlx5: Query maximum frequency adjustment of the PTP hardware clock Saeed Mahameed
2023-11-13 23:00 ` [net-next 13/14] net/mlx5e: Add local loopback counter to vport rep stats Saeed Mahameed
2023-11-13 23:00 ` [net-next 14/14] net/mlx5e: Remove early assignment to netdev->features Saeed Mahameed
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).