[PATCH v2] ice: Add get/set hw address for VFs using devlink commands

From: Karthik Sundaravel
Date: Thu Feb 08 2024 - 03:27:09 EST




Thanks for the review comments and suggestions.
In the V2 version of the patch, I have called ice_set_vf_mac() directly from the devlink port function handlers.

I did the following testing to verify the changes.

root@10:~# ethtool -i enp8s0f0np0 | grep bus
bus-info: 0000:08:00.0

root@10:~# devlink dev eswitch set pci/0000:08:00.0 mode switchdev
Warning: ice: Changed eswitch mode to switchdev.

root@10:~# echo 4 > /sys/class/net/enp8s0f0np0/device/sriov_numvfs

root@10:~# devlink port show
pci/0000:08:00.0/0: type eth netdev enp8s0f0np0 flavour physical port 0 splittable true lanes 8
pci/0000:08:00.0/2: type eth netdev enp8s0f0npf0vf0 flavour pcivf controller 0 pfnum 0 vfnum 0 external false splittable false
function:
hw_addr 1a:33:f2:e7:64:d8
pci/0000:08:00.0/3: type eth netdev enp8s0f0npf0vf3 flavour pcivf controller 0 pfnum 0 vfnum 3 external false splittable false
function:
hw_addr 4e:ef:ca:9e:e7:5d
pci/0000:08:00.0/4: type eth netdev enp8s0f0npf0vf1 flavour pcivf controller 0 pfnum 0 vfnum 1 external false splittable false
function:
hw_addr 5a:f0:e3:f8:41:93
pci/0000:08:00.0/5: type eth netdev enp8s0f0npf0vf2 flavour pcivf controller 0 pfnum 0 vfnum 2 external false splittable false
function:
hw_addr 1a:62:c6:4b:d2:f0
pci/0000:08:00.1/0: type eth netdev enp8s0f1np1 flavour physical port 1 splittable false

root@10:~# devlink port function set pci/0000:08:00.0/5 hw_addr 00:11:22:33:44:55

root@10:~# devlink port show
pci/0000:08:00.0/0: type eth netdev enp8s0f0np0 flavour physical port 0 splittable true lanes 8
pci/0000:08:00.0/2: type eth netdev enp8s0f0npf0vf0 flavour pcivf controller 0 pfnum 0 vfnum 0 external false splittable false
function:
hw_addr 1a:33:f2:e7:64:d8
pci/0000:08:00.0/3: type eth netdev enp8s0f0npf0vf3 flavour pcivf controller 0 pfnum 0 vfnum 3 external false splittable false
function:
hw_addr 4e:ef:ca:9e:e7:5d
pci/0000:08:00.0/4: type eth netdev enp8s0f0npf0vf1 flavour pcivf controller 0 pfnum 0 vfnum 1 external false splittable false
function:
hw_addr 5a:f0:e3:f8:41:93
pci/0000:08:00.0/5: type eth netdev enp8s0f0npf0vf2 flavour pcivf controller 0 pfnum 0 vfnum 2 external false splittable false
function:
hw_addr 00:11:22:33:44:55
pci/0000:08:00.1/0: type eth netdev enp8s0f1np1 flavour physical port 1 splittable false

root@10:~# ip link show enp8s0f0np0
12: enp8s0f0np0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 40:a6:b7:18:dd:68 brd ff:ff:ff:ff:ff:ff
vf 0 link/ether 1a:33:f2:e7:64:d8 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off
vf 1 link/ether 5a:f0:e3:f8:41:93 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off
vf 2 link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off
vf 3 link/ether 4e:ef:ca:9e:e7:5d brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off

root@10:~# ip link set dev enp8s0f0np0 vf 2 mac AA:BB:CC:DD:EE:FF

root@10:~# ip link show enp8s0f0np0
12: enp8s0f0np0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 40:a6:b7:18:dd:68 brd ff:ff:ff:ff:ff:ff
vf 0 link/ether 1a:33:f2:e7:64:d8 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off
vf 1 link/ether 5a:f0:e3:f8:41:93 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off
vf 2 link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off
vf 3 link/ether 4e:ef:ca:9e:e7:5d brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off

root@10:~# devlink port show
pci/0000:08:00.0/0: type eth netdev enp8s0f0np0 flavour physical port 0 splittable true lanes 8
pci/0000:08:00.0/2: type eth netdev enp8s0f0npf0vf0 flavour pcivf controller 0 pfnum 0 vfnum 0 external false splittable false
function:
hw_addr 1a:33:f2:e7:64:d8
pci/0000:08:00.0/3: type eth netdev enp8s0f0npf0vf3 flavour pcivf controller 0 pfnum 0 vfnum 3 external false splittable false
function:
hw_addr 4e:ef:ca:9e:e7:5d
pci/0000:08:00.0/4: type eth netdev enp8s0f0npf0vf1 flavour pcivf controller 0 pfnum 0 vfnum 1 external false splittable false
function:
hw_addr 5a:f0:e3:f8:41:93
pci/0000:08:00.0/5: type eth netdev enp8s0f0npf0vf2 flavour pcivf controller 0 pfnum 0 vfnum 2 external false splittable false
function:
hw_addr aa:bb:cc:dd:ee:ff
pci/0000:08:00.1/0: type eth netdev enp8s0f1np1 flavour physical port 1 splittable false