diff options
author | Ajit Khaparde <ajit.khaparde@emulex.com> | 2011-04-06 14:08:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-07 18:04:45 -0400 |
commit | 48f5a19168c228e6533401c563d9fcbc152bc33f (patch) | |
tree | 5d9968910d64671a5719f198528419c5daf94299 /drivers/net | |
parent | 81be8f0ab47db1171dac0eb8b062291603b57dd4 (diff) |
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: Ajit Khaparde <ajit.khaparde@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/benet/be.h | 4 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 14 |
2 files changed, 13 insertions, 5 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index 7e2040084654..d2c42f5d5e9e 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -92,8 +92,6 @@ static inline char *nic_name(struct pci_dev *pdev) | |||
92 | 92 | ||
93 | #define FW_VER_LEN 32 | 93 | #define FW_VER_LEN 32 |
94 | 94 | ||
95 | #define BE_MAX_VF 32 | ||
96 | |||
97 | struct be_dma_mem { | 95 | struct be_dma_mem { |
98 | void *va; | 96 | void *va; |
99 | dma_addr_t dma; | 97 | dma_addr_t dma; |
@@ -336,7 +334,7 @@ struct be_adapter { | |||
336 | 334 | ||
337 | bool be3_native; | 335 | bool be3_native; |
338 | bool sriov_enabled; | 336 | bool sriov_enabled; |
339 | struct be_vf_cfg vf_cfg[BE_MAX_VF]; | 337 | struct be_vf_cfg *vf_cfg; |
340 | u8 is_virtfn; | 338 | u8 is_virtfn; |
341 | u32 sli_family; | 339 | u32 sli_family; |
342 | u8 hba_port_num; | 340 | u8 hba_port_num; |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index bc110782da88..6e7df0dd418b 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -2838,6 +2838,7 @@ static void __devexit be_remove(struct pci_dev *pdev) | |||
2838 | 2838 | ||
2839 | be_ctrl_cleanup(adapter); | 2839 | be_ctrl_cleanup(adapter); |
2840 | 2840 | ||
2841 | kfree(adapter->vf_cfg); | ||
2841 | be_sriov_disable(adapter); | 2842 | be_sriov_disable(adapter); |
2842 | 2843 | ||
2843 | be_msix_disable(adapter); | 2844 | be_msix_disable(adapter); |
@@ -3022,16 +3023,23 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
3022 | } | 3023 | } |
3023 | 3024 | ||
3024 | be_sriov_enable(adapter); | 3025 | be_sriov_enable(adapter); |
3026 | if (adapter->sriov_enabled) { | ||
3027 | adapter->vf_cfg = kcalloc(num_vfs, | ||
3028 | sizeof(struct be_vf_cfg), GFP_KERNEL); | ||
3029 | |||
3030 | if (!adapter->vf_cfg) | ||
3031 | goto free_netdev; | ||
3032 | } | ||
3025 | 3033 | ||
3026 | status = be_ctrl_init(adapter); | 3034 | status = be_ctrl_init(adapter); |
3027 | if (status) | 3035 | if (status) |
3028 | goto free_netdev; | 3036 | goto free_vf_cfg; |
3029 | 3037 | ||
3030 | if (lancer_chip(adapter)) { | 3038 | if (lancer_chip(adapter)) { |
3031 | status = lancer_test_and_set_rdy_state(adapter); | 3039 | status = lancer_test_and_set_rdy_state(adapter); |
3032 | if (status) { | 3040 | if (status) { |
3033 | dev_err(&pdev->dev, "Adapter in non recoverable error\n"); | 3041 | dev_err(&pdev->dev, "Adapter in non recoverable error\n"); |
3034 | goto free_netdev; | 3042 | goto ctrl_clean; |
3035 | } | 3043 | } |
3036 | } | 3044 | } |
3037 | 3045 | ||
@@ -3093,6 +3101,8 @@ stats_clean: | |||
3093 | be_stats_cleanup(adapter); | 3101 | be_stats_cleanup(adapter); |
3094 | ctrl_clean: | 3102 | ctrl_clean: |
3095 | be_ctrl_cleanup(adapter); | 3103 | be_ctrl_cleanup(adapter); |
3104 | free_vf_cfg: | ||
3105 | kfree(adapter->vf_cfg); | ||
3096 | free_netdev: | 3106 | free_netdev: |
3097 | be_sriov_disable(adapter); | 3107 | be_sriov_disable(adapter); |
3098 | free_netdev(netdev); | 3108 | free_netdev(netdev); |