提交 48f5a191 编写于 作者: A Ajit Khaparde 提交者: David S. Miller

be2net: dynamically allocate adapter->vf_cfg

Instead of a fixed sized array for vf_cfg, allocate the size dynamically
depending on number of VFs the device supports.
Signed-off-by: NAjit Khaparde <ajit.khaparde@emulex.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 81be8f0a
...@@ -92,8 +92,6 @@ static inline char *nic_name(struct pci_dev *pdev) ...@@ -92,8 +92,6 @@ static inline char *nic_name(struct pci_dev *pdev)
#define FW_VER_LEN 32 #define FW_VER_LEN 32
#define BE_MAX_VF 32
struct be_dma_mem { struct be_dma_mem {
void *va; void *va;
dma_addr_t dma; dma_addr_t dma;
...@@ -336,7 +334,7 @@ struct be_adapter { ...@@ -336,7 +334,7 @@ struct be_adapter {
bool be3_native; bool be3_native;
bool sriov_enabled; bool sriov_enabled;
struct be_vf_cfg vf_cfg[BE_MAX_VF]; struct be_vf_cfg *vf_cfg;
u8 is_virtfn; u8 is_virtfn;
u32 sli_family; u32 sli_family;
u8 hba_port_num; u8 hba_port_num;
......
...@@ -2838,6 +2838,7 @@ static void __devexit be_remove(struct pci_dev *pdev) ...@@ -2838,6 +2838,7 @@ static void __devexit be_remove(struct pci_dev *pdev)
be_ctrl_cleanup(adapter); be_ctrl_cleanup(adapter);
kfree(adapter->vf_cfg);
be_sriov_disable(adapter); be_sriov_disable(adapter);
be_msix_disable(adapter); be_msix_disable(adapter);
...@@ -3022,16 +3023,23 @@ static int __devinit be_probe(struct pci_dev *pdev, ...@@ -3022,16 +3023,23 @@ static int __devinit be_probe(struct pci_dev *pdev,
} }
be_sriov_enable(adapter); be_sriov_enable(adapter);
if (adapter->sriov_enabled) {
adapter->vf_cfg = kcalloc(num_vfs,
sizeof(struct be_vf_cfg), GFP_KERNEL);
if (!adapter->vf_cfg)
goto free_netdev;
}
status = be_ctrl_init(adapter); status = be_ctrl_init(adapter);
if (status) if (status)
goto free_netdev; goto free_vf_cfg;
if (lancer_chip(adapter)) { if (lancer_chip(adapter)) {
status = lancer_test_and_set_rdy_state(adapter); status = lancer_test_and_set_rdy_state(adapter);
if (status) { if (status) {
dev_err(&pdev->dev, "Adapter in non recoverable error\n"); dev_err(&pdev->dev, "Adapter in non recoverable error\n");
goto free_netdev; goto ctrl_clean;
} }
} }
...@@ -3093,6 +3101,8 @@ static int __devinit be_probe(struct pci_dev *pdev, ...@@ -3093,6 +3101,8 @@ static int __devinit be_probe(struct pci_dev *pdev,
be_stats_cleanup(adapter); be_stats_cleanup(adapter);
ctrl_clean: ctrl_clean:
be_ctrl_cleanup(adapter); be_ctrl_cleanup(adapter);
free_vf_cfg:
kfree(adapter->vf_cfg);
free_netdev: free_netdev:
be_sriov_disable(adapter); be_sriov_disable(adapter);
free_netdev(netdev); free_netdev(netdev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册