Skip to content

Commit f846833

Browse files
Rajesh Borundiadavem330
authored andcommitted
qlcnic: SR-IOV VF probe
o Add PCI device entry for VF. o Add HW operations for VF. Signed-off-by: Manish Chopra <[email protected]> Signed-off-by: Sucheta Chakraborty <[email protected]> Signed-off-by: Rajesh Borundia <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 02feda1 commit f846833

File tree

8 files changed

+214
-22
lines changed

8 files changed

+214
-22
lines changed

drivers/net/ethernet/qlogic/qlcnic/qlcnic.h

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,9 @@ int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *);
15231523
void qlcnic_add_lb_filter(struct qlcnic_adapter *, struct sk_buff *, int,
15241524
__le16);
15251525
int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter);
1526+
int qlcnic_read_mac_addr(struct qlcnic_adapter *);
1527+
int qlcnic_setup_netdev(struct qlcnic_adapter *, struct net_device *, int);
1528+
15261529
/*
15271530
* QLOGIC Board information
15281531
*/
@@ -1647,7 +1650,10 @@ static inline int qlcnic_alloc_mbx_args(struct qlcnic_cmd_args *mbx,
16471650
static inline int qlcnic_issue_cmd(struct qlcnic_adapter *adapter,
16481651
struct qlcnic_cmd_args *cmd)
16491652
{
1650-
return adapter->ahw->hw_ops->mbx_cmd(adapter, cmd);
1653+
if (adapter->ahw->hw_ops->mbx_cmd)
1654+
return adapter->ahw->hw_ops->mbx_cmd(adapter, cmd);
1655+
1656+
return -EIO;
16511657
}
16521658

16531659
static inline void qlcnic_get_func_no(struct qlcnic_adapter *adapter)
@@ -1667,12 +1673,14 @@ static inline void qlcnic_api_unlock(struct qlcnic_adapter *adapter)
16671673

16681674
static inline void qlcnic_add_sysfs(struct qlcnic_adapter *adapter)
16691675
{
1670-
adapter->ahw->hw_ops->add_sysfs(adapter);
1676+
if (adapter->ahw->hw_ops->add_sysfs)
1677+
adapter->ahw->hw_ops->add_sysfs(adapter);
16711678
}
16721679

16731680
static inline void qlcnic_remove_sysfs(struct qlcnic_adapter *adapter)
16741681
{
1675-
adapter->ahw->hw_ops->remove_sysfs(adapter);
1682+
if (adapter->ahw->hw_ops->remove_sysfs)
1683+
adapter->ahw->hw_ops->remove_sysfs(adapter);
16761684
}
16771685

16781686
static inline void
@@ -1790,12 +1798,14 @@ static inline int qlcnic_get_board_info(struct qlcnic_adapter *adapter)
17901798
static inline void qlcnic_dev_request_reset(struct qlcnic_adapter *adapter,
17911799
u32 key)
17921800
{
1793-
adapter->nic_ops->request_reset(adapter, key);
1801+
if (adapter->nic_ops->request_reset)
1802+
adapter->nic_ops->request_reset(adapter, key);
17941803
}
17951804

17961805
static inline void qlcnic_cancel_idc_work(struct qlcnic_adapter *adapter)
17971806
{
1798-
adapter->nic_ops->cancel_idc_work(adapter);
1807+
if (adapter->nic_ops->cancel_idc_work)
1808+
adapter->nic_ops->cancel_idc_work(adapter);
17991809
}
18001810

18011811
static inline irqreturn_t
@@ -1842,7 +1852,9 @@ extern const struct ethtool_ops qlcnic_ethtool_failed_ops;
18421852
} while (0)
18431853

