ice: get switch id on switchdev devices
authorMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Wed, 20 Apr 2022 11:22:43 +0000 (13:22 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 5 May 2022 18:28:35 +0000 (11:28 -0700)
commit4b889474adc628326df35bb2196cf36b506c7706
tree3562fc1aeae21235e5b29598ff06947bd660f7a3
parentbd1ffe8e5df4e24fc637d85b01f40e282c29856d
ice: get switch id on switchdev devices

Switch id should be the same for each netdevice on a driver.
The id must be unique between devices on the same system, but
does not need to be unique between devices on different systems.

The switch id is used to locate ports on a switch and to know if
aggregated ports belong to the same switch.

To meet this requirements, use pci_get_dsn as switch id value, as
this is unique value for each devices on the same system.

Implementing switch id is needed by automatic tools for kubernetes.

Set switch id by setting devlink port attribiutes and calling
devlink_port_attrs_set while creating pf (for uplink) and vf
(for representator) devlink port.

To get switch id (in switchdev mode):
cat /sys/class/net/$PF0/phys_switch_id

Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com>
Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_devlink.c
drivers/net/ethernet/intel/ice/ice_main.c