16
16
#include "octep_config.h"
17
17
#include "octep_main.h"
18
18
#include "octep_ctrl_net.h"
19
+ #include "octep_pfvf_mbox.h"
19
20
20
21
#define OCTEP_INTR_POLL_TIME_MSECS 100
21
22
struct workqueue_struct * octep_wq ;
@@ -159,6 +160,21 @@ static void octep_disable_msix(struct octep_device *oct)
159
160
dev_info (& oct -> pdev -> dev , "Disabled MSI-X\n" );
160
161
}
161
162
163
+ /**
164
+ * octep_mbox_intr_handler() - common handler for pfvf mbox interrupts.
165
+ *
166
+ * @irq: Interrupt number.
167
+ * @data: interrupt data.
168
+ *
169
+ * this is common handler for pfvf mbox interrupts.
170
+ */
171
+ static irqreturn_t octep_mbox_intr_handler (int irq , void * data )
172
+ {
173
+ struct octep_device * oct = data ;
174
+
175
+ return oct -> hw_ops .mbox_intr_handler (oct );
176
+ }
177
+
162
178
/**
163
179
* octep_oei_intr_handler() - common handler for output endpoint interrupts.
164
180
*
@@ -362,8 +378,12 @@ static int octep_request_irqs(struct octep_device *oct)
362
378
363
379
snprintf (irq_name , OCTEP_MSIX_NAME_SIZE ,
364
380
"%s-%s" , netdev -> name , non_ioq_msix_names [i ]);
365
- if (!strncmp (non_ioq_msix_names [i ], "epf_oei_rint" ,
366
- strlen ("epf_oei_rint" ))) {
381
+ if (!strncmp (non_ioq_msix_names [i ], "epf_mbox_rint" , strlen ("epf_mbox_rint" ))) {
382
+ ret = request_irq (msix_entry -> vector ,
383
+ octep_mbox_intr_handler , 0 ,
384
+ irq_name , oct );
385
+ } else if (!strncmp (non_ioq_msix_names [i ], "epf_oei_rint" ,
386
+ strlen ("epf_oei_rint" ))) {
367
387
ret = request_irq (msix_entry -> vector ,
368
388
octep_oei_intr_handler , 0 ,
369
389
irq_name , oct );
@@ -1322,6 +1342,7 @@ static void octep_device_cleanup(struct octep_device *oct)
1322
1342
oct -> mbox [i ] = NULL ;
1323
1343
}
1324
1344
1345
+ octep_delete_pfvf_mbox (oct );
1325
1346
octep_ctrl_net_uninit (oct );
1326
1347
cancel_delayed_work_sync (& oct -> hb_task );
1327
1348
@@ -1419,6 +1440,12 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1419
1440
goto err_octep_config ;
1420
1441
}
1421
1442
1443
+ err = octep_setup_pfvf_mbox (octep_dev );
1444
+ if (err ) {
1445
+ dev_err (& pdev -> dev , "PF-VF mailbox setup failed\n" );
1446
+ goto register_dev_err ;
1447
+ }
1448
+
1422
1449
err = octep_ctrl_net_get_info (octep_dev , OCTEP_CTRL_NET_INVALID_VFID ,
1423
1450
& octep_dev -> conf -> fw_info );
1424
1451
if (err ) {
@@ -1487,6 +1514,21 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1487
1514
return err ;
1488
1515
}
1489
1516
1517
+ static int octep_sriov_disable (struct octep_device * oct )
1518
+ {
1519
+ struct pci_dev * pdev = oct -> pdev ;
1520
+
1521
+ if (pci_vfs_assigned (oct -> pdev )) {
1522
+ dev_warn (& pdev -> dev , "Can't disable SRIOV while VFs are assigned\n" );
1523
+ return - EPERM ;
1524
+ }
1525
+
1526
+ pci_disable_sriov (pdev );
1527
+ CFG_GET_ACTIVE_VFS (oct -> conf ) = 0 ;
1528
+
1529
+ return 0 ;
1530
+ }
1531
+
1490
1532
/**
1491
1533
* octep_remove() - Remove Octeon PCI device from driver control.
1492
1534
*
@@ -1504,6 +1546,7 @@ static void octep_remove(struct pci_dev *pdev)
1504
1546
return ;
1505
1547
1506
1548
netdev = oct -> netdev ;
1549
+ octep_sriov_disable (oct );
1507
1550
if (netdev -> reg_state == NETREG_REGISTERED )
1508
1551
unregister_netdev (netdev );
1509
1552
@@ -1514,11 +1557,47 @@ static void octep_remove(struct pci_dev *pdev)
1514
1557
pci_disable_device (pdev );
1515
1558
}
1516
1559
1560
+ static int octep_sriov_enable (struct octep_device * oct , int num_vfs )
1561
+ {
1562
+ struct pci_dev * pdev = oct -> pdev ;
1563
+ int err ;
1564
+
1565
+ CFG_GET_ACTIVE_VFS (oct -> conf ) = num_vfs ;
1566
+ err = pci_enable_sriov (pdev , num_vfs );
1567
+ if (err ) {
1568
+ dev_warn (& pdev -> dev , "Failed to enable SRIOV err=%d\n" , err );
1569
+ CFG_GET_ACTIVE_VFS (oct -> conf ) = 0 ;
1570
+ return err ;
1571
+ }
1572
+
1573
+ return num_vfs ;
1574
+ }
1575
+
1576
+ static int octep_sriov_configure (struct pci_dev * pdev , int num_vfs )
1577
+ {
1578
+ struct octep_device * oct = pci_get_drvdata (pdev );
1579
+ int max_nvfs ;
1580
+
1581
+ if (num_vfs == 0 )
1582
+ return octep_sriov_disable (oct );
1583
+
1584
+ max_nvfs = CFG_GET_MAX_VFS (oct -> conf );
1585
+
1586
+ if (num_vfs > max_nvfs ) {
1587
+ dev_err (& pdev -> dev , "Invalid VF count Max supported VFs = %d\n" ,
1588
+ max_nvfs );
1589
+ return - EINVAL ;
1590
+ }
1591
+
1592
+ return octep_sriov_enable (oct , num_vfs );
1593
+ }
1594
+
1517
1595
static struct pci_driver octep_driver = {
1518
1596
.name = OCTEP_DRV_NAME ,
1519
1597
.id_table = octep_pci_id_tbl ,
1520
1598
.probe = octep_probe ,
1521
1599
.remove = octep_remove ,
1600
+ .sriov_configure = octep_sriov_configure ,
1522
1601
};
1523
1602
1524
1603
/**
0 commit comments