18441854
#define PCI_DEVICE_ID_QLOGIC_QLE834X 0x8030
1855+
#define PCI_DEVICE_ID_QLOGIC_VF_QLE834X 0x8430
18451856
#define PCI_DEVICE_ID_QLOGIC_QLE824X 0x8020
1857+
18461858
static inline bool qlcnic_82xx_check(struct qlcnic_adapter *adapter)
18471859
{
18481860
unsigned short device = adapter->pdev->device;
@@ -1852,12 +1864,23 @@ static inline bool qlcnic_82xx_check(struct qlcnic_adapter *adapter)
18521864
static inline bool qlcnic_83xx_check(struct qlcnic_adapter *adapter)
18531865
{
18541866
unsigned short device = adapter->pdev->device;
1855-
return (device == PCI_DEVICE_ID_QLOGIC_QLE834X) ? true : false;
1867+
bool status;
1868+
1869+
status = ((device == PCI_DEVICE_ID_QLOGIC_QLE834X) ||
1870+
(device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X)) ? true : false;
1871+
1872+
return status;
18561873
}
18571874

18581875
static inline bool qlcnic_sriov_pf_check(struct qlcnic_adapter *adapter)
18591876
{
18601877
return (adapter->ahw->op_mode == QLCNIC_SRIOV_PF_FUNC) ? true : false;
18611878
}
18621879

1880+
static inline bool qlcnic_sriov_vf_check(struct qlcnic_adapter *adapter)
1881+
{
1882+
unsigned short device = adapter->pdev->device;
1883+
1884+
return (device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X) ? true : false;
1885+
}
18631886
#endif /* __QLCNIC_H_ */

drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "qlcnic.h"
9+
#include "qlcnic_sriov.h"
910
#include <linux/if_vlan.h>
1011
#include <linux/ipv6.h>
1112
#include <linux/ethtool.h>
@@ -212,7 +213,7 @@ static const struct qlcnic_mailbox_metadata qlcnic_83xx_mbx_tbl[] = {
212213
{QLCNIC_CMD_CONFIG_VPORT, 4, 4},
213214
};
214215

215-
static const u32 qlcnic_83xx_ext_reg_tbl[] = {
216+
const u32 qlcnic_83xx_ext_reg_tbl[] = {
216217
0x38CC, /* Global Reset */
217218
0x38F0, /* Wildcard */
218219
0x38FC, /* Informant */
@@ -258,7 +259,7 @@ static const u32 qlcnic_83xx_ext_reg_tbl[] = {
258259
0x34A4, /* QLC_83XX_ASIC_TEMP */
259260
};
260261

261-
static const u32 qlcnic_83xx_reg_tbl[] = {
262+
const u32 qlcnic_83xx_reg_tbl[] = {
262263
0x34A8, /* PEG_HALT_STAT1 */
263264
0x34AC, /* PEG_HALT_STAT2 */
264265
0x34B0, /* FW_HEARTBEAT */
@@ -415,8 +416,11 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr)
415416
return err;
416417
if (adapter->flags & QLCNIC_MSIX_ENABLED)
417418
num_msix = adapter->ahw->num_msix;
418-
else
419+
else {
420+
if (qlcnic_sriov_vf_check(adapter))
421+
return -EINVAL;
419422
num_msix = 1;
423+
}
420424
/* setup interrupt mapping table for fw */
421425
ahw->intr_tbl = vzalloc(num_msix *
422426
sizeof(struct qlcnic_intrpt_config));
@@ -649,7 +653,7 @@ int qlcnic_83xx_setup_mbx_intr(struct qlcnic_adapter *adapter)
649653
void qlcnic_83xx_get_func_no(struct qlcnic_adapter *adapter)
650654
{
651655
u32 val = QLCRDX(adapter->ahw, QLCNIC_INFORMANT);
652-
adapter->ahw->pci_func = val & 0xf;
656+
adapter->ahw->pci_func = (val >> 24) & 0xff;
653657
}
654658

655659
int qlcnic_83xx_cam_lock(struct qlcnic_adapter *adapter)
@@ -761,6 +765,11 @@ void qlcnic_83xx_check_vf(struct qlcnic_adapter *adapter,
761765
ahw->fw_hal_version = 2;
762766
qlcnic_get_func_no(adapter);
763767

768+
if (qlcnic_sriov_vf_check(adapter)) {
769+
qlcnic_sriov_vf_set_ops(adapter);
770+
return;
771+
}
772+
764773
/* Determine function privilege level */
765774
op_mode = QLCRDX(adapter->ahw, QLC_83XX_DRV_OP_MODE);
766775
if (op_mode == QLC_83XX_DEFAULT_OPMODE)
@@ -1487,6 +1496,9 @@ void qlcnic_83xx_register_nic_idc_func(struct qlcnic_adapter *adapter,
14871496
struct qlcnic_cmd_args cmd;
14881497
int status;
14891498

1499+
if (qlcnic_sriov_vf_check(adapter))
1500+
return;
1501+
14901502
if (enable) {
14911503
qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_INIT_NIC_FUNC);
14921504
cmd.req.arg[1] = BIT_0 | BIT_31;

drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ int qlcnic_83xx_read_flash_descriptor_table(struct qlcnic_adapter *);
419419
int qlcnic_83xx_flash_read32(struct qlcnic_adapter *, u32, u8 *, int);
420420
int qlcnic_83xx_lockless_flash_read32(struct qlcnic_adapter *,
421421
u32, u8 *, int);
422-
int qlcnic_83xx_init(struct qlcnic_adapter *);
422+
int qlcnic_83xx_init(struct qlcnic_adapter *, int);
423423
int qlcnic_83xx_idc_ready_state_entry(struct qlcnic_adapter *);
424424
int qlcnic_83xx_check_hw_status(struct qlcnic_adapter *p_dev);
425425
void qlcnic_83xx_idc_poll_dev_state(struct work_struct *);

drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* See LICENSE.qlcnic for copyright and licensing details.
66
*/
77

8+
#include "qlcnic_sriov.h"
89
#include "qlcnic.h"
910
#include "qlcnic_hw.h"
1011

@@ -2045,10 +2046,13 @@ static void qlcnic_83xx_clear_function_resources(struct qlcnic_adapter *adapter)
20452046
}
20462047
}
20472048

2048-
int qlcnic_83xx_init(struct qlcnic_adapter *adapter)
2049+
int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
20492050
{
20502051
struct qlcnic_hardware_context *ahw = adapter->ahw;
20512052

2053+
if (qlcnic_sriov_vf_check(adapter))
2054+
return qlcnic_sriov_vf_init(adapter, pci_using_dac);
2055+
20522056
if (qlcnic_83xx_check_hw_status(adapter))
20532057
return -EIO;
20542058

drivers/net/ethernet/qlogic/qlcnic/qlcnic_hdr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ enum {
715715
QLCNIC_PRIV_FUNC = 1,
716716
QLCNIC_NON_PRIV_FUNC = 2,
717717
QLCNIC_SRIOV_PF_FUNC = 3,
718-
QLCNIC_UNKNOWN_FUNC_MODE = 4
718+
QLCNIC_SRIOV_VF_FUNC = 4,
719+
QLCNIC_UNKNOWN_FUNC_MODE = 5
719720
};
720721

721722
enum {

drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static u32 qlcnic_vlan_tx_check(struct qlcnic_adapter *adapter)
110110
static DEFINE_PCI_DEVICE_TABLE(qlcnic_pci_tbl) = {
111111
ENTRY(PCI_DEVICE_ID_QLOGIC_QLE824X),
112112
ENTRY(PCI_DEVICE_ID_QLOGIC_QLE834X),
113+
ENTRY(PCI_DEVICE_ID_QLOGIC_VF_QLE834X),
113114
{0,}
114115
};
115116

@@ -199,8 +200,7 @@ void qlcnic_free_sds_rings(struct qlcnic_recv_context *recv_ctx)
199200
recv_ctx->sds_rings = NULL;
200201
}
201202

202-
static int
203-
qlcnic_read_mac_addr(struct qlcnic_adapter *adapter)
203+
int qlcnic_read_mac_addr(struct qlcnic_adapter *adapter)
204204
{
205205
u8 mac_addr[ETH_ALEN];
206206
struct net_device *netdev = adapter->netdev;
@@ -713,6 +713,7 @@ static void qlcnic_get_bar_length(u32 dev_id, ulong *bar)
713713
*bar = QLCNIC_82XX_BAR0_LENGTH;
714714
break;
715715
case PCI_DEVICE_ID_QLOGIC_QLE834X:
716+
case PCI_DEVICE_ID_QLOGIC_VF_QLE834X:
716717
*bar = QLCNIC_83XX_BAR0_LENGTH;
717718
break;
718719
default:
@@ -743,7 +744,7 @@ static int qlcnic_setup_pci_map(struct pci_dev *pdev,
743744
return -EIO;
744745
}
745746

746-
dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
747+
dev_info(&pdev->dev, "%dKB memory map\n", (int)(mem_len >> 10));
747748

748749
ahw->pci_base0 = mem_ptr0;
749750
ahw->pci_len0 = pci_len0;
@@ -1678,7 +1679,7 @@ qlcnic_reset_context(struct qlcnic_adapter *adapter)
16781679
return err;
16791680
}
16801681

1681-
static int
1682+
int
16821683
qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev,
16831684
int pci_using_dac)
16841685
{
@@ -1813,6 +1814,9 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
18131814
u32 capab2;
18141815
char board_name[QLCNIC_MAX_BOARD_NAME_LEN + 19]; /* MAC + ": " + name */
18151816

1817+
if (pdev->is_virtfn)
1818+
return -ENODEV;
1819+
18161820
err = pci_enable_device(pdev);
18171821
if (err)
18181822
return err;
@@ -1837,12 +1841,18 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
18371841
if (!ahw)
18381842
goto err_out_free_res;
18391843

1840-
if (ent->device == PCI_DEVICE_ID_QLOGIC_QLE824X) {
1844+
switch (ent->device) {
1845+
case PCI_DEVICE_ID_QLOGIC_QLE824X:
18411846
ahw->hw_ops = &qlcnic_hw_ops;
1842-
ahw->reg_tbl = (u32 *)qlcnic_reg_tbl;
1843-
} else if (ent->device == PCI_DEVICE_ID_QLOGIC_QLE834X) {
1847+
ahw->reg_tbl = (u32 *) qlcnic_reg_tbl;
1848+
break;
1849+
case PCI_DEVICE_ID_QLOGIC_QLE834X:
18441850
qlcnic_83xx_register_map(ahw);
1845-
} else {
1851+
break;
1852+
case PCI_DEVICE_ID_QLOGIC_VF_QLE834X:
1853+
qlcnic_sriov_vf_register_map(ahw);
1854+
break;
1855+
default:
18461856
goto err_out_free_hw_res;
18471857
}
18481858

@@ -1904,11 +1914,13 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
19041914
} else if (qlcnic_83xx_check(adapter)) {
19051915
qlcnic_83xx_check_vf(adapter, ent);
19061916
adapter->portnum = adapter->ahw->pci_func;
1907-
err = qlcnic_83xx_init(adapter);
1917+
err = qlcnic_83xx_init(adapter, pci_using_dac);
19081918
if (err) {
19091919
dev_err(&pdev->dev, "%s: failed\n", __func__);
19101920
goto err_out_free_hw;
19111921
}
1922+
if (qlcnic_sriov_vf_check(adapter))
1923+
return 0;
19121924
} else {
19131925
dev_err(&pdev->dev,
19141926
"%s: failed. Please Reboot\n", __func__);

drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <linux/types.h>
1313
#include <linux/pci.h>
1414

15+
extern const u32 qlcnic_83xx_reg_tbl[];
16+
extern const u32 qlcnic_83xx_ext_reg_tbl[];
17+
1518
struct qlcnic_resources {
1619
u16 num_tx_mac_filters;
1720
u16 num_rx_ucast_mac_filters;
@@ -40,6 +43,9 @@ struct qlcnic_sriov {
4043
int qlcnic_sriov_init(struct qlcnic_adapter *, int);
4144
void qlcnic_sriov_cleanup(struct qlcnic_adapter *);
4245
void __qlcnic_sriov_cleanup(struct qlcnic_adapter *);
46+
void qlcnic_sriov_vf_register_map(struct qlcnic_hardware_context *);
47+
int qlcnic_sriov_vf_init(struct qlcnic_adapter *, int);
48+
void qlcnic_sriov_vf_set_ops(struct qlcnic_adapter *);
4349

4450
static inline bool qlcnic_sriov_enable_check(struct qlcnic_adapter *adapter)
4551
{

0 commit comments

Comments
 (0)