Skip to content

Commit 0cd2c13

Browse files
ahubbe-amdmstsirkin
authored andcommitted
pds_vdpa: reset to vdpa specified mac
When the vdpa device is reset, also reinitialize it with the mac address that was assigned when the device was added. Fixes: 151cc83 ("pds_vdpa: add support for vdpa and vdpamgmt interfaces") Signed-off-by: Allen Hubbe <allen.hubbe@amd.com> Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Message-Id: <20230711042437.69381-2-shannon.nelson@amd.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
1 parent 2c507ce commit 0cd2c13

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

drivers/vdpa/pds/vdpa_dev.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ static void pds_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status)
409409
pdsv->vqs[i].avail_idx = 0;
410410
pdsv->vqs[i].used_idx = 0;
411411
}
412+
413+
pds_vdpa_cmd_set_mac(pdsv, pdsv->mac);
412414
}
413415

414416
if (status & ~old_status & VIRTIO_CONFIG_S_FEATURES_OK) {
@@ -532,7 +534,6 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
532534
struct device *dma_dev;
533535
struct pci_dev *pdev;
534536
struct device *dev;
535-
u8 mac[ETH_ALEN];
536537
int err;
537538
int i;
538539

@@ -617,19 +618,18 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
617618
* or set a random mac if default is 00:..:00
618619
*/
619620
if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
620-
ether_addr_copy(mac, add_config->net.mac);
621-
pds_vdpa_cmd_set_mac(pdsv, mac);
621+
ether_addr_copy(pdsv->mac, add_config->net.mac);
622622
} else {
623623
struct virtio_net_config __iomem *vc;
624624

625625
vc = pdsv->vdpa_aux->vd_mdev.device;
626-
memcpy_fromio(mac, vc->mac, sizeof(mac));
627-
if (is_zero_ether_addr(mac)) {
628-
eth_random_addr(mac);
629-
dev_info(dev, "setting random mac %pM\n", mac);
630-
pds_vdpa_cmd_set_mac(pdsv, mac);
626+
memcpy_fromio(pdsv->mac, vc->mac, sizeof(pdsv->mac));
627+
if (is_zero_ether_addr(pdsv->mac)) {
628+
eth_random_addr(pdsv->mac);
629+
dev_info(dev, "setting random mac %pM\n", pdsv->mac);
631630
}
632631
}
632+
pds_vdpa_cmd_set_mac(pdsv, pdsv->mac);
633633

634634
for (i = 0; i < pdsv->num_vqs; i++) {
635635
pdsv->vqs[i].qid = i;

drivers/vdpa/pds/vdpa_dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct pds_vdpa_device {
3939
u64 req_features; /* features requested by vdpa */
4040
u8 vdpa_index; /* rsvd for future subdevice use */
4141
u8 num_vqs; /* num vqs in use */
42+
u8 mac[ETH_ALEN]; /* mac selected when the device was added */
4243
struct vdpa_callback config_cb;
4344
struct notifier_block nb;
4445
};

0 commit comments

Comments
 (0)