@@ -1898,6 +1898,42 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
18981898 return err ;
18991899}
19001900
1901+ int mlx5_devlink_port_function_hw_addr_set (struct devlink * devlink ,
1902+ struct devlink_port * port ,
1903+ const u8 * hw_addr , int hw_addr_len ,
1904+ struct netlink_ext_ack * extack )
1905+ {
1906+ struct mlx5_eswitch * esw ;
1907+ struct mlx5_vport * vport ;
1908+ int err = - EOPNOTSUPP ;
1909+ u16 vport_num ;
1910+
1911+ esw = mlx5_devlink_eswitch_get (devlink );
1912+ if (IS_ERR (esw )) {
1913+ NL_SET_ERR_MSG_MOD (extack , "Eswitch doesn't support set hw_addr" );
1914+ return PTR_ERR (esw );
1915+ }
1916+
1917+ vport_num = mlx5_esw_devlink_port_index_to_vport_num (port -> index );
1918+ if (!is_port_function_supported (esw , vport_num )) {
1919+ NL_SET_ERR_MSG_MOD (extack , "Port doesn't support set hw_addr" );
1920+ return - EINVAL ;
1921+ }
1922+ vport = mlx5_eswitch_get_vport (esw , vport_num );
1923+ if (IS_ERR (vport )) {
1924+ NL_SET_ERR_MSG_MOD (extack , "Invalid port" );
1925+ return PTR_ERR (vport );
1926+ }
1927+
1928+ mutex_lock (& esw -> state_lock );
1929+ if (vport -> enabled )
1930+ err = mlx5_esw_set_vport_mac_locked (esw , vport , hw_addr );
1931+ else
1932+ NL_SET_ERR_MSG_MOD (extack , "Eswitch vport is disabled" );
1933+ mutex_unlock (& esw -> state_lock );
1934+ return err ;
1935+ }
1936+
19011937int mlx5_eswitch_set_vport_state (struct mlx5_eswitch * esw ,
19021938 u16 vport , int link_state )
19031939{
0 commit comments