Skip to content

Commit 64151ae

Browse files
committed
Merge branch 'be2net-noncrit-fixes'
Sathya Perla says: ==================== be2net: patch set Hi David, the following patch set contains three non-critical fixes that can go into the net-next tree. Patch 1 fixes the logic for provisioning queue pairs on VFs to take into account the limit on number of TXQs too as in some profiles the number of TXQs is less than that of RXQs. Patch 2 enables WoL support from shutdown on Skyhawk. Patch 3 enhances the logic for provisioning queue pairs on VFs on SR-IOV over multi-partition configs. Each PF (partition) on a port has to compute the number of RSS tables it's VFs can use. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents c19b6d2 + de2b1e0 commit 64151ae

File tree

5 files changed

+256
-159
lines changed

5 files changed

+256
-159
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@
9797
* SURF/DPDK
9898
*/
9999

100-
#define MAX_RSS_IFACES 15
100+
#define MAX_PORT_RSS_TABLES 15
101+
#define MAX_NIC_FUNCS 16
101102
#define MAX_RX_QS 32
102103
#define MAX_EVT_QS 32
103104
#define MAX_TX_QS 32
@@ -444,6 +445,17 @@ struct be_resources {
444445
u16 max_evt_qs;
445446
u32 if_cap_flags;
446447
u32 vf_if_cap_flags; /* VF if capability flags */
448+
u32 flags;
449+
/* Calculated PF Pool's share of RSS Tables. This is not enforced by
450+
* the FW, but is a self-imposed driver limitation.
451+
*/
452+
u16 max_rss_tables;
453+
};
454+
455+
/* These are port-wide values */
456+
struct be_port_resources {
457+
u16 max_vfs;
458+
u16 nic_pfs;
447459
};
448460

449461
#define be_is_os2bmc_enabled(adapter) (adapter->flags & BE_FLAGS_OS2BMC)
@@ -634,6 +646,8 @@ struct be_adapter {
634646
#define be_max_rxqs(adapter) (adapter->res.max_rx_qs)
635647
#define be_max_eqs(adapter) (adapter->res.max_evt_qs)
636648
#define be_if_cap_flags(adapter) (adapter->res.if_cap_flags)
649+
#define be_max_pf_pool_rss_tables(adapter) \
650+
(adapter->pool_res.max_rss_tables)
637651

638652
static inline u16 be_max_qs(struct be_adapter *adapter)
639653
{

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

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4023,7 +4023,10 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
40234023
resp = (struct be_cmd_resp_acpi_wol_magic_config_v1 *)cmd.va;
40244024

40254025
adapter->wol_cap = resp->wol_settings;
4026-
if (adapter->wol_cap & BE_WOL_CAP)
4026+
4027+
/* Non-zero macaddr indicates WOL is enabled */
4028+
if (adapter->wol_cap & BE_WOL_CAP &&
4029+
!is_zero_ether_addr(resp->magic_mac))
40274030
adapter->wol_en = true;
40284031
}
40294032
err:
@@ -4360,9 +4363,35 @@ int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res)
43604363
return status;
43614364
}
43624365

