diff options
author | Sreenivasa Honnur <sreenivasa.honnur@exar.com> | 2010-04-08 04:48:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-08 04:48:57 -0400 |
commit | cb27ec60640b3d3b40412c57a3fa92a0ae88dd2f (patch) | |
tree | 9e3d86c987a4a75fe72d09d7bdf0016869d7ced7 /drivers/net/vxge | |
parent | 9002397e2999b53a0d673cd89892c4cda58e1416 (diff) |
vxge: Pass correct number of VFs value to pci_sriov_enable().
- max_config_dev loadable parameter is set to 0xFF by default. Pass correct
number of VFs value to pci_sriov_enable() if max_config_dev is set to its
default value.
Signed-off-by: Sreenivasa Honnur <sreenivasa.honnur@exar.com>
Signed-off-by: Ramkrishna Vepa <ram.vepa@exar.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vxge')
-rw-r--r-- | drivers/net/vxge/vxge-config.h | 14 | ||||
-rw-r--r-- | drivers/net/vxge/vxge-main.c | 64 | ||||
-rw-r--r-- | drivers/net/vxge/vxge-main.h | 5 |
3 files changed, 71 insertions, 12 deletions
diff --git a/drivers/net/vxge/vxge-config.h b/drivers/net/vxge/vxge-config.h index 01595242a6e8..1530060d5811 100644 --- a/drivers/net/vxge/vxge-config.h +++ b/drivers/net/vxge/vxge-config.h | |||
@@ -764,10 +764,18 @@ struct vxge_hw_device_hw_info { | |||
764 | #define VXGE_HW_SR_VH_VIRTUAL_FUNCTION 6 | 764 | #define VXGE_HW_SR_VH_VIRTUAL_FUNCTION 6 |
765 | #define VXGE_HW_VH_NORMAL_FUNCTION 7 | 765 | #define VXGE_HW_VH_NORMAL_FUNCTION 7 |
766 | u64 function_mode; | 766 | u64 function_mode; |
767 | #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION 0 | 767 | #define VXGE_HW_FUNCTION_MODE_SINGLE_FUNCTION 0 |
768 | #define VXGE_HW_FUNCTION_MODE_SINGLE_FUNCTION 1 | 768 | #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION 1 |
769 | #define VXGE_HW_FUNCTION_MODE_SRIOV 2 | 769 | #define VXGE_HW_FUNCTION_MODE_SRIOV 2 |
770 | #define VXGE_HW_FUNCTION_MODE_MRIOV 3 | 770 | #define VXGE_HW_FUNCTION_MODE_MRIOV 3 |
771 | #define VXGE_HW_FUNCTION_MODE_MRIOV_8 4 | ||
772 | #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_17 5 | ||
773 | #define VXGE_HW_FUNCTION_MODE_SRIOV_8 6 | ||
774 | #define VXGE_HW_FUNCTION_MODE_SRIOV_4 7 | ||
775 | #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_2 8 | ||
776 | #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_4 9 | ||
777 | #define VXGE_HW_FUNCTION_MODE_MRIOV_4 10 | ||
778 | |||
771 | u32 func_id; | 779 | u32 func_id; |
772 | u64 vpath_mask; | 780 | u64 vpath_mask; |
773 | struct vxge_hw_device_version fw_version; | 781 | struct vxge_hw_device_version fw_version; |
@@ -2265,4 +2273,6 @@ enum vxge_hw_status vxge_hw_vpath_rts_rth_set( | |||
2265 | struct vxge_hw_rth_hash_types *hash_type, | 2273 | struct vxge_hw_rth_hash_types *hash_type, |
2266 | u16 bucket_size); | 2274 | u16 bucket_size); |
2267 | 2275 | ||
2276 | enum vxge_hw_status | ||
2277 | __vxge_hw_device_is_privilaged(u32 host_type, u32 func_id); | ||
2268 | #endif | 2278 | #endif |
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c index eceb6922c809..f7482eb9c669 100644 --- a/drivers/net/vxge/vxge-main.c +++ b/drivers/net/vxge/vxge-main.c | |||
@@ -3965,6 +3965,36 @@ static void vxge_io_resume(struct pci_dev *pdev) | |||
3965 | netif_device_attach(netdev); | 3965 | netif_device_attach(netdev); |
3966 | } | 3966 | } |
3967 | 3967 | ||
3968 | static inline u32 vxge_get_num_vfs(u64 function_mode) | ||
3969 | { | ||
3970 | u32 num_functions = 0; | ||
3971 | |||
3972 | switch (function_mode) { | ||
3973 | case VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION: | ||
3974 | case VXGE_HW_FUNCTION_MODE_SRIOV_8: | ||
3975 | num_functions = 8; | ||
3976 | break; | ||
3977 | case VXGE_HW_FUNCTION_MODE_SINGLE_FUNCTION: | ||
3978 | num_functions = 1; | ||
3979 | break; | ||
3980 | case VXGE_HW_FUNCTION_MODE_SRIOV: | ||
3981 | case VXGE_HW_FUNCTION_MODE_MRIOV: | ||
3982 | case VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_17: | ||
3983 | num_functions = 17; | ||
3984 | break; | ||
3985 | case VXGE_HW_FUNCTION_MODE_SRIOV_4: | ||
3986 | num_functions = 4; | ||
3987 | break; | ||
3988 | case VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_2: | ||
3989 | num_functions = 2; | ||
3990 | break; | ||
3991 | case VXGE_HW_FUNCTION_MODE_MRIOV_8: | ||
3992 | num_functions = 8; /* TODO */ | ||
3993 | break; | ||
3994 | } | ||
3995 | return num_functions; | ||
3996 | } | ||
3997 | |||
3968 | /** | 3998 | /** |
3969 | * vxge_probe | 3999 | * vxge_probe |
3970 | * @pdev : structure containing the PCI related information of the device. | 4000 | * @pdev : structure containing the PCI related information of the device. |
@@ -3992,14 +4022,19 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
3992 | u8 *macaddr; | 4022 | u8 *macaddr; |
3993 | struct vxge_mac_addrs *entry; | 4023 | struct vxge_mac_addrs *entry; |
3994 | static int bus = -1, device = -1; | 4024 | static int bus = -1, device = -1; |
4025 | u32 host_type; | ||
3995 | u8 new_device = 0; | 4026 | u8 new_device = 0; |
4027 | enum vxge_hw_status is_privileged; | ||
4028 | u32 function_mode; | ||
4029 | u32 num_vfs = 0; | ||
3996 | 4030 | ||
3997 | vxge_debug_entryexit(VXGE_TRACE, "%s:%d", __func__, __LINE__); | 4031 | vxge_debug_entryexit(VXGE_TRACE, "%s:%d", __func__, __LINE__); |
3998 | attr.pdev = pdev; | 4032 | attr.pdev = pdev; |
3999 | 4033 | ||
4000 | if (bus != pdev->bus->number) | 4034 | /* In SRIOV-17 mode, functions of the same adapter |
4001 | new_device = 1; | 4035 | * can be deployed on different buses */ |
4002 | if (device != PCI_SLOT(pdev->devfn)) | 4036 | if ((!pdev->is_virtfn) && ((bus != pdev->bus->number) || |
4037 | (device != PCI_SLOT(pdev->devfn)))) | ||
4003 | new_device = 1; | 4038 | new_device = 1; |
4004 | 4039 | ||
4005 | bus = pdev->bus->number; | 4040 | bus = pdev->bus->number; |
@@ -4133,6 +4168,11 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4133 | "%s:%d Vpath mask = %llx", __func__, __LINE__, | 4168 | "%s:%d Vpath mask = %llx", __func__, __LINE__, |
4134 | (unsigned long long)vpath_mask); | 4169 | (unsigned long long)vpath_mask); |
4135 | 4170 | ||
4171 | function_mode = ll_config.device_hw_info.function_mode; | ||
4172 | host_type = ll_config.device_hw_info.host_type; | ||
4173 | is_privileged = __vxge_hw_device_is_privilaged(host_type, | ||
4174 | ll_config.device_hw_info.func_id); | ||
4175 | |||
4136 | /* Check how many vpaths are available */ | 4176 | /* Check how many vpaths are available */ |
4137 | for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++) { | 4177 | for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++) { |
4138 | if (!((vpath_mask) & vxge_mBIT(i))) | 4178 | if (!((vpath_mask) & vxge_mBIT(i))) |
@@ -4140,14 +4180,18 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4140 | max_vpath_supported++; | 4180 | max_vpath_supported++; |
4141 | } | 4181 | } |
4142 | 4182 | ||
4183 | if (new_device) | ||
4184 | num_vfs = vxge_get_num_vfs(function_mode) - 1; | ||
4185 | |||
4143 | /* Enable SRIOV mode, if firmware has SRIOV support and if it is a PF */ | 4186 | /* Enable SRIOV mode, if firmware has SRIOV support and if it is a PF */ |
4144 | if ((VXGE_HW_FUNCTION_MODE_SRIOV == | 4187 | if (is_sriov(function_mode) && (max_config_dev > 1) && |
4145 | ll_config.device_hw_info.function_mode) && | 4188 | (ll_config.intr_type != INTA) && |
4146 | (max_config_dev > 1) && (pdev->is_physfn)) { | 4189 | (is_privileged == VXGE_HW_OK)) { |
4147 | ret = pci_enable_sriov(pdev, max_config_dev - 1); | 4190 | ret = pci_enable_sriov(pdev, ((max_config_dev - 1) < num_vfs) |
4148 | if (ret) | 4191 | ? (max_config_dev - 1) : num_vfs); |
4149 | vxge_debug_ll_config(VXGE_ERR, | 4192 | if (ret) |
4150 | "Failed to enable SRIOV: %d\n", ret); | 4193 | vxge_debug_ll_config(VXGE_ERR, |
4194 | "Failed in enabling SRIOV mode: %d\n", ret); | ||
4151 | } | 4195 | } |
4152 | 4196 | ||
4153 | /* | 4197 | /* |
diff --git a/drivers/net/vxge/vxge-main.h b/drivers/net/vxge/vxge-main.h index 0441d5aa3042..60276b20fa5e 100644 --- a/drivers/net/vxge/vxge-main.h +++ b/drivers/net/vxge/vxge-main.h | |||
@@ -90,6 +90,11 @@ | |||
90 | 90 | ||
91 | #define VXGE_LL_MAX_FRAME_SIZE(dev) ((dev)->mtu + VXGE_HW_MAC_HEADER_MAX_SIZE) | 91 | #define VXGE_LL_MAX_FRAME_SIZE(dev) ((dev)->mtu + VXGE_HW_MAC_HEADER_MAX_SIZE) |
92 | 92 | ||
93 | #define is_sriov(function_mode) \ | ||
94 | ((function_mode == VXGE_HW_FUNCTION_MODE_SRIOV) || \ | ||
95 | (function_mode == VXGE_HW_FUNCTION_MODE_SRIOV_8) || \ | ||
96 | (function_mode == VXGE_HW_FUNCTION_MODE_SRIOV_4)) | ||
97 | |||
93 | enum vxge_reset_event { | 98 | enum vxge_reset_event { |
94 | /* reset events */ | 99 | /* reset events */ |
95 | VXGE_LL_VPATH_RESET = 0, | 100 | VXGE_LL_VPATH_RESET = 0, |