Skip to content

Commit d883aa7

Browse files
Vasanthy Kolluridavem330
authored andcommitted
enic: Clean up: Add wrapper functions
Add wrapper functions vnic_dev_notify_setcmd and vnic_dev_notify_unsetcmd for firmware notify commands. Signed-off-by: Scott Feldman <[email protected]> Signed-off-by: Vasanthy Kolluri <[email protected]> Signed-off-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 73c1ea9 commit d883aa7

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

drivers/net/enic/vnic_dev.c

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,22 +573,18 @@ int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr)
573573
return err;
574574
}
575575

576-
int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
576+
int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
577+
void *notify_addr, dma_addr_t notify_pa, u16 intr)
577578
{
578579
u64 a0, a1;
579580
int wait = 1000;
580581
int r;
581582

582-
if (!vdev->notify) {
583-
vdev->notify = pci_alloc_consistent(vdev->pdev,
584-
sizeof(struct vnic_devcmd_notify),
585-
&vdev->notify_pa);
586-
if (!vdev->notify)
587-
return -ENOMEM;
588-
memset(vdev->notify, 0, sizeof(struct vnic_devcmd_notify));
589-
}
583+
memset(notify_addr, 0, sizeof(struct vnic_devcmd_notify));
584+
vdev->notify = notify_addr;
585+
vdev->notify_pa = notify_pa;
590586

591-
a0 = vdev->notify_pa;
587+
a0 = (u64)notify_pa;
592588
a1 = ((u64)intr << 32) & 0x0000ffff00000000ULL;
593589
a1 += sizeof(struct vnic_devcmd_notify);
594590

@@ -597,7 +593,27 @@ int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
597593
return r;
598594
}
599595

600-
void vnic_dev_notify_unset(struct vnic_dev *vdev)
596+
int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
597+
{
598+
void *notify_addr;
599+
dma_addr_t notify_pa;
600+
601+
if (vdev->notify || vdev->notify_pa) {
602+
printk(KERN_ERR "notify block %p still allocated",
603+
vdev->notify);
604+
return -EINVAL;
605+
}
606+
607+
notify_addr = pci_alloc_consistent(vdev->pdev,
608+
sizeof(struct vnic_devcmd_notify),
609+
&notify_pa);
610+
if (!notify_addr)
611+
return -ENOMEM;
612+
613+
return vnic_dev_notify_setcmd(vdev, notify_addr, notify_pa, intr);
614+
}
615+
616+
void vnic_dev_notify_unsetcmd(struct vnic_dev *vdev)
601617
{
602618
u64 a0, a1;
603619
int wait = 1000;
@@ -607,9 +623,23 @@ void vnic_dev_notify_unset(struct vnic_dev *vdev)
607623
a1 += sizeof(struct vnic_devcmd_notify);
608624

609625
vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait);
626+
vdev->notify = NULL;
627+
vdev->notify_pa = 0;
610628
vdev->notify_sz = 0;
611629
}
612630

631+
void vnic_dev_notify_unset(struct vnic_dev *vdev)
632+
{
633+
if (vdev->notify) {
634+
pci_free_consistent(vdev->pdev,
635+
sizeof(struct vnic_devcmd_notify),
636+
vdev->notify,
637+
vdev->notify_pa);
638+
}
639+
640+
vnic_dev_notify_unsetcmd(vdev);
641+
}
642+
613643
static int vnic_dev_notify_ready(struct vnic_dev *vdev)
614644
{
615645
u32 *words;

drivers/net/enic/vnic_dev.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
107107
void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
108108
int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
109109
int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr);
110+
int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
111+
void *notify_addr, dma_addr_t notify_pa, u16 intr);
110112
int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
113+
void vnic_dev_notify_unsetcmd(struct vnic_dev *vdev);
111114
void vnic_dev_notify_unset(struct vnic_dev *vdev);
112115
int vnic_dev_link_status(struct vnic_dev *vdev);
113116
u32 vnic_dev_port_speed(struct vnic_dev *vdev);

0 commit comments

Comments
 (0)