Skip to content

Commit e20f469

Browse files
vguvvadavem330
authored andcommitted
liquidio: synchronize VF representor names with NIC firmware
LiquidIO firmware supports a vswitch that needs to know the names of the VF representors in the host to maintain compatibility for direct programming using external Openflow agents. So, for each VF representor, send its name to the firmware when it gets registered and when its name changes. Signed-off-by: Vijaya Mohan Guvva <[email protected]> Signed-off-by: Raghu Vatsavayi <[email protected]> Signed-off-by: Felix Manlunas <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 74b200d commit e20f469

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,10 @@ static void liquidio_remove(struct pci_dev *pdev)
16391639
if (oct_dev->watchdog_task)
16401640
kthread_stop(oct_dev->watchdog_task);
16411641

1642+
if (!oct_dev->octeon_id &&
1643+
oct_dev->fw_info.app_cap_flags & LIQUIDIO_SWITCHDEV_CAP)
1644+
lio_vf_rep_modexit();
1645+
16421646
if (oct_dev->app_mode && (oct_dev->app_mode == CVM_DRV_NIC_APP))
16431647
liquidio_stop_nic_module(oct_dev);
16441648

@@ -4029,6 +4033,17 @@ static int liquidio_init_nic_module(struct octeon_device *oct)
40294033
goto octnet_init_failure;
40304034
}
40314035

4036+
/* Call vf_rep_modinit if the firmware is switchdev capable
4037+
* and do it from the first liquidio function probed.
4038+
*/
4039+
if (!oct->octeon_id &&
4040+
oct->fw_info.app_cap_flags & LIQUIDIO_SWITCHDEV_CAP) {
4041+
if (lio_vf_rep_modinit()) {
4042+
liquidio_stop_nic_module(oct);
4043+
goto octnet_init_failure;
4044+
}
4045+
}
4046+
40324047
liquidio_ptp_init(oct);
40334048

40344049
dev_dbg(&oct->pci_dev->dev, "Network interfaces ready\n");

drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,71 @@ lio_vf_rep_destroy(struct octeon_device *oct)
625625

626626
oct->vf_rep_list.num_vfs = 0;
627627
}
628+
629+
static int
630+
lio_vf_rep_netdev_event(struct notifier_block *nb,
631+
unsigned long event, void *ptr)
632+
{
633+
struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
634+
struct lio_vf_rep_desc *vf_rep;
635+
struct lio_vf_rep_req rep_cfg;
636+
struct octeon_device *oct;
637+
int ret;
638+
639+
switch (event) {
640+
case NETDEV_REGISTER:
641+
case NETDEV_CHANGENAME:
642+
break;
643+
644+
default:
645+
return NOTIFY_DONE;
646+
}
647+
648+
if (ndev->netdev_ops != &lio_vf_rep_ndev_ops)
649+
return NOTIFY_DONE;
650+
651+
vf_rep = netdev_priv(ndev);
652+
oct = vf_rep->oct;
653+
654+
if (strlen(ndev->name) > LIO_IF_NAME_SIZE) {
655+
dev_err(&oct->pci_dev->dev,
656+
"Device name change sync failed as the size is > %d\n",
657+
LIO_IF_NAME_SIZE);
658+
return NOTIFY_DONE;
659+
}
660+
661+
memset(&rep_cfg, 0, sizeof(rep_cfg));
662+
rep_cfg.req_type = LIO_VF_REP_REQ_DEVNAME;
663+
rep_cfg.ifidx = vf_rep->ifidx;
664+
strncpy(rep_cfg.rep_name.name, ndev->name, LIO_IF_NAME_SIZE);
665+
666+
ret = lio_vf_rep_send_soft_command(oct, &rep_cfg,
667+
sizeof(rep_cfg), NULL, 0);
668+
if (ret)
669+
dev_err(&oct->pci_dev->dev,
670+
"vf_rep netdev name change failed with err %d\n", ret);
671+
672+
return NOTIFY_DONE;
673+
}
674+
675+
static struct notifier_block lio_vf_rep_netdev_notifier = {
676+
.notifier_call = lio_vf_rep_netdev_event,
677+
};
678+
679+
int
680+
lio_vf_rep_modinit(void)
681+
{
682+
if (register_netdevice_notifier(&lio_vf_rep_netdev_notifier)) {
683+
pr_err("netdev notifier registration failed\n");
684+
return -EFAULT;
685+
}
686+
687+
return 0;
688+
}
689+
690+
void
691+
lio_vf_rep_modexit(void)
692+
{
693+
if (unregister_netdevice_notifier(&lio_vf_rep_netdev_notifier))
694+
pr_err("netdev notifier unregister failed\n");
695+
}

drivers/net/ethernet/cavium/liquidio/lio_vf_rep.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ struct lio_vf_rep_sc_ctx {
4444

4545
int lio_vf_rep_create(struct octeon_device *oct);
4646
void lio_vf_rep_destroy(struct octeon_device *oct);
47+
int lio_vf_rep_modinit(void);
48+
void lio_vf_rep_modexit(void);
4749
#endif

drivers/net/ethernet/cavium/liquidio/liquidio_common.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,20 +928,26 @@ enum lio_vf_rep_req_type {
928928
LIO_VF_REP_REQ_NONE,
929929
LIO_VF_REP_REQ_STATE,
930930
LIO_VF_REP_REQ_MTU,
931-
LIO_VF_REP_REQ_STATS
931+
LIO_VF_REP_REQ_STATS,
932+
LIO_VF_REP_REQ_DEVNAME
932933
};
933934

934935
enum {
935936
LIO_VF_REP_STATE_DOWN,
936937
LIO_VF_REP_STATE_UP
937938
};
938939

940+
#define LIO_IF_NAME_SIZE 16
939941
struct lio_vf_rep_req {
940942
u8 req_type;
941943
u8 ifidx;
942944
u8 rsvd[6];
943945

944946
union {
947+
struct lio_vf_rep_name {
948+
char name[LIO_IF_NAME_SIZE];
949+
} rep_name;
950+
945951
struct lio_vf_rep_mtu {
946952
u32 mtu;
947953
u32 rsvd;

0 commit comments

Comments
 (0)