net/mlx5: Prepare eswitch infrastructure for satellite PF support
Subsystems (4)
Tariq Toukan
maintainercover net/mlx5: Prepare eswitch infrastructure for satellite PF support
Hi,
See detailed description by Moshe below.
Regards,
Tariq
This series prepares the mlx5 eswitch command interface and vport infrastructure for satellite PF support.
The first two patches abstract host PF data parsing behind a helper and switch to the v1 response layout for query_esw_functions when supported, so callers are insulated from layout differences.
The IPsec VF checks are tightened to use mlx5_eswitch_is_vf_vport() instead of comparing against a specific vport number.
The remaining patches refactor SET_HCA_CAP and enable/disable_hca command helpers to support vhca_id-based addressing, which is required for managing functions that are not directly addressable by function_id.
A follow-up series will introduce satellite PF discovery and management using this infrastructure.
Moshe Shemesh (8):
net/mlx5: Use helper to parse host PF info net/mlx5: Use v1 response layout for query_esw_functions net/mlx5: Use mlx5_eswitch_is_vf_vport() for IPsec VF checks net/mlx5: Switch vport HCA cap helpers to kvzalloc net/mlx5: Add mlx5_vport_set_other_func_general_cap macro net/mlx5: Refactor mlx5_set_msix_vec_count() SET_HCA_CAP net/mlx5: Use vport helper for IPsec eswitch set caps net/mlx5: Generalize enable/disable HCA for any PF vport
.../net/ethernet/mellanox/mlx5/core/ecpf.c | 24 ++- .../net/ethernet/mellanox/mlx5/core/ecpf.h | 4 +- .../ethernet/mellanox/mlx5/core/esw/ipsec.c | 83 +++------ .../net/ethernet/mellanox/mlx5/core/eswitch.c | 157 +++++++++++++++--- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 16 ++ .../mellanox/mlx5/core/eswitch_offloads.c | 38 ++--- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 6 + .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 27 +-- .../net/ethernet/mellanox/mlx5/core/sriov.c | 8 +- .../net/ethernet/mellanox/mlx5/core/vport.c | 12 +- 10 files changed, 227 insertions(+), 148 deletions(-)
base-commit: 8b2feced65cd3aa0597d596ed5733a1abd4c4d78
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 1/8 net/mlx5: Use helper to parse host PF info
From: Moshe Shemesh <[email protected]>
Add a helper mlx5_esw_get_host_pf_info() to retrieve host PF data from the query_esw_functions command output, so callers no longer need to parse the layout to obtain the required information.
Convert all callers of mlx5_esw_query_functions() to use the new helper, preparing for upcoming support of the new op_mod that returns data in the network_function_params layout.
--- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 43 ++++++++++++++----- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 15 +++++++ .../mellanox/mlx5/core/eswitch_offloads.c | 34 ++++++--------- .../net/ethernet/mellanox/mlx5/core/sriov.c | 8 ++-- 4 files changed, 62 insertions(+), 38 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +32 -11
@@ -1083,10 +1083,36 @@ const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)return ERR_PTR (err); } +static struct mlx5_esw_pf_info +mlx5_esw_host_pf_from_host_params (const void *entry) +{ +return (struct mlx5_esw_pf_info ) { + .pf_not_exist =MLX5_GET (host_params_context, entry, + host_pf_not_exist), + .pf_disabled =MLX5_GET (host_params_context, entry, + host_pf_disabled), + .num_of_vfs =MLX5_GET (host_params_context, entry, + host_num_of_vfs), + .total_vfs =MLX5_GET (host_params_context, entry, + host_total_vfs), + .host_number =MLX5_GET (host_params_context, entry, + host_number), + }; +} + +struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (const u32 *out) +{ +const void *entry; + + entry =MLX5_ADDR_OF (query_esw_functions_out, out, net_function_params); + +return mlx5_esw_host_pf_from_host_params (entry); +} +static int mlx5_esw_host_functions_enabled_query (struct mlx5_eswitch *esw) { +struct mlx5_esw_pf_info host_pf_info;const u32 *query_host_out; -void *host_params;if (!mlx5_core_is_ecpf_esw_manager (esw->dev))return 0 ;
@@ -1095,11 +1121,8 @@ static int mlx5_esw_host_functions_enabled_query(struct mlx5_eswitch *esw)if (IS_ERR (query_host_out))return PTR_ERR (query_host_out); - host_params =MLX5_ADDR_OF (query_esw_functions_out, - query_host_out, net_function_params); - esw->esw_funcs.host_funcs_disabled = -MLX5_GET (host_params_context, host_params, - host_pf_not_exist); + host_pf_info =mlx5_esw_get_host_pf_info (query_host_out); + esw->esw_funcs.host_funcs_disabled = host_pf_info.pf_not_exist;kvfree (query_host_out);return 0 ;
@@ -1523,7 +1546,7 @@ static void mlx5_eswitch_get_devlink_param(struct mlx5_eswitch *esw)static void mlx5_eswitch_update_num_of_vfs (struct mlx5_eswitch *esw,int num_vfs) { -void *host_params; +struct mlx5_esw_pf_info host_pf_info;const u32 *out;if (num_vfs <0 )
@@ -1538,10 +1561,8 @@ mlx5_eswitch_update_num_of_vfs(struct mlx5_eswitch *esw, int num_vfs)if (IS_ERR (out))return ; - host_params =MLX5_ADDR_OF (query_esw_functions_out, out, - net_function_params); - esw->esw_funcs.num_vfs =MLX5_GET (host_params_context, host_params, - host_num_of_vfs); + host_pf_info =mlx5_esw_get_host_pf_info (out); + esw->esw_funcs.num_vfs = host_pf_info.num_of_vfs;if (mlx5_core_ec_sriov_enabled (esw->dev)) esw->esw_funcs.num_ec_vfs = num_vfs;
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +15 -0
@@ -71,6 +71,14 @@ struct mlx5_mapped_obj { }; }; +struct mlx5_esw_pf_info { +bool pf_not_exist; +bool pf_disabled; +u16 num_of_vfs; +u16 total_vfs; +u16 host_number; +}; +#ifdef CONFIG_MLX5_ESWITCH #define ESW_OFFLOADS_DEFAULT_NUM_GROUPS 15
@@ -649,6 +657,7 @@ bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1);const u32 *mlx5_esw_query_functions (struct mlx5_core_dev *dev); +struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (const u32 *out);int mlx5_esw_host_pf_enable_hca (struct mlx5_core_dev *dev);int mlx5_esw_host_pf_disable_hca (struct mlx5_core_dev *dev);
@@ -976,6 +985,12 @@ static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)return ERR_PTR (-EOPNOTSUPP ); } +static inline struct mlx5_esw_pf_info +mlx5_esw_get_host_pf_info (const u32 *out) +{ +return (struct mlx5_esw_pf_info ) {}; +} +static inline struct mlx5_flow_handle *esw_add_restore_rule (struct mlx5_eswitch *esw,u32 tag) {
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +12 -22
@@ -3708,8 +3708,7 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw)static void esw_vfs_changed_event_handler (struct mlx5_eswitch *esw) { -bool host_pf_disabled; -void *host_params; +struct mlx5_esw_pf_info host_pf_info;u16 new_num_vfs;const u32 *out;
@@ -3717,14 +3716,10 @@ static void esw_vfs_changed_event_handler(struct mlx5_eswitch *esw)if (IS_ERR (out))return ; - host_params =MLX5_ADDR_OF (query_esw_functions_out, out, - net_function_params); - new_num_vfs =MLX5_GET (host_params_context, host_params, - host_num_of_vfs); - host_pf_disabled =MLX5_GET (host_params_context, host_params, - host_pf_disabled); + host_pf_info =mlx5_esw_get_host_pf_info (out); + new_num_vfs = host_pf_info.num_of_vfs; -if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_disabled) +if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_info.pf_disabled) goto free;mlx5_esw_reps_block (esw);
@@ -3826,8 +3821,8 @@ int mlx5_esw_funcs_changed_handler(struct notifier_block *nb,static int mlx5_esw_host_number_init (struct mlx5_eswitch *esw) { +struct mlx5_esw_pf_info host_pf_info;const u32 *query_host_out; -void *host_params;if (!mlx5_core_is_ecpf_esw_manager (esw->dev))return 0 ;
@@ -3837,10 +3832,8 @@ static int mlx5_esw_host_number_init(struct mlx5_eswitch *esw)return PTR_ERR (query_host_out);/* Mark non local controller with non zero controller number. */ - host_params =MLX5_ADDR_OF (query_esw_functions_out, - query_host_out, net_function_params); - esw->offloads.host_number =MLX5_GET (host_params_context, - host_params, host_number); + host_pf_info =mlx5_esw_get_host_pf_info (query_host_out); + esw->offloads.host_number = host_pf_info.host_number;kvfree (query_host_out);return 0 ; }
@@ -4980,9 +4973,8 @@ int mlx5_devlink_pf_port_fn_state_get(struct devlink_port *port, struct netlink_ext_ack *extack) {struct mlx5_vport *vport =mlx5_devlink_port_vport_get (port); +struct mlx5_esw_pf_info host_pf_info;const u32 *query_out; -void *host_params; -bool pf_disabled;if (vport->vport !=MLX5_VPORT_HOST_PF ) {NL_SET_ERR_MSG_MOD (extack,"State get is not supported for VF" );
@@ -4996,13 +4988,11 @@ int mlx5_devlink_pf_port_fn_state_get(struct devlink_port *port,if (IS_ERR (query_out))return PTR_ERR (query_out); - host_params =MLX5_ADDR_OF (query_esw_functions_out, query_out, - net_function_params); - pf_disabled =MLX5_GET (host_params_context, host_params, - host_pf_disabled); + host_pf_info =mlx5_esw_get_host_pf_info (query_out); - *opstate = pf_disabled ?DEVLINK_PORT_FN_OPSTATE_DETACHED : -DEVLINK_PORT_FN_OPSTATE_ATTACHED ; + *opstate = host_pf_info.pf_disabled ? +DEVLINK_PORT_FN_OPSTATE_DETACHED : +DEVLINK_PORT_FN_OPSTATE_ATTACHED ;kvfree (query_out);return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +3 -5
@@ -273,8 +273,8 @@ void mlx5_sriov_detach(struct mlx5_core_dev *dev)static u16 mlx5_get_max_vfs (struct mlx5_core_dev *dev) { +struct mlx5_esw_pf_info host_pf_info;u16 host_total_vfs; -void *host_params;const u32 *out;if (mlx5_core_is_ecpf_esw_manager (dev)) {
@@ -285,10 +285,8 @@ static u16 mlx5_get_max_vfs(struct mlx5_core_dev *dev)*/ if (IS_ERR (out)) goto done; - host_params =MLX5_ADDR_OF (query_esw_functions_out, out, - net_function_params); - host_total_vfs =MLX5_GET (host_params_context, host_params, - host_total_vfs); + host_pf_info =mlx5_esw_get_host_pf_info (out); + host_total_vfs = host_pf_info.total_vfs;kvfree (out);return host_total_vfs; }
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 3/8 net/mlx5: Use mlx5_eswitch_is_vf_vport() for IPsec VF checks
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
IPsec eswitch offload operations and the enabled_ipsec_vf_count counter are intended for VF vports only. Replace the MLX5_VPORT_HOST_PF checks with mlx5_eswitch_is_vf_vport() to properly identify VF vports, as preparation for adding another type of PF vports.
--- drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec.c +1 -1
@@ -209,7 +209,7 @@ static int esw_ipsec_vf_offload_set_bytype(struct mlx5_eswitch *esw, struct mlx5struct mlx5_core_dev *dev = esw->dev;int err; -if (vport->vport ==MLX5_VPORT_HOST_PF ) +if (!mlx5_eswitch_is_vf_vport (esw, vport->vport))return -EOPNOTSUPP ;if (type ==MLX5_ESW_VPORT_IPSEC_CRYPTO_OFFLOAD ) {
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +2 -2
@@ -958,7 +958,7 @@ int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, struct mlx5_vport *vport,/* Sync with current vport context */ vport->enabled_events = enabled_events; vport->enabled = true; -if (vport->vport !=MLX5_VPORT_HOST_PF && +if (mlx5_eswitch_is_vf_vport (esw, vport_num) && (vport->info.ipsec_crypto_enabled || vport->info.ipsec_packet_enabled)) esw->enabled_ipsec_vf_count++;
@@ -1020,7 +1020,7 @@ void mlx5_esw_vport_disable(struct mlx5_eswitch *esw, struct mlx5_vport *vport)mlx5_esw_vport_vhca_id_unmap (esw, vport); } -if (vport->vport !=MLX5_VPORT_HOST_PF && +if (mlx5_eswitch_is_vf_vport (esw, vport_num) && (vport->info.ipsec_crypto_enabled || vport->info.ipsec_packet_enabled)) esw->enabled_ipsec_vf_count--;
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 2/8 net/mlx5: Use v1 response layout for query_esw_functions
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
Use the v1 response layout for the query_esw_functions command when supported by the device. When query_host_net_function_v1 capability is set, use MLX5_QUERY_ESW_FUNC_OP_MOD_LAYOUT_V1 to retrieve parameters for multiple network functions, allocating the output buffer according to query_host_net_function_num_max. Validate that firmware does not return more entries than the allocated buffer.
This change does not introduce new functionality, but enables the existing mlx5_esw_query_functions() callers to retrieve host PF information with the new layout as well. The mlx5_esw_get_host_pf_info() helper abstracts parsing the command output in both legacy and new formats, so callers do not need to handle the different layouts.
--- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 88 +++++++++++++++++-- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 5 +- .../mellanox/mlx5/core/eswitch_offloads.c | 6 +- .../net/ethernet/mellanox/mlx5/core/sriov.c | 2 +- 4 files changed, 89 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +82 -6
@@ -1063,11 +1063,28 @@ static int eswitch_vport_event(struct notifier_block *nb,*/ const u32 *mlx5_esw_query_functions (struct mlx5_core_dev *dev) { -int outlen =MLX5_ST_SZ_BYTES (query_esw_functions_out); +bool net_func_v1 =MLX5_CAP_GEN (dev, query_host_net_function_v1);u32 in[MLX5_ST_SZ_DW (query_esw_functions_in)] = {}; +int alloc_entries; +int outlen;u32 *out;int err; +if (net_func_v1) { + alloc_entries =MLX5_CAP_GEN (dev, + query_host_net_function_num_max); + alloc_entries =max (alloc_entries,1 ); +MLX5_SET (query_esw_functions_in, in, op_mod, +MLX5_QUERY_ESW_FUNC_OP_MOD_LAYOUT_V1 ); + outlen =MLX5_BYTE_OFF (query_esw_functions_out, + net_function_params) + + alloc_entries *MLX5_UN_SZ_BYTES (net_function_params); + outlen =max_t (int, outlen, +MLX5_ST_SZ_BYTES (query_esw_functions_out)); + }else { + outlen =MLX5_ST_SZ_BYTES (query_esw_functions_out); + } + out =kvzalloc (outlen,GFP_KERNEL );if (!out)return ERR_PTR (-ENOMEM );
@@ -1076,9 +1093,25 @@ const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev) MLX5_CMD_OP_QUERY_ESW_FUNCTIONS); err =mlx5_cmd_exec (dev, in,sizeof (in), out, outlen); -if (!err) -return out; +if (err) + goto free; + +if (net_func_v1) { +int num_entries; + + num_entries =MLX5_GET (query_esw_functions_out, out, + net_function_num); +if (num_entries > alloc_entries) { +mlx5_core_warn (dev,"Got %d entries, max expected %d\n" , + num_entries, alloc_entries); + err = -EINVAL ; + goto free; + } + } + +return out; +free:kvfree (out);return ERR_PTR (err); }
@@ -1100,12 +1133,55 @@ mlx5_esw_host_pf_from_host_params(const void *entry) }; } -struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (const u32 *out) +static struct mlx5_esw_pf_info +mlx5_esw_host_pf_from_net_func_params (const u8 *entry,int num_entries) +{ +int i; + +for (i =0 ; i < num_entries; i++) { +int pf_type, state; + + pf_type =MLX5_GET (network_function_params, entry, pci_pf_type); +if (pf_type !=MLX5_PCI_PF_TYPE_EXTERNAL_HOST_PF ) { + entry +=MLX5_UN_SZ_BYTES (net_function_params); +continue ; + } + + state =MLX5_GET (network_function_params, entry, vhca_state); + +return (struct mlx5_esw_pf_info ) { + .pf_disabled = state !=MLX5_VHCA_STATE_IN_USE , + .num_of_vfs =MLX5_GET (network_function_params, + entry, pci_num_vfs), + .total_vfs =MLX5_GET (network_function_params, + entry, pci_total_vfs), + .host_number =MLX5_GET (network_function_params, + entry, host_number), + }; + } + +/* No external host PF entry found */ +return (struct mlx5_esw_pf_info ) { + .pf_not_exist = true, + .pf_disabled = true, + }; +} + +struct mlx5_esw_pf_info +mlx5_esw_get_host_pf_info (struct mlx5_core_dev *dev,const u32 *out) {const void *entry; entry =MLX5_ADDR_OF (query_esw_functions_out, out, net_function_params); +if (MLX5_CAP_GEN (dev, query_host_net_function_v1)) { +int num_entries =MLX5_GET (query_esw_functions_out, out, + net_function_num); + +return mlx5_esw_host_pf_from_net_func_params (entry, + num_entries); + } +return mlx5_esw_host_pf_from_host_params (entry); }
@@ -1121,7 +1197,7 @@ static int mlx5_esw_host_functions_enabled_query(struct mlx5_eswitch *esw)if (IS_ERR (query_host_out))return PTR_ERR (query_host_out); - host_pf_info =mlx5_esw_get_host_pf_info (query_host_out); + host_pf_info =mlx5_esw_get_host_pf_info (esw->dev, query_host_out); esw->esw_funcs.host_funcs_disabled = host_pf_info.pf_not_exist;kvfree (query_host_out);
@@ -1561,7 +1637,7 @@ mlx5_eswitch_update_num_of_vfs(struct mlx5_eswitch *esw, int num_vfs)if (IS_ERR (out))return ; - host_pf_info =mlx5_esw_get_host_pf_info (out); + host_pf_info =mlx5_esw_get_host_pf_info (esw->dev, out); esw->esw_funcs.num_vfs = host_pf_info.num_of_vfs;if (mlx5_core_ec_sriov_enabled (esw->dev)) esw->esw_funcs.num_ec_vfs = num_vfs;
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +3 -2
@@ -657,7 +657,8 @@ bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1);const u32 *mlx5_esw_query_functions (struct mlx5_core_dev *dev); -struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (const u32 *out); +struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (struct mlx5_core_dev *dev, +const u32 *out);int mlx5_esw_host_pf_enable_hca (struct mlx5_core_dev *dev);int mlx5_esw_host_pf_disable_hca (struct mlx5_core_dev *dev);
@@ -986,7 +987,7 @@ static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev) }static inline struct mlx5_esw_pf_info -mlx5_esw_get_host_pf_info (const u32 *out) +mlx5_esw_get_host_pf_info (struct mlx5_core_dev *dev,const u32 *out) {return (struct mlx5_esw_pf_info ) {}; }
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +3 -3
@@ -3716,7 +3716,7 @@ static void esw_vfs_changed_event_handler(struct mlx5_eswitch *esw)if (IS_ERR (out))return ; - host_pf_info =mlx5_esw_get_host_pf_info (out); + host_pf_info =mlx5_esw_get_host_pf_info (esw->dev, out); new_num_vfs = host_pf_info.num_of_vfs;if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_info.pf_disabled)
@@ -3832,7 +3832,7 @@ static int mlx5_esw_host_number_init(struct mlx5_eswitch *esw)return PTR_ERR (query_host_out);/* Mark non local controller with non zero controller number. */ - host_pf_info =mlx5_esw_get_host_pf_info (query_host_out); + host_pf_info =mlx5_esw_get_host_pf_info (esw->dev, query_host_out); esw->offloads.host_number = host_pf_info.host_number;kvfree (query_host_out);return 0 ;
@@ -4988,7 +4988,7 @@ int mlx5_devlink_pf_port_fn_state_get(struct devlink_port *port,if (IS_ERR (query_out))return PTR_ERR (query_out); - host_pf_info =mlx5_esw_get_host_pf_info (query_out); + host_pf_info =mlx5_esw_get_host_pf_info (vport->dev, query_out); *opstate = host_pf_info.pf_disabled ? DEVLINK_PORT_FN_OPSTATE_DETACHED :
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +1 -1
@@ -285,7 +285,7 @@ static u16 mlx5_get_max_vfs(struct mlx5_core_dev *dev)*/ if (IS_ERR (out)) goto done; - host_pf_info =mlx5_esw_get_host_pf_info (out); + host_pf_info =mlx5_esw_get_host_pf_info (dev, out); host_total_vfs = host_pf_info.total_vfs;kvfree (out);return host_total_vfs;
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 4/8 net/mlx5: Switch vport HCA cap helpers to kvzalloc
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
mlx5_vport_set_other_func_cap() and mlx5_vport_get_vhca_id() allocate command buffers that embed the HCA capability union, exceeding 4KiB. Use kvzalloc/kvfree so the allocation can fall back to vmalloc when contiguous memory is scarce.
--- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/vport.c +4 -4
@@ -1336,7 +1336,7 @@ int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id)if (mlx5_esw_vport_vhca_id (dev->priv.eswitch, vport, vhca_id))return 0 ; - query_ctx =kzalloc (query_out_sz,GFP_KERNEL ); + query_ctx =kvzalloc (query_out_sz,GFP_KERNEL );if (!query_ctx)return -ENOMEM ;
@@ -1348,7 +1348,7 @@ int mlx5_vport_get_vhca_id(struct mlx5_core_dev *dev, u16 vport, u16 *vhca_id) *vhca_id =MLX5_GET (cmd_hca_cap, hca_caps, vhca_id); out_free: -kfree (query_ctx); +kvfree (query_ctx);return err; }EXPORT_SYMBOL_GPL (mlx5_vport_get_vhca_id);
@@ -1363,7 +1363,7 @@ int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_capvoid *set_ctx;int ret; - set_ctx =kzalloc (set_sz,GFP_KERNEL ); + set_ctx =kvzalloc (set_sz,GFP_KERNEL );if (!set_ctx)return -ENOMEM ;
@@ -1392,6 +1392,6 @@ int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_capMLX5_SET (set_hca_cap_in, set_ctx, function_id, function_id); ret =mlx5_cmd_exec_in (dev, set_hca_cap, set_ctx); -kfree (set_ctx); +kvfree (set_ctx);return ret; }
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 5/8 net/mlx5: Add mlx5_vport_set_other_func_general_cap macro
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
Add mlx5_vport_set_other_func_general_cap() convenience macro, symmetric to the existing mlx5_vport_get_other_func_general_cap(), and use it in mlx5_devlink_port_fn_roce_set().
No functional change in this patch.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -2
@@ -4951,8 +4951,8 @@ int mlx5_devlink_port_fn_roce_set(struct devlink_port *port, bool enable, hca_caps =MLX5_ADDR_OF (query_hca_cap_out, query_ctx, capability);MLX5_SET (cmd_hca_cap, hca_caps, roce, enable); - err =mlx5_vport_set_other_func_cap (esw->dev, hca_caps, vport_num, -MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE ); + err =mlx5_vport_set_other_func_general_cap (esw->dev, hca_caps, + vport_num);if (err) {NL_SET_ERR_MSG_MOD (extack,"Failed setting HCA roce cap" ); goto out_free;
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +4 -0
@@ -457,6 +457,10 @@ int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap#define mlx5_vport_get_other_func_general_cap (dev, vport, out) \ mlx5_vport_get_other_func_cap(dev, vport, out, MLX5_CAP_GENERAL) +#define mlx5_vport_set_other_func_general_cap (dev, hca_cap, vport) \ + mlx5_vport_set_other_func_cap(dev, hca_cap, vport, \ + MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE) +static inline u32 mlx5_sriov_get_vf_total_msix (struct pci_dev *pdev) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev);
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 6/8 net/mlx5: Refactor mlx5_set_msix_vec_count() SET_HCA_CAP
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
Use mlx5_vport_set_other_func_general_cap() instead of open-coding the SET_HCA_CAP command. This removes redundant buffer allocation and ensures consistent use of vport-based function addressing.
mlx5_vport_set_other_func_general_cap() supports both function_id and vhca_id based addressing, so this also enables SET_HCA_CAP for vhca_id indexed functions which was not supported before.
--- .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +7 -20
@@ -87,9 +87,8 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id, int msix_vec_count) {int query_sz =MLX5_ST_SZ_BYTES (query_hca_cap_out); -int set_sz =MLX5_ST_SZ_BYTES (set_hca_cap_in); -void *hca_cap =NULL , *query_cap =NULL , *cap;int num_vf_msix, min_msix, max_msix; +void *query_cap, *hca_caps;bool ec_vf_function;int vport;int ret;
@@ -111,11 +110,8 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,return -EOVERFLOW ; query_cap =kvzalloc (query_sz,GFP_KERNEL ); - hca_cap =kvzalloc (set_sz,GFP_KERNEL ); -if (!hca_cap || !query_cap) { - ret = -ENOMEM ; - goto out; - } +if (!query_cap) +return -ENOMEM ; ec_vf_function =mlx5_core_ec_sriov_enabled (dev); vport =mlx5_core_func_to_vport (dev, function_id, ec_vf_function);
@@ -123,21 +119,12 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,if (ret) goto out; - cap =MLX5_ADDR_OF (set_hca_cap_in, hca_cap, capability); -memcpy (cap,MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability), -MLX5_UN_SZ_BYTES (hca_cap_union)); -MLX5_SET (cmd_hca_cap, cap, dynamic_msix_table_size, msix_vec_count); - -MLX5_SET (set_hca_cap_in, hca_cap, opcode,MLX5_CMD_OP_SET_HCA_CAP ); -MLX5_SET (set_hca_cap_in, hca_cap, other_function,1 ); -MLX5_SET (set_hca_cap_in, hca_cap, ec_vf_function, ec_vf_function); -MLX5_SET (set_hca_cap_in, hca_cap, function_id, function_id); + hca_caps =MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability); +MLX5_SET (cmd_hca_cap, hca_caps, dynamic_msix_table_size, + msix_vec_count); -MLX5_SET (set_hca_cap_in, hca_cap, op_mod, -MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE <<1 ); - ret =mlx5_cmd_exec_in (dev, set_hca_cap, hca_cap); + ret =mlx5_vport_set_other_func_general_cap (dev, hca_caps, vport); out: -kvfree (hca_cap);kvfree (query_cap);return ret; }
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 8/8 net/mlx5: Generalize enable/disable HCA for any PF vport
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
Refactor the host-PF-specific mlx5_cmd_host_pf_enable/disable_hca() into generic mlx5_cmd_pf_enable/disable_hca() that accept a vport number. The new functions use vhca_id as function_id when supported.
Similarly, refactor the eswitch layer into generic static helpers mlx5_esw_pf_enable/disable_hca() with thin wrappers for the host PF case, in preparation for enable_hca on satellite PF vports.
--- .../net/ethernet/mellanox/mlx5/core/ecpf.c | 24 +++++++++++----- .../net/ethernet/mellanox/mlx5/core/ecpf.h | 4 +-- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 28 +++++++++++++------ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 2 ++ .../net/ethernet/mellanox/mlx5/core/vport.c | 4 +-- 5 files changed, 42 insertions(+), 20 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/ecpf.c +17 -7
@@ -18,25 +18,35 @@ static bool mlx5_ecpf_esw_admins_host_pf(const struct mlx5_core_dev *dev)return mlx5_core_is_ecpf_esw_manager (dev); } -int mlx5_cmd_host_pf_enable_hca (struct mlx5_core_dev *dev) +int mlx5_cmd_pf_enable_hca (struct mlx5_core_dev *dev,u16 vport_num) {u32 out[MLX5_ST_SZ_DW (enable_hca_out)] = {};u32 in[MLX5_ST_SZ_DW (enable_hca_in)] = {}; +u16 vhca_id;MLX5_SET (enable_hca_in, in, opcode,MLX5_CMD_OP_ENABLE_HCA ); -MLX5_SET (enable_hca_in, in, function_id,0 ); -MLX5_SET (enable_hca_in, in, embedded_cpu_function,0 ); -return mlx5_cmd_exec (dev, &in,sizeof (in), &out,sizeof (out)); +if (mlx5_vport_use_vhca_id_as_func_id (dev, vport_num, &vhca_id)) { +MLX5_SET (enable_hca_in, in, function_id, vhca_id); +MLX5_SET (enable_hca_in, in, function_id_type,1 ); + }else { +MLX5_SET (enable_hca_in, in, function_id, vport_num); + } +return mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); } -int mlx5_cmd_host_pf_disable_hca (struct mlx5_core_dev *dev) +int mlx5_cmd_pf_disable_hca (struct mlx5_core_dev *dev,u16 vport_num) {u32 out[MLX5_ST_SZ_DW (disable_hca_out)] = {};u32 in[MLX5_ST_SZ_DW (disable_hca_in)] = {}; +u16 vhca_id;MLX5_SET (disable_hca_in, in, opcode,MLX5_CMD_OP_DISABLE_HCA ); -MLX5_SET (disable_hca_in, in, function_id,0 ); -MLX5_SET (disable_hca_in, in, embedded_cpu_function,0 ); +if (mlx5_vport_use_vhca_id_as_func_id (dev, vport_num, &vhca_id)) { +MLX5_SET (disable_hca_in, in, function_id, vhca_id); +MLX5_SET (disable_hca_in, in, function_id_type,1 ); + }else { +MLX5_SET (disable_hca_in, in, function_id, vport_num); + }return mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); }
drivers/net/ethernet/mellanox/mlx5/core/ecpf.h +2 -2
@@ -17,8 +17,8 @@ bool mlx5_read_embedded_cpu(struct mlx5_core_dev *dev);int mlx5_ec_init (struct mlx5_core_dev *dev);void mlx5_ec_cleanup (struct mlx5_core_dev *dev); -int mlx5_cmd_host_pf_enable_hca (struct mlx5_core_dev *dev); -int mlx5_cmd_host_pf_disable_hca (struct mlx5_core_dev *dev); +int mlx5_cmd_pf_enable_hca (struct mlx5_core_dev *dev,u16 vport_num); +int mlx5_cmd_pf_disable_hca (struct mlx5_core_dev *dev,u16 vport_num);#else /* CONFIG_MLX5_ESWITCH */
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +19 -9
@@ -1452,7 +1452,7 @@ static int mlx5_eswitch_load_ec_vf_vports(struct mlx5_eswitch *esw, u16 num_ec_vreturn err; } -int mlx5_esw_host_pf_enable_hca (struct mlx5_core_dev *dev) +static int mlx5_esw_pf_enable_hca (struct mlx5_core_dev *dev,u16 vport_num) {struct mlx5_eswitch *esw = dev->priv.eswitch;struct mlx5_vport *vport;
@@ -1461,15 +1461,15 @@ int mlx5_esw_host_pf_enable_hca(struct mlx5_core_dev *dev)if (!mlx5_core_is_ecpf (dev) || !mlx5_esw_allowed (esw))return 0 ; - vport =mlx5_eswitch_get_vport (esw,MLX5_VPORT_HOST_PF ); + vport =mlx5_eswitch_get_vport (esw, vport_num);if (IS_ERR (vport))return PTR_ERR (vport); -/* Once vport and representor are ready, take out the external host PF -* out of initializing state. Enabling HCA clears the iser->initializing -* bit and host PF driver loading can progress. +/* Once vport and representor are ready, take the PF out of +* initializing state. Enabling HCA clears the iser->initializing +* bit and PF driver loading can progress. */ - err =mlx5_cmd_host_pf_enable_hca (dev); + err =mlx5_cmd_pf_enable_hca (dev, vport_num);if (err)return err;
@@ -1478,7 +1478,7 @@ int mlx5_esw_host_pf_enable_hca(struct mlx5_core_dev *dev)return 0 ; } -int mlx5_esw_host_pf_disable_hca (struct mlx5_core_dev *dev) +static int mlx5_esw_pf_disable_hca (struct mlx5_core_dev *dev,u16 vport_num) {struct mlx5_eswitch *esw = dev->priv.eswitch;struct mlx5_vport *vport;
@@ -1487,11 +1487,11 @@ int mlx5_esw_host_pf_disable_hca(struct mlx5_core_dev *dev)if (!mlx5_core_is_ecpf (dev) || !mlx5_esw_allowed (esw))return 0 ; - vport =mlx5_eswitch_get_vport (esw,MLX5_VPORT_HOST_PF ); + vport =mlx5_eswitch_get_vport (esw, vport_num);if (IS_ERR (vport))return PTR_ERR (vport); - err =mlx5_cmd_host_pf_disable_hca (dev); + err =mlx5_cmd_pf_disable_hca (dev, vport_num);if (err)return err;
@@ -1500,6 +1500,16 @@ int mlx5_esw_host_pf_disable_hca(struct mlx5_core_dev *dev)return 0 ; } +int mlx5_esw_host_pf_enable_hca (struct mlx5_core_dev *dev) +{ +return mlx5_esw_pf_enable_hca (dev,MLX5_VPORT_HOST_PF ); +} + +int mlx5_esw_host_pf_disable_hca (struct mlx5_core_dev *dev) +{ +return mlx5_esw_pf_disable_hca (dev,MLX5_VPORT_HOST_PF ); +} +/* mlx5_eswitch_enable_pf_vf_vports() enables vports of PF, ECPF and VFs * whichever are present on the eswitch. */
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +2 -0
@@ -452,6 +452,8 @@ void mlx5_unload_one_light(struct mlx5_core_dev *dev);void mlx5_query_nic_sw_system_image_guid (struct mlx5_core_dev *mdev,u8 *buf,u8 *len); +bool mlx5_vport_use_vhca_id_as_func_id (struct mlx5_core_dev *dev, +u16 vport_num,u16 *vhca_id);int mlx5_vport_set_other_func_cap (struct mlx5_core_dev *dev,const void *hca_cap,u16 vport,u16 opmod);#define mlx5_vport_get_other_func_general_cap (dev, vport, out) \
drivers/net/ethernet/mellanox/mlx5/core/vport.c +2 -2
@@ -1283,8 +1283,8 @@ void mlx5_query_nic_sw_system_image_guid(struct mlx5_core_dev *mdev, u8 *buf, buf[(*len)++] =MLX5_CAP_GEN_2 (mdev, load_balance_id); } -static bool mlx5_vport_use_vhca_id_as_func_id (struct mlx5_core_dev *dev, -u16 vport_num,u16 *vhca_id) +bool mlx5_vport_use_vhca_id_as_func_id (struct mlx5_core_dev *dev, +u16 vport_num,u16 *vhca_id) {if (!MLX5_CAP_GEN_2 (dev, function_id_type_vhca_id))return false;
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 7/8 net/mlx5: Use vport helper for IPsec eswitch set caps
In reply to Tariq ToukanFrom: Moshe Shemesh <[email protected]>
Use mlx5_vport_set_other_func_cap() and mlx5_vport_set_other_func_general_cap() in the IPsec eswitch functions instead of open-coding the SET_HCA_CAP command. This removes redundant buffer allocation and boilerplate, and also enables vhca_id based addressing when supported.
--- .../ethernet/mellanox/mlx5/core/esw/ipsec.c | 81 ++++++------------- 1 file changed, 23 insertions(+), 58 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec.c +23 -58
@@ -81,38 +81,25 @@ int mlx5_esw_ipsec_vf_offload_get(struct mlx5_core_dev *dev, struct mlx5_vport *static int esw_ipsec_vf_set_generic (struct mlx5_core_dev *dev,u16 vport_num,bool ipsec_ofld) {int query_sz =MLX5_ST_SZ_BYTES (query_hca_cap_out); -int set_sz =MLX5_ST_SZ_BYTES (set_hca_cap_in); -void *hca_cap, *query_cap, *cap; +void *query_cap, *hca_caps;int ret;if (!MLX5_CAP_GEN (dev, vhca_resource_manager))return -EOPNOTSUPP ; query_cap =kvzalloc (query_sz,GFP_KERNEL ); - hca_cap =kvzalloc (set_sz,GFP_KERNEL ); -if (!hca_cap || !query_cap) { - ret = -ENOMEM ; - goto free; - } +if (!query_cap) +return -ENOMEM ; ret =mlx5_vport_get_other_func_general_cap (dev, vport_num, query_cap);if (ret) goto free; - cap =MLX5_ADDR_OF (set_hca_cap_in, hca_cap, capability); -memcpy (cap,MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability), -MLX5_UN_SZ_BYTES (hca_cap_union)); -MLX5_SET (cmd_hca_cap, cap, ipsec_offload, ipsec_ofld); + hca_caps =MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability); +MLX5_SET (cmd_hca_cap, hca_caps, ipsec_offload, ipsec_ofld); -MLX5_SET (set_hca_cap_in, hca_cap, opcode,MLX5_CMD_OP_SET_HCA_CAP ); -MLX5_SET (set_hca_cap_in, hca_cap, other_function,1 ); -MLX5_SET (set_hca_cap_in, hca_cap, function_id, vport_num); - -MLX5_SET (set_hca_cap_in, hca_cap, op_mod, -MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE <<1 ); - ret =mlx5_cmd_exec_in (dev, set_hca_cap, hca_cap); + ret =mlx5_vport_set_other_func_general_cap (dev, hca_caps, vport_num); free: -kvfree (hca_cap);kvfree (query_cap);return ret; }
@@ -121,49 +108,37 @@ static int esw_ipsec_vf_set_bytype(struct mlx5_core_dev *dev, struct mlx5_vport bool enable, enum esw_vport_ipsec_offload type) { int query_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out); -int set_sz =MLX5_ST_SZ_BYTES (set_hca_cap_in); -void *hca_cap, *query_cap, *cap; +void *query_cap, *hca_caps;int ret;if (!MLX5_CAP_GEN (dev, vhca_resource_manager))return -EOPNOTSUPP ; query_cap =kvzalloc (query_sz,GFP_KERNEL ); - hca_cap =kvzalloc (set_sz,GFP_KERNEL ); -if (!hca_cap || !query_cap) { - ret = -ENOMEM ; - goto free; - } +if (!query_cap) +return -ENOMEM ; ret =mlx5_vport_get_other_func_cap (dev, vport->vport, query_cap,MLX5_CAP_IPSEC );if (ret) goto free; - cap =MLX5_ADDR_OF (set_hca_cap_in, hca_cap, capability); -memcpy (cap,MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability), -MLX5_UN_SZ_BYTES (hca_cap_union)); + hca_caps =MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability);switch (type) {case MLX5_ESW_VPORT_IPSEC_CRYPTO_OFFLOAD : -MLX5_SET (ipsec_cap, cap, ipsec_crypto_offload, enable); +MLX5_SET (ipsec_cap, hca_caps, ipsec_crypto_offload, enable);break ;case MLX5_ESW_VPORT_IPSEC_PACKET_OFFLOAD : -MLX5_SET (ipsec_cap, cap, ipsec_full_offload, enable); +MLX5_SET (ipsec_cap, hca_caps, ipsec_full_offload, enable);break ;default : ret = -EOPNOTSUPP ; goto free; } -MLX5_SET (set_hca_cap_in, hca_cap, opcode,MLX5_CMD_OP_SET_HCA_CAP ); -MLX5_SET (set_hca_cap_in, hca_cap, other_function,1 ); -MLX5_SET (set_hca_cap_in, hca_cap, function_id, vport->vport); - -MLX5_SET (set_hca_cap_in, hca_cap, op_mod, -MLX5_SET_HCA_CAP_OP_MOD_IPSEC <<1 ); - ret =mlx5_cmd_exec_in (dev, set_hca_cap, hca_cap); + ret =mlx5_vport_set_other_func_cap (dev, hca_caps, vport->vport, +MLX5_SET_HCA_CAP_OP_MOD_IPSEC ); free: -kvfree (hca_cap);kvfree (query_cap);return ret; }
@@ -171,34 +146,24 @@ static int esw_ipsec_vf_set_bytype(struct mlx5_core_dev *dev, struct mlx5_vportstatic int esw_ipsec_vf_crypto_aux_caps_set (struct mlx5_core_dev *dev,u16 vport_num,bool enable) {int query_sz =MLX5_ST_SZ_BYTES (query_hca_cap_out); -int set_sz =MLX5_ST_SZ_BYTES (set_hca_cap_in); -struct mlx5_eswitch *esw = dev->priv.eswitch; -void *hca_cap, *query_cap, *cap; +void *query_cap, *hca_caps;int ret; query_cap =kvzalloc (query_sz,GFP_KERNEL ); - hca_cap =kvzalloc (set_sz,GFP_KERNEL ); -if (!hca_cap || !query_cap) { - ret = -ENOMEM ; - goto free; - } +if (!query_cap) +return -ENOMEM ; ret =mlx5_vport_get_other_func_cap (dev, vport_num, query_cap,MLX5_CAP_ETHERNET_OFFLOADS );if (ret) goto free; - cap =MLX5_ADDR_OF (set_hca_cap_in, hca_cap, capability); -memcpy (cap,MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability), -MLX5_UN_SZ_BYTES (hca_cap_union)); -MLX5_SET (per_protocol_networking_offload_caps, cap, insert_trailer, enable); -MLX5_SET (set_hca_cap_in, hca_cap, opcode,MLX5_CMD_OP_SET_HCA_CAP ); -MLX5_SET (set_hca_cap_in, hca_cap, other_function,1 ); -MLX5_SET (set_hca_cap_in, hca_cap, function_id, vport_num); -MLX5_SET (set_hca_cap_in, hca_cap, op_mod, -MLX5_SET_HCA_CAP_OP_MOD_ETHERNET_OFFLOADS <<1 ); - ret =mlx5_cmd_exec_in (esw->dev, set_hca_cap, hca_cap); + hca_caps =MLX5_ADDR_OF (query_hca_cap_out, query_cap, capability); +MLX5_SET (per_protocol_networking_offload_caps, hca_caps, + insert_trailer, enable); + + ret =mlx5_vport_set_other_func_cap (dev, hca_caps, vport_num, +MLX5_SET_HCA_CAP_OP_MOD_ETHERNET_OFFLOADS ); free: -kvfree (hca_cap);kvfree (query_cap);return ret; }
Signature · 1 line
2.44.0
Jakub Kicinski
maintainerQuoted 2 lines · On Sun, 10 May 2026 08:34:40 +0300 Tariq Toukan wrote:
This series prepares the mlx5 eswitch command interface and vport infrastructure for satellite PF support.
Could you perhaps start by explaining what "satellite PF" is? And how it differs from "socket direct"
Quoted 9 lines · Jakub Kicinski
External email: Use caution opening links or attachments
Quoted 2 lines · On Sun, 10 May 2026 08:34:40 +0300 Tariq Toukan wrote:
This series prepares the mlx5 eswitch command interface and vport infrastructure for satellite PF support.
Could you perhaps start by explaining what "satellite PF" is? And how it differs from "socket direct"
Satellite PF is another type of Physical Function, its role and privileges are similar to the host PF, but unlike host PF the Satellite PF is on the DPU and not on another host. So it's kind of "Satellite" for the ECPF which is also on the DPU.
The next patchset will introduce the Satellite PF, while this patchset only does some preparations. Small changes to prepare the eswitch to manage another PF.
While Socket Direct is a hardware PCIe topology, that adds another PCIe link to the NIC, the Satellite PF is just logical entity, by firmware configuration, no hardware change.
Thanks, Moshe.
Paolo Abeni
maintainerQuoted 16 lines · Moshe Shemesh
Quoted 9 lines · Jakub Kicinski
External email: Use caution opening links or attachments
Quoted 2 lines · On Sun, 10 May 2026 08:34:40 +0300 Tariq Toukan wrote:
This series prepares the mlx5 eswitch command interface and vport infrastructure for satellite PF support.
Could you perhaps start by explaining what "satellite PF" is? And how it differs from "socket direct"
Satellite PF is another type of Physical Function, its role and privileges are similar to the host PF, but unlike host PF the Satellite PF is on the DPU and not on another host. So it's kind of "Satellite" for the ECPF which is also on the DPU.
Quoted 7 lines
The next patchset will introduce the Satellite PF, while this patchset only does some preparations. Small changes to prepare the eswitch to manage another PF.
While Socket Direct is a hardware PCIe topology, that adds another PCIe link to the NIC, the Satellite PF is just logical entity, by firmware configuration, no hardware change.
My understanding is that Jakub wants you to capture the above info in the cover letter.
Thanks,
Paolo
Paolo Abeni
maintainerQuoted 21 lines · Paolo Abeni
Quoted 20 lines · Moshe Shemesh
Quoted 9 lines · Jakub Kicinski
External email: Use caution opening links or attachments
Quoted 2 lines · On Sun, 10 May 2026 08:34:40 +0300 Tariq Toukan wrote:
This series prepares the mlx5 eswitch command interface and vport infrastructure for satellite PF support.
Could you perhaps start by explaining what "satellite PF" is? And how it differs from "socket direct"
Satellite PF is another type of Physical Function, its role and privileges are similar to the host PF, but unlike host PF the Satellite PF is on the DPU and not on another host. So it's kind of "Satellite" for the ECPF which is also on the DPU.
The next patchset will introduce the Satellite PF, while this patchset only does some preparations. Small changes to prepare the eswitch to manage another PF.
Quoted 6 lines
Quoted 3 lines
While Socket Direct is a hardware PCIe topology, that adds another PCIe link to the NIC, the Satellite PF is just logical entity, by firmware configuration, no hardware change.
My understanding is that Jakub wants you to capture the above info in the cover letter.
I take my own words back. Actually I'm not sure about the above and given the constant ML flood I think we prefer to avoid a repost if possible. The series LGTM, please wait a bit for Jakub eventual explicit repost request.
Thanks,
Paolo
Simon Horman
reviewerRe: [PATCH net-next 2/8] net/mlx5: Use v1 response layout for query_esw_functions
In reply to Tariq ToukanFrom: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
net/mlx5: Use v1 response layout for query_esw_functions
This patch teaches mlx5_esw_query_functions() to use the v1 response layout (MLX5_QUERY_ESW_FUNC_OP_MOD_LAYOUT_V1) when the firmware advertises query_host_net_function_v1, allocates the output buffer based on query_host_net_function_num_max, and adds a parser for the new network_function_params layout in mlx5_esw_get_host_pf_info().
Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0
-0
[ ... ]
Quoted 13 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8
-1@@ -1100,12 +1133,55 @@ mlx5_esw_host_pf_from_host_params(const void *entry) }; } -struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (const u32 *out) +static struct mlx5_esw_pf_info +mlx5_esw_host_pf_from_net_func_params (const u8 *entry,int num_entries) +{ +int i; + +for (i =0 ; i < num_entries; i++) { +int pf_type, state; +
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c mlx5_esw_host_pf_from_host_params(const void *entry) · line 1153
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +10
-0+ pf_type =MLX5_GET (network_function_params, entry, pci_pf_type); +if (pf_type !=MLX5_PCI_PF_TYPE_EXTERNAL_HOST_PF ) { + entry +=MLX5_UN_SZ_BYTES (net_function_params); +continue ; + } + + state =MLX5_GET (network_function_params, entry, vhca_state); + +return (struct mlx5_esw_pf_info ) { + .pf_disabled = state !=MLX5_VHCA_STATE_IN_USE ,
[Medium]
The commit message says "this change does not introduce new functionality," but the legacy parser reads an explicit firmware host_pf_disabled bit while the v1 parser derives pf_disabled from a multi-valued vhca_state enum:
.pf_disabled = state != MLX5_VHCA_STATE_IN_USE,
Is this mapping intended to be exactly equivalent to the legacy host_pf_disabled bit across all five vhca_state values (INVALID/ALLOCATED/ACTIVE/IN_USE/TEARDOWN_REQUEST)?
The same vhca_state value is interpreted differently elsewhere in mlx5 for SFs. mlx5_sf_to_devlink_opstate() in drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c reports:
case MLX5_VHCA_STATE_IN_USE:
case MLX5_VHCA_STATE_TEARDOWN_REQUEST:
return DEVLINK_PORT_FN_OPSTATE_ATTACHED;
case MLX5_VHCA_STATE_INVALID:
case MLX5_VHCA_STATE_ALLOCATED:
case MLX5_VHCA_STATE_ACTIVE:
default:
return DEVLINK_PORT_FN_OPSTATE_DETACHED;so SFs in TEARDOWN_REQUEST are reported as ATTACHED, while a host PF in TEARDOWN_REQUEST would now end up as pf_disabled = true and therefore DETACHED via mlx5_devlink_pf_port_fn_state_get():
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c mlx5_esw_host_pf_from_host_params(const void *entry) · line 1161
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8
-0+ .num_of_vfs = MLX5_GET(network_function_params, + entry, pci_num_vfs), + .total_vfs = MLX5_GET(network_function_params, + entry, pci_total_vfs), + .host_number = MLX5_GET(network_function_params, + entry, host_number), + }; + }
[Medium]pf_disabled also feeds esw_vfs_changed_event_handler(), which skips VF reload when it is true:
Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0
-0@@ -3716,7 +3716,7 @@ static void esw_vfs_changed_event_handler(struct mlx5_eswitch *esw)
[ ... ]
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1
-1- host_pf_info =mlx5_esw_get_host_pf_info (out); + host_pf_info =mlx5_esw_get_host_pf_info (esw->dev, out); new_num_vfs = host_pf_info.num_of_vfs;if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_info.pf_disabled)
Could the commit message spell out the firmware/PRM mapping between the legacy host_pf_disabled bit and the vhca_state enum so it is clear that ACTIVE, ALLOCATED and TEARDOWN_REQUEST really should be treated as disabled here?
Would it also be worth aligning with mlx5_sf_to_devlink_opstate() (at least for TEARDOWN_REQUEST) so the devlink opstate reported via mlx5_devlink_pf_port_fn_state_get() stays consistent between SFs and host PFs on v1-capable firmware?
Re: [PATCH net-next 1/8] net/mlx5: Use helper to parse host PF info
In reply to Tariq ToukanQuoted 6 lines · Tariq Toukan
From: Moshe Shemesh <[email protected]>
Add a helper
mlx5_esw_get_host_pf_info()to retrieve host PF data from thequery_esw_functionscommand output, so callers no longer need to parse the layout to obtain the required information.
Quoted 6 lines
Convert all callers of
mlx5_esw_query_functions()to use the new helper, preparing for upcoming support of the newop_modthat returns data in thenetwork_function_paramslayout.Signed-off-by Moshe Shemesh <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
Jakub Kicinski
maintainerQuoted 4 lines · On Thu, 14 May 2026 10:56:26 +0300 Moshe Shemesh wrote:
Satellite PF is another type of Physical Function, its role and privileges are similar to the host PF, but unlike host PF the Satellite PF is on the DPU and not on another host. So it's kind of "Satellite" for the ECPF which is also on the DPU.
Do you genuinely think these 2 sentences explain anything?
Maybe it's just me. If anyone reading this thinks Moshe's explanation clarifies things - please speak up..
Quoted 10 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 14 May 2026 10:56:26 +0300 Moshe Shemesh wrote:
Satellite PF is another type of Physical Function, its role and privileges are similar to the host PF, but unlike host PF the Satellite PF is on the DPU and not on another host. So it's kind of "Satellite" for the ECPF which is also on the DPU.
Do you genuinely think these 2 sentences explain anything?
Maybe it's just me. If anyone reading this thinks Moshe's explanation clarifies things - please speak up..
OK, let me explain the idea of this feature:
Currently in Smartnic configuration we have 2 Physical Functions : one is the ECPF on the DPU, and it is the eswitch manager and page manager, while the other is the host PF on the external host and it doesn't have privileges of eswitch manager or page manager.
Now we have a new Smartnic configuration that adds another physical function, on the DPU, that is not eswitch manager and not page manager. The new PF can have its own SFs and the customer can passthrough this Satellite PF to a VM on the DPU and give it to a user that should not have access to the ECPF privileged function. As will be shown in the next patchset, the ECPF handles the Satellite PF and the Host PF in a similar way, using the same management framework.
Re: [PATCH net-next 2/8] net/mlx5: Use v1 response layout for query_esw_functions
In reply to Simon HormanQuoted 70 lines · Simon Horman
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
net/mlx5: Use v1 response layout forquery_esw_functionsThis patch teaches
mlx5_esw_query_functions()to use the v1 response layout (MLX5_QUERY_ESW_FUNC_OP_MOD_LAYOUT_V1) when the firmware advertisesquery_host_net_function_v1, allocates the output buffer based onquery_host_net_function_num_max, and adds a parser for the newnetwork_function_paramslayout inmlx5_esw_get_host_pf_info().Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0
-0[ ... ]
Quoted 13 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8
-1@@ -1100,12 +1133,55 @@ mlx5_esw_host_pf_from_host_params(const void *entry) }; } -struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (const u32 *out) +static struct mlx5_esw_pf_info +mlx5_esw_host_pf_from_net_func_params (const u8 *entry,int num_entries) +{ +int i; + +for (i =0 ; i < num_entries; i++) { +int pf_type, state; +drivers/net/ethernet/mellanox/mlx5/core/eswitch.c mlx5_esw_host_pf_from_host_params(const void *entry) · line 1153
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +10
-0+ pf_type =MLX5_GET (network_function_params, entry, pci_pf_type); +if (pf_type !=MLX5_PCI_PF_TYPE_EXTERNAL_HOST_PF ) { + entry +=MLX5_UN_SZ_BYTES (net_function_params); +continue ; + } + + state =MLX5_GET (network_function_params, entry, vhca_state); + +return (struct mlx5_esw_pf_info ) { + .pf_disabled = state !=MLX5_VHCA_STATE_IN_USE ,[Medium]
The commit message says "this change does not introduce new functionality," but the legacy parser reads an explicit firmwarehost_pf_disabledbit while the v1 parser derivespf_disabledfrom a multi-valuedvhca_stateenum:.pf_disabled = state != MLX5_VHCA_STATE_IN_USE,Is this mapping intended to be exactly equivalent to the legacy
host_pf_disabledbit across all fivevhca_statevalues (INVALID/ALLOCATED/ACTIVE/IN_USE/TEARDOWN_REQUEST)?The same
vhca_statevalue is interpreted differently elsewhere in mlx5 for SFs.mlx5_sf_to_devlink_opstate()indrivers/net/ethernet/mellanox/mlx5/core/sf/devlink.creports:case MLX5_VHCA_STATE_IN_USE: case MLX5_VHCA_STATE_TEARDOWN_REQUEST: return DEVLINK_PORT_FN_OPSTATE_ATTACHED; case MLX5_VHCA_STATE_INVALID: case MLX5_VHCA_STATE_ALLOCATED: case MLX5_VHCA_STATE_ACTIVE: default: return DEVLINK_PORT_FN_OPSTATE_DETACHED;
Quoted 3 lines
so SFs in
TEARDOWN_REQUESTare reported as ATTACHED, while a host PF inTEARDOWN_REQUESTwould now end up aspf_disabled= true and therefore DETACHED viamlx5_devlink_pf_port_fn_state_get():
PFs do not use the state TEARDOWN_REQUEST.
Once the ECPF sets the PF disbale_hca, it is down and can't be used till ECPF does PF enable_hca. So state != MLX5_VHCA_STATE_IN_USE is the equivalent to the legacy host_pf_disabled.
Quoted 20 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c mlx5_esw_host_pf_from_host_params(const void *entry) · line 1161
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8
-0+ .num_of_vfs = MLX5_GET(network_function_params, + entry, pci_num_vfs), + .total_vfs = MLX5_GET(network_function_params, + entry, pci_total_vfs), + .host_number = MLX5_GET(network_function_params, + entry, host_number), + }; + }[Medium]
pf_disabledalso feedsesw_vfs_changed_event_handler(), which skips VF reload when it is true:Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0
-0@@ -3716,7 +3716,7 @@ static void esw_vfs_changed_event_handler(struct mlx5_eswitch *esw)[ ... ]
Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1
-1- host_pf_info =mlx5_esw_get_host_pf_info (out); + host_pf_info =mlx5_esw_get_host_pf_info (esw->dev, out); new_num_vfs = host_pf_info.num_of_vfs;
Quoted 6 lines
Quoted 1 line
if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_info.pf_disabled)Could the commit message spell out the
firmware/PRMmapping between the legacyhost_pf_disabledbit and thevhca_stateenum so it is clear that ACTIVE, ALLOCATED andTEARDOWN_REQUESTreally should be treated as disabled here?
Yes, I can add explanation on that in commit message.
Quoted 5 lines
Would it also be worth aligning with
mlx5_sf_to_devlink_opstate()(at least forTEARDOWN_REQUEST) so the devlink opstate reported viamlx5_devlink_pf_port_fn_state_get()stays consistent between SFs and host PFs on v1-capable firmware?
Same answer as first comment above.
Simon Horman
reviewerRe: [PATCH net-next 2/8] net/mlx5: Use v1 response layout for query_esw_functions
Quoted 77 lines · Moshe Shemesh
Quoted 70 lines · Simon Horman
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
net/mlx5: Use v1 response layout forquery_esw_functionsThis patch teaches
mlx5_esw_query_functions()to use the v1 response layout (MLX5_QUERY_ESW_FUNC_OP_MOD_LAYOUT_V1) when the firmware advertisesquery_host_net_function_v1, allocates the output buffer based onquery_host_net_function_num_max, and adds a parser for the newnetwork_function_paramslayout inmlx5_esw_get_host_pf_info().Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0
-0[ ... ]
Quoted 13 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8
-1@@ -1100,12 +1133,55 @@ mlx5_esw_host_pf_from_host_params(const void *entry) }; } -struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info (const u32 *out) +static struct mlx5_esw_pf_info +mlx5_esw_host_pf_from_net_func_params (const u8 *entry,int num_entries) +{ +int i; + +for (i =0 ; i < num_entries; i++) { +int pf_type, state; +drivers/net/ethernet/mellanox/mlx5/core/eswitch.c mlx5_esw_host_pf_from_host_params(const void *entry) · line 1153
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +10
-0+ pf_type =MLX5_GET (network_function_params, entry, pci_pf_type); +if (pf_type !=MLX5_PCI_PF_TYPE_EXTERNAL_HOST_PF ) { + entry +=MLX5_UN_SZ_BYTES (net_function_params); +continue ; + } + + state =MLX5_GET (network_function_params, entry, vhca_state); + +return (struct mlx5_esw_pf_info ) { + .pf_disabled = state !=MLX5_VHCA_STATE_IN_USE ,[Medium]
The commit message says "this change does not introduce new functionality," but the legacy parser reads an explicit firmwarehost_pf_disabledbit while the v1 parser derivespf_disabledfrom a multi-valuedvhca_stateenum:.pf_disabled = state != MLX5_VHCA_STATE_IN_USE,Is this mapping intended to be exactly equivalent to the legacy
host_pf_disabledbit across all fivevhca_statevalues (INVALID/ALLOCATED/ACTIVE/IN_USE/TEARDOWN_REQUEST)?The same
vhca_statevalue is interpreted differently elsewhere in mlx5 for SFs.mlx5_sf_to_devlink_opstate()indrivers/net/ethernet/mellanox/mlx5/core/sf/devlink.creports:case MLX5_VHCA_STATE_IN_USE: case MLX5_VHCA_STATE_TEARDOWN_REQUEST: return DEVLINK_PORT_FN_OPSTATE_ATTACHED; case MLX5_VHCA_STATE_INVALID: case MLX5_VHCA_STATE_ALLOCATED: case MLX5_VHCA_STATE_ACTIVE: default: return DEVLINK_PORT_FN_OPSTATE_DETACHED;Quoted 3 lines
so SFs in
TEARDOWN_REQUESTare reported as ATTACHED, while a host PF inTEARDOWN_REQUESTwould now end up aspf_disabled= true and therefore DETACHED viamlx5_devlink_pf_port_fn_state_get():
Quoted 5 lines
PFs do not use the state
TEARDOWN_REQUEST.
Once the ECPF sets the PFdisbale_hca, it is down and can't be used till ECPF does PFenable_hca.
So state !=MLX5_VHCA_STATE_IN_USEis the equivalent to the legacyhost_pf_disabled.
This was the main thing I was concerned about.
Thanks for clarifying.
Quoted 39 lines
Quoted 21 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c mlx5_esw_host_pf_from_host_params(const void *entry) · line 1161
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +8
-0+ .num_of_vfs = MLX5_GET(network_function_params, + entry, pci_num_vfs), + .total_vfs = MLX5_GET(network_function_params, + entry, pci_total_vfs), + .host_number = MLX5_GET(network_function_params, + entry, host_number), + }; + }[Medium]
pf_disabledalso feedsesw_vfs_changed_event_handler(), which skips VF reload when it is true:Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0
-0@@ -3716,7 +3716,7 @@ static void esw_vfs_changed_event_handler(struct mlx5_eswitch *esw)[ ... ]
Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1
-1- host_pf_info =mlx5_esw_get_host_pf_info (out); + host_pf_info =mlx5_esw_get_host_pf_info (esw->dev, out); new_num_vfs = host_pf_info.num_of_vfs;Quoted 6 lines
Quoted 1 line
if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_info.pf_disabled)Could the commit message spell out the
firmware/PRMmapping between the legacyhost_pf_disabledbit and thevhca_stateenum so it is clear that ACTIVE, ALLOCATED andTEARDOWN_REQUESTreally should be treated as disabled here?Yes, I can add explanation on that in commit message.
Quoted 5 lines
Would it also be worth aligning with
mlx5_sf_to_devlink_opstate()(at least forTEARDOWN_REQUEST) so the devlink opstate reported viamlx5_devlink_pf_port_fn_state_get()stays consistent between SFs and host PFs on v1-capable firmware?Same answer as first comment above.
Jakub Kicinski
maintainerQuoted 7 lines · On Fri, 15 May 2026 12:36:50 +0300 Moshe Shemesh wrote:
Now we have a new Smartnic configuration that adds another physical function, on the DPU, that is not eswitch manager and not page manager. The new PF can have its own SFs and the customer can passthrough this Satellite PF to a VM on the DPU and give it to a user that should not have access to the ECPF privileged function.
As will be shown in the next patchset, the ECPF handles the Satellite PF and the Host PF in a similar way, using the same management framework.
Makes sense! Please respin with this in the cover letter and the clarification in patch 2. Thanks!