Skip to content

Commit b9263cb

Browse files
be2netdavem330
authored andcommitted
be2net: use max-TXQs limit too while provisioning VF queue pairs
When the PF driver provisions resources for VFs, it currently only looks at max RSS queues available to calculate the number of VF queue pairs. This logic breaks when there are less number of TX-queues than RSS-queues. This patch fixes this problem by using the max-TXQs available in the PF-pool in the calculations. As a part of this change the be_calculate_vf_qs() routine is renamed as be_calculate_vf_res() and the code that calculates limits on other related resources is moved here to contain all resource calculation code inside one routine. Signed-off-by: Suresh Reddy <[email protected]> Signed-off-by: Sathya Perla <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c19b6d2 commit b9263cb

File tree

4 files changed

+90
-85
lines changed

4 files changed

+90
-85
lines changed

drivers/net/ethernet/emulex/benet/be.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ struct be_resources {
444444
u16 max_evt_qs;
445445
u32 if_cap_flags;
446446
u32 vf_if_cap_flags; /* VF if capability flags */
447+
u32 flags;
447448
};
448449

449450
#define be_is_os2bmc_enabled(adapter) (adapter->flags & BE_FLAGS_OS2BMC)

drivers/net/ethernet/emulex/benet/be_cmds.c

Lines changed: 20 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4465,7 +4465,7 @@ static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc,
44654465
}
44664466

44674467
/* Mark all fields invalid */
4468-
static void be_reset_nic_desc(struct be_nic_res_desc *nic)
4468+
void be_reset_nic_desc(struct be_nic_res_desc *nic)
44694469
{
44704470
memset(nic, 0, sizeof(*nic));
44714471
nic->unicast_mac_count = 0xFFFF;
@@ -4534,73 +4534,9 @@ int be_cmd_config_qos(struct be_adapter *adapter, u32 max_rate, u16 link_speed,
45344534
1, version, domain);
45354535
}
45364536

