Skip to content

Commit e02b941

Browse files
jjagielskgregkh
authored andcommitted
devlink: let driver opt out of automatic phys_port_name generation
[ Upstream commit c5ec7f4 ] Currently when adding devlink port, phys_port_name is automatically generated within devlink port initialization flow. As a result adding devlink port support to driver may result in forced changes of interface names, which breaks already existing network configs. This is an expected behavior but in some scenarios it would not be preferable to provide such limitation for legacy driver not being able to keep 'pre-devlink' interface name. Add flag no_phys_port_name to devlink_port_attrs struct which indicates if devlink should not alter name of interface. Suggested-by: Jiri Pirko <jiri@resnulli.us> Link: https://lore.kernel.org/all/nbwrfnjhvrcduqzjl4a2jafnvvud6qsbxlvxaxilnryglf4j7r@btuqrimnfuly/ Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Cc: stable@vger.kernel.org # 6.16 Tested-By: Calvin Owens <calvin@wbinvd.org> Signed-off-by: Calvin Owens <calvin@wbinvd.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ce94b5a commit e02b941

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

include/net/devlink.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ struct devlink_port_pci_sf_attrs {
7878
* @flavour: flavour of the port
7979
* @split: indicates if this is split port
8080
* @splittable: indicates if the port can be split.
81+
* @no_phys_port_name: skip automatic phys_port_name generation; for
82+
* compatibility only, newly added driver/port instance
83+
* should never set this.
8184
* @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink.
8285
* @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL
8386
* @phys: physical port attributes
@@ -87,7 +90,8 @@ struct devlink_port_pci_sf_attrs {
8790
*/
8891
struct devlink_port_attrs {
8992
u8 split:1,
90-
splittable:1;
93+
splittable:1,
94+
no_phys_port_name:1;
9195
u32 lanes;
9296
enum devlink_port_flavour flavour;
9397
struct netdev_phys_item_id switch_id;

net/devlink/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
15191519
struct devlink_port_attrs *attrs = &devlink_port->attrs;
15201520
int n = 0;
15211521

1522-
if (!devlink_port->attrs_set)
1522+
if (!devlink_port->attrs_set || devlink_port->attrs.no_phys_port_name)
15231523
return -EOPNOTSUPP;
15241524

15251525
switch (attrs->flavour) {

0 commit comments

Comments
 (0)