4366+
/* This routine returns a list of all the NIC PF_nums in the adapter */
4367+
u16 be_get_nic_pf_num_list(u8 *buf, u32 desc_count, u16 *nic_pf_nums)
4368+
{
4369+
struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
4370+
struct be_pcie_res_desc *pcie = NULL;
4371+
int i;
4372+
u16 nic_pf_count = 0;
4373+
4374+
for (i = 0; i < desc_count; i++) {
4375+
if (hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V0 ||
4376+
hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V1) {
4377+
pcie = (struct be_pcie_res_desc *)hdr;
4378+
if (pcie->pf_state && (pcie->pf_type == MISSION_NIC ||
4379+
pcie->pf_type == MISSION_RDMA)) {
4380+
nic_pf_nums[nic_pf_count++] = pcie->pf_num;
4381+
}
4382+
}
4383+
4384+
hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
4385+
hdr = (void *)hdr + hdr->desc_len;
4386+
}
4387+
return nic_pf_count;
4388+
}
4389+
43634390
/* Will use MBOX only if MCCQ has not been created */
43644391
int be_cmd_get_profile_config(struct be_adapter *adapter,
4365-
struct be_resources *res, u8 query, u8 domain)
4392+
struct be_resources *res,
4393+
struct be_port_resources *port_res,
4394+
u8 profile_type, u8 query, u8 domain)
43664395
{
43674396
struct be_cmd_resp_get_profile_config *resp;
43684397
struct be_cmd_req_get_profile_config *req;
@@ -4389,7 +4418,7 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
43894418

43904419
if (!lancer_chip(adapter))
43914420
req->hdr.version = 1;
4392-
req->type = ACTIVE_PROFILE_TYPE;
4421+
req->type = profile_type;
43934422
req->hdr.domain = domain;
43944423

43954424
/* When QUERY_MODIFIABLE_FIELDS_TYPE bit is set, cmd returns the
@@ -4406,6 +4435,28 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
44064435
resp = cmd.va;
44074436
desc_count = le16_to_cpu(resp->desc_count);
44084437

4438+
if (port_res) {
4439+
u16 nic_pf_cnt = 0, i;
4440+
u16 nic_pf_num_list[MAX_NIC_FUNCS];
4441+
4442+
nic_pf_cnt = be_get_nic_pf_num_list(resp->func_param,
4443+
desc_count,
4444+
nic_pf_num_list);
4445+
4446+
for (i = 0; i < nic_pf_cnt; i++) {
4447+
nic = be_get_func_nic_desc(resp->func_param, desc_count,
4448+
nic_pf_num_list[i]);
4449+
if (nic->link_param == adapter->port_num) {
4450+
port_res->nic_pfs++;
4451+
pcie = be_get_pcie_desc(resp->func_param,
4452+
desc_count,
4453+
nic_pf_num_list[i]);
4454+
port_res->max_vfs += le16_to_cpu(pcie->num_vfs);
4455+
}
4456+
}
4457+
return status;
4458+
}
4459+
44094460
pcie = be_get_pcie_desc(resp->func_param, desc_count,
44104461
adapter->pf_num);
44114462
if (pcie)
@@ -4465,7 +4516,7 @@ static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc,
44654516
}
44664517

44674518
/* Mark all fields invalid */
4468-
static void be_reset_nic_desc(struct be_nic_res_desc *nic)
4519+
void be_reset_nic_desc(struct be_nic_res_desc *nic)
44694520
{
44704521
memset(nic, 0, sizeof(*nic));
44714522
nic->unicast_mac_count = 0xFFFF;
@@ -4534,73 +4585,9 @@ int be_cmd_config_qos(struct be_adapter *adapter, u32 max_rate, u16 link_speed,
45344585
1, version, domain);
45354586
}
45364587

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-
46014588
int be_cmd_set_sriov_config(struct be_adapter *adapter,
46024589
struct be_resources pool_res, u16 num_vfs,
4603-
u16 num_vf_qs)
4590+
struct be_resources *vft_res)
46044591
{
46054592
struct {
46064593
struct be_pcie_res_desc pcie;
@@ -4620,12 +4607,26 @@ int be_cmd_set_sriov_config(struct be_adapter *adapter,
46204607
be_reset_nic_desc(&desc.nic_vft);
46214608
desc.nic_vft.hdr.desc_type = NIC_RESOURCE_DESC_TYPE_V1;
46224609
desc.nic_vft.hdr.desc_len = RESOURCE_DESC_SIZE_V1;
4623-
desc.nic_vft.flags = BIT(VFT_SHIFT) | BIT(IMM_SHIFT) | BIT(NOSV_SHIFT);
4610+
desc.nic_vft.flags = vft_res->flags | BIT(VFT_SHIFT) |
4611+
BIT(IMM_SHIFT) | BIT(NOSV_SHIFT);
46244612
desc.nic_vft.pf_num = adapter->pdev->devfn;
46254613
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);
4614+
desc.nic_vft.cap_flags = cpu_to_le32(vft_res->vf_if_cap_flags);
4615+
desc.nic_vft.rq_count = cpu_to_le16(vft_res->max_rx_qs);
4616+
desc.nic_vft.txq_count = cpu_to_le16(vft_res->max_tx_qs);
4617+
desc.nic_vft.rssq_count = cpu_to_le16(vft_res->max_rss_qs);
4618+
desc.nic_vft.cq_count = cpu_to_le16(vft_res->max_cq_count);
4619+
4620+
if (vft_res->max_uc_mac)
4621+
desc.nic_vft.unicast_mac_count =
4622+
cpu_to_le16(vft_res->max_uc_mac);
4623+
if (vft_res->max_vlans)
4624+
desc.nic_vft.vlan_count = cpu_to_le16(vft_res->max_vlans);
4625+
if (vft_res->max_iface_count)
4626+
desc.nic_vft.iface_count =
4627+
cpu_to_le16(vft_res->max_iface_count);
4628+
if (vft_res->max_mcc_count)
4629+
desc.nic_vft.mcc_count = cpu_to_le16(vft_res->max_mcc_count);
46294630

46304631
return be_cmd_set_profile_config(adapter, &desc,
46314632
2 * RESOURCE_DESC_SIZE_V1, 2, 1, 0);

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,9 @@ struct be_cmd_resp_acpi_wol_magic_config_v1 {
15561556
u8 rsvd0[2];
15571557
u8 wol_settings;
15581558
u8 rsvd1[5];
1559-
u32 rsvd2[295];
1559+
u32 rsvd2[288];
1560+
u8 magic_mac[6];
1561+
u8 rsvd3[22];
15601562
} __packed;
15611563

15621564
#define BE_GET_WOL_CAP 2
@@ -2128,6 +2130,9 @@ struct be_cmd_req_set_ext_fat_caps {
21282130
#define IMM_SHIFT 6 /* Immediate */
21292131
#define NOSV_SHIFT 7 /* No save */
21302132

2133+
#define MISSION_NIC 1
2134+
#define MISSION_RDMA 8
2135+
21312136
struct be_res_desc_hdr {
21322137
u8 desc_type;
21332138
u8 desc_len;
@@ -2244,6 +2249,7 @@ struct be_cmd_req_get_profile_config {
22442249
struct be_cmd_req_hdr hdr;
22452250
u8 rsvd;
22462251
#define ACTIVE_PROFILE_TYPE 0x2
2252+
#define SAVED_PROFILE_TYPE 0x0
22472253
#define QUERY_MODIFIABLE_FIELDS_TYPE BIT(3)
22482254
u8 type;
22492255
u16 rsvd1;
@@ -2449,7 +2455,9 @@ int be_cmd_query_port_name(struct be_adapter *adapter);
24492455
int be_cmd_get_func_config(struct be_adapter *adapter,
24502456
struct be_resources *res);
24512457
int be_cmd_get_profile_config(struct be_adapter *adapter,
2452-
struct be_resources *res, u8 query, u8 domain);
2458+
struct be_resources *res,
2459+
struct be_port_resources *port_res,
2460+
u8 profile_type, u8 query, u8 domain);
24532461
int be_cmd_get_active_profile(struct be_adapter *adapter, u16 *profile);
24542462
int be_cmd_get_if_id(struct be_adapter *adapter, struct be_vf_cfg *vf_cfg,
24552463
int vf_num);
@@ -2461,4 +2469,4 @@ int be_cmd_set_vxlan_port(struct be_adapter *adapter, __be16 port);
24612469
int be_cmd_manage_iface(struct be_adapter *adapter, u32 iface, u8 op);
24622470
int be_cmd_set_sriov_config(struct be_adapter *adapter,
24632471
struct be_resources res, u16 num_vfs,
2464-
u16 num_vf_qs);
2472+
struct be_resources *vft_res);

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

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,11 @@ static void be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
793793
static int be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
794794
{
795795
struct be_adapter *adapter = netdev_priv(netdev);
796+
struct device *dev = &adapter->pdev->dev;
797+
struct be_dma_mem cmd;
798+
u8 mac[ETH_ALEN];
799+
bool enable;
800+
int status;
796801

797802
if (wol->wolopts & ~WAKE_MAGIC)
798803
return -EOPNOTSUPP;
@@ -802,12 +807,32 @@ static int be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
802807
return -EOPNOTSUPP;
803808
}
804809

805-
if (wol->wolopts & WAKE_MAGIC)
806-
adapter->wol_en = true;
807-
else
808-
adapter->wol_en = false;
810+
cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config);
811+
cmd.va = dma_zalloc_coherent(dev, cmd.size, &cmd.dma, GFP_KERNEL);
812+
if (!cmd.va)
813+
return -ENOMEM;
809814

810-
return 0;
815+
eth_zero_addr(mac);
816+
817+
enable = wol->wolopts & WAKE_MAGIC;
818+
if (enable)
819+
ether_addr_copy(mac, adapter->netdev->dev_addr);
820+
821+
status = be_cmd_enable_magic_wol(adapter, mac, &cmd);
822+
if (status) {
823+
dev_err(dev, "Could not set Wake-on-lan mac address\n");
824+
status = be_cmd_status(status);
825+
goto err;
826+
}
827+
828+
pci_enable_wake(adapter->pdev, PCI_D3hot, enable);
829+
pci_enable_wake(adapter->pdev, PCI_D3cold, enable);
830+
831+
adapter->wol_en = enable ? true : false;
832+
833+
err:
834+
dma_free_coherent(dev, cmd.size, cmd.va, cmd.dma);
835+
return status;
811836
}
812837

813838
static int be_test_ddr_dma(struct be_adapter *adapter)

0 commit comments

Comments
 (0)