4537-
static void be_fill_vf_res_template(struct be_adapter *adapter,
4538-
struct be_resources pool_res,
4539-
u16 num_vfs, u16 num_vf_qs,
4540-
struct be_nic_res_desc *nic_vft)
4541-
{
4542-
u32 vf_if_cap_flags = pool_res.vf_if_cap_flags;
4543-
struct be_resources res_mod = {0};
4544-
4545-
/* Resource with fields set to all '1's by GET_PROFILE_CONFIG cmd,
4546-
* which are modifiable using SET_PROFILE_CONFIG cmd.
4547-
*/
4548-
be_cmd_get_profile_config(adapter, &res_mod, RESOURCE_MODIFIABLE, 0);
4549-
4550-
/* If RSS IFACE capability flags are modifiable for a VF, set the
4551-
* capability flag as valid and set RSS and DEFQ_RSS IFACE flags if
4552-
* more than 1 RSSQ is available for a VF.
4553-
* Otherwise, provision only 1 queue pair for VF.
4554-
*/
4555-
if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_RSS) {
4556-
nic_vft->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
4557-
if (num_vf_qs > 1) {
4558-
vf_if_cap_flags |= BE_IF_FLAGS_RSS;
4559-
if (pool_res.if_cap_flags & BE_IF_FLAGS_DEFQ_RSS)
4560-
vf_if_cap_flags |= BE_IF_FLAGS_DEFQ_RSS;
4561-
} else {
4562-
vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS |
4563-
BE_IF_FLAGS_DEFQ_RSS);
4564-
}
4565-
} else {
4566-
num_vf_qs = 1;
4567-
}
4568-
4569-
if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
4570-
nic_vft->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
4571-
vf_if_cap_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS;
4572-
}
4573-
4574-
nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags);
4575-
nic_vft->rq_count = cpu_to_le16(num_vf_qs);
4576-
nic_vft->txq_count = cpu_to_le16(num_vf_qs);
4577-
nic_vft->rssq_count = cpu_to_le16(num_vf_qs);
4578-
nic_vft->cq_count = cpu_to_le16(pool_res.max_cq_count /
4579-
(num_vfs + 1));
4580-
4581-
/* Distribute unicast MACs, VLANs, IFACE count and MCCQ count equally
4582-
* among the PF and it's VFs, if the fields are changeable
4583-
*/
4584-
if (res_mod.max_uc_mac == FIELD_MODIFIABLE)
4585-
nic_vft->unicast_mac_count = cpu_to_le16(pool_res.max_uc_mac /
4586-
(num_vfs + 1));
4587-
4588-
if (res_mod.max_vlans == FIELD_MODIFIABLE)
4589-
nic_vft->vlan_count = cpu_to_le16(pool_res.max_vlans /
4590-
(num_vfs + 1));
4591-
4592-
if (res_mod.max_iface_count == FIELD_MODIFIABLE)
4593-
nic_vft->iface_count = cpu_to_le16(pool_res.max_iface_count /
4594-
(num_vfs + 1));
4595-
4596-
if (res_mod.max_mcc_count == FIELD_MODIFIABLE)
4597-
nic_vft->mcc_count = cpu_to_le16(pool_res.max_mcc_count /
4598-
(num_vfs + 1));
4599-
}
4600-
46014537
int be_cmd_set_sriov_config(struct be_adapter *adapter,
46024538
struct be_resources pool_res, u16 num_vfs,
4603-
u16 num_vf_qs)
4539+
struct be_resources *vft_res)
46044540
{
46054541
struct {
46064542
struct be_pcie_res_desc pcie;
@@ -4620,12 +4556,26 @@ int be_cmd_set_sriov_config(struct be_adapter *adapter,
46204556
be_reset_nic_desc(&desc.nic_vft);
46214557
desc.nic_vft.hdr.desc_type = NIC_RESOURCE_DESC_TYPE_V1;
46224558
desc.nic_vft.hdr.desc_len = RESOURCE_DESC_SIZE_V1;
4623-
desc.nic_vft.flags = BIT(VFT_SHIFT) | BIT(IMM_SHIFT) | BIT(NOSV_SHIFT);
4559+
desc.nic_vft.flags = vft_res->flags | BIT(VFT_SHIFT) |
4560+
BIT(IMM_SHIFT) | BIT(NOSV_SHIFT);
46244561
desc.nic_vft.pf_num = adapter->pdev->devfn;
46254562
desc.nic_vft.vf_num = 0;
4626-
4627-
be_fill_vf_res_template(adapter, pool_res, num_vfs, num_vf_qs,
4628-
&desc.nic_vft);
4563+
desc.nic_vft.cap_flags = cpu_to_le32(vft_res->vf_if_cap_flags);
4564+
desc.nic_vft.rq_count = cpu_to_le16(vft_res->max_rx_qs);
4565+
desc.nic_vft.txq_count = cpu_to_le16(vft_res->max_tx_qs);
4566+
desc.nic_vft.rssq_count = cpu_to_le16(vft_res->max_rss_qs);
4567+
desc.nic_vft.cq_count = cpu_to_le16(vft_res->max_cq_count);
4568+
4569+
if (vft_res->max_uc_mac)
4570+
desc.nic_vft.unicast_mac_count =
4571+
cpu_to_le16(vft_res->max_uc_mac);
4572+
if (vft_res->max_vlans)
4573+
desc.nic_vft.vlan_count = cpu_to_le16(vft_res->max_vlans);
4574+
if (vft_res->max_iface_count)
4575+
desc.nic_vft.iface_count =
4576+
cpu_to_le16(vft_res->max_iface_count);
4577+
if (vft_res->max_mcc_count)
4578+
desc.nic_vft.mcc_count = cpu_to_le16(vft_res->max_mcc_count);
46294579

46304580
return be_cmd_set_profile_config(adapter, &desc,
46314581
2 * RESOURCE_DESC_SIZE_V1, 2, 1, 0);

drivers/net/ethernet/emulex/benet/be_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2461,4 +2461,4 @@ int be_cmd_set_vxlan_port(struct be_adapter *adapter, __be16 port);
24612461
int be_cmd_manage_iface(struct be_adapter *adapter, u32 iface, u8 op);
24622462
int be_cmd_set_sriov_config(struct be_adapter *adapter,
24632463
struct be_resources res, u16 num_vfs,
2464-
u16 num_vf_qs);
2464+
struct be_resources *vft_res);

drivers/net/ethernet/emulex/benet/be_main.c

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,17 +3810,20 @@ static void be_disable_vxlan_offloads(struct be_adapter *adapter)
38103810
}
38113811
#endif
38123812

3813-
static u16 be_calculate_vf_qs(struct be_adapter *adapter, u16 num_vfs)
3813+
static void be_calculate_vf_res(struct be_adapter *adapter, u16 num_vfs,
3814+
struct be_resources *vft_res)
38143815
{
38153816
struct be_resources res = adapter->pool_res;
3817+
u32 vf_if_cap_flags = res.vf_if_cap_flags;
3818+
struct be_resources res_mod = {0};
38163819
u16 num_vf_qs = 1;
38173820

38183821
/* Distribute the queue resources among the PF and it's VFs
38193822
* Do not distribute queue resources in multi-channel configuration.
38203823
*/
38213824
if (num_vfs && !be_is_mc(adapter)) {
3822-
/* Divide the qpairs evenly among the VFs and the PF, capped
3823-
* at VF-EQ-count. Any remainder qpairs belong to the PF.
3825+
/* Divide the rx queues evenly among the VFs and the PF, capped
3826+
* at VF-EQ-count. Any remainder queues belong to the PF.
38243827
*/
38253828
num_vf_qs = min(SH_VF_MAX_NIC_EQS,
38263829
res.max_rss_qs / (num_vfs + 1));
@@ -3832,13 +3835,62 @@ static u16 be_calculate_vf_qs(struct be_adapter *adapter, u16 num_vfs)
38323835
if (num_vfs >= MAX_RSS_IFACES)
38333836
num_vf_qs = 1;
38343837
}
3835-
return num_vf_qs;
3838+
3839+
/* Resource with fields set to all '1's by GET_PROFILE_CONFIG cmd,
3840+
* which are modifiable using SET_PROFILE_CONFIG cmd.
3841+
*/
3842+
be_cmd_get_profile_config(adapter, &res_mod, RESOURCE_MODIFIABLE, 0);
3843+
3844+
/* If RSS IFACE capability flags are modifiable for a VF, set the
3845+
* capability flag as valid and set RSS and DEFQ_RSS IFACE flags if
3846+
* more than 1 RSSQ is available for a VF.
3847+
* Otherwise, provision only 1 queue pair for VF.
3848+
*/
3849+
if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_RSS) {
3850+
vft_res->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
3851+
if (num_vf_qs > 1) {
3852+
vf_if_cap_flags |= BE_IF_FLAGS_RSS;
3853+
if (res.if_cap_flags & BE_IF_FLAGS_DEFQ_RSS)
3854+
vf_if_cap_flags |= BE_IF_FLAGS_DEFQ_RSS;
3855+
} else {
3856+
vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS |
3857+
BE_IF_FLAGS_DEFQ_RSS);
3858+
}
3859+
} else {
3860+
num_vf_qs = 1;
3861+
}
3862+
3863+
if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
3864+
vft_res->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
3865+
vf_if_cap_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS;
3866+
}
3867+
3868+
vft_res->vf_if_cap_flags = vf_if_cap_flags;
3869+
vft_res->max_rx_qs = num_vf_qs;
3870+
vft_res->max_rss_qs = num_vf_qs;
3871+
vft_res->max_tx_qs = res.max_tx_qs / (num_vfs + 1);
3872+
vft_res->max_cq_count = res.max_cq_count / (num_vfs + 1);
3873+
3874+
/* Distribute unicast MACs, VLANs, IFACE count and MCCQ count equally
3875+
* among the PF and it's VFs, if the fields are changeable
3876+
*/
3877+
if (res_mod.max_uc_mac == FIELD_MODIFIABLE)
3878+
vft_res->max_uc_mac = res.max_uc_mac / (num_vfs + 1);
3879+
3880+
if (res_mod.max_vlans == FIELD_MODIFIABLE)
3881+
vft_res->max_vlans = res.max_vlans / (num_vfs + 1);
3882+
3883+
if (res_mod.max_iface_count == FIELD_MODIFIABLE)
3884+
vft_res->max_iface_count = res.max_iface_count / (num_vfs + 1);
3885+
3886+
if (res_mod.max_mcc_count == FIELD_MODIFIABLE)
3887+
vft_res->max_mcc_count = res.max_mcc_count / (num_vfs + 1);
38363888
}
38373889

