Commit 150d58c7 authored by Vasundhara Volam's avatar Vasundhara Volam Committed by David S. Miller

be2net: Fixup profile management routines

1) Parse PCIe descriptor for max-VFs supported by HW
2) Cleanup NIC descriptor parsing in get_func/profile_config() routines
3) Use common struct definitions for v0 and v1 versions of GET_FUNC_CONFIG
Signed-off-by: default avatarVasundhara Volam <vasundhara.volam@emulex.com>
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f2f781a7
...@@ -3066,25 +3066,40 @@ int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name) ...@@ -3066,25 +3066,40 @@ int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name)
return status; return status;
} }
static struct be_nic_resource_desc *be_get_nic_desc(u8 *buf, u32 desc_count, static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, u32 desc_count)
u32 max_buf_size)
{ {
struct be_nic_resource_desc *desc = (struct be_nic_resource_desc *)buf; struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
int i; int i;
for (i = 0; i < desc_count; i++) { for (i = 0; i < desc_count; i++) {
desc->desc_len = desc->desc_len ? : RESOURCE_DESC_SIZE; if (hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V0 ||
if (((void *)desc + desc->desc_len) > hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V1)
(void *)(buf + max_buf_size)) return (struct be_nic_res_desc *)hdr;
return NULL;
if (desc->desc_type == NIC_RESOURCE_DESC_TYPE_V0 || hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
desc->desc_type == NIC_RESOURCE_DESC_TYPE_V1) hdr = (void *)hdr + hdr->desc_len;
return desc;
desc = (void *)desc + desc->desc_len;
} }
return NULL;
}
static struct be_pcie_res_desc *be_get_pcie_desc(u8 devfn, u8 *buf,
u32 desc_count)
{
struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
struct be_pcie_res_desc *pcie;
int i;
for (i = 0; i < desc_count; i++) {
if ((hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V0 ||
hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V1)) {
pcie = (struct be_pcie_res_desc *)hdr;
if (pcie->pf_num == devfn)
return pcie;
}
hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
hdr = (void *)hdr + hdr->desc_len;
}
return NULL; return NULL;
} }
...@@ -3128,10 +3143,9 @@ int be_cmd_get_func_config(struct be_adapter *adapter) ...@@ -3128,10 +3143,9 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
if (!status) { if (!status) {
struct be_cmd_resp_get_func_config *resp = cmd.va; struct be_cmd_resp_get_func_config *resp = cmd.va;
u32 desc_count = le32_to_cpu(resp->desc_count); u32 desc_count = le32_to_cpu(resp->desc_count);
struct be_nic_resource_desc *desc; struct be_nic_res_desc *desc;
desc = be_get_nic_desc(resp->func_param, desc_count, desc = be_get_nic_desc(resp->func_param, desc_count);
sizeof(resp->func_param));
if (!desc) { if (!desc) {
status = -EINVAL; status = -EINVAL;
goto err; goto err;
...@@ -3223,51 +3237,51 @@ static int be_cmd_get_profile_config_mccq(struct be_adapter *adapter, ...@@ -3223,51 +3237,51 @@ static int be_cmd_get_profile_config_mccq(struct be_adapter *adapter,
int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags, int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags,
u16 *txq_count, u8 domain) u16 *txq_count, u8 domain)
{ {
struct be_cmd_resp_get_profile_config *resp;
struct be_pcie_res_desc *pcie;
struct be_nic_res_desc *nic;
struct be_queue_info *mccq = &adapter->mcc_obj.q; struct be_queue_info *mccq = &adapter->mcc_obj.q;
struct be_dma_mem cmd; struct be_dma_mem cmd;
u32 desc_count;
int status; int status;
memset(&cmd, 0, sizeof(struct be_dma_mem)); memset(&cmd, 0, sizeof(struct be_dma_mem));
if (!lancer_chip(adapter)) cmd.size = sizeof(struct be_cmd_resp_get_profile_config);
cmd.size = sizeof(struct be_cmd_resp_get_profile_config_v1); cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
else if (!cmd.va)
cmd.size = sizeof(struct be_cmd_resp_get_profile_config);
cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size,
&cmd.dma);
if (!cmd.va) {
dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
return -ENOMEM; return -ENOMEM;
}
if (!mccq->created) if (!mccq->created)
status = be_cmd_get_profile_config_mbox(adapter, domain, &cmd); status = be_cmd_get_profile_config_mbox(adapter, domain, &cmd);
else else
status = be_cmd_get_profile_config_mccq(adapter, domain, &cmd); status = be_cmd_get_profile_config_mccq(adapter, domain, &cmd);
if (!status) { if (status)
struct be_cmd_resp_get_profile_config *resp = cmd.va; goto err;
u32 desc_count = le32_to_cpu(resp->desc_count);
struct be_nic_resource_desc *desc;
desc = be_get_nic_desc(resp->func_param, desc_count, resp = cmd.va;
sizeof(resp->func_param)); desc_count = le32_to_cpu(resp->desc_count);
if (!desc) { pcie = be_get_pcie_desc(adapter->pdev->devfn, resp->func_param,
status = -EINVAL; desc_count);
goto err; if (pcie)
} adapter->dev_num_vfs = le16_to_cpu(pcie->num_vfs);
nic = be_get_nic_desc(resp->func_param, desc_count);
if (nic) {
if (cap_flags) if (cap_flags)
*cap_flags = le32_to_cpu(desc->cap_flags); *cap_flags = le32_to_cpu(nic->cap_flags);
if (txq_count) if (txq_count)
*txq_count = le32_to_cpu(desc->txq_count); *txq_count = le16_to_cpu(nic->txq_count);
} }
err: err:
if (cmd.va) if (cmd.va)
pci_free_consistent(adapter->pdev, cmd.size, pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
cmd.va, cmd.dma);
return status; return status;
} }
/* Uses sync mcc */ /* Currently only Lancer uses this command and it supports version 0 only
* Uses sync mcc
*/
int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps, int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
u8 domain) u8 domain)
{ {
...@@ -3288,12 +3302,10 @@ int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps, ...@@ -3288,12 +3302,10 @@ int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
OPCODE_COMMON_SET_PROFILE_CONFIG, sizeof(*req), OPCODE_COMMON_SET_PROFILE_CONFIG, sizeof(*req),
wrb, NULL); wrb, NULL);
req->hdr.domain = domain; req->hdr.domain = domain;
req->desc_count = cpu_to_le32(1); req->desc_count = cpu_to_le32(1);
req->nic_desc.hdr.desc_type = NIC_RESOURCE_DESC_TYPE_V0;
req->nic_desc.desc_type = NIC_RESOURCE_DESC_TYPE_V0; req->nic_desc.hdr.desc_len = RESOURCE_DESC_SIZE_V0;
req->nic_desc.desc_len = RESOURCE_DESC_SIZE;
req->nic_desc.flags = (1 << QUN) | (1 << IMM) | (1 << NOSV); req->nic_desc.flags = (1 << QUN) | (1 << IMM) | (1 << NOSV);
req->nic_desc.pf_num = adapter->pf_number; req->nic_desc.pf_num = adapter->pf_number;
req->nic_desc.vf_num = domain; req->nic_desc.vf_num = domain;
......
...@@ -1718,11 +1718,13 @@ struct be_cmd_req_set_ext_fat_caps { ...@@ -1718,11 +1718,13 @@ struct be_cmd_req_set_ext_fat_caps {
struct be_fat_conf_params set_params; struct be_fat_conf_params set_params;
}; };
#define RESOURCE_DESC_SIZE 88 #define RESOURCE_DESC_SIZE_V0 72
#define RESOURCE_DESC_SIZE_V1 88
#define PCIE_RESOURCE_DESC_TYPE_V0 0x40
#define NIC_RESOURCE_DESC_TYPE_V0 0x41 #define NIC_RESOURCE_DESC_TYPE_V0 0x41
#define PCIE_RESOURCE_DESC_TYPE_V1 0x50
#define NIC_RESOURCE_DESC_TYPE_V1 0x51 #define NIC_RESOURCE_DESC_TYPE_V1 0x51
#define MAX_RESOURCE_DESC 4 #define MAX_RESOURCE_DESC 264
#define MAX_RESOURCE_DESC_V1 32
/* QOS unit number */ /* QOS unit number */
#define QUN 4 #define QUN 4
...@@ -1731,9 +1733,30 @@ struct be_cmd_req_set_ext_fat_caps { ...@@ -1731,9 +1733,30 @@ struct be_cmd_req_set_ext_fat_caps {
/* No save */ /* No save */
#define NOSV 7 #define NOSV 7
struct be_nic_resource_desc { struct be_res_desc_hdr {
u8 desc_type; u8 desc_type;
u8 desc_len; u8 desc_len;
} __packed;
struct be_pcie_res_desc {
struct be_res_desc_hdr hdr;
u8 rsvd0;
u8 flags;
u16 rsvd1;
u8 pf_num;
u8 rsvd2;
u32 rsvd3;
u8 sriov_state;
u8 pf_state;
u8 pf_type;
u8 rsvd4;
u16 num_vfs;
u16 rsvd5;
u32 rsvd6[17];
} __packed;
struct be_nic_res_desc {
struct be_res_desc_hdr hdr;
u8 rsvd1; u8 rsvd1;
u8 flags; u8 flags;
u8 vf_num; u8 vf_num;
...@@ -1762,7 +1785,7 @@ struct be_nic_resource_desc { ...@@ -1762,7 +1785,7 @@ struct be_nic_resource_desc {
u8 wol_param; u8 wol_param;
u16 rsvd7; u16 rsvd7;
u32 rsvd8[3]; u32 rsvd8[3];
}; } __packed;
struct be_cmd_req_get_func_config { struct be_cmd_req_get_func_config {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
...@@ -1771,7 +1794,7 @@ struct be_cmd_req_get_func_config { ...@@ -1771,7 +1794,7 @@ struct be_cmd_req_get_func_config {
struct be_cmd_resp_get_func_config { struct be_cmd_resp_get_func_config {
struct be_cmd_resp_hdr hdr; struct be_cmd_resp_hdr hdr;
u32 desc_count; u32 desc_count;
u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE]; u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE_V1];
}; };
#define ACTIVE_PROFILE_TYPE 0x2 #define ACTIVE_PROFILE_TYPE 0x2
...@@ -1783,26 +1806,20 @@ struct be_cmd_req_get_profile_config { ...@@ -1783,26 +1806,20 @@ struct be_cmd_req_get_profile_config {
}; };
struct be_cmd_resp_get_profile_config { struct be_cmd_resp_get_profile_config {
struct be_cmd_req_hdr hdr; struct be_cmd_resp_hdr hdr;
u32 desc_count;
u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE];
};
struct be_cmd_resp_get_profile_config_v1 {
struct be_cmd_req_hdr hdr;
u32 desc_count; u32 desc_count;
u8 func_param[MAX_RESOURCE_DESC_V1 * RESOURCE_DESC_SIZE]; u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE_V1];
}; };
struct be_cmd_req_set_profile_config { struct be_cmd_req_set_profile_config {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u32 rsvd; u32 rsvd;
u32 desc_count; u32 desc_count;
struct be_nic_resource_desc nic_desc; struct be_nic_res_desc nic_desc;
}; };
struct be_cmd_resp_set_profile_config { struct be_cmd_resp_set_profile_config {
struct be_cmd_req_hdr hdr; struct be_cmd_resp_hdr hdr;
}; };
struct be_cmd_enable_disable_vf { struct be_cmd_enable_disable_vf {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment