Commit 02feda17 authored by Rajesh Borundia's avatar Rajesh Borundia Committed by David S. Miller

qlcnic: Support SR-IOV enable and disable

o Add QLCNIC_SRIOV to Kconfig.
o Provide PCI sysfs hooks to enable and disable SR-IOV.
o Allow enabling only when CONFIG_QLCNIC_SRIOV is defined.
o qlcnic_sriov_pf.c has all the PF related SR-IOV
  functionality.
o qlcnic_sriov_common.c has VF functionality and SR-IOV
  functionality which is common between VF and PF.
o qlcnic_sriov.h is a common header file for SR-IOV defines.
Signed-off-by: default avatarManish Chopra <manish.chopra@qlogic.com>
Signed-off-by: default avatarSucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: default avatarRajesh Borundia <rajesh.borundia@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c23343cf
......@@ -35,6 +35,16 @@ config QLCNIC
This driver supports QLogic QLE8240 and QLE8242 Converged Ethernet
devices.
config QLCNIC_SRIOV
bool "QLOGIC QLCNIC 83XX family SR-IOV Support"
depends on QLCNIC && PCI_IOV
default y
---help---
This configuration parameter enables Single Root Input Output
Virtualization support for QLE83XX Converged Ethernet devices.
This allows for virtual function acceleration in virtualized
environments.
config QLGE
tristate "QLogic QLGE 10Gb Ethernet Driver Support"
depends on PCI
......
......@@ -8,4 +8,6 @@ qlcnic-y := qlcnic_hw.o qlcnic_main.o qlcnic_init.o \
qlcnic_ethtool.o qlcnic_ctx.o qlcnic_io.o \
qlcnic_sysfs.o qlcnic_minidump.o qlcnic_83xx_hw.o \
qlcnic_83xx_init.o qlcnic_83xx_vnic.o \
qlcnic_minidump.o
qlcnic_minidump.o qlcnic_sriov_common.o
qlcnic-$(CONFIG_QLCNIC_SRIOV) += qlcnic_sriov_pf.o
......@@ -449,6 +449,7 @@ struct qlcnic_hardware_context {
struct qlc_83xx_idc idc;
struct qlc_83xx_fw_info fw_info;
struct qlcnic_intrpt_config *intr_tbl;
struct qlcnic_sriov *sriov;
u32 *reg_tbl;
u32 *ext_reg_tbl;
u32 mbox_aen[QLC_83XX_MBX_AEN_CNT];
......@@ -914,7 +915,9 @@ struct qlcnic_ipaddr {
#define __QLCNIC_AER 5
#define __QLCNIC_DIAG_RES_ALLOC 6
#define __QLCNIC_LED_ENABLE 7
#define __QLCNIC_ELB_INPROGRESS 8
#define __QLCNIC_ELB_INPROGRESS 8
#define __QLCNIC_SRIOV_ENABLE 10
#define __QLCNIC_SRIOV_CAPABLE 11
#define QLCNIC_INTERRUPT_TEST 1
#define QLCNIC_LOOPBACK_TEST 2
......@@ -1051,7 +1054,11 @@ struct qlcnic_info_le {
u8 total_pf;
u8 total_rss_engines;
__le16 max_vports;
u8 reserved2[64];
__le16 linkstate_reg_offset;
__le16 bit_offsets;
__le16 max_local_ipv6_addrs;
__le16 max_remote_ipv6_addrs;
u8 reserved2[56];
} __packed;
struct qlcnic_info {
......@@ -1083,6 +1090,10 @@ struct qlcnic_info {
u8 total_pf;
u8 total_rss_engines;
u16 max_vports;
u16 linkstate_reg_offset;
u16 bit_offsets;
u16 max_local_ipv6_addrs;
u16 max_remote_ipv6_addrs;
};
struct qlcnic_pci_info_le {
......@@ -1511,6 +1522,7 @@ int qlcnic_reset_npar_config(struct qlcnic_adapter *);
int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *);
void qlcnic_add_lb_filter(struct qlcnic_adapter *, struct sk_buff *, int,
__le16);
int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter);
/*
* QLOGIC Board information
*/
......@@ -1843,5 +1855,9 @@ static inline bool qlcnic_83xx_check(struct qlcnic_adapter *adapter)
return (device == PCI_DEVICE_ID_QLOGIC_QLE834X) ? true : false;
}
static inline bool qlcnic_sriov_pf_check(struct qlcnic_adapter *adapter)
{
return (adapter->ahw->op_mode == QLCNIC_SRIOV_PF_FUNC) ? true : false;
}
#endif /* __QLCNIC_H_ */
......@@ -209,6 +209,7 @@ static const struct qlcnic_mailbox_metadata qlcnic_83xx_mbx_tbl[] = {
{QLCNIC_CMD_SET_LED_CONFIG, 5, 1},
{QLCNIC_CMD_GET_LED_CONFIG, 1, 5},
{QLCNIC_CMD_ADD_RCV_RINGS, 130, 26},
{QLCNIC_CMD_CONFIG_VPORT, 4, 4},
};
static const u32 qlcnic_83xx_ext_reg_tbl[] = {
......@@ -775,6 +776,9 @@ void qlcnic_83xx_check_vf(struct qlcnic_adapter *adapter,
ahw->fw_hal_version);
adapter->nic_ops = &qlcnic_vf_ops;
} else {
if (pci_find_ext_capability(adapter->pdev,
PCI_EXT_CAP_ID_SRIOV))
set_bit(__QLCNIC_SRIOV_CAPABLE, &adapter->state);
adapter->nic_ops = &qlcnic_83xx_ops;
}
}
......
......@@ -243,6 +243,7 @@ struct qlc_83xx_idc {
#define QLC_83XX_GET_FW_LRO_MSS_CAPABILITY(val) (val & 0x20000)
#define QLC_83XX_VIRTUAL_NIC_MODE 0xFF
#define QLC_83XX_DEFAULT_MODE 0x0
#define QLC_83XX_SRIOV_MODE 0x1
#define QLCNIC_BRDTYPE_83XX_10G 0x0083
#define QLC_83XX_FLASH_SPI_STATUS 0x2808E010
......
......@@ -25,7 +25,6 @@
#define QLC_83XX_OPCODE_POLL_READ_LIST 0x0100
static int qlcnic_83xx_init_default_driver(struct qlcnic_adapter *adapter);
static int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter);
static int qlcnic_83xx_check_heartbeat(struct qlcnic_adapter *p_dev);
static int qlcnic_83xx_restart_hw(struct qlcnic_adapter *adapter);
......@@ -1918,6 +1917,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
qlcnic_get_func_no(adapter);
op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
if (test_bit(__QLCNIC_SRIOV_CAPABLE, &adapter->state))
op_mode = QLC_83XX_DEFAULT_OPMODE;
if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
......@@ -1947,6 +1949,16 @@ int qlcnic_83xx_get_nic_configuration(struct qlcnic_adapter *adapter)
ahw->max_mac_filters = nic_info.max_mac_filters;
ahw->max_mtu = nic_info.max_mtu;
/* VNIC mode is detected by BIT_23 in capabilities. This bit is also
* set in case device is SRIOV capable. VNIC and SRIOV are mutually
* exclusive. So in case of sriov capable device load driver in
* default mode
*/
if (test_bit(__QLCNIC_SRIOV_CAPABLE, &adapter->state)) {
ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
return ahw->nic_mode;
}
if (ahw->capabilities & BIT_23)
ahw->nic_mode = QLC_83XX_VIRTUAL_NIC_MODE;
else
......@@ -1955,7 +1967,7 @@ int qlcnic_83xx_get_nic_configuration(struct qlcnic_adapter *adapter)
return ahw->nic_mode;
}
static int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
{
int ret;
......
......@@ -714,7 +714,8 @@ enum {
QLCNIC_MGMT_FUNC = 0,
QLCNIC_PRIV_FUNC = 1,
QLCNIC_NON_PRIV_FUNC = 2,
QLCNIC_UNKNOWN_FUNC_MODE = 3
QLCNIC_SRIOV_PF_FUNC = 3,
QLCNIC_UNKNOWN_FUNC_MODE = 4
};
enum {
......
......@@ -83,6 +83,7 @@ enum qlcnic_regs {
#define QLCNIC_CMD_CONFIG_PORT 0x2e
#define QLCNIC_CMD_TEMP_SIZE 0x2f
#define QLCNIC_CMD_GET_TEMP_HDR 0x30
#define QLCNIC_CMD_CONFIG_VPORT 0x32
#define QLCNIC_CMD_GET_MAC_STATS 0x37
#define QLCNIC_CMD_SET_DRV_VER 0x38
#define QLCNIC_CMD_CONFIGURE_RSS 0x41
......
......@@ -9,6 +9,7 @@
#include <linux/interrupt.h>
#include "qlcnic.h"
#include "qlcnic_sriov.h"
#include "qlcnic_hw.h"
#include <linux/swab.h>
......@@ -2022,11 +2023,13 @@ static void qlcnic_remove(struct pci_dev *pdev)
return;
netdev = adapter->netdev;
qlcnic_sriov_pf_disable(adapter);
qlcnic_cancel_idc_work(adapter);
ahw = adapter->ahw;
unregister_netdev(netdev);
qlcnic_sriov_cleanup(adapter);
if (qlcnic_83xx_check(adapter)) {
qlcnic_83xx_free_mbx_intr(adapter);
......@@ -3430,7 +3433,10 @@ static struct pci_driver qlcnic_driver = {
.resume = qlcnic_resume,
#endif
.shutdown = qlcnic_shutdown,
.err_handler = &qlcnic_err_handler
.err_handler = &qlcnic_err_handler,
#ifdef CONFIG_QLCNIC_SRIOV
.sriov_configure = qlcnic_pci_sriov_configure,
#endif
};
......
/*
* QLogic qlcnic NIC Driver
* Copyright (c) 2009-2013 QLogic Corporation
*
* See LICENSE.qlcnic for copyright and licensing details.
*/
#ifndef _QLCNIC_83XX_SRIOV_H_
#define _QLCNIC_83XX_SRIOV_H_
#include "qlcnic.h"
#include <linux/types.h>
#include <linux/pci.h>
struct qlcnic_resources {
u16 num_tx_mac_filters;
u16 num_rx_ucast_mac_filters;
u16 num_rx_mcast_mac_filters;
u16 num_txvlan_keys;
u16 num_rx_queues;
u16 num_tx_queues;
u16 num_rx_buf_rings;
u16 num_rx_status_rings;
u16 num_destip;
u32 num_lro_flows_supported;
u16 max_local_ipv6_addrs;
u16 max_remote_ipv6_addrs;
};
struct qlcnic_sriov {
u16 vp_handle;
u8 num_vfs;
struct qlcnic_resources ff_max;
};
int qlcnic_sriov_init(struct qlcnic_adapter *, int);
void qlcnic_sriov_cleanup(struct qlcnic_adapter *);
void __qlcnic_sriov_cleanup(struct qlcnic_adapter *);
static inline bool qlcnic_sriov_enable_check(struct qlcnic_adapter *adapter)
{
return test_bit(__QLCNIC_SRIOV_ENABLE, &adapter->state) ? true : false;
}
#ifdef CONFIG_QLCNIC_SRIOV
void qlcnic_sriov_pf_disable(struct qlcnic_adapter *);
void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter *);
int qlcnic_pci_sriov_configure(struct pci_dev *, int);
#else
static inline void qlcnic_sriov_pf_disable(struct qlcnic_adapter *adapter) {}
static inline void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter *adapter) {}
#endif
#endif
/*
* QLogic qlcnic NIC Driver
* Copyright (c) 2009-2013 QLogic Corporation
*
* See LICENSE.qlcnic for copyright and licensing details.
*/
#include "qlcnic_sriov.h"
#include "qlcnic.h"
#include <linux/types.h>
int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
{
struct qlcnic_sriov *sriov;
if (!qlcnic_sriov_enable_check(adapter))
return -EIO;
sriov = kzalloc(sizeof(struct qlcnic_sriov), GFP_KERNEL);
if (!sriov)
return -ENOMEM;
adapter->ahw->sriov = sriov;
sriov->num_vfs = num_vfs;
return 0;
}
void __qlcnic_sriov_cleanup(struct qlcnic_adapter *adapter)
{
if (!qlcnic_sriov_enable_check(adapter))
return;
kfree(adapter->ahw->sriov);
}
void qlcnic_sriov_cleanup(struct qlcnic_adapter *adapter)
{
if (qlcnic_sriov_pf_check(adapter))
qlcnic_sriov_pf_cleanup(adapter);
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment