mlx5 updates 2021-04-16
Subsystems (6)
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub,
This series provides some updates to mlx5e 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 392c36e5be1dee19ffce8c8ba8f07f90f5aa3f7c:
Merge branch 'ehtool-fec-stats' (2021-04-15 17:08:30 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2021-04-16
for you to fetch changes up to 95742c1cc59d0a6aa2ca9e75bd21f2a8721f5129:
net/mlx5: Enhance diagnostics info for TX/RX reporters (2021-04-16 11:48:34 -0700)
----------------------------------------------------------------
mlx5-updates-2021-04-16
This patchset introduces updates to mlx5e netdev driver.
1) Tariq refactors TLS offloads and adds resiliency against RX resync failures
2) Maxim reduces code duplications by unifying channels reset flow regardless if channels are closed or open
3) Aya Enhances TX/RX health reporters diagnostics to expose the internal clock time-stamping format
4) Moshe adds support for ethtool extended link state, to show the reason for link down
----------------------------------------------------------------
Aya Levin (2):
net/mlx5: Add helper to initialize 1PPS net/mlx5: Enhance diagnostics info for TX/RX reporters
Maor Dickman (1):
net/mlx5: Allocate FC bulk structs with kvzalloc() instead of kzalloc()
Maxim Mikityanskiy (4):
net/mlx5e: Allow mlx5e_safe_switch_channels to work with channels closed net/mlx5e: Use mlx5e_safe_switch_channels when channels are closed net/mlx5e: Refactor on-the-fly configuration changes net/mlx5e: Cleanup safe switch channels API by passing params
Moshe Tal (2):
net/mlx5: Add register layout to support extended link state net/mlx5e: Add ethtool extended link state
Tariq Toukan (5):
net/mlx5e: Remove non-essential TLS SQ state bit net/mlx5e: Cleanup unused function parameter net/mlx5e: TX, Inline TLS skb check
net/mlx5e: TX, Inline function mlx5e_tls_handle_tx_wqe() net/mlx5e: kTLS, Add resiliency to RX resync failures
drivers/net/ethernet/mellanox/mlx5/core/en.h | 13 +- .../net/ethernet/mellanox/mlx5/core/en/params.c | 3 + .../net/ethernet/mellanox/mlx5/core/en/params.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 3 + .../ethernet/mellanox/mlx5/core/en/reporter_rx.c | 6 + .../ethernet/mellanox/mlx5/core/en/reporter_tx.c | 6 + .../mellanox/mlx5/core/en_accel/en_accel.h | 7 +- .../ethernet/mellanox/mlx5/core/en_accel/ktls.h | 11 + .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 129 ++++++-- .../mellanox/mlx5/core/en_accel/ktls_txrx.h | 20 ++ .../mellanox/mlx5/core/en_accel/tls_rxtx.c | 9 - .../mellanox/mlx5/core/en_accel/tls_rxtx.h | 14 +- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 34 +-- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 338 ++++++++++++++------- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 250 +++++++-------- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 3 + drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 2 + drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 5 + .../net/ethernet/mellanox/mlx5/core/fs_counters.c | 16 +- .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 19 +- .../net/ethernet/mellanox/mlx5/core/lib/clock.c | 25 +- include/linux/mlx5/driver.h | 1 + include/linux/mlx5/mlx5_ifc.h | 50 +++ 23 files changed, 621 insertions(+), 344 deletions(-)
PATCH 1/14 net/mlx5e: Remove non-essential TLS SQ state bit
From: Tariq Toukan <[email protected]>
Maintaining an SQ state bit to indicate TLS support has no real need, a simple and fast test [1] for the SKB is almost equally good.
[1] !skb->sk || !tls_is_sk_tx_device_offloaded(skb->sk)
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 - .../net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h | 8 +++----- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 -- 3 files changed, 3 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +0 -1
@@ -325,7 +325,6 @@ enum {MLX5E_SQ_STATE_RECOVERING ,MLX5E_SQ_STATE_IPSEC ,MLX5E_SQ_STATE_AM , -MLX5E_SQ_STATE_TLS ,MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE , MLX5E_SQ_STATE_PENDING_XSK_TX, };
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +3 -5
@@ -123,11 +123,9 @@ static inline bool mlx5e_accel_tx_begin(struct net_device *dev,mlx5e_udp_gso_handle_tx_skb (skb);#ifdef CONFIG_MLX5_EN_TLS -if (test_bit (MLX5E_SQ_STATE_TLS , &sq->state)) { -/* May send SKBs and WQEs. */ -if (unlikely (!mlx5e_tls_handle_tx_skb (dev, sq, skb, &state->tls))) -return false; - } +/* May send SKBs and WQEs. */ +if (unlikely (!mlx5e_tls_handle_tx_skb (dev, sq, skb, &state->tls))) +return false;#endif #ifdef CONFIG_MLX5_EN_IPSEC
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0 -2
@@ -1134,8 +1134,6 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,set_bit (MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE , &sq->state);if (MLX5_IPSEC_DEV (c->priv->mdev))set_bit (MLX5E_SQ_STATE_IPSEC , &sq->state); -if (mlx5_accel_is_tls_device (c->priv->mdev)) -set_bit (MLX5E_SQ_STATE_TLS , &sq->state);if (param->is_mpw)set_bit (MLX5E_SQ_STATE_MPWQE , &sq->state); sq->stop_room = param->stop_room;
Signature · 1 line
2.30.2
Re: [net-next 01/14] net/mlx5e: Remove non-essential TLS SQ state bit
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Fri, 16 Apr 2021 11:54:17 -0700 you wrote:
From: Tariq Toukan <[email protected]>
Maintaining an SQ state bit to indicate TLS support has no real need, a simple and fast test [1] for the SKB is almost equally good.
[1] !skb->sk || !tls_is_sk_tx_device_offloaded(skb->sk)
[...]
Here is the summary with links:
- [net-next,01/14] net/mlx5e: Remove non-essential TLS SQ state bit
https://git.kernel.org/netdev/net-next/c/2f014f4016db - [net-next,02/14] net/mlx5e: Cleanup unused function parameter https://git.kernel.org/netdev/net-next/c/8668587a33b9 - [net-next,03/14] net/mlx5e: TX, Inline TLS skb check https://git.kernel.org/netdev/net-next/c/b6b3ad2175c8 - [net-next,04/14] net/mlx5e: TX, Inline function mlx5e_tls_handle_tx_wqe() https://git.kernel.org/netdev/net-next/c/72f6f2f8d6aa - [net-next,05/14] net/mlx5e: kTLS, Add resiliency to RX resync failures https://git.kernel.org/netdev/net-next/c/e9ce991bce5b - [net-next,06/14] net/mlx5e: Allow mlx5e_safe_switch_channels to work with channels closed https://git.kernel.org/netdev/net-next/c/6cad120d9e62 - [net-next,07/14] net/mlx5e: Use mlx5e_safe_switch_channels when channels are closed https://git.kernel.org/netdev/net-next/c/69cc4185dcba - [net-next,08/14] net/mlx5e: Refactor on-the-fly configuration changes https://git.kernel.org/netdev/net-next/c/b3b886cf965d - [net-next,09/14] net/mlx5e: Cleanup safe switch channels API by passing params https://git.kernel.org/netdev/net-next/c/94872d4ef9c0 - [net-next,10/14] net/mlx5: Allocate FC bulk structs with kvzalloc() instead of kzalloc() https://git.kernel.org/netdev/net-next/c/5cec6de0ae09 - [net-next,11/14] net/mlx5: Add register layout to support extended link state https://git.kernel.org/netdev/net-next/c/36830159acbe - [net-next,12/14] net/mlx5e: Add ethtool extended link state https://git.kernel.org/netdev/net-next/c/b3446acb2b9a - [net-next,13/14] net/mlx5: Add helper to initialize 1PPS https://git.kernel.org/netdev/net-next/c/302522e67c70 - [net-next,14/14] net/mlx5: Enhance diagnostics info for TX/RX reporters https://git.kernel.org/netdev/net-next/c/95742c1cc59d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
PATCH 2/14 net/mlx5e: Cleanup unused function parameter
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Socket parameter is not used in accel_rule_init(), remove it.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +2 -3
@@ -119,8 +119,7 @@ static void accel_rule_handle_work(struct work_struct *work)complete (&priv_rx->add_ctx); } -static void accel_rule_init (struct accel_rule *rule,struct mlx5e_priv *priv, -struct sock *sk) +static void accel_rule_init (struct accel_rule *rule,struct mlx5e_priv *priv) {INIT_WORK (&rule->work, accel_rule_handle_work); rule->priv = priv;
@@ -618,7 +617,7 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk,init_completion (&priv_rx->add_ctx); -accel_rule_init (&priv_rx->rule, priv, sk); +accel_rule_init (&priv_rx->rule, priv); resync = &priv_rx->resync;resync_init (resync, priv);tls_offload_ctx_rx (tls_ctx)->resync_async = &resync->core;
Signature · 1 line
2.30.2
PATCH 3/14 net/mlx5e: TX, Inline TLS skb check
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
When TLS is supported and enabled, every transmitted packet is tested to identify if TLS offload is required.
Take the early-return condition into an inline function, to save the overhead of a function call for non-TLS packets.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h | 5 +++-- drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c | 3 --- drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.h | 6 ++++++ 3 files changed, 9 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +3 -2
@@ -124,8 +124,9 @@ static inline bool mlx5e_accel_tx_begin(struct net_device *dev,#ifdef CONFIG_MLX5_EN_TLS /* May send SKBs and WQEs. */ -if (unlikely (!mlx5e_tls_handle_tx_skb (dev, sq, skb, &state->tls))) -return false; +if (mlx5e_tls_skb_offloaded (skb)) +if (unlikely (!mlx5e_tls_handle_tx_skb (dev, sq, skb, &state->tls))) +return false;#endif #ifdef CONFIG_MLX5_EN_IPSEC
drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c +0 -3
@@ -263,9 +263,6 @@ bool mlx5e_tls_handle_tx_skb(struct net_device *netdev, struct mlx5e_txqsq *sq,int datalen;u32 skb_seq; -if (!skb->sk || !tls_is_sk_tx_device_offloaded (skb->sk)) -return true; - datalen = skb->len - (skb_transport_offset (skb) +tcp_hdrlen (skb));if (!datalen)return true;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.h +6 -0
@@ -47,6 +47,12 @@ u16 mlx5e_tls_get_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *parbool mlx5e_tls_handle_tx_skb (struct net_device *netdev,struct mlx5e_txqsq *sq,struct sk_buff *skb,struct mlx5e_accel_tx_tls_state *state); + +static inline bool mlx5e_tls_skb_offloaded (struct sk_buff *skb) +{ +return skb->sk &&tls_is_sk_tx_device_offloaded (skb->sk); +} +void mlx5e_tls_handle_tx_wqe (struct mlx5e_txqsq *sq,struct mlx5_wqe_ctrl_seg *cseg,struct mlx5e_accel_tx_tls_state *state);
Signature · 1 line
2.30.2
PATCH 4/14 net/mlx5e: TX, Inline function mlx5e_tls_handle_tx_wqe()
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
When TLS is supported, WQE ctrl segment of every transmitted packet is updated with the (possibly empty, for non-TLS packets) TISN field.
Take this one-liner function into the header file and inline it, to save the overhead of a function call per packet.
While here, remove unused function parameter.
--- .../net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h | 2 +- .../net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c | 6 ------ .../net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.h | 8 ++++++-- 3 files changed, 7 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +1 -1
@@ -185,7 +185,7 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq, struct mlx5_wqe_inline_seg *inlseg) {#ifdef CONFIG_MLX5_EN_TLS -mlx5e_tls_handle_tx_wqe (sq, &wqe->ctrl, &state->tls); +mlx5e_tls_handle_tx_wqe (&wqe->ctrl, &state->tls);#endif #ifdef CONFIG_MLX5_EN_IPSEC
drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c +0 -6
@@ -298,12 +298,6 @@ bool mlx5e_tls_handle_tx_skb(struct net_device *netdev, struct mlx5e_txqsq *sq,return false; } -void mlx5e_tls_handle_tx_wqe (struct mlx5e_txqsq *sq,struct mlx5_wqe_ctrl_seg *cseg, -struct mlx5e_accel_tx_tls_state *state) -{ - cseg->tis_tir_num =cpu_to_be32 (state->tls_tisn <<8 ); -} -static int tls_update_resync_sn (struct net_device *netdev,struct sk_buff *skb,struct mlx5e_tls_metadata *mdata)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.h +6 -2
@@ -53,8 +53,12 @@ static inline bool mlx5e_tls_skb_offloaded(struct sk_buff *skb)return skb->sk &&tls_is_sk_tx_device_offloaded (skb->sk); } -void mlx5e_tls_handle_tx_wqe (struct mlx5e_txqsq *sq,struct mlx5_wqe_ctrl_seg *cseg, -struct mlx5e_accel_tx_tls_state *state); +static inline void +mlx5e_tls_handle_tx_wqe (struct mlx5_wqe_ctrl_seg *cseg, +struct mlx5e_accel_tx_tls_state *state) +{ + cseg->tis_tir_num =cpu_to_be32 (state->tls_tisn <<8 ); +}void mlx5e_tls_handle_rx_skb_metadata (struct mlx5e_rq *rq,struct sk_buff *skb,u32 *cqe_bcnt);
Signature · 1 line
2.30.2
PATCH 5/14 net/mlx5e: kTLS, Add resiliency to RX resync failures
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
When the TLS logic finds a tcp seq match for a kTLS RX resync request, it calls the driver callback function mlx5e_ktls_resync() to handle it and communicate it to the device.
Errors might occur during mlx5e_ktls_resync(), however, they are not reported to the stack. Moreover, there is no error handling in the stack for these errors.
In this patch, the driver obtains responsibility on errors handling, adding queue and retry mechanisms to these resyncs.
We maintain a linked list of resync matches, and try posting them to the async ICOSQ in the NAPI context.
Only possible failure that demands driver handling is ICOSQ being full. By relying on the NAPI mechanism, we make sure that the entries in list will be handled when ICOSQ completions arrive and make some room available.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 + .../ethernet/mellanox/mlx5/core/en/params.c | 3 + .../ethernet/mellanox/mlx5/core/en/params.h | 1 + .../mellanox/mlx5/core/en_accel/ktls.h | 11 ++ .../mellanox/mlx5/core/en_accel/ktls_rx.c | 124 +++++++++++++++--- .../mellanox/mlx5/core/en_accel/ktls_txrx.h | 20 +++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 11 ++ .../ethernet/mellanox/mlx5/core/en_stats.c | 3 + .../ethernet/mellanox/mlx5/core/en_stats.h | 2 + .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 5 + 10 files changed, 166 insertions(+), 18 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +4 -0
@@ -327,6 +327,7 @@ enum {MLX5E_SQ_STATE_AM ,MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE ,MLX5E_SQ_STATE_PENDING_XSK_TX , + MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC, }; struct mlx5e_tx_mpwqe {
@@ -499,6 +500,8 @@ struct mlx5e_xdpsq {struct mlx5e_channel *channel; }____cacheline_aligned_in_smp ; +struct mlx5e_ktls_resync_resp ; +struct mlx5e_icosq {/* data path */ u16 cc;
@@ -518,6 +521,7 @@ struct mlx5e_icosq {u32 sqn;u16 reserved_room;unsigned long state; +struct mlx5e_ktls_resync_resp *ktls_resync;/* control path */ struct mlx5_wq_ctrl wq_ctrl;
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +3 -0
@@ -621,6 +621,9 @@ static void mlx5e_build_async_icosq_param(struct mlx5_core_dev *mdev,mlx5e_build_sq_param_common (mdev, param); param->stop_room =mlx5e_stop_room_for_wqe (1 );/* for XSK NOP */ + param->is_tls =mlx5_accel_is_ktls_rx (mdev); +if (param->is_tls) + param->stop_room +=mlx5e_stop_room_for_wqe (1 );/* for TLS RX resync NOP */ MLX5_SET (sqc, sqc, reg_umr,MLX5_CAP_ETH (mdev, reg_umr_sq));MLX5_SET (wq, wq, log_wq_sz, log_wq_size);mlx5e_build_ico_cq_param (mdev, log_wq_size, ¶m->cqp);
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +1 -0
@@ -30,6 +30,7 @@ struct mlx5e_sq_param {u32 sqc[MLX5_ST_SZ_DW (sqc)];struct mlx5_wq_param wq;bool is_mpw; +bool is_tls;u16 stop_room; };
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h +11 -0
@@ -12,6 +12,9 @@ void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv);int mlx5e_ktls_init_rx (struct mlx5e_priv *priv);void mlx5e_ktls_cleanup_rx (struct mlx5e_priv *priv);int mlx5e_ktls_set_feature_rx (struct net_device *netdev,bool enable); +struct mlx5e_ktls_resync_resp * +mlx5e_ktls_rx_resync_create_resp_list (void ); +void mlx5e_ktls_rx_resync_destroy_resp_list (struct mlx5e_ktls_resync_resp *resp_list);#else static inline void mlx5e_ktls_build_netdev (struct mlx5e_priv *priv)
@@ -33,6 +36,14 @@ static inline int mlx5e_ktls_set_feature_rx(struct net_device *netdev, bool enabreturn -EOPNOTSUPP ; } +static inline struct mlx5e_ktls_resync_resp * +mlx5e_ktls_rx_resync_create_resp_list (void ) +{ +return ERR_PTR (-EOPNOTSUPP ); +} + +static inline void +mlx5e_ktls_rx_resync_destroy_resp_list (struct mlx5e_ktls_resync_resp *resp_list) {}#endif #endif /* __MLX5E_TLS_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +106 -18
154 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h +20 -0
@@ -40,6 +40,14 @@ mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq, }return false; } + +bool mlx5e_ktls_rx_handle_resync_list (struct mlx5e_channel *c,int budget); + +static inline bool +mlx5e_ktls_rx_pending_resync_list (struct mlx5e_channel *c,int budget) +{ +return budget &&test_bit (MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC , &c->async_icosq.state); +}#else static inline bool mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
@@ -49,6 +57,18 @@ mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,return false; } +static inline bool +mlx5e_ktls_rx_handle_resync_list (struct mlx5e_channel *c,int budget) +{ +return false; +} + +static inline bool +mlx5e_ktls_rx_pending_resync_list (struct mlx5e_channel *c,int budget) +{ +return false; +} +#endif /* CONFIG_MLX5_EN_TLS */ #endif /* __MLX5E_TLS_TXRX_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +11 -0
@@ -1409,8 +1409,17 @@ int mlx5e_open_icosq(struct mlx5e_channel *c, struct mlx5e_params *params,if (err) goto err_free_icosq; +if (param->is_tls) { + sq->ktls_resync =mlx5e_ktls_rx_resync_create_resp_list (); +if (IS_ERR (sq->ktls_resync)) { + err =PTR_ERR (sq->ktls_resync); + goto err_destroy_icosq; + } + }return 0 ; +err_destroy_icosq: +mlx5e_destroy_sq (c->mdev, sq->sqn); err_free_icosq:mlx5e_free_icosq (sq);
@@ -1432,6 +1441,8 @@ void mlx5e_close_icosq(struct mlx5e_icosq *sq) {struct mlx5e_channel *c = sq->channel; +if (sq->ktls_resync) +mlx5e_ktls_rx_resync_destroy_resp_list (sq->ktls_resync);mlx5e_destroy_sq (c->mdev, sq->sqn);mlx5e_free_icosq_descs (sq);mlx5e_free_icosq (sq);
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +3 -0
@@ -184,6 +184,7 @@ static const struct counter_desc sw_stats_desc[] = { { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_resync_req_end) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_resync_req_skip) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_resync_res_ok) }, + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_resync_res_retry) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_resync_res_skip) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_tls_err) }, #endif
@@ -344,6 +345,7 @@ static void mlx5e_stats_grp_sw_update_stats_rq_stats(struct mlx5e_sw_stats *s, s->rx_tls_resync_req_end += rq_stats->tls_resync_req_end; s->rx_tls_resync_req_skip += rq_stats->tls_resync_req_skip; s->rx_tls_resync_res_ok += rq_stats->tls_resync_res_ok; + s->rx_tls_resync_res_retry += rq_stats->tls_resync_res_retry; s->rx_tls_resync_res_skip += rq_stats->tls_resync_res_skip; s->rx_tls_err += rq_stats->tls_err;#endif
@@ -1654,6 +1656,7 @@ static const struct counter_desc rq_stats_desc[] = { { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_resync_req_end) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_resync_req_skip) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_resync_res_ok) }, + { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_resync_res_retry) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_resync_res_skip) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, tls_err) }, #endif
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +2 -0
@@ -209,6 +209,7 @@ struct mlx5e_sw_stats {u64 rx_tls_resync_req_end;u64 rx_tls_resync_req_skip;u64 rx_tls_resync_res_ok; +u64 rx_tls_resync_res_retry;u64 rx_tls_resync_res_skip;u64 rx_tls_err;#endif
@@ -339,6 +340,7 @@ struct mlx5e_rq_stats {u64 tls_resync_req_end;u64 tls_resync_req_skip;u64 tls_resync_res_ok; +u64 tls_resync_res_retry;u64 tls_resync_res_skip;u64 tls_err;#endif
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +5 -0
@@ -36,6 +36,7 @@#include "en/xdp.h" #include "en/xsk/rx.h" #include "en/xsk/tx.h" +#include "en_accel/ktls_txrx.h" static inline bool mlx5e_channel_no_affinity_change (struct mlx5e_channel *c) {
@@ -171,6 +172,10 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)*/ clear_bit (MLX5E_SQ_STATE_PENDING_XSK_TX , &c->async_icosq.state); +/* Keep after async ICOSQ CQ poll */ +if (unlikely (mlx5e_ktls_rx_pending_resync_list (c, budget))) + busy |=mlx5e_ktls_rx_handle_resync_list (c, budget); + busy |= INDIRECT_CALL_2(rq->post_wqes, mlx5e_post_rx_mpwqes, mlx5e_post_rx_wqes,
Signature · 1 line
2.30.2
PATCH 6/14 net/mlx5e: Allow mlx5e_safe_switch_channels to work with channels closed
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
mlx5e_safe_switch_channels is used to modify channel parameters and/or hardware configuration in a safe way, so that if anything goes wrong, everything reverts to the old configuration and remains in a consistent state.
However, this function only works when the channels are open. When the caller needs to modify some parameters, first it has to check that the channels are open, otherwise it has to assign parameters directly, and such boilerplate repeats in many different places.
This commit prepares for the refactoring of such places by allowing mlx5e_safe_switch_channels to work when the channels are closed. In this case it will assign the new parameters and run the preactivate hook.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +27 -13
@@ -2852,12 +2852,16 @@ static int mlx5e_switch_priv_channels(struct mlx5e_priv *priv,struct net_device *netdev = priv->netdev;struct mlx5e_channels old_chs;int carrier_ok; +bool opened;int err =0 ; - carrier_ok =netif_carrier_ok (netdev); -netif_carrier_off (netdev); + opened =test_bit (MLX5E_STATE_OPENED , &priv->state); +if (opened) { + carrier_ok =netif_carrier_ok (netdev); +netif_carrier_off (netdev); -mlx5e_deactivate_priv_channels (priv); +mlx5e_deactivate_priv_channels (priv); + } old_chs = priv->channels; priv->channels = *new_chs;
@@ -2873,15 +2877,19 @@ static int mlx5e_switch_priv_channels(struct mlx5e_priv *priv, } } -mlx5e_close_channels (&old_chs); - priv->profile->update_rx (priv); +if (opened) { +mlx5e_close_channels (&old_chs); + priv->profile->update_rx (priv); + } out: -mlx5e_activate_priv_channels (priv); +if (opened) { +mlx5e_activate_priv_channels (priv); -/* return carrier back if needed */ -if (carrier_ok) -netif_carrier_on (netdev); +/* return carrier back if needed */ +if (carrier_ok) +netif_carrier_on (netdev); + }return err; }
@@ -2891,11 +2899,16 @@ int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,mlx5e_fp_preactivate preactivate, void *context) { + bool opened;int err; - err =mlx5e_open_channels (priv, new_chs); -if (err) -return err; + opened =test_bit (MLX5E_STATE_OPENED , &priv->state); + +if (opened) { + err =mlx5e_open_channels (priv, new_chs); +if (err) +return err; + } err =mlx5e_switch_priv_channels (priv, new_chs, preactivate, context);if (err)
@@ -2904,7 +2917,8 @@ int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,return 0 ; err_close: -mlx5e_close_channels (new_chs); +if (opened) +mlx5e_close_channels (new_chs);return err; }
Signature · 1 line
2.30.2
PATCH 7/14 net/mlx5e: Use mlx5e_safe_switch_channels when channels are closed
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
This commit uses new functionality of mlx5e_safe_switch_channels introduced by the previous commit to reduce the amount of repeating similar code all over the driver.
It's very common in mlx5e to call mlx5e_safe_switch_channels when the channels are open, but assign parameters and run hardware commands manually when the channels are closed.
After the previous commit it's no longer needed to do such manual things every time, so this commit removes unneeded code and relies on the new functionality of mlx5e_safe_switch_channels. Some of the places are refactored and simplified, where more complex flows are used to change configuration on the fly, without recreating the channels (the logic is rewritten in a more robust way, with a reset required by default and a list of exceptions).
--- .../net/ethernet/mellanox/mlx5/core/en/ptp.c | 3 + .../ethernet/mellanox/mlx5/core/en_dcbnl.c | 23 ++----- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 65 +++---------------- .../net/ethernet/mellanox/mlx5/core/en_main.c | 65 ++++++------------- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 11 +--- 5 files changed, 40 insertions(+), 127 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +3 -0
@@ -792,6 +792,9 @@ int mlx5e_ptp_rx_manage_fs(struct mlx5e_priv *priv, bool set)if (!priv->profile->rx_ptp_support)return 0 ; +if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) +return 0 ; +if (set) {if (!c || !test_bit (MLX5E_PTP_STATE_RX , c->state)) {netdev_WARN_ONCE (priv->netdev,"Don't try to add PTP RX-FS rules" );
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +7 -16
@@ -1150,8 +1150,6 @@ static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context)static int mlx5e_set_trust_state (struct mlx5e_priv *priv,u8 trust_state) {struct mlx5e_channels new_channels = {}; -bool reset_channels = true; -bool opened;int err =0 ;mutex_lock (&priv->state_lock);
@@ -1160,25 +1158,18 @@ static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state)mlx5e_params_calc_trust_tx_min_inline_mode (priv->mdev, &new_channels.params, trust_state); - opened =test_bit (MLX5E_STATE_OPENED , &priv->state); -if (!opened) - reset_channels = false; -/* Skip if tx_min_inline is the same */ if (new_channels.params.tx_min_inline_mode == - priv->channels.params.tx_min_inline_mode) - reset_channels = false; - -if (reset_channels) { - err =mlx5e_safe_switch_channels (priv, &new_channels, - mlx5e_update_trust_state_hw, - &trust_state); - }else { + priv->channels.params.tx_min_inline_mode) { err =mlx5e_update_trust_state_hw (priv, &trust_state); -if (!err && !opened) - priv->channels.params = new_channels.params; + goto out; } + err =mlx5e_safe_switch_channels (priv, &new_channels, + mlx5e_update_trust_state_hw, + &trust_state); + +out:mutex_unlock (&priv->state_lock);return err;
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +8 -57
128 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +21 -44
145 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +1 -10
@@ -482,20 +482,11 @@ static int mlx5i_change_mtu(struct net_device *netdev, int new_mtu) {struct mlx5e_priv *priv =mlx5i_epriv (netdev);struct mlx5e_channels new_channels = {}; -struct mlx5e_params *params;int err =0 ;mutex_lock (&priv->state_lock); - params = &priv->channels.params; - -if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) { - params->sw_mtu = new_mtu; - netdev->mtu = params->sw_mtu; - goto out; - } - - new_channels.params = *params; + new_channels.params = priv->channels.params; new_channels.params.sw_mtu = new_mtu; err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL );
Signature · 1 line
2.30.2
PATCH 8/14 net/mlx5e: Refactor on-the-fly configuration changes
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
This commit extends mlx5e_safe_switch_channels() to support on-the-fly configuration changes, when the channels are open, but don't need to be recreated. Such flows exist when a parameter being changed doesn't affect how the queues are created, or when the queues can be modified while remaining active.
Before this commit, such flows were handled as special cases on the caller site. This commit adds this functionality to mlx5e_safe_switch_channels(), allowing the caller to pass a boolean indicating whether it's required to recreate the channels or it's allowed to skip it. The logic of switching channel parameters is now completely encapsulated into mlx5e_safe_switch_channels().
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- .../ethernet/mellanox/mlx5/core/en_dcbnl.c | 12 +- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 24 ++- .../net/ethernet/mellanox/mlx5/core/en_main.c | 151 +++++++----------- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 2 +- 5 files changed, 78 insertions(+), 113 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
@@ -1021,7 +1021,7 @@ int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv);int mlx5e_safe_switch_channels (struct mlx5e_priv *priv,struct mlx5e_channels *new_chs,mlx5e_fp_preactivate preactivate, -void *context); +void *context,bool reset);int mlx5e_update_tx_netdev_queues (struct mlx5e_priv *priv);int mlx5e_num_channels_changed (struct mlx5e_priv *priv);int mlx5e_num_channels_changed_ctx (struct mlx5e_priv *priv,void *context);
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +5 -7
@@ -1150,7 +1150,8 @@ static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context)static int mlx5e_set_trust_state (struct mlx5e_priv *priv,u8 trust_state) {struct mlx5e_channels new_channels = {}; -int err =0 ; +bool reset = true; +int err;mutex_lock (&priv->state_lock);
@@ -1160,16 +1161,13 @@ static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state)/* Skip if tx_min_inline is the same */ if (new_channels.params.tx_min_inline_mode == - priv->channels.params.tx_min_inline_mode) { - err =mlx5e_update_trust_state_hw (priv, &trust_state); - goto out; - } + priv->channels.params.tx_min_inline_mode) + reset = false; err =mlx5e_safe_switch_channels (priv, &new_channels, mlx5e_update_trust_state_hw, - &trust_state); + &trust_state, reset); -out:mutex_unlock (&priv->state_lock);return err;
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +11 -13
@@ -373,7 +373,7 @@ int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,if (err) goto unlock; - err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL ); + err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , true); unlock:mutex_unlock (&priv->state_lock);
@@ -466,7 +466,7 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,/* Switch to new channels, set new parameters and close old ones */ err =mlx5e_safe_switch_channels (priv, &new_channels, - mlx5e_num_channels_changed_ctx,NULL ); + mlx5e_num_channels_changed_ctx,NULL , true);if (arfs_enabled) {int err2 =mlx5e_arfs_enable (priv);
@@ -563,6 +563,7 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,struct mlx5_core_dev *mdev = priv->mdev;struct mlx5e_channels new_channels = {};bool reset_rx, reset_tx; +bool reset = true;int err =0 ;if (!MLX5_CAP_GEN (mdev, cq_moderation))
@@ -619,13 +620,11 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,mlx5e_set_priv_channels_rx_coalesce (priv, coal);if (!coal->use_adaptive_tx_coalesce)mlx5e_set_priv_channels_tx_coalesce (priv, coal); - priv->channels.params = new_channels.params; - goto out; + reset = false; } - err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL ); + err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , reset); -out:mutex_unlock (&priv->state_lock);return err; }
@@ -1869,7 +1868,7 @@ static int set_pflag_cqe_based_moder(struct net_device *netdev, bool enable,else mlx5e_set_tx_cq_mode_params (&new_channels.params, cq_period_mode); -return mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL ); +return mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , true); }static int set_pflag_tx_cqe_based_moder (struct net_device *netdev,bool enable)
@@ -1899,12 +1898,11 @@ int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool new_valif (priv->tstamp.rx_filter !=HWTSTAMP_FILTER_NONE ) new_channels.params.ptp_rx = new_val; -if (new_channels.params.ptp_rx == priv->channels.params.ptp_rx) - err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL ); + err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , true);else err =mlx5e_safe_switch_channels (priv, &new_channels, mlx5e_ptp_rx_manage_fs_ctx, - &new_channels.params.ptp_rx); + &new_channels.params.ptp_rx, true);if (err)return err;
@@ -1955,7 +1953,7 @@ static int set_pflag_rx_striding_rq(struct net_device *netdev, bool enable)MLX5E_SET_PFLAG (&new_channels.params,MLX5E_PFLAG_RX_STRIDING_RQ , enable);mlx5e_set_rq_type (mdev, &new_channels.params); -return mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL ); +return mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , true); }static int set_pflag_rx_no_csum_complete (struct net_device *netdev,bool enable)
@@ -1993,7 +1991,7 @@ static int set_pflag_tx_mpwqe_common(struct net_device *netdev, u32 flag, bool eMLX5E_SET_PFLAG (&new_channels.params, flag, enable); -return mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL ); +return mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , true); }static int set_pflag_xdp_tx_mpwqe (struct net_device *netdev,bool enable)
@@ -2034,7 +2032,7 @@ static int set_pflag_tx_port_ts(struct net_device *netdev, bool enable)*/ err =mlx5e_safe_switch_channels (priv, &new_channels, - mlx5e_num_channels_changed_ctx,NULL ); + mlx5e_num_channels_changed_ctx,NULL , true);if (!err) priv->tx_ptp_opened = true;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +60 -91
268 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +1 -1
@@ -489,7 +489,7 @@ static int mlx5i_change_mtu(struct net_device *netdev, int new_mtu) new_channels.params = priv->channels.params; new_channels.params.sw_mtu = new_mtu; - err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL ); + err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , true);if (err) goto out;
Signature · 1 line
2.30.2
PATCH 9/14 net/mlx5e: Cleanup safe switch channels API by passing params
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
mlx5e_safe_switch_channels accepts new_chs as a parameter and opens new channels in place, then copying them to priv->channels. It requires all the callers to allocate space for this temporary storage of the new channels.
This commit cleans up the API by replacing new_chs with new_params, a meaningful subset of new_chs to be filled by the caller. The temporary space for the new channels is allocated inside mlx5e_safe_switch_params (a new name for mlx5e_safe_switch_channels). An extra copy of params is made, but since it's control flow, it's not critical.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 8 +- .../ethernet/mellanox/mlx5/core/en_dcbnl.c | 15 ++- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 98 +++++++++--------- .../net/ethernet/mellanox/mlx5/core/en_main.c | 99 +++++++++---------- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 10 +- 5 files changed, 114 insertions(+), 116 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +4 -4
@@ -1018,10 +1018,10 @@ int fn##_ctx(struct mlx5e_priv *priv, void *context) \return fn (priv); \ }int mlx5e_safe_reopen_channels (struct mlx5e_priv *priv); -int mlx5e_safe_switch_channels (struct mlx5e_priv *priv, -struct mlx5e_channels *new_chs, -mlx5e_fp_preactivate preactivate, -void *context,bool reset); +int mlx5e_safe_switch_params (struct mlx5e_priv *priv, +struct mlx5e_params *new_params, +mlx5e_fp_preactivate preactivate, +void *context,bool reset);int mlx5e_update_tx_netdev_queues (struct mlx5e_priv *priv);int mlx5e_num_channels_changed (struct mlx5e_priv *priv);int mlx5e_num_channels_changed_ctx (struct mlx5e_priv *priv,void *context);
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +7 -8
@@ -1149,24 +1149,23 @@ static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context)static int mlx5e_set_trust_state (struct mlx5e_priv *priv,u8 trust_state) { -struct mlx5e_channels new_channels = {}; +struct mlx5e_params new_params;bool reset = true;int err;mutex_lock (&priv->state_lock); - new_channels.params = priv->channels.params; -mlx5e_params_calc_trust_tx_min_inline_mode (priv->mdev, &new_channels.params, + new_params = priv->channels.params; +mlx5e_params_calc_trust_tx_min_inline_mode (priv->mdev, &new_params, trust_state);/* Skip if tx_min_inline is the same */ -if (new_channels.params.tx_min_inline_mode == - priv->channels.params.tx_min_inline_mode) +if (new_params.tx_min_inline_mode == priv->channels.params.tx_min_inline_mode) reset = false; - err =mlx5e_safe_switch_channels (priv, &new_channels, - mlx5e_update_trust_state_hw, - &trust_state, reset); + err =mlx5e_safe_switch_params (priv, &new_params, + mlx5e_update_trust_state_hw, + &trust_state, reset);mutex_unlock (&priv->state_lock);
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +49 -49
240 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +49 -50
250 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +5 -5
@@ -481,19 +481,19 @@ static const struct mlx5e_profile mlx5i_nic_profile = {static int mlx5i_change_mtu (struct net_device *netdev,int new_mtu) {struct mlx5e_priv *priv =mlx5i_epriv (netdev); -struct mlx5e_channels new_channels = {}; +struct mlx5e_params new_params;int err =0 ;mutex_lock (&priv->state_lock); - new_channels.params = priv->channels.params; - new_channels.params.sw_mtu = new_mtu; + new_params = priv->channels.params; + new_params.sw_mtu = new_mtu; - err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ,NULL , true); + err =mlx5e_safe_switch_params (priv, &new_params,NULL ,NULL , true);if (err) goto out; - netdev->mtu = new_channels.params.sw_mtu; + netdev->mtu = new_params.sw_mtu; out:mutex_unlock (&priv->state_lock);
Signature · 1 line
2.30.2
PATCH 10/14 net/mlx5: Allocate FC bulk structs with kvzalloc() instead of kzalloc()
In reply to Saeed MahameedFrom: Maor Dickman <[email protected]>
The bulk size is larger than 16K so use kvzalloc(). The bulk bitmask upper size limit is 16K so use kvcalloc().
--- .../ethernet/mellanox/mlx5/core/fs_counters.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c +8 -8
@@ -497,13 +497,13 @@ static struct mlx5_fc_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev) alloc_bitmask =MLX5_CAP_GEN (dev, flow_counter_bulk_alloc); bulk_len = alloc_bitmask >0 ?MLX5_FC_BULK_NUM_FCS (alloc_bitmask) :1 ; - bulk =kzalloc (sizeof (*bulk) + bulk_len *sizeof (struct mlx5_fc ), -GFP_KERNEL ); + bulk =kvzalloc (sizeof (*bulk) + bulk_len *sizeof (struct mlx5_fc ), +GFP_KERNEL );if (!bulk) goto err_alloc_bulk; - bulk->bitmask =kcalloc (BITS_TO_LONGS (bulk_len),sizeof (unsigned long ), -GFP_KERNEL ); + bulk->bitmask =kvcalloc (BITS_TO_LONGS (bulk_len),sizeof (unsigned long ), +GFP_KERNEL );if (!bulk->bitmask) goto err_alloc_bitmask;
@@ -521,9 +521,9 @@ static struct mlx5_fc_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev)return bulk; err_mlx5_cmd_bulk_alloc: -kfree (bulk->bitmask); +kvfree (bulk->bitmask); err_alloc_bitmask: -kfree (bulk); +kvfree (bulk); err_alloc_bulk:return ERR_PTR (err); }
@@ -537,8 +537,8 @@ mlx5_fc_bulk_destroy(struct mlx5_core_dev *dev, struct mlx5_fc_bulk *bulk) }mlx5_cmd_fc_free (dev, bulk->base_id); -kfree (bulk->bitmask); -kfree (bulk); +kvfree (bulk->bitmask); +kvfree (bulk);return 0 ; }
Signature · 1 line
2.30.2
PATCH 11/14 net/mlx5: Add register layout to support extended link state
In reply to Saeed MahameedFrom: Moshe Tal <[email protected]>
Add needed structure layouts and defines for pddr register (Port Diagnostics Database Register) and the troublshooting page.
This will be used to get extended link state from the monitor opcode bits.
--- include/linux/mlx5/driver.h | 1 + include/linux/mlx5/mlx5_ifc.h | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
include/linux/mlx5/driver.h +1 -0
@@ -127,6 +127,7 @@ enum {MLX5_REG_PELC =0x500e ,MLX5_REG_PVLC =0x500f ,MLX5_REG_PCMR =0x5041 , +MLX5_REG_PDDR =0x5031 ,MLX5_REG_PMLP =0x5002 ,MLX5_REG_PPLM =0x5023 , MLX5_REG_PCAM = 0x507f,
include/linux/mlx5/mlx5_ifc.h +50 -0
62 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 12/14 net/mlx5e: Add ethtool extended link state
In reply to Saeed MahameedFrom: Moshe Tal <[email protected]>
In case the interface was set up but cannot establish the link, ethtool will print more information to help the user troubleshoot the state.
For example, no link due to missing cable:
$ ethtool eth1 ... Link detected: no (No cable)
Beside the general extended state, drivers can pass additional information about the link state using the sub-state field. For example:
$ ethtool eth1 ... Link detected: no (Autoneg, No partner detected)
The extended state is available only for specific cases, in other cases ethtool with print only "Link detected: no" as before
--- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +171 -0
@@ -2125,12 +2125,183 @@ int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)return mlx5e_ethtool_set_rxnfc (dev, cmd); } +static int query_port_status_opcode (struct mlx5_core_dev *mdev,u32 *status_opcode) +{ +struct mlx5_ifc_pddr_troubleshooting_page_bits *pddr_troubleshooting_page; +u32 in[MLX5_ST_SZ_DW (pddr_reg)] = {}; +u32 out[MLX5_ST_SZ_DW (pddr_reg)]; +int err; + +MLX5_SET (pddr_reg, in, local_port,1 ); +MLX5_SET (pddr_reg, in, page_select, +MLX5_PDDR_REG_PAGE_SELECT_TROUBLESHOOTING_INFO_PAGE ); + + pddr_troubleshooting_page =MLX5_ADDR_OF (pddr_reg, in, page_data); +MLX5_SET (pddr_troubleshooting_page, pddr_troubleshooting_page, + group_opcode,MLX5_PDDR_REG_TRBLSH_GROUP_OPCODE_MONITOR ); + err =mlx5_core_access_reg (mdev, in,sizeof (in), out, +sizeof (out),MLX5_REG_PDDR ,0 ,0 ); +if (err) +return err; + + pddr_troubleshooting_page =MLX5_ADDR_OF (pddr_reg, out, page_data); + *status_opcode =MLX5_GET (pddr_troubleshooting_page, pddr_troubleshooting_page, + status_opcode); +return 0 ; +} + +struct mlx5e_ethtool_link_ext_state_opcode_mapping { +u32 status_opcode; +enum ethtool_link_ext_state link_ext_state; +u8 link_ext_substate; +}; + +static const struct mlx5e_ethtool_link_ext_state_opcode_mapping +mlx5e_link_ext_state_opcode_map[] = { +/* States relating to the autonegotiation or issues therein */ + {2 ,ETHTOOL_LINK_EXT_STATE_AUTONEG , +ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED }, + {3 ,ETHTOOL_LINK_EXT_STATE_AUTONEG , +ETHTOOL_LINK_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED }, + {4 ,ETHTOOL_LINK_EXT_STATE_AUTONEG , +ETHTOOL_LINK_EXT_SUBSTATE_AN_NEXT_PAGE_EXCHANGE_FAILED }, + {36 ,ETHTOOL_LINK_EXT_STATE_AUTONEG , +ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED_FORCE_MODE }, + {38 ,ETHTOOL_LINK_EXT_STATE_AUTONEG , +ETHTOOL_LINK_EXT_SUBSTATE_AN_FEC_MISMATCH_DURING_OVERRIDE }, + {39 ,ETHTOOL_LINK_EXT_STATE_AUTONEG , +ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_HCD }, + +/* Failure during link training */ + {5 ,ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE , +ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED }, + {6 ,ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE , +ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_INHIBIT_TIMEOUT }, + {7 ,ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE , +ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_PARTNER_DID_NOT_SET_RECEIVER_READY }, + {8 ,ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE ,0 }, + {14 ,ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE , +ETHTOOL_LINK_EXT_SUBSTATE_LT_REMOTE_FAULT }, + +/* Logical mismatch in physical coding sublayer or forward error correction sublayer */ + {9 ,ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH , +ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK }, + {10 ,ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH , +ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_AM_LOCK }, + {11 ,ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH , +ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_GET_ALIGN_STATUS }, + {12 ,ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH , +ETHTOOL_LINK_EXT_SUBSTATE_LLM_FC_FEC_IS_NOT_LOCKED }, + {13 ,ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH , +ETHTOOL_LINK_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED }, + +/* Signal integrity issues */ + {15 ,ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY ,0 }, + {17 ,ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY , +ETHTOOL_LINK_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS }, + {42 ,ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY , +ETHTOOL_LINK_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE }, + +/* No cable connected */ + {1024 ,ETHTOOL_LINK_EXT_STATE_NO_CABLE ,0 }, + +/* Failure is related to cable, e.g., unsupported cable */ + {16 ,ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE , +ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE }, + {20 ,ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE , +ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE }, + {29 ,ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE , +ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE }, + {1025 ,ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE , +ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE }, + {1029 ,ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE , +ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE }, + {1031 ,ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE ,0 }, + +/* Failure is related to EEPROM, e.g., failure during reading or parsing the data */ + {1027 ,ETHTOOL_LINK_EXT_STATE_EEPROM_ISSUE ,0 }, + +/* Failure during calibration algorithm */ + {23 ,ETHTOOL_LINK_EXT_STATE_CALIBRATION_FAILURE ,0 }, + +/* The hardware is not able to provide the power required from cable or module */ + {1032 ,ETHTOOL_LINK_EXT_STATE_POWER_BUDGET_EXCEEDED ,0 }, + +/* The module is overheated */ + {1030 ,ETHTOOL_LINK_EXT_STATE_OVERHEAT ,0 }, +}; + +static void +mlx5e_set_link_ext_state (struct mlx5e_ethtool_link_ext_state_opcode_mapping + link_ext_state_mapping, +struct ethtool_link_ext_state_info *link_ext_state_info) +{ +switch (link_ext_state_mapping.link_ext_state) { +case ETHTOOL_LINK_EXT_STATE_AUTONEG : + link_ext_state_info->autoneg = + link_ext_state_mapping.link_ext_substate; +break ; +case ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE : + link_ext_state_info->link_training = + link_ext_state_mapping.link_ext_substate; +break ; +case ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH : + link_ext_state_info->link_logical_mismatch = + link_ext_state_mapping.link_ext_substate; +break ; +case ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY : + link_ext_state_info->bad_signal_integrity = + link_ext_state_mapping.link_ext_substate; +break ; +case ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE : + link_ext_state_info->cable_issue = + link_ext_state_mapping.link_ext_substate; +break ; +default : +break ; + } + + link_ext_state_info->link_ext_state = link_ext_state_mapping.link_ext_state; +} + +static int +mlx5e_get_link_ext_state (struct net_device *dev, +struct ethtool_link_ext_state_info *link_ext_state_info) +{ +struct mlx5e_ethtool_link_ext_state_opcode_mapping link_ext_state_mapping; +struct mlx5e_priv *priv =netdev_priv (dev); +u32 status_opcode =0 ; +int i; + +/* Exit without data if the interface state is OK, since no extended data is +* available in such case +*/ +if (netif_carrier_ok (dev)) +return -ENODATA ; + +if (query_port_status_opcode (priv->mdev, &status_opcode) || + !status_opcode) +return -ENODATA ; + +for (i =0 ; i <ARRAY_SIZE (mlx5e_link_ext_state_opcode_map); i++) { + link_ext_state_mapping = mlx5e_link_ext_state_opcode_map[i]; +if (link_ext_state_mapping.status_opcode == status_opcode) { +mlx5e_set_link_ext_state (link_ext_state_mapping, + link_ext_state_info); +return 0 ; + } + } + +return -ENODATA ; +} +const struct ethtool_ops mlx5e_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES |ETHTOOL_COALESCE_USE_ADAPTIVE , .get_drvinfo = mlx5e_get_drvinfo, .get_link = ethtool_op_get_link, + .get_link_ext_state = mlx5e_get_link_ext_state, .get_strings = mlx5e_get_strings, .get_sset_count = mlx5e_get_sset_count, .get_ethtool_stats = mlx5e_get_ethtool_stats,
Signature · 1 line
2.30.2
PATCH 13/14 net/mlx5: Add helper to initialize 1PPS
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Wrap 1PPS initialization in a helper for a cleaner init flow.
--- .../ethernet/mellanox/mlx5/core/lib/clock.c | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +17 -8
@@ -645,16 +645,19 @@ static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)return PTP_PF_NONE ; } -static int mlx5_init_pin_config (struct mlx5_clock *clock) +static void mlx5_init_pin_config (struct mlx5_clock *clock) {int i; +if (!clock->ptp_info.n_pins) +return ; + clock->ptp_info.pin_config =kcalloc (clock->ptp_info.n_pins,sizeof (*clock->ptp_info.pin_config),GFP_KERNEL );if (!clock->ptp_info.pin_config) -return -ENOMEM ; +return ; clock->ptp_info.enable = mlx5_ptp_enable; clock->ptp_info.verify = mlx5_ptp_verify; clock->ptp_info.pps =1 ;
@@ -667,8 +670,6 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock) clock->ptp_info.pin_config[i].func =mlx5_get_pps_pin_mode (clock, i); clock->ptp_info.pin_config[i].chan =0 ; } - -return 0 ; }static void mlx5_get_pps_caps (struct mlx5_core_dev *mdev)
@@ -859,6 +860,17 @@ static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev) } } +static void mlx5_init_pps (struct mlx5_core_dev *mdev) +{ +struct mlx5_clock *clock = &mdev->clock; + +if (!MLX5_PPS_CAP (mdev)) +return ; + +mlx5_get_pps_caps (mdev); +mlx5_init_pin_config (clock); +} +void mlx5_init_clock (struct mlx5_core_dev *mdev) {struct mlx5_clock *clock = &mdev->clock;
@@ -876,10 +888,7 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev) clock->ptp_info = mlx5_ptp_clock_info;/* Initialize 1PPS data structures */ -if (MLX5_PPS_CAP (mdev)) -mlx5_get_pps_caps (mdev); -if (clock->ptp_info.n_pins) -mlx5_init_pin_config (clock); +mlx5_init_pps (mdev); clock->ptp =ptp_clock_register (&clock->ptp_info, &mdev->pdev->dev);
Signature · 1 line
2.30.2
PATCH 14/14 net/mlx5: Enhance diagnostics info for TX/RX reporters
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Add ts_format to 'Common Config' section of the TX/RX devlink reporters diagnostics info. Possible values for ts_format: 'RT' or 'FRC' which stands for: Real Time and Free Running Counters correspondingly.
--- drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c | 6 ++++++ drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c | 6 ++++++ 2 files changed, 12 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +6 -0
@@ -323,10 +323,12 @@ static int mlx5e_rx_reporter_diagnose_generic_rq(struct mlx5e_rq *rq,struct mlx5e_priv *priv = rq->priv;struct mlx5e_params *params;u32 rq_stride, rq_sz; +bool real_time;int err; params = &priv->channels.params; rq_sz =mlx5e_rqwq_get_size (rq); + real_time =mlx5_is_real_time_rq (priv->mdev); rq_stride =BIT (mlx5e_mpwqe_get_log_stride_size (priv->mdev, params,NULL )); err =mlx5e_health_fmsg_named_obj_nest_start (fmsg,"RQ" );
@@ -345,6 +347,10 @@ static int mlx5e_rx_reporter_diagnose_generic_rq(struct mlx5e_rq *rq,if (err)return err; + err =devlink_fmsg_string_pair_put (fmsg,"ts_format" , real_time ?"RT" :"FRC" ); +if (err) +return err; + err =mlx5e_health_cq_common_diag_fmsg (&rq->cq, fmsg);if (err)return err;
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +6 -0
@@ -257,12 +257,14 @@ mlx5e_tx_reporter_diagnose_generic_txqsq(struct devlink_fmsg *fmsg, struct mlx5e_txqsq *txqsq) {u32 sq_stride, sq_sz; +bool real_time;int err; err =mlx5e_health_fmsg_named_obj_nest_start (fmsg,"SQ" );if (err)return err; + real_time =mlx5_is_real_time_sq (txqsq->mdev); sq_sz =mlx5_wq_cyc_get_size (&txqsq->wq); sq_stride =MLX5_SEND_WQE_BB ;
@@ -274,6 +276,10 @@ mlx5e_tx_reporter_diagnose_generic_txqsq(struct devlink_fmsg *fmsg,if (err)return err; + err =devlink_fmsg_string_pair_put (fmsg,"ts_format" , real_time ?"RT" :"FRC" ); +if (err) +return err; + err =mlx5e_health_cq_common_diag_fmsg (&txqsq->cq, fmsg);if (err)return err;
Signature · 1 line
2.30.2