devlink: let driver opt out of automatic phys_port_name generation
authorJedrzej Jagielski <jedrzej.jagielski@intel.com>
Fri, 4 Jul 2025 11:17:47 +0000 (13:17 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 12 Aug 2025 20:23:39 +0000 (13:23 -0700)
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>
include/net/devlink.h
net/devlink/port.c

index 93640a29427cd84f73ffa0983db87df4d24d44cc..b32c9ceeb81d384ec21aacfacccd6f718804dfab 100644 (file)
@@ -78,6 +78,9 @@ struct devlink_port_pci_sf_attrs {
  * @flavour: flavour of the port
  * @split: indicates if this is split port
  * @splittable: indicates if the port can be split.
+ * @no_phys_port_name: skip automatic phys_port_name generation; for
+ *                    compatibility only, newly added driver/port instance
+ *                    should never set this.
  * @lanes: maximum number of lanes the port supports. 0 value is not passed to netlink.
  * @switch_id: if the port is part of switch, this is buffer with ID, otherwise this is NULL
  * @phys: physical port attributes
@@ -87,7 +90,8 @@ struct devlink_port_pci_sf_attrs {
  */
 struct devlink_port_attrs {
        u8 split:1,
-          splittable:1;
+          splittable:1,
+          no_phys_port_name:1;
        u32 lanes;
        enum devlink_port_flavour flavour;
        struct netdev_phys_item_id switch_id;
index 939081a0e6154a78b55ff08f7942a8bc450c6792..cb8d4df616199ef69e091e0f6151702b4bbfafcd 100644 (file)
@@ -1519,7 +1519,7 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
        struct devlink_port_attrs *attrs = &devlink_port->attrs;
        int n = 0;
 
-       if (!devlink_port->attrs_set)
+       if (!devlink_port->attrs_set || devlink_port->attrs.no_phys_port_name)
                return -EOPNOTSUPP;
 
        switch (attrs->flavour) {