* [PATCH v2] ice: Add get/set hw address for VFs using devlink commands
@ 2024-02-08 8:24 ` Karthik Sundaravel
0 siblings, 0 replies; 6+ messages in thread
From: Karthik Sundaravel @ 2024-02-08 8:24 UTC (permalink / raw)
To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
pabeni, intel-wired-lan, netdev, linux-kernel
Cc: pmenzel, jiri, michal.swiatkowski, rjarry, aharivel, vchundur,
ksundara, cfontain
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Intel-wired-lan] [PATCH v2] ice: Add get/set hw address for VFs using devlink commands
@ 2024-02-08 8:24 ` Karthik Sundaravel
0 siblings, 0 replies; 6+ messages in thread
From: Karthik Sundaravel @ 2024-02-08 8:24 UTC (permalink / raw)
To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
pabeni, intel-wired-lan, netdev, linux-kernel
Cc: pmenzel, aharivel, jiri, cfontain, vchundur, ksundara,
michal.swiatkowski, rjarry
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] ice: Add get/set hw address for VFs using devlink commands
2024-02-08 8:24 ` [Intel-wired-lan] " Karthik Sundaravel
@ 2024-02-08 8:24 ` Karthik Sundaravel
-1 siblings, 0 replies; 6+ messages in thread
From: Karthik Sundaravel @ 2024-02-08 8:24 UTC (permalink / raw)
To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
pabeni, intel-wired-lan, netdev, linux-kernel
Cc: pmenzel, jiri, michal.swiatkowski, rjarry, aharivel, vchundur,
ksundara, cfontain
Changing the MAC address of the VF ports are not available
via devlink. Add the function handlers to set and get
the HW address for the VF ports.
Signed-off-by: Karthik Sundaravel <ksundara@redhat.com>
---
drivers/net/ethernet/intel/ice/ice_devlink.c | 89 +++++++++++++++++++-
1 file changed, 88 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
index 80dc5445b50d..8455fa94a687 100644
--- a/drivers/net/ethernet/intel/ice/ice_devlink.c
+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
@@ -1576,6 +1576,92 @@ void ice_devlink_destroy_pf_port(struct ice_pf *pf)
devlink_port_unregister(&pf->devlink_port);
}
+/**
+ * ice_devlink_port_get_vf_mac_address - .port_fn_hw_addr_get devlink handler
+ * @port: devlink port structure
+ * @hw_addr: MAC address of the port
+ * @hw_addr_len: length of MAC address
+ * @extack: extended netdev ack structure
+ *
+ * Callback for the devlink .port_fn_hw_addr_get operation
+ * Return: zero on success or an error code on failure.
+ */
+
+static int ice_devlink_port_get_vf_mac_address(struct devlink_port *port,
+ u8 *hw_addr, int *hw_addr_len,
+ struct netlink_ext_ack *extack)
+{
+ struct devlink *devlink = port->devlink;
+ struct ice_pf *pf = devlink_priv(devlink);
+ struct device *dev = ice_pf_to_dev(pf);
+ struct devlink_port_attrs *attrs = &port->attrs;
+ struct devlink_port_pci_vf_attrs *pci_vf;
+ int vf_id;
+ struct ice_vf *vf;
+
+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
+ pci_vf = &attrs->pci_vf;
+ vf_id = pci_vf->vf;
+ } else {
+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
+ return -EADDRNOTAVAIL;
+ }
+ vf = ice_get_vf_by_id(pf, vf_id);
+ if (!vf) {
+ dev_err(dev, "Unable to get the vf for PF %d\n", pf->hw.pf_id);
+ return -EINVAL;
+ }
+ ether_addr_copy(hw_addr, vf->dev_lan_addr);
+ *hw_addr_len = ETH_ALEN;
+ return 0;
+}
+
+/**
+ * ice_devlink_port_set_vf_mac_address - .port_fn_hw_addr_set devlink handler
+ * @port: devlink port structure
+ * @hw_addr: MAC address of the port
+ * @hw_addr_len: length of MAC address
+ * @extack: extended netdev ack structure
+ *
+ * Callback for the devlink .port_fn_hw_addr_set operation
+ * Return: zero on success or an error code on failure.
+ */
+static int ice_devlink_port_set_vf_mac_address(struct devlink_port *port,
+ const u8 *hw_addr,
+ int hw_addr_len,
+ struct netlink_ext_ack *extack)
+{
+ struct devlink *devlink = port->devlink;
+ struct ice_pf *pf = devlink_priv(devlink);
+ struct device *dev = ice_pf_to_dev(pf);
+ struct net_device *netdev = port->type_eth.netdev;
+ struct devlink_port_attrs *attrs = &port->attrs;
+ struct devlink_port_pci_vf_attrs *pci_vf;
+ int vf_id;
+ u8 mac[ETH_ALEN];
+
+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
+ pci_vf = &attrs->pci_vf;
+ vf_id = pci_vf->vf;
+ } else {
+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
+ return -EADDRNOTAVAIL;
+ }
+
+ if (!netdev) {
+ dev_err(dev, "Unable to get the netdev for PF %d\n", pf->hw.pf_id);
+ return -EADDRNOTAVAIL;
+ }
+ ether_addr_copy(mac, hw_addr);
+
+ return ice_set_vf_mac(netdev, vf_id, mac);
+}
+
+static const struct devlink_port_ops ice_devlink_vf_port_ops = {
+ .port_fn_hw_addr_get = ice_devlink_port_get_vf_mac_address,
+ .port_fn_hw_addr_set = ice_devlink_port_set_vf_mac_address,
+};
+
/**
* ice_devlink_create_vf_port - Create a devlink port for this VF
* @vf: the VF to create a port for
@@ -1611,7 +1697,8 @@ int ice_devlink_create_vf_port(struct ice_vf *vf)
devlink_port_attrs_set(devlink_port, &attrs);
devlink = priv_to_devlink(pf);
- err = devlink_port_register(devlink, devlink_port, vsi->idx);
+ err = devlink_port_register_with_ops(devlink, devlink_port,
+ vsi->idx, &ice_devlink_vf_port_ops);
if (err) {
dev_err(dev, "Failed to create devlink port for VF %d, error %d\n",
vf->vf_id, err);
--
2.39.3 (Apple Git-145)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Intel-wired-lan] [PATCH v2] ice: Add get/set hw address for VFs using devlink commands
@ 2024-02-08 8:24 ` Karthik Sundaravel
0 siblings, 0 replies; 6+ messages in thread
From: Karthik Sundaravel @ 2024-02-08 8:24 UTC (permalink / raw)
To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
pabeni, intel-wired-lan, netdev, linux-kernel
Cc: pmenzel, aharivel, jiri, cfontain, vchundur, ksundara,
michal.swiatkowski, rjarry
Changing the MAC address of the VF ports are not available
via devlink. Add the function handlers to set and get
the HW address for the VF ports.
Signed-off-by: Karthik Sundaravel <ksundara@redhat.com>
---
drivers/net/ethernet/intel/ice/ice_devlink.c | 89 +++++++++++++++++++-
1 file changed, 88 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
index 80dc5445b50d..8455fa94a687 100644
--- a/drivers/net/ethernet/intel/ice/ice_devlink.c
+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
@@ -1576,6 +1576,92 @@ void ice_devlink_destroy_pf_port(struct ice_pf *pf)
devlink_port_unregister(&pf->devlink_port);
}
+/**
+ * ice_devlink_port_get_vf_mac_address - .port_fn_hw_addr_get devlink handler
+ * @port: devlink port structure
+ * @hw_addr: MAC address of the port
+ * @hw_addr_len: length of MAC address
+ * @extack: extended netdev ack structure
+ *
+ * Callback for the devlink .port_fn_hw_addr_get operation
+ * Return: zero on success or an error code on failure.
+ */
+
+static int ice_devlink_port_get_vf_mac_address(struct devlink_port *port,
+ u8 *hw_addr, int *hw_addr_len,
+ struct netlink_ext_ack *extack)
+{
+ struct devlink *devlink = port->devlink;
+ struct ice_pf *pf = devlink_priv(devlink);
+ struct device *dev = ice_pf_to_dev(pf);
+ struct devlink_port_attrs *attrs = &port->attrs;
+ struct devlink_port_pci_vf_attrs *pci_vf;
+ int vf_id;
+ struct ice_vf *vf;
+
+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
+ pci_vf = &attrs->pci_vf;
+ vf_id = pci_vf->vf;
+ } else {
+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
+ return -EADDRNOTAVAIL;
+ }
+ vf = ice_get_vf_by_id(pf, vf_id);
+ if (!vf) {
+ dev_err(dev, "Unable to get the vf for PF %d\n", pf->hw.pf_id);
+ return -EINVAL;
+ }
+ ether_addr_copy(hw_addr, vf->dev_lan_addr);
+ *hw_addr_len = ETH_ALEN;
+ return 0;
+}
+
+/**
+ * ice_devlink_port_set_vf_mac_address - .port_fn_hw_addr_set devlink handler
+ * @port: devlink port structure
+ * @hw_addr: MAC address of the port
+ * @hw_addr_len: length of MAC address
+ * @extack: extended netdev ack structure
+ *
+ * Callback for the devlink .port_fn_hw_addr_set operation
+ * Return: zero on success or an error code on failure.
+ */
+static int ice_devlink_port_set_vf_mac_address(struct devlink_port *port,
+ const u8 *hw_addr,
+ int hw_addr_len,
+ struct netlink_ext_ack *extack)
+{
+ struct devlink *devlink = port->devlink;
+ struct ice_pf *pf = devlink_priv(devlink);
+ struct device *dev = ice_pf_to_dev(pf);
+ struct net_device *netdev = port->type_eth.netdev;
+ struct devlink_port_attrs *attrs = &port->attrs;
+ struct devlink_port_pci_vf_attrs *pci_vf;
+ int vf_id;
+ u8 mac[ETH_ALEN];
+
+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
+ pci_vf = &attrs->pci_vf;
+ vf_id = pci_vf->vf;
+ } else {
+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
+ return -EADDRNOTAVAIL;
+ }
+
+ if (!netdev) {
+ dev_err(dev, "Unable to get the netdev for PF %d\n", pf->hw.pf_id);
+ return -EADDRNOTAVAIL;
+ }
+ ether_addr_copy(mac, hw_addr);
+
+ return ice_set_vf_mac(netdev, vf_id, mac);
+}
+
+static const struct devlink_port_ops ice_devlink_vf_port_ops = {
+ .port_fn_hw_addr_get = ice_devlink_port_get_vf_mac_address,
+ .port_fn_hw_addr_set = ice_devlink_port_set_vf_mac_address,
+};
+
/**
* ice_devlink_create_vf_port - Create a devlink port for this VF
* @vf: the VF to create a port for
@@ -1611,7 +1697,8 @@ int ice_devlink_create_vf_port(struct ice_vf *vf)
devlink_port_attrs_set(devlink_port, &attrs);
devlink = priv_to_devlink(pf);
- err = devlink_port_register(devlink, devlink_port, vsi->idx);
+ err = devlink_port_register_with_ops(devlink, devlink_port,
+ vsi->idx, &ice_devlink_vf_port_ops);
if (err) {
dev_err(dev, "Failed to create devlink port for VF %d, error %d\n",
vf->vf_id, err);
--
2.39.3 (Apple Git-145)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ice: Add get/set hw address for VFs using devlink commands
2024-02-08 8:24 ` [Intel-wired-lan] " Karthik Sundaravel
@ 2024-02-08 11:26 ` Jiri Pirko
-1 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2024-02-08 11:26 UTC (permalink / raw)
To: Karthik Sundaravel
Cc: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba,
pabeni, intel-wired-lan, netdev, linux-kernel, pmenzel,
michal.swiatkowski, rjarry, aharivel, vchundur, cfontain
Thu, Feb 08, 2024 at 09:24:55AM CET, ksundara@redhat.com wrote:
>Changing the MAC address of the VF ports are not available
>via devlink. Add the function handlers to set and get
>the HW address for the VF ports.
"VFs". Avoid the word "port" here, as it may falsely indicate you are
talking about the eswitch representor port.
>
>Signed-off-by: Karthik Sundaravel <ksundara@redhat.com>
>---
> drivers/net/ethernet/intel/ice/ice_devlink.c | 89 +++++++++++++++++++-
> 1 file changed, 88 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
>index 80dc5445b50d..8455fa94a687 100644
>--- a/drivers/net/ethernet/intel/ice/ice_devlink.c
>+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
>@@ -1576,6 +1576,92 @@ void ice_devlink_destroy_pf_port(struct ice_pf *pf)
> devlink_port_unregister(&pf->devlink_port);
> }
>
>+/**
>+ * ice_devlink_port_get_vf_mac_address - .port_fn_hw_addr_get devlink handler
>+ * @port: devlink port structure
>+ * @hw_addr: MAC address of the port
>+ * @hw_addr_len: length of MAC address
>+ * @extack: extended netdev ack structure
>+ *
>+ * Callback for the devlink .port_fn_hw_addr_get operation
>+ * Return: zero on success or an error code on failure.
>+ */
>+
>+static int ice_devlink_port_get_vf_mac_address(struct devlink_port *port,
>+ u8 *hw_addr, int *hw_addr_len,
>+ struct netlink_ext_ack *extack)
>+{
>+ struct devlink *devlink = port->devlink;
>+ struct ice_pf *pf = devlink_priv(devlink);
>+ struct device *dev = ice_pf_to_dev(pf);
>+ struct devlink_port_attrs *attrs = &port->attrs;
>+ struct devlink_port_pci_vf_attrs *pci_vf;
>+ int vf_id;
>+ struct ice_vf *vf;
Reverse xmas tree:
https://www.kernel.org/doc/html/v6.7/process/maintainer-netdev.html#tl-dr
>+
>+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
>+ pci_vf = &attrs->pci_vf;
>+ vf_id = pci_vf->vf;
>+ } else {
>+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EADDRNOTAVAIL;
>+ }
>+ vf = ice_get_vf_by_id(pf, vf_id);
>+ if (!vf) {
>+ dev_err(dev, "Unable to get the vf for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EINVAL;
>+ }
>+ ether_addr_copy(hw_addr, vf->dev_lan_addr);
>+ *hw_addr_len = ETH_ALEN;
>+ return 0;
>+}
>+
>+/**
>+ * ice_devlink_port_set_vf_mac_address - .port_fn_hw_addr_set devlink handler
>+ * @port: devlink port structure
>+ * @hw_addr: MAC address of the port
>+ * @hw_addr_len: length of MAC address
>+ * @extack: extended netdev ack structure
>+ *
>+ * Callback for the devlink .port_fn_hw_addr_set operation
>+ * Return: zero on success or an error code on failure.
>+ */
>+static int ice_devlink_port_set_vf_mac_address(struct devlink_port *port,
>+ const u8 *hw_addr,
>+ int hw_addr_len,
>+ struct netlink_ext_ack *extack)
>+{
>+ struct devlink *devlink = port->devlink;
>+ struct ice_pf *pf = devlink_priv(devlink);
>+ struct device *dev = ice_pf_to_dev(pf);
>+ struct net_device *netdev = port->type_eth.netdev;
>+ struct devlink_port_attrs *attrs = &port->attrs;
>+ struct devlink_port_pci_vf_attrs *pci_vf;
>+ int vf_id;
>+ u8 mac[ETH_ALEN];
Reverse xmas tree:
https://www.kernel.org/doc/html/v6.7/process/maintainer-netdev.html#tl-dr
>+
>+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
>+ pci_vf = &attrs->pci_vf;
>+ vf_id = pci_vf->vf;
>+ } else {
>+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EADDRNOTAVAIL;
>+ }
>+
>+ if (!netdev) {
>+ dev_err(dev, "Unable to get the netdev for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EADDRNOTAVAIL;
>+ }
>+ ether_addr_copy(mac, hw_addr);
>+
>+ return ice_set_vf_mac(netdev, vf_id, mac);
>+}
>+
>+static const struct devlink_port_ops ice_devlink_vf_port_ops = {
>+ .port_fn_hw_addr_get = ice_devlink_port_get_vf_mac_address,
>+ .port_fn_hw_addr_set = ice_devlink_port_set_vf_mac_address,
>+};
>+
> /**
> * ice_devlink_create_vf_port - Create a devlink port for this VF
> * @vf: the VF to create a port for
>@@ -1611,7 +1697,8 @@ int ice_devlink_create_vf_port(struct ice_vf *vf)
> devlink_port_attrs_set(devlink_port, &attrs);
> devlink = priv_to_devlink(pf);
>
>- err = devlink_port_register(devlink, devlink_port, vsi->idx);
>+ err = devlink_port_register_with_ops(devlink, devlink_port,
>+ vsi->idx, &ice_devlink_vf_port_ops);
> if (err) {
> dev_err(dev, "Failed to create devlink port for VF %d, error %d\n",
> vf->vf_id, err);
>--
>2.39.3 (Apple Git-145)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-wired-lan] [PATCH v2] ice: Add get/set hw address for VFs using devlink commands
@ 2024-02-08 11:26 ` Jiri Pirko
0 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2024-02-08 11:26 UTC (permalink / raw)
To: Karthik Sundaravel
Cc: pmenzel, aharivel, michal.swiatkowski, cfontain, intel-wired-lan,
jesse.brandeburg, linux-kernel, edumazet, anthony.l.nguyen,
vchundur, netdev, kuba, rjarry, pabeni, davem
Thu, Feb 08, 2024 at 09:24:55AM CET, ksundara@redhat.com wrote:
>Changing the MAC address of the VF ports are not available
>via devlink. Add the function handlers to set and get
>the HW address for the VF ports.
"VFs". Avoid the word "port" here, as it may falsely indicate you are
talking about the eswitch representor port.
>
>Signed-off-by: Karthik Sundaravel <ksundara@redhat.com>
>---
> drivers/net/ethernet/intel/ice/ice_devlink.c | 89 +++++++++++++++++++-
> 1 file changed, 88 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
>index 80dc5445b50d..8455fa94a687 100644
>--- a/drivers/net/ethernet/intel/ice/ice_devlink.c
>+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
>@@ -1576,6 +1576,92 @@ void ice_devlink_destroy_pf_port(struct ice_pf *pf)
> devlink_port_unregister(&pf->devlink_port);
> }
>
>+/**
>+ * ice_devlink_port_get_vf_mac_address - .port_fn_hw_addr_get devlink handler
>+ * @port: devlink port structure
>+ * @hw_addr: MAC address of the port
>+ * @hw_addr_len: length of MAC address
>+ * @extack: extended netdev ack structure
>+ *
>+ * Callback for the devlink .port_fn_hw_addr_get operation
>+ * Return: zero on success or an error code on failure.
>+ */
>+
>+static int ice_devlink_port_get_vf_mac_address(struct devlink_port *port,
>+ u8 *hw_addr, int *hw_addr_len,
>+ struct netlink_ext_ack *extack)
>+{
>+ struct devlink *devlink = port->devlink;
>+ struct ice_pf *pf = devlink_priv(devlink);
>+ struct device *dev = ice_pf_to_dev(pf);
>+ struct devlink_port_attrs *attrs = &port->attrs;
>+ struct devlink_port_pci_vf_attrs *pci_vf;
>+ int vf_id;
>+ struct ice_vf *vf;
Reverse xmas tree:
https://www.kernel.org/doc/html/v6.7/process/maintainer-netdev.html#tl-dr
>+
>+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
>+ pci_vf = &attrs->pci_vf;
>+ vf_id = pci_vf->vf;
>+ } else {
>+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EADDRNOTAVAIL;
>+ }
>+ vf = ice_get_vf_by_id(pf, vf_id);
>+ if (!vf) {
>+ dev_err(dev, "Unable to get the vf for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EINVAL;
>+ }
>+ ether_addr_copy(hw_addr, vf->dev_lan_addr);
>+ *hw_addr_len = ETH_ALEN;
>+ return 0;
>+}
>+
>+/**
>+ * ice_devlink_port_set_vf_mac_address - .port_fn_hw_addr_set devlink handler
>+ * @port: devlink port structure
>+ * @hw_addr: MAC address of the port
>+ * @hw_addr_len: length of MAC address
>+ * @extack: extended netdev ack structure
>+ *
>+ * Callback for the devlink .port_fn_hw_addr_set operation
>+ * Return: zero on success or an error code on failure.
>+ */
>+static int ice_devlink_port_set_vf_mac_address(struct devlink_port *port,
>+ const u8 *hw_addr,
>+ int hw_addr_len,
>+ struct netlink_ext_ack *extack)
>+{
>+ struct devlink *devlink = port->devlink;
>+ struct ice_pf *pf = devlink_priv(devlink);
>+ struct device *dev = ice_pf_to_dev(pf);
>+ struct net_device *netdev = port->type_eth.netdev;
>+ struct devlink_port_attrs *attrs = &port->attrs;
>+ struct devlink_port_pci_vf_attrs *pci_vf;
>+ int vf_id;
>+ u8 mac[ETH_ALEN];
Reverse xmas tree:
https://www.kernel.org/doc/html/v6.7/process/maintainer-netdev.html#tl-dr
>+
>+ if (attrs->flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
>+ pci_vf = &attrs->pci_vf;
>+ vf_id = pci_vf->vf;
>+ } else {
>+ dev_err(dev, "Unable to get the vf id for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EADDRNOTAVAIL;
>+ }
>+
>+ if (!netdev) {
>+ dev_err(dev, "Unable to get the netdev for PF %d\n", pf->hw.pf_id);
Fill the extack message instead.
>+ return -EADDRNOTAVAIL;
>+ }
>+ ether_addr_copy(mac, hw_addr);
>+
>+ return ice_set_vf_mac(netdev, vf_id, mac);
>+}
>+
>+static const struct devlink_port_ops ice_devlink_vf_port_ops = {
>+ .port_fn_hw_addr_get = ice_devlink_port_get_vf_mac_address,
>+ .port_fn_hw_addr_set = ice_devlink_port_set_vf_mac_address,
>+};
>+
> /**
> * ice_devlink_create_vf_port - Create a devlink port for this VF
> * @vf: the VF to create a port for
>@@ -1611,7 +1697,8 @@ int ice_devlink_create_vf_port(struct ice_vf *vf)
> devlink_port_attrs_set(devlink_port, &attrs);
> devlink = priv_to_devlink(pf);
>
>- err = devlink_port_register(devlink, devlink_port, vsi->idx);
>+ err = devlink_port_register_with_ops(devlink, devlink_port,
>+ vsi->idx, &ice_devlink_vf_port_ops);
> if (err) {
> dev_err(dev, "Failed to create devlink port for VF %d, error %d\n",
> vf->vf_id, err);
>--
>2.39.3 (Apple Git-145)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-08 16:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-08 8:24 [PATCH v2] ice: Add get/set hw address for VFs using devlink commands Karthik Sundaravel
2024-02-08 8:24 ` [Intel-wired-lan] " Karthik Sundaravel
2024-02-08 8:24 ` Karthik Sundaravel
2024-02-08 8:24 ` [Intel-wired-lan] " Karthik Sundaravel
2024-02-08 11:26 ` Jiri Pirko
2024-02-08 11:26 ` [Intel-wired-lan] " Jiri Pirko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.