vdpa/mlx5: Add the support of set mac address
Subsystems (5)
PATCH 1/1 vdpa/mlx5: Add the support of set mac address
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use mlx5_mpfs_add_mac to set the mac address
Tested in ConnectX-6 Dx device
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +23 -0
@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, +const struct vdpa_dev_set_config *add_config) +{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; + +if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) { +memcpy (config->mac, add_config->net.mac,ETH_ALEN ); + pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err) +return -1 ; + } + } +return 0 ; +}static const struct vdpa_mgmtdev_ops mdev_ops = { .dev_add = mlx5_vdpa_dev_add, .dev_del = mlx5_vdpa_dev_del, + .dev_set_attr = mlx5_vdpa_set_attr_mac, };static struct virtio_device_id id_table[] = {
Signature · 1 line
2.45.0
Quoted 6 lines · Cindy Lu
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use
mlx5_mpfs_add_macto set the mac addressTested in ConnectX-6 Dx device
Great.
Quoted 2 lines
Signed-off-by Cindy Lu <[email protected]>
I guess this should be part of the series "vdpa: support set mac address from vdpa tool" ?
Quoted 29 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +17
-0@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, +const struct vdpa_dev_set_config *add_config) +{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; + +if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) { +memcpy (config->mac, add_config->net.mac,ETH_ALEN ); + pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err)
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3645
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +6
-0+return -1 ; + } + } +return 0 ; +}static const struct vdpa_mgmtdev_ops mdev_ops = { .dev_add = mlx5_vdpa_dev_add, .dev_del = mlx5_vdpa_dev_del, + .dev_set_attr = mlx5_vdpa_set_attr_mac,
Let's rename this as we will add the support for mtu as well or not?
Thanks
Quoted 6 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-1};static struct virtio_device_id id_table[] = { --2.45.0
Quoted 9 lines · Jason Wang
Quoted 6 lines · Cindy Lu
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use
mlx5_mpfs_add_macto set the mac addressTested in ConnectX-6 Dx device
Quoted 8 lines
Great.
Quoted 2 lines
Signed-off-by Cindy Lu <[email protected]>I guess this should be part of the series "vdpa: support set mac address from vdpa tool" ?
yes, Will add this in next version
Thanks
cindy
Quoted 35 lines
Quoted 35 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +22
-0@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, +const struct vdpa_dev_set_config *add_config) +{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; + +if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) { +memcpy (config->mac, add_config->net.mac,ETH_ALEN ); + pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err) +return -1 ; + } + } +return 0 ; +}
Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3645
Quoted 4 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0static const struct vdpa_mgmtdev_ops mdev_ops = { .dev_add = mlx5_vdpa_dev_add, .dev_del = mlx5_vdpa_dev_del, + .dev_set_attr = mlx5_vdpa_set_attr_mac,Let's rename this as we will add the support for mtu as well or not?
sure ,will change this
Thanks
cindy
Quoted 9 lines
Thanks
Quoted 6 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-1};static struct virtio_device_id id_table[] = { --2.45.0
Dragos Tatulea
maintainerQuoted 20 lines · Cindy Lu
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use
mlx5_mpfs_add_macto set the mac addressTested in ConnectX-6 Dx device
Signed-off-by Cindy Lu <[email protected]>--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac(struct vdpa_mgmt_dev *v_mdev,
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3629
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +10
-0+struct vdpa_device *dev, + const struct vdpa_dev_set_config *add_config) +{ + struct mlx5_vdpa_dev *mvdev = to_mvdev(dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; +
You need to take the ndev->reslock.
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3632
Quoted 3 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +3
-0+if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) { +memcpy (config->mac, add_config->net.mac,ETH_ALEN );
I would do the memcpy after mlx5_mpfs_add_mac() was called successfully. This way the config gets changed only on success.
Quoted 6 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +6
-0+ pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err) +return -1 ; + } + }
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3648
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +3
-0+return 0 ; +}static const struct vdpa_mgmtdev_ops mdev_ops = { .dev_add = mlx5_vdpa_dev_add, .dev_del = mlx5_vdpa_dev_del, + .dev_set_attr = mlx5_vdpa_set_attr_mac, };static struct virtio_device_id id_table[] = {
Thanks,
Dragos
Quoted 25 lines · Dragos Tatulea
Quoted 23 lines · Cindy Lu
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use
mlx5_mpfs_add_macto set the mac addressTested in ConnectX-6 Dx device
Signed-off-by Cindy Lu <[email protected]>--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +4
-0@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, +const struct vdpa_dev_set_config *add_config) +{
Quoted 9 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3629
Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +7
-0+struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; +You need to take the
ndev->reslock.
thanks will change this
Quoted 6 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3632
Quoted 3 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +3
-0+if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) { +memcpy (config->mac, add_config->net.mac,ETH_ALEN );I would do the memcpy after
mlx5_mpfs_add_mac()was called successfully. This way the config gets changed only on success.
thanks Dragos, Will fix this
thanks
cindy
Quoted 20 lines
Quoted 6 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +6
-0+ pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err) +return -1 ; + } + }drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3648
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +3
-0+return 0 ; +}static const struct vdpa_mgmtdev_ops mdev_ops = { .dev_add = mlx5_vdpa_dev_add, .dev_del = mlx5_vdpa_dev_del, + .dev_set_attr = mlx5_vdpa_set_attr_mac, };static struct virtio_device_id id_table[] = {Thanks,
Dragos
Michael S. Tsirkin
maintainerQuoted 7 lines · Cindy Lu
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use
mlx5_mpfs_add_macto set the mac addressTested in ConnectX-6 Dx device
Signed-off-by Cindy Lu <[email protected]>
Is this on top of your other patchset?
Quoted 44 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +23
-0@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, +const struct vdpa_dev_set_config *add_config) +{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; + +if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) { +memcpy (config->mac, add_config->net.mac,ETH_ALEN ); + pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err) +return -1 ; + } + } +return 0 ; +}static const struct vdpa_mgmtdev_ops mdev_ops = { .dev_add = mlx5_vdpa_dev_add, .dev_del = mlx5_vdpa_dev_del, + .dev_set_attr = mlx5_vdpa_set_attr_mac, };static struct virtio_device_id id_table[] = {Signature · 1 line
2.45.0
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Cindy Lu
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use
mlx5_mpfs_add_macto set the mac address
Quoted 6 lines
Quoted 3 lines
Tested in ConnectX-6 Dx device
Signed-off-by Cindy Lu <[email protected]>Is this on top of your other patchset?
yes, Will send a new version of these patch
Thanks
cindy
Quoted 45 lines
Quoted 44 lines
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +23
-1@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, +const struct vdpa_dev_set_config *add_config) +{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; + +if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) { +memcpy (config->mac, add_config->net.mac,ETH_ALEN ); + pfmdev =pci_get_drvdata (pci_physfn (mdev->pdev)); + err =mlx5_mpfs_add_mac (pfmdev, config->mac); +if (err) +return -1 ; + } + } +return 0 ; +}static const struct vdpa_mgmtdev_ops mdev_ops = { .dev_add = mlx5_vdpa_dev_add, .dev_del = mlx5_vdpa_dev_del, + .dev_set_attr = mlx5_vdpa_set_attr_mac, };static struct virtio_device_id id_table[] = { --2.45.0
Quoted 22 lines · Cindy Lu
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use
mlx5_mpfs_add_macto set the mac addressTested in ConnectX-6 Dx device
Signed-off-by Cindy Lu <[email protected]>--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +3
-0@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, +const struct vdpa_dev_set_config *add_config)
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3631
Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +10
-0+{ +struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; + +if (add_config->mask & (1 <<VDPA_ATTR_DEV_NET_CFG_MACADDR )) { +if (!is_zero_ether_addr (add_config->net.mac)) {
Is the core happy to call into the driver without validating the MAC address? Will the core pass the broadcast address? That is not zero. Or a multicast address? Should every driver repeat the same validation, and probably get it just as wrong?
Andrew
---
pw-bot: cr
Hi Andrew,
Quoted 44 lines
From: Andrew Lunn <[email protected]>
Sent: Tuesday, July 9, 2024 12:31 AM
To: Cindy Lu <[email protected]>
Cc: Dragos Tatulea <[email protected]>; [email protected]; [email protected]; Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected] foundation.org; [email protected]; [email protected]
Subject: Re: [PATCH] vdpa/mlx5: Add the support of set mac addressdrivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct
Quoted 17 lines · Cindy Lu
Add the function to support setting the MAC address.
For vdpa/mlx5, the function will usemlx5_mpfs_add_macto set the mac addressTested in ConnectX-6 Dx device
Signed-off-by Cindy Lu <[email protected]>--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/vdpa/mlx5/net/mlx5_vnet.c +0
-0@@ -3616,10 +3616,33 @@ static void mlx5_vdpa_dev_del(struct
vdpa_mgmt_dev*v_mdev, structvdpa_device*drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
Quoted 6 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +3
-0destroy_workqueue (wq); mgtdev->ndev =NULL ; } +static int mlx5_vdpa_set_attr_mac (struct vdpa_mgmt_dev *v_mdev, +struct vdpa_device *dev, + const struct vdpa_dev_set_config
*add_config) {drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +8
-0+struct mlx5_vdpa_dev *mvdev =to_mvdev (dev); +struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev); +struct mlx5_core_dev *mdev = mvdev->mdev; +struct virtio_net_config *config = &ndev->config; +int err; +struct mlx5_core_dev *pfmdev; + + if (add_config->mask & (1 <<
VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
Quoted 9 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * · line 3631
Quoted 1 line
drivers/vdpa/mlx5/net/mlx5_vnet.c +1
-0+if (!is_zero_ether_addr (add_config->net.mac)) {Is the core happy to call into the driver without validating the MAC address? Will the core pass the broadcast address? That is not zero. Or a multicast address? Should every driver repeat the same validation, and probably get it just as wrong?
Andrew
I will submit the patch to add the check in the vdpa core for mac address validation.
Quoted 2 lines
---
pw-bot: cr