net/mlx5: misc changes 2025-07-14
Subsystems (6)
Tariq Toukan
maintainercover net/mlx5: misc changes 2025-07-14
Hi,
This series contains misc enhancements to the mlx5 driver.
Regards,
Tariq
Lama Kayal (4):
net/mlx5: HWS, Enable IPSec hardware offload in legacy mode net/mlx5e: SHAMPO, Cleanup reservation size formula net/mlx5e: SHAMPO, Remove mlx5e_shampo_get_log_hd_entry_size() net/mlx5e: Remove duplicate mkey from SHAMPO header
Leon Romanovsky (1):
net/mlx5e: Properly access RCU protected qdisc_sleeping variable
Moshe Shemesh (1):
net/mlx5e: fix kdoc warning on eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/en.h | 10 ++--- .../ethernet/mellanox/mlx5/core/en/params.c | 43 ++++++------------- .../ethernet/mellanox/mlx5/core/en/params.h | 6 --- .../net/ethernet/mellanox/mlx5/core/en/qos.c | 2 +- .../mlx5/core/en_accel/ipsec_offload.c | 3 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 27 ++++++++---- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- 8 files changed, 41 insertions(+), 54 deletions(-)
base-commit: a52f9f0d77f20efc285908a28b5697603b6597c7
Signature · 1 line
2.40.1
Tariq Toukan
maintainerPATCH 1/6 net/mlx5: HWS, Enable IPSec hardware offload in legacy mode
From: Lama Kayal <[email protected]>
IPSec hardware offload in legacy mode should not be affected by the steering mode, hence it should also work properly with hmfs mode.
Remove steering mode validation when calculating the cap for packet offload, this will also enable the missing cap MLX5_IPSEC_CAP_PRIO needed for crypto offload.
--- .../net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +1 -2
@@ -42,8 +42,7 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev) if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload) && (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS || - (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS && - is_mdev_legacy_mode(mdev)))) { + is_mdev_legacy_mode(mdev))) { if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev, reformat_add_esp_trasport) && MLX5_CAP_FLOWTABLE_NIC_RX(mdev,
Signature · 1 line
2.40.1
Re: [PATCH net-next 1/6] net/mlx5: HWS, Enable IPSec hardware offload in legacy mode
Quoted 4 lines · Tariq Toukan
From: Lama Kayal <[email protected]>
IPSec hardware offload in legacy mode should not be affected by the steering mode, hence it should also work properly with hmfs mode.
What about dmfs mode? I am not sure, if you didn't remove it because it is still needed or just forgot about removing it.
In case it is ok as it is:
Thanks
Quoted 29 lines
Remove steering mode validation when calculating the cap for packet offload, this will also enable the missing cap
MLX5_IPSEC_CAP_PRIOneeded for crypto offload.Signed-off-by Lama Kayal <[email protected]>Reviewed-by Jianbo Liu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- .../net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +1
-2@@ -42,8 +42,7 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev) if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload) && (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS || - (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS && - is_mdev_legacy_mode(mdev)))) { + is_mdev_legacy_mode(mdev))) { if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev, reformat_add_esp_trasport) && MLX5_CAP_FLOWTABLE_NIC_RX(mdev,Signature · 1 line
2.40.1
Re: [PATCH net-next 1/6] net/mlx5: HWS, Enable IPSec hardware offload in legacy mode
Quoted 9 lines · Michal Swiatkowski
Quoted 4 lines · Tariq Toukan
From: Lama Kayal <[email protected]>
IPSec hardware offload in legacy mode should not be affected by the steering mode, hence it should also work properly with hmfs mode.
What about dmfs mode? I am not sure, if you didn't remove it because it is still needed or just forgot about removing it.
It is still needed.
We support packet offload for all steering modes in legacy, and only dmfs in switchdev. This is the logic we added before:
dmfs smfs
legacy Y Y switchdev Y N
Now we support hmfs. It is the same as smfs. So the table becomes:
dmfs smfs hmfs
legacy Y Y Y switchdev Y N N
Instead of adding "mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_HMFS", We removed "mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS", and the code is simpler and clean.
Quoted 3 lines
In case it is ok as it is:
Reviewed-by Michal Swiatkowski <[email protected]>
Yes, it's ok. Thanks for the review.
Jianbo
Quoted 32 lines
Thanks
Quoted 29 lines
Remove steering mode validation when calculating the cap for packet offload, this will also enable the missing cap
MLX5_IPSEC_CAP_PRIOneeded for crypto offload.Signed-off-by Lama Kayal <[email protected]>Reviewed-by Jianbo Liu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- .../net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +1
-2@@ -42,8 +42,7 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev) if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload) && (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS || - (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS && - is_mdev_legacy_mode(mdev)))) { + is_mdev_legacy_mode(mdev))) { if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev, reformat_add_esp_trasport) && MLX5_CAP_FLOWTABLE_NIC_RX(mdev,Signature · 1 line
2.40.1
Re: [PATCH net-next 1/6] net/mlx5: HWS, Enable IPSec hardware offload in legacy mode
Quoted 21 lines · Jianbo Liu
Quoted 9 lines · Michal Swiatkowski
Quoted 4 lines · Tariq Toukan
From: Lama Kayal <[email protected]>
IPSec hardware offload in legacy mode should not be affected by the steering mode, hence it should also work properly with hmfs mode.
What about dmfs mode? I am not sure, if you didn't remove it because it is still needed or just forgot about removing it.
It is still needed.
We support packet offload for all steering modes in legacy, and only dmfs in switchdev. This is the logic we added before:dmfs smfs
legacy Y Y switchdev Y N
Quoted 9 lines
Now we support hmfs. It is the same as smfs. So the table becomes:
dmfs smfs hmfslegacy Y Y Y switchdev Y N NInstead of adding "
mdev->priv.steering->mode==MLX5_FLOW_STEERING_MODE_HMFS", We removed "mdev->priv.steering->mode==MLX5_FLOW_STEERING_MODE_SMFS", and the code is simpler and clean.
Ok, got it, thanks.
Quoted 41 lines
Quoted 4 lines
In case it is ok as it is:
Reviewed-by Michal Swiatkowski <[email protected]>Yes, it's ok. Thanks for the review.
Jianbo
Quoted 31 lines
Thanks
Quoted 28 lines
Remove steering mode validation when calculating the cap for packet offload, this will also enable the missing cap
MLX5_IPSEC_CAP_PRIOneeded for crypto offload.Signed-off-by Lama Kayal <[email protected]>Reviewed-by Jianbo Liu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- .../net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +1
-2@@ -42,8 +42,7 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev) if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload) && (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS || - (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS && - is_mdev_legacy_mode(mdev)))) { + is_mdev_legacy_mode(mdev))) { if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev, reformat_add_esp_trasport) && MLX5_CAP_FLOWTABLE_NIC_RX(mdev,Signature · 1 line
2.40.1
Tariq Toukan
maintainerPATCH 2/6 net/mlx5e: fix kdoc warning on eswitch.h
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
Fix the following kdoc warning:
git ls-files *.[ch] | egrep drivers/net/ethernet/mellanox/mlx5/core/ |\
xargs scripts/kernel-doc --none drivers/net/ethernet/mellanox/mlx5/core/eswitch.h:824: warning: cannot understand function prototype: 'struct mlx5_esw_event_info '
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
@@ -827,7 +827,7 @@ void mlx5_esw_vport_vhca_id_clear(struct mlx5_eswitch *esw, u16 vport_num);int mlx5_eswitch_vhca_id_to_vport (struct mlx5_eswitch *esw,u16 vhca_id,u16 *vport_num);/** -* mlx5_esw_event_info - Indicates eswitch mode changed/changing. +* struct mlx5_esw_event_info - Indicates eswitch mode changed/changing. * * @new_mode: New mode of eswitch. */
Signature · 1 line
2.40.1
Re: [PATCH net-next 2/6] net/mlx5e: fix kdoc warning on eswitch.h
Quoted 19 lines · Tariq Toukan
From: Moshe Shemesh <[email protected]>
Fix the following kdoc warning:
git ls-files *.[ch] | egrepdrivers/net/ethernet/mellanox/mlx5/core/|\
xargsscripts/kernel-doc--nonedrivers/net/ethernet/mellanox/mlx5/core/eswitch.h:824: warning: cannot understand function prototype: 'structmlx5_esw_event_info'Signed-off-by Moshe Shemesh <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0
-0
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h void mlx5_esw_vport_vhca_id_clear(struct mlx5_eswitch *esw, u16 vport_num); · line 833
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1
-1@@ -827,7 +827,7 @@ void mlx5_esw_vport_vhca_id_clear(struct mlx5_eswitch *esw, u16 vport_num);int mlx5_eswitch_vhca_id_to_vport (struct mlx5_eswitch *esw,u16 vhca_id,u16 *vport_num);/** -* mlx5_esw_event_info - Indicates eswitch mode changed/changing. +* struct mlx5_esw_event_info - Indicates eswitch mode changed/changing. * * @new_mode: New mode of eswitch. */
Looks like it is the only one structure in this file described using kdoc.
Quoted 2 lines
Signature · 1 line
2.40.1
Tariq Toukan
maintainerPATCH 3/6 net/mlx5e: Properly access RCU protected qdisc_sleeping variable
In reply to Tariq ToukanFrom: Leon Romanovsky <[email protected]>
qdisc_sleeping variable is declared as "struct Qdisc __rcu" and as such needs proper annotation while accessing it.
Without rtnl_dereference(), the following error is generated by sparse:
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c:377:40: warning:
incorrect type in initializer (different address spaces)drivers/net/ethernet/mellanox/mlx5/core/en/qos.c:377:40: expected
struct Qdisc *qdiscdrivers/net/ethernet/mellanox/mlx5/core/en/qos.c:377:40: got struct
Qdisc [noderef] __rcu *qdisc_sleeping
--- drivers/net/ethernet/mellanox/mlx5/core/en/qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +1 -1
@@ -374,7 +374,7 @@ void mlx5e_reactivate_qos_sq(struct mlx5e_priv *priv, u16 qid, struct netdev_quevoid mlx5e_reset_qdisc (struct net_device *dev,u16 qid) {struct netdev_queue *dev_queue =netdev_get_tx_queue (dev, qid); -struct Qdisc *qdisc = dev_queue->qdisc_sleeping; +struct Qdisc *qdisc =rtnl_dereference (dev_queue->qdisc_sleeping);if (!qdisc)return ;
Signature · 1 line
2.40.1
Re: [PATCH net-next 3/6] net/mlx5e: Properly access RCU protected qdisc_sleeping variable
Quoted 25 lines · Tariq Toukan
From: Leon Romanovsky <[email protected]>
qdisc_sleepingvariable is declared as "struct Qdisc__rcu" and as such needs proper annotation while accessing it.Without
rtnl_dereference(), the following error is generated by sparse:
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c:377:40: warning:
incorrect type in initializer (different address spaces)drivers/net/ethernet/mellanox/mlx5/core/en/qos.c:377:40: expected
struct Qdisc *qdiscdrivers/net/ethernet/mellanox/mlx5/core/en/qos.c:377:40: got struct
Qdisc [noderef]__rcu*qdisc_sleepingSigned-off-by Leon Romanovsky <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en/qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c void mlx5e_reactivate_qos_sq(struct mlx5e_priv *priv, u16 qid, struct netdev_que · line 380
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c +1
-1@@ -374,7 +374,7 @@ void mlx5e_reactivate_qos_sq(struct mlx5e_priv *priv, u16 qid, struct netdev_quevoid mlx5e_reset_qdisc (struct net_device *dev,u16 qid) {struct netdev_queue *dev_queue =netdev_get_tx_queue (dev, qid); -struct Qdisc *qdisc = dev_queue->qdisc_sleeping; +struct Qdisc *qdisc =rtnl_dereference (dev_queue->qdisc_sleeping);if (!qdisc)return ;
Good catch, other acesses to the qdisc_sleeping are fine.
Quoted 2 lines
Signature · 1 line
2.40.1
Tariq Toukan
maintainerPATCH 4/6 net/mlx5e: SHAMPO, Cleanup reservation size formula
In reply to Tariq ToukanFrom: Lama Kayal <[email protected]>
The reservation size formula can be reduced to a simple evaluation of MLX5E_SHAMPO_WQ_RESRV_SIZE. This leaves mlx5e_shampo_get_log_rsrv_size() with one single use, which can be replaced with a macro for simplicity.
Also, function mlx5e_shampo_get_log_rsrv_size() is used only throughout params.c, make it static.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 5 +-- .../ethernet/mellanox/mlx5/core/en/params.c | 34 +++++++------------ .../ethernet/mellanox/mlx5/core/en/params.h | 4 --- 3 files changed, 15 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +3 -2
@@ -85,8 +85,9 @@ struct page_pool;#define MLX5E_SHAMPO_WQ_HEADER_PER_PAGE (PAGE_SIZE >> MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE)#define MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE (PAGE_SHIFT - MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE)#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE (64) -#define MLX5E_SHAMPO_WQ_RESRV_SIZE (64 * 1024) -#define MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE (4096) +#define MLX5E_SHAMPO_WQ_RESRV_SIZE_BASE_SHIFT (12) +#define MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE (16) +#define MLX5E_SHAMPO_WQ_RESRV_SIZE BIT(MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE)#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ (mdev) \ (6 + MLX5_CAP_GEN(mdev, cache_line_128byte))/* HW restriction */
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +12 -22
@@ -420,19 +420,10 @@ u8 mlx5e_shampo_get_log_hd_entry_size(struct mlx5_core_dev *mdev,return order_base_2 (DIV_ROUND_UP (MLX5E_RX_MAX_HEAD ,MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE )); } -u8 mlx5e_shampo_get_log_rsrv_size (struct mlx5_core_dev *mdev, -struct mlx5e_params *params) +static u8 mlx5e_shampo_get_log_pkt_per_rsrv (struct mlx5e_params *params) { -return order_base_2 (MLX5E_SHAMPO_WQ_RESRV_SIZE /MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE ); -} - -u8 mlx5e_shampo_get_log_pkt_per_rsrv (struct mlx5_core_dev *mdev, -struct mlx5e_params *params) -{ -u32 resrv_size =BIT (mlx5e_shampo_get_log_rsrv_size (mdev, params)) * -MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE ; - -return order_base_2 (DIV_ROUND_UP (resrv_size, params->sw_mtu)); +return order_base_2 (DIV_ROUND_UP (MLX5E_SHAMPO_WQ_RESRV_SIZE , + params->sw_mtu)); } u8 mlx5e_mpwqe_get_log_stride_size(struct mlx5_core_dev *mdev,
@@ -834,10 +825,9 @@ static u32 mlx5e_shampo_get_log_cq_size(struct mlx5_core_dev *mdev,struct mlx5e_params *params, struct mlx5e_xsk_param *xsk) { - int rsrv_size = BIT(mlx5e_shampo_get_log_rsrv_size(mdev, params)) * -MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE ; + int rsrv_size = MLX5E_SHAMPO_WQ_RESRV_SIZE;u16 num_strides =BIT (mlx5e_mpwqe_get_log_num_strides (mdev, params, xsk)); -int pkt_per_rsrv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (mdev, params)); +int pkt_per_rsrv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (params));u8 log_stride_sz =mlx5e_mpwqe_get_log_stride_size (mdev, params, xsk);int wq_size =BIT (mlx5e_mpwqe_get_log_rq_size (mdev, params, xsk));int wqe_size =BIT (log_stride_sz) * num_strides;
@@ -932,10 +922,11 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,MLX5_SET (wq, wq, shampo_enable, true);MLX5_SET (wq, wq, log_reservation_size, -mlx5e_shampo_get_log_rsrv_size (mdev, params)); +MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE - +MLX5E_SHAMPO_WQ_RESRV_SIZE_BASE_SHIFT );MLX5_SET (wq, wq, log_max_num_of_packets_per_reservation, -mlx5e_shampo_get_log_pkt_per_rsrv (mdev, params)); +mlx5e_shampo_get_log_pkt_per_rsrv (params));MLX5_SET (wq, wq, log_headers_entry_size,mlx5e_shampo_get_log_hd_entry_size (mdev, params)); lro_timeout =
@@ -1048,18 +1039,17 @@ u32 mlx5e_shampo_hd_per_wqe(struct mlx5_core_dev *mdev,struct mlx5e_params *params, struct mlx5e_rq_param *rq_param) { - int resv_size = BIT(mlx5e_shampo_get_log_rsrv_size(mdev, params)) * -MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE ; + int rsrv_size = MLX5E_SHAMPO_WQ_RESRV_SIZE;u16 num_strides =BIT (mlx5e_mpwqe_get_log_num_strides (mdev, params,NULL )); -int pkt_per_resv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (mdev, params)); +int pkt_per_resv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (params));u8 log_stride_sz =mlx5e_mpwqe_get_log_stride_size (mdev, params,NULL );int wqe_size =BIT (log_stride_sz) * num_strides;u32 hd_per_wqe;/* Assumption: hd_per_wqe % 8 == 0. */ - hd_per_wqe = (wqe_size / resv_size) * pkt_per_resv; + hd_per_wqe = (wqe_size / rsrv_size) * pkt_per_resv;mlx5_core_dbg (mdev,"%s hd_per_wqe = %d rsrv_size = %d wqe_size = %d pkt_per_resv = %d\n" , - __func__, hd_per_wqe, resv_size, wqe_size, pkt_per_resv); + __func__, hd_per_wqe, rsrv_size, wqe_size, pkt_per_resv);return hd_per_wqe; }
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +0 -4
@@ -97,10 +97,6 @@ u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5_core_dev *mdev, struct mlx5e_xsk_param *xsk);u8 mlx5e_shampo_get_log_hd_entry_size (struct mlx5_core_dev *mdev,struct mlx5e_params *params); -u8 mlx5e_shampo_get_log_rsrv_size (struct mlx5_core_dev *mdev, -struct mlx5e_params *params); -u8 mlx5e_shampo_get_log_pkt_per_rsrv (struct mlx5_core_dev *mdev, -struct mlx5e_params *params);u32 mlx5e_shampo_hd_per_wqe (struct mlx5_core_dev *mdev,struct mlx5e_params *params,struct mlx5e_rq_param *rq_param);
Signature · 1 line
2.40.1
Re: [PATCH net-next 4/6] net/mlx5e: SHAMPO, Cleanup reservation size formula
Quoted 38 lines · Tariq Toukan
From: Lama Kayal <[email protected]>
The reservation size formula can be reduced to a simple evaluation of
MLX5E_SHAMPO_WQ_RESRV_SIZE. This leavesmlx5e_shampo_get_log_rsrv_size()with one single use, which can be replaced with a macro for simplicity.Also, function
mlx5e_shampo_get_log_rsrv_size()is used only throughoutparams.c, make it static.Signed-off-by Lama Kayal <[email protected]>Reviewed-by Dragos Tatulea <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 5 +-- .../ethernet/mellanox/mlx5/core/en/params.c | 34 +++++++------------ .../ethernet/mellanox/mlx5/core/en/params.h | 4 --- 3 files changed, 15 insertions(+), 28 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en.h +3
-2@@ -85,8 +85,9 @@ struct page_pool;#define MLX5E_SHAMPO_WQ_HEADER_PER_PAGE (PAGE_SIZE >> MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE)#define MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE (PAGE_SHIFT - MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE)#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE (64) -#define MLX5E_SHAMPO_WQ_RESRV_SIZE (64 * 1024) -#define MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE (4096) +#define MLX5E_SHAMPO_WQ_RESRV_SIZE_BASE_SHIFT (12) +#define MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE (16) +#define MLX5E_SHAMPO_WQ_RESRV_SIZE BIT(MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE)#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ (mdev) \ (6 + MLX5_CAP_GEN(mdev, cache_line_128byte))/* HW restriction */ drivers/net/ethernet/mellanox/mlx5/core/en/params.c +0
-0
[...]
drivers/net/ethernet/mellanox/mlx5/core/en/params.c static u32 mlx5e_shampo_get_log_cq_size(struct mlx5_core_dev *mdev, · line 828
Quoted 9 lines
u8 mlx5e_mpwqe_get_log_stride_size(struct
mlx5_core_dev*mdev,drivers/net/ethernet/mellanox/mlx5/core/en/params.c +1
-2@@ -834,10 +825,9 @@ static u32 mlx5e_shampo_get_log_cq_size(struct mlx5_core_dev *mdev,struct mlx5e_params *params, struct mlx5e_xsk_param *xsk) { - int rsrv_size = BIT(mlx5e_shampo_get_log_rsrv_size(mdev, params)) * -MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE ; + int rsrv_size = MLX5E_SHAMPO_WQ_RESRV_SIZE;
Broken RCT, you can use MLX5E_SHAMPO_WQ_RESRV_SIZE directly in order_base_2() call.
Quoted 21 lines
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +4
-3u16 num_strides =BIT (mlx5e_mpwqe_get_log_num_strides (mdev, params, xsk)); -int pkt_per_rsrv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (mdev, params)); +int pkt_per_rsrv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (params));u8 log_stride_sz =mlx5e_mpwqe_get_log_stride_size (mdev, params, xsk);int wq_size =BIT (mlx5e_mpwqe_get_log_rq_size (mdev, params, xsk));int wqe_size =BIT (log_stride_sz) * num_strides;@@ -932,10 +922,11 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,MLX5_SET (wq, wq, shampo_enable, true);MLX5_SET (wq, wq, log_reservation_size, -mlx5e_shampo_get_log_rsrv_size (mdev, params)); +MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE - +MLX5E_SHAMPO_WQ_RESRV_SIZE_BASE_SHIFT );MLX5_SET (wq, wq, log_max_num_of_packets_per_reservation, -mlx5e_shampo_get_log_pkt_per_rsrv (mdev, params)); +mlx5e_shampo_get_log_pkt_per_rsrv (params));MLX5_SET (wq, wq, log_headers_entry_size,mlx5e_shampo_get_log_hd_entry_size (mdev, params)); lro_timeout =
drivers/net/ethernet/mellanox/mlx5/core/en/params.c u32 mlx5e_shampo_hd_per_wqe(struct mlx5_core_dev *mdev, · line 1042
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +1
-2@@ -1048,18 +1039,17 @@ u32 mlx5e_shampo_hd_per_wqe(struct mlx5_core_dev *mdev,struct mlx5e_params *params, struct mlx5e_rq_param *rq_param) { - int resv_size = BIT(mlx5e_shampo_get_log_rsrv_size(mdev, params)) * -MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE ; + int rsrv_size = MLX5E_SHAMPO_WQ_RESRV_SIZE;
Can be moved down to have RCT.
Quoted 21 lines
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +3
-3u16 num_strides =BIT (mlx5e_mpwqe_get_log_num_strides (mdev, params,NULL )); -int pkt_per_resv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (mdev, params)); +int pkt_per_resv =BIT (mlx5e_shampo_get_log_pkt_per_rsrv (params));u8 log_stride_sz =mlx5e_mpwqe_get_log_stride_size (mdev, params,NULL );int wqe_size =BIT (log_stride_sz) * num_strides;u32 hd_per_wqe;/* Assumption: hd_per_wqe % 8 == 0. */ - hd_per_wqe = (wqe_size / resv_size) * pkt_per_resv; + hd_per_wqe = (wqe_size / rsrv_size) * pkt_per_resv;mlx5_core_dbg (mdev,"%s hd_per_wqe = %d rsrv_size = %d wqe_size = %d pkt_per_resv = %d\n" , - __func__, hd_per_wqe, resv_size, wqe_size, pkt_per_resv); + __func__, hd_per_wqe, rsrv_size, wqe_size, pkt_per_resv);return hd_per_wqe; }drivers/net/ethernet/mellanox/mlx5/core/en/params.h +0
-0
drivers/net/ethernet/mellanox/mlx5/core/en/params.h u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5_core_dev *mdev, · line 102
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +0
-4@@ -97,10 +97,6 @@ u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5_core_dev *mdev, struct mlx5e_xsk_param *xsk);u8 mlx5e_shampo_get_log_hd_entry_size (struct mlx5_core_dev *mdev,struct mlx5e_params *params); -u8 mlx5e_shampo_get_log_rsrv_size (struct mlx5_core_dev *mdev, -struct mlx5e_params *params); -u8 mlx5e_shampo_get_log_pkt_per_rsrv (struct mlx5_core_dev *mdev, -struct mlx5e_params *params);u32 mlx5e_shampo_hd_per_wqe (struct mlx5_core_dev *mdev,struct mlx5e_params *params,struct mlx5e_rq_param *rq_param);
Just small nits, otherwise:
Quoted 2 lines
Signature · 1 line
2.40.1
Tariq Toukan
maintainerPATCH 5/6 net/mlx5e: SHAMPO, Remove mlx5e_shampo_get_log_hd_entry_size()
In reply to Tariq ToukanFrom: Lama Kayal <[email protected]>
Refactor mlx5e_shampo_get_log_hd_entry_size() as macro, for more simplicity.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/params.c | 9 ++------- drivers/net/ethernet/mellanox/mlx5/core/en/params.h | 2 -- 3 files changed, 3 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
@@ -84,7 +84,7 @@ struct page_pool;#define MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE (9)#define MLX5E_SHAMPO_WQ_HEADER_PER_PAGE (PAGE_SIZE >> MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE)#define MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE (PAGE_SHIFT - MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE) -#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE (64) +#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE_SHIFT (6)#define MLX5E_SHAMPO_WQ_RESRV_SIZE_BASE_SHIFT (12)#define MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE (16)#define MLX5E_SHAMPO_WQ_RESRV_SIZE BIT(MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE)
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +2 -7
@@ -414,12 +414,6 @@ u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5_core_dev *mdev,return params->log_rq_mtu_frames - log_pkts_per_wqe; } -u8 mlx5e_shampo_get_log_hd_entry_size (struct mlx5_core_dev *mdev, -struct mlx5e_params *params) -{ -return order_base_2 (DIV_ROUND_UP (MLX5E_RX_MAX_HEAD ,MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE )); -} -static u8 mlx5e_shampo_get_log_pkt_per_rsrv (struct mlx5e_params *params) { return order_base_2(DIV_ROUND_UP(MLX5E_SHAMPO_WQ_RESRV_SIZE,
@@ -928,7 +922,8 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev, log_max_num_of_packets_per_reservation, mlx5e_shampo_get_log_pkt_per_rsrv(params));MLX5_SET (wq, wq, log_headers_entry_size, -mlx5e_shampo_get_log_hd_entry_size (mdev, params)); +MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE - +MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE_SHIFT ); lro_timeout =mlx5e_choose_lro_timeout (mdev,MLX5E_DEFAULT_SHAMPO_TIMEOUT );
drivers/net/ethernet/mellanox/mlx5/core/en/params.h +0 -2
@@ -95,8 +95,6 @@ bool mlx5e_rx_mpwqe_is_linear_skb(struct mlx5_core_dev *mdev,u8 mlx5e_mpwqe_get_log_rq_size (struct mlx5_core_dev *mdev,struct mlx5e_params *params,struct mlx5e_xsk_param *xsk); -u8 mlx5e_shampo_get_log_hd_entry_size (struct mlx5_core_dev *mdev, -struct mlx5e_params *params);u32 mlx5e_shampo_hd_per_wqe (struct mlx5_core_dev *mdev,struct mlx5e_params *params,struct mlx5e_rq_param *rq_param);
Signature · 1 line
2.40.1
Re: [PATCH net-next 5/6] net/mlx5e: SHAMPO, Remove mlx5e_shampo_get_log_hd_entry_size()
Quoted 45 lines · Tariq Toukan
From: Lama Kayal <[email protected]>
Refactor
mlx5e_shampo_get_log_hd_entry_size()as macro, for more simplicity.Signed-off-by Lama Kayal <[email protected]>Reviewed-by Dragos Tatulea <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/params.c | 9 ++------- drivers/net/ethernet/mellanox/mlx5/core/en/params.h | 2 -- 3 files changed, 3 insertions(+), 10 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en.h +1
-1@@ -84,7 +84,7 @@ struct page_pool;#define MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE (9)#define MLX5E_SHAMPO_WQ_HEADER_PER_PAGE (PAGE_SIZE >> MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE)#define MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE (PAGE_SHIFT - MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE) -#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE (64) +#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE_SHIFT (6)#define MLX5E_SHAMPO_WQ_RESRV_SIZE_BASE_SHIFT (12)#define MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE (16)#define MLX5E_SHAMPO_WQ_RESRV_SIZE BIT(MLX5E_SHAMPO_WQ_LOG_RESRV_SIZE)drivers/net/ethernet/mellanox/mlx5/core/en/params.c +0
-6@@ -414,12 +414,6 @@ u8 mlx5e_mpwqe_get_log_rq_size(struct mlx5_core_dev *mdev,return params->log_rq_mtu_frames - log_pkts_per_wqe; } -u8 mlx5e_shampo_get_log_hd_entry_size (struct mlx5_core_dev *mdev, -struct mlx5e_params *params) -{ -return order_base_2 (DIV_ROUND_UP (MLX5E_RX_MAX_HEAD ,MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE )); -} -static u8 mlx5e_shampo_get_log_pkt_per_rsrv (struct mlx5e_params *params) { return order_base_2(DIV_ROUND_UP(MLX5E_SHAMPO_WQ_RESRV_SIZE,
drivers/net/ethernet/mellanox/mlx5/core/en/params.c int mlx5e_build_rq_param(struct mlx5_core_dev *mdev, · line 926
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +2
-1@@ -928,7 +922,8 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev, log_max_num_of_packets_per_reservation, mlx5e_shampo_get_log_pkt_per_rsrv(params));MLX5_SET (wq, wq, log_headers_entry_size, -mlx5e_shampo_get_log_hd_entry_size (mdev, params)); +MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE - +MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE_SHIFT );
We had 2 here, now it is 8 - 6, so it is fine, it wasn't obvious for me.
Quoted 19 lines
drivers/net/ethernet/mellanox/mlx5/core/en/params.c +0
-0lro_timeout =mlx5e_choose_lro_timeout (mdev,MLX5E_DEFAULT_SHAMPO_TIMEOUT );drivers/net/ethernet/mellanox/mlx5/core/en/params.h +0
-2@@ -95,8 +95,6 @@ bool mlx5e_rx_mpwqe_is_linear_skb(struct mlx5_core_dev *mdev,u8 mlx5e_mpwqe_get_log_rq_size (struct mlx5_core_dev *mdev,struct mlx5e_params *params,struct mlx5e_xsk_param *xsk); -u8 mlx5e_shampo_get_log_hd_entry_size (struct mlx5_core_dev *mdev, -struct mlx5e_params *params);u32 mlx5e_shampo_hd_per_wqe (struct mlx5_core_dev *mdev,struct mlx5e_params *params,struct mlx5e_rq_param *rq_param);Signature · 1 line
2.40.1
Tariq Toukan
maintainerPATCH 6/6 net/mlx5e: Remove duplicate mkey from SHAMPO header
In reply to Tariq ToukanFrom: Lama Kayal <[email protected]>
SHAMPO structure holds two variations of the mkey, which is unnecessary, a duplication that's repeated per rq.
Remove duplicate mkey information and keep only one version, the one used in the fast path, rename field to reflect field type clearly.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 3 +-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 27 ++++++++++++------- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -2
@@ -630,14 +630,13 @@ struct mlx5e_dma_info { };struct mlx5e_shampo_hd { -u32 mkey;struct mlx5e_frag_page *pages;u32 hd_per_wq;u16 hd_per_wqe;unsigned long *bitmap;u16 pi;u16 ci; -__be32 key; +__be32 mkey_be; };struct mlx5e_hw_gro_data {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +18 -9
@@ -545,18 +545,26 @@ static int mlx5e_create_rq_umr_mkey(struct mlx5_core_dev *mdev, struct mlx5e_rq }static int mlx5e_create_rq_hd_umr_mkey (struct mlx5_core_dev *mdev, -u16 hd_per_wq,u32 *umr_mkey) +u16 hd_per_wq,__be32 *umr_mkey) {u32 max_ksm_size =BIT (MLX5_CAP_GEN (mdev, log_max_klm_list_size)); +u32 mkey; +int err;if (max_ksm_size < hd_per_wq) {mlx5_core_err (mdev,"max ksm list size 0x%x is smaller than shampo header buffer list size 0x%x\n" , max_ksm_size, hd_per_wq);return -EINVAL ; } -return mlx5e_create_umr_ksm_mkey (mdev, hd_per_wq, -MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE , - umr_mkey); + + err =mlx5e_create_umr_ksm_mkey (mdev, hd_per_wq, +MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE , + &mkey); +if (err) +return err; + + *umr_mkey =cpu_to_be32 (mkey); +return 0 ; }static void mlx5e_init_frags_partition (struct mlx5e_rq *rq)
@@ -782,11 +790,10 @@ static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev, goto err_shampo_hd_info_alloc; err =mlx5e_create_rq_hd_umr_mkey (mdev, hd_per_wq, - &rq->mpwqe.shampo->mkey); + &rq->mpwqe.shampo->mkey_be);if (err) goto err_umr_mkey; - rq->mpwqe.shampo->key =cpu_to_be32 (rq->mpwqe.shampo->mkey); rq->mpwqe.shampo->hd_per_wqe =mlx5e_shampo_hd_per_wqe (mdev, params, rqp); wq_size =BIT (MLX5_GET (wq, wqc, log_wq_sz));
@@ -831,7 +838,7 @@ static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev, err_hw_gro_data:page_pool_destroy (rq->hd_page_pool); err_hds_page_pool: -mlx5_core_destroy_mkey (mdev, rq->mpwqe.shampo->mkey); +mlx5_core_destroy_mkey (mdev,be32_to_cpu (rq->mpwqe.shampo->mkey_be)); err_umr_mkey:mlx5e_rq_shampo_hd_info_free (rq); err_shampo_hd_info_alloc:
@@ -848,7 +855,8 @@ static void mlx5e_rq_free_shampo(struct mlx5e_rq *rq)if (rq->hd_page_pool != rq->page_pool)page_pool_destroy (rq->hd_page_pool);mlx5e_rq_shampo_hd_info_free (rq); -mlx5_core_destroy_mkey (rq->mdev, rq->mpwqe.shampo->mkey); +mlx5_core_destroy_mkey (rq->mdev, +be32_to_cpu (rq->mpwqe.shampo->mkey_be));kvfree (rq->mpwqe.shampo); }
@@ -1121,7 +1129,8 @@ int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param, u16 q_couif (test_bit (MLX5E_RQ_STATE_SHAMPO , &rq->state)) {MLX5_SET (wq, wq, log_headers_buffer_entry_num,order_base_2 (rq->mpwqe.shampo->hd_per_wq)); -MLX5_SET (wq, wq, headers_mkey, rq->mpwqe.shampo->mkey); +MLX5_SET (wq, wq, headers_mkey, +be32_to_cpu (rq->mpwqe.shampo->mkey_be)); } mlx5_fill_page_frag_array(&rq->wq_ctrl.buf,
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -1
@@ -676,7 +676,7 @@ static int mlx5e_build_shampo_hd_umr(struct mlx5e_rq *rq, wqe_bbs =MLX5E_KSM_UMR_WQEBBS (ksm_entries); pi =mlx5e_icosq_get_next_pi (sq, wqe_bbs); umr_wqe =mlx5_wq_cyc_get_wqe (&sq->wq, pi); -build_ksm_umr (sq, umr_wqe, shampo->key, index, ksm_entries); +build_ksm_umr (sq, umr_wqe, shampo->mkey_be, index, ksm_entries);WARN_ON_ONCE (ksm_entries & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE -1 ));while (i < ksm_entries) {
Signature · 1 line
2.40.1
Re: [PATCH net-next 6/6] net/mlx5e: Remove duplicate mkey from SHAMPO header
Quoted 8 lines · Tariq Toukan
From: Lama Kayal <[email protected]>
SHAMPO structure holds two variations of the mkey, which is unnecessary, a duplication that's repeated per rq.
Remove duplicate mkey information and keep only one version, the one used in the fast path, rename field to reflect field type clearly.
Quoted 8 lines
Signed-off-by Lama Kayal <[email protected]>Reviewed-by Dragos Tatulea <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 3 +-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 27 ++++++++++++------- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-)
Thanks
Quoted 3 lines
Signature · 1 line
2.40.1