aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vxge/vxge-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/vxge/vxge-main.c')
-rw-r--r--drivers/net/vxge/vxge-main.c64
1 files changed, 54 insertions, 10 deletions
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
3968static 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 /*