38383890
static int be_clear(struct be_adapter *adapter)
38393891
{
38403892
struct pci_dev *pdev = adapter->pdev;
3841-
u16 num_vf_qs;
3893+
struct be_resources vft_res = {0};
38423894

38433895
be_cancel_worker(adapter);
38443896

@@ -3850,11 +3902,12 @@ static int be_clear(struct be_adapter *adapter)
38503902
*/
38513903
if (skyhawk_chip(adapter) && be_physfn(adapter) &&
38523904
!pci_vfs_assigned(pdev)) {
3853-
num_vf_qs = be_calculate_vf_qs(adapter,
3854-
pci_sriov_get_totalvfs(pdev));
3905+
be_calculate_vf_res(adapter,
3906+
pci_sriov_get_totalvfs(pdev),
3907+
&vft_res);
38553908
be_cmd_set_sriov_config(adapter, adapter->pool_res,
38563909
pci_sriov_get_totalvfs(pdev),
3857-
num_vf_qs);
3910+
&vft_res);
38583911
}
38593912

38603913
#ifdef CONFIG_BE2NET_VXLAN
@@ -4144,7 +4197,7 @@ static int be_get_sriov_config(struct be_adapter *adapter)
41444197
static void be_alloc_sriov_res(struct be_adapter *adapter)
41454198
{
41464199
int old_vfs = pci_num_vf(adapter->pdev);
4147-
u16 num_vf_qs;
4200+
struct be_resources vft_res = {0};
41484201
int status;
41494202

41504203
be_get_sriov_config(adapter);
@@ -4158,9 +4211,9 @@ static void be_alloc_sriov_res(struct be_adapter *adapter)
41584211
* Also, this is done by FW in Lancer chip.
41594212
*/
41604213
if (skyhawk_chip(adapter) && be_max_vfs(adapter) && !old_vfs) {
4161-
num_vf_qs = be_calculate_vf_qs(adapter, 0);
4214+
be_calculate_vf_res(adapter, 0, &vft_res);
41624215
status = be_cmd_set_sriov_config(adapter, adapter->pool_res, 0,
4163-
num_vf_qs);
4216+
&vft_res);
41644217
if (status)
41654218
dev_err(&adapter->pdev->dev,
41664219
"Failed to optimize SRIOV resources\n");
@@ -5552,7 +5605,7 @@ static void be_eeh_resume(struct pci_dev *pdev)
55525605
static int be_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
55535606
{
55545607
struct be_adapter *adapter = pci_get_drvdata(pdev);
5555-
u16 num_vf_qs;
5608+
struct be_resources vft_res = {0};
55565609
int status;
55575610

55585611
if (!num_vfs)
@@ -5575,9 +5628,10 @@ static int be_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
55755628
* Also, this is done by FW in Lancer chip.
55765629
*/
55775630
if (skyhawk_chip(adapter) && !pci_num_vf(pdev)) {
5578-
num_vf_qs = be_calculate_vf_qs(adapter, adapter->num_vfs);
5631+
be_calculate_vf_res(adapter, adapter->num_vfs,
5632+
&vft_res);
55795633
status = be_cmd_set_sriov_config(adapter, adapter->pool_res,
5580-
adapter->num_vfs, num_vf_qs);
5634+
adapter->num_vfs, &vft_res);
55815635
if (status)
55825636
dev_err(&pdev->dev,
55835637
"Failed to optimize SR-IOV resources\n");

0 commit comments

Comments
 (0)