Commit 92bf14ab authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: refactor be_get_resources() code

1) use be_resources{} struct to query/store HW resource limits
2) The HW queue/resource limits for BE2/BE3 chips are mostly called out
   in driver as constants.  Code to handle this is scattered across various
   places in be_setup(). Consolidate this code into BEx_get_resources().
   For Lancer-R, Skyhawk-R, these limits are queried from FW.
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 150d58c7
...@@ -101,12 +101,15 @@ static inline char *nic_name(struct pci_dev *pdev) ...@@ -101,12 +101,15 @@ static inline char *nic_name(struct pci_dev *pdev)
#define BE3_MAX_RSS_QS 8 #define BE3_MAX_RSS_QS 8
#define BE2_MAX_RSS_QS 4 #define BE2_MAX_RSS_QS 4
#define BE3_MAX_TX_QS 8
#define MAX_RSS_QS BE3_MAX_RSS_QS #define MAX_RSS_QS BE3_MAX_RSS_QS
#define MAX_RX_QS (MAX_RSS_QS + 1) /* RSS qs + 1 def Rx */ #define MAX_RX_QS (MAX_RSS_QS + 1) /* RSS qs + 1 def Rx */
#define MAX_EVT_QS MAX_RSS_QS
#define MAX_TX_QS 8 #define MAX_TX_QS 8
#define MAX_ROCE_EQS 5 #define MAX_ROCE_EQS 5
#define MAX_MSIX_VECTORS (MAX_RSS_QS + MAX_ROCE_EQS) /* RSS qs + RoCE */ #define MAX_MSIX_VECTORS (MAX_RSS_QS + MAX_ROCE_EQS) /* RSS qs + RoCE */
#define MIN_MSIX_VECTORS 1
#define BE_TX_BUDGET 256 #define BE_TX_BUDGET 256
#define BE_NAPI_WEIGHT 64 #define BE_NAPI_WEIGHT 64
#define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */ #define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */
...@@ -353,6 +356,18 @@ struct phy_info { ...@@ -353,6 +356,18 @@ struct phy_info {
u32 supported; u32 supported;
}; };
struct be_resources {
u16 max_vfs; /* Total VFs "really" supported by FW/HW */
u16 max_mcast_mac;
u16 max_tx_qs;
u16 max_rss_qs;
u16 max_rx_qs;
u16 max_uc_mac; /* Max UC MACs programmable */
u16 max_vlans; /* Number of vlans supported */
u16 max_evt_qs;
u32 if_cap_flags;
};
struct be_adapter { struct be_adapter {
struct pci_dev *pdev; struct pci_dev *pdev;
struct net_device *netdev; struct net_device *netdev;
...@@ -370,18 +385,19 @@ struct be_adapter { ...@@ -370,18 +385,19 @@ struct be_adapter {
spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */ spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock; spinlock_t mcc_cq_lock;
u32 num_msix_vec; u16 cfg_num_qs; /* configured via set-channels */
u32 num_evt_qs; u16 num_evt_qs;
struct be_eq_obj eq_obj[MAX_MSIX_VECTORS]; u16 num_msix_vec;
struct be_eq_obj eq_obj[MAX_EVT_QS];
struct msix_entry msix_entries[MAX_MSIX_VECTORS]; struct msix_entry msix_entries[MAX_MSIX_VECTORS];
bool isr_registered; bool isr_registered;
/* TX Rings */ /* TX Rings */
u32 num_tx_qs; u16 num_tx_qs;
struct be_tx_obj tx_obj[MAX_TX_QS]; struct be_tx_obj tx_obj[MAX_TX_QS];
/* Rx rings */ /* Rx rings */
u32 num_rx_qs; u16 num_rx_qs;
struct be_rx_obj rx_obj[MAX_RX_QS]; struct be_rx_obj rx_obj[MAX_RX_QS];
u32 big_page_size; /* Compounded page size shared by rx wrbs */ u32 big_page_size; /* Compounded page size shared by rx wrbs */
...@@ -431,8 +447,8 @@ struct be_adapter { ...@@ -431,8 +447,8 @@ struct be_adapter {
u32 flash_status; u32 flash_status;
struct completion flash_compl; struct completion flash_compl;
u32 num_vfs; /* Number of VFs provisioned by PF driver */ struct be_resources res; /* resources available for the func */
u32 dev_num_vfs; /* Number of VFs supported by HW */ u16 num_vfs; /* Number of VFs provisioned by PF */
u8 virtfn; u8 virtfn;
struct be_vf_cfg *vf_cfg; struct be_vf_cfg *vf_cfg;
bool be3_native; bool be3_native;
...@@ -447,21 +463,13 @@ struct be_adapter { ...@@ -447,21 +463,13 @@ struct be_adapter {
u16 qnq_vid; u16 qnq_vid;
u32 msg_enable; u32 msg_enable;
int be_get_temp_freq; int be_get_temp_freq;
u16 max_mcast_mac;
u16 max_tx_queues;
u16 max_rss_queues;
u16 max_rx_queues;
u16 max_pmac_cnt;
u16 max_vlans;
u16 max_event_queues;
u32 if_cap_flags;
u8 pf_number; u8 pf_number;
u64 rss_flags; u64 rss_flags;
}; };
#define be_physfn(adapter) (!adapter->virtfn) #define be_physfn(adapter) (!adapter->virtfn)
#define sriov_enabled(adapter) (adapter->num_vfs > 0) #define sriov_enabled(adapter) (adapter->num_vfs > 0)
#define sriov_want(adapter) (adapter->dev_num_vfs && num_vfs && \ #define sriov_want(adapter) (be_max_vfs(adapter) && num_vfs && \
be_physfn(adapter)) be_physfn(adapter))
#define for_all_vfs(adapter, vf_cfg, i) \ #define for_all_vfs(adapter, vf_cfg, i) \
for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \ for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \
...@@ -470,6 +478,26 @@ struct be_adapter { ...@@ -470,6 +478,26 @@ struct be_adapter {
#define ON 1 #define ON 1
#define OFF 0 #define OFF 0
#define be_max_vlans(adapter) (adapter->res.max_vlans)
#define be_max_uc(adapter) (adapter->res.max_uc_mac)
#define be_max_mc(adapter) (adapter->res.max_mcast_mac)
#define be_max_vfs(adapter) (adapter->res.max_vfs)
#define be_max_rss(adapter) (adapter->res.max_rss_qs)
#define be_max_txqs(adapter) (adapter->res.max_tx_qs)
#define be_max_prio_txqs(adapter) (adapter->res.max_prio_tx_qs)
#define be_max_rxqs(adapter) (adapter->res.max_rx_qs)
#define be_max_eqs(adapter) (adapter->res.max_evt_qs)
#define be_if_cap_flags(adapter) (adapter->res.if_cap_flags)
static inline u16 be_max_qs(struct be_adapter *adapter)
{
/* If no RSS, need atleast the one def RXQ */
u16 num = max_t(u16, be_max_rss(adapter), 1);
num = min(num, be_max_eqs(adapter));
return min_t(u16, num, num_online_cpus());
}
#define lancer_chip(adapter) (adapter->pdev->device == OC_DEVICE_ID3 || \ #define lancer_chip(adapter) (adapter->pdev->device == OC_DEVICE_ID3 || \
adapter->pdev->device == OC_DEVICE_ID4) adapter->pdev->device == OC_DEVICE_ID4)
......
...@@ -1776,8 +1776,7 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value) ...@@ -1776,8 +1776,7 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
*/ */
req->if_flags_mask |= req->if_flags_mask |=
cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS & cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS &
adapter->if_cap_flags); be_if_cap_flags(adapter));
req->mcast_num = cpu_to_le32(netdev_mc_count(adapter->netdev)); req->mcast_num = cpu_to_le32(netdev_mc_count(adapter->netdev));
netdev_for_each_mc_addr(ha, adapter->netdev) netdev_for_each_mc_addr(ha, adapter->netdev)
memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN); memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN);
...@@ -3103,8 +3102,26 @@ static struct be_pcie_res_desc *be_get_pcie_desc(u8 devfn, u8 *buf, ...@@ -3103,8 +3102,26 @@ static struct be_pcie_res_desc *be_get_pcie_desc(u8 devfn, u8 *buf,
return NULL; return NULL;
} }
static void be_copy_nic_desc(struct be_resources *res,
struct be_nic_res_desc *desc)
{
res->max_uc_mac = le16_to_cpu(desc->unicast_mac_count);
res->max_vlans = le16_to_cpu(desc->vlan_count);
res->max_mcast_mac = le16_to_cpu(desc->mcast_mac_count);
res->max_tx_qs = le16_to_cpu(desc->txq_count);
res->max_rss_qs = le16_to_cpu(desc->rssq_count);
res->max_rx_qs = le16_to_cpu(desc->rq_count);
res->max_evt_qs = le16_to_cpu(desc->eq_count);
/* Clear flags that driver is not interested in */
res->if_cap_flags = le32_to_cpu(desc->cap_flags) &
BE_IF_CAP_FLAGS_WANT;
/* Need 1 RXQ as the default RXQ */
if (res->max_rss_qs && res->max_rss_qs == res->max_rx_qs)
res->max_rss_qs -= 1;
}
/* Uses Mbox */ /* Uses Mbox */
int be_cmd_get_func_config(struct be_adapter *adapter) int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res)
{ {
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_get_func_config *req; struct be_cmd_req_get_func_config *req;
...@@ -3152,18 +3169,7 @@ int be_cmd_get_func_config(struct be_adapter *adapter) ...@@ -3152,18 +3169,7 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
} }
adapter->pf_number = desc->pf_num; adapter->pf_number = desc->pf_num;
adapter->max_pmac_cnt = le16_to_cpu(desc->unicast_mac_count); be_copy_nic_desc(res, desc);
adapter->max_vlans = le16_to_cpu(desc->vlan_count);
adapter->max_mcast_mac = le16_to_cpu(desc->mcast_mac_count);
adapter->max_tx_queues = le16_to_cpu(desc->txq_count);
adapter->max_rss_queues = le16_to_cpu(desc->rssq_count);
adapter->max_rx_queues = le16_to_cpu(desc->rq_count);
adapter->max_event_queues = le16_to_cpu(desc->eq_count);
adapter->if_cap_flags = le32_to_cpu(desc->cap_flags);
/* Clear flags that driver is not interested in */
adapter->if_cap_flags &= BE_IF_CAP_FLAGS_WANT;
} }
err: err:
mutex_unlock(&adapter->mbox_lock); mutex_unlock(&adapter->mbox_lock);
...@@ -3234,8 +3240,8 @@ static int be_cmd_get_profile_config_mccq(struct be_adapter *adapter, ...@@ -3234,8 +3240,8 @@ static int be_cmd_get_profile_config_mccq(struct be_adapter *adapter,
} }
/* Uses sync mcc, if MCCQ is already created otherwise mbox */ /* Uses sync mcc, if MCCQ is already created otherwise mbox */
int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags, int be_cmd_get_profile_config(struct be_adapter *adapter,
u16 *txq_count, u8 domain) struct be_resources *res, u8 domain)
{ {
struct be_cmd_resp_get_profile_config *resp; struct be_cmd_resp_get_profile_config *resp;
struct be_pcie_res_desc *pcie; struct be_pcie_res_desc *pcie;
...@@ -3264,15 +3270,12 @@ int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags, ...@@ -3264,15 +3270,12 @@ int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags,
pcie = be_get_pcie_desc(adapter->pdev->devfn, resp->func_param, pcie = be_get_pcie_desc(adapter->pdev->devfn, resp->func_param,
desc_count); desc_count);
if (pcie) if (pcie)
adapter->dev_num_vfs = le16_to_cpu(pcie->num_vfs); res->max_vfs = le16_to_cpu(pcie->num_vfs);
nic = be_get_nic_desc(resp->func_param, desc_count); nic = be_get_nic_desc(resp->func_param, desc_count);
if (nic) { if (nic)
if (cap_flags) be_copy_nic_desc(res, nic);
*cap_flags = le32_to_cpu(nic->cap_flags);
if (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, cmd.va, cmd.dma); pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
......
...@@ -1980,10 +1980,10 @@ extern int lancer_initiate_dump(struct be_adapter *adapter); ...@@ -1980,10 +1980,10 @@ extern int lancer_initiate_dump(struct be_adapter *adapter);
extern bool dump_present(struct be_adapter *adapter); extern bool dump_present(struct be_adapter *adapter);
extern int lancer_test_and_set_rdy_state(struct be_adapter *adapter); extern int lancer_test_and_set_rdy_state(struct be_adapter *adapter);
extern int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name); extern int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name);
extern int be_cmd_get_func_config(struct be_adapter *adapter); int be_cmd_get_func_config(struct be_adapter *adapter,
extern int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags, struct be_resources *res);
u16 *txq_count, u8 domain); int be_cmd_get_profile_config(struct be_adapter *adapter,
struct be_resources *res, u8 domain);
extern int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps, extern int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
u8 domain); u8 domain);
extern int be_cmd_get_if_id(struct be_adapter *adapter, extern int be_cmd_get_if_id(struct be_adapter *adapter,
......
This diff is collapsed.
...@@ -60,7 +60,7 @@ static void _be_roce_dev_add(struct be_adapter *adapter) ...@@ -60,7 +60,7 @@ static void _be_roce_dev_add(struct be_adapter *adapter)
*/ */
num_vec = adapter->num_msix_vec + adapter->num_msix_roce_vec; num_vec = adapter->num_msix_vec + adapter->num_msix_roce_vec;
dev_info.intr_mode = BE_INTERRUPT_MODE_MSIX; dev_info.intr_mode = BE_INTERRUPT_MODE_MSIX;
dev_info.msix.num_vectors = min(num_vec, MAX_ROCE_MSIX_VECTORS); dev_info.msix.num_vectors = min(num_vec, MAX_MSIX_VECTORS);
/* provide start index of the vector, /* provide start index of the vector,
* so in case of linear usage, * so in case of linear usage,
* it can use the base as starting point. * it can use the base as starting point.
......
...@@ -29,7 +29,7 @@ enum be_interrupt_mode { ...@@ -29,7 +29,7 @@ enum be_interrupt_mode {
BE_INTERRUPT_MODE_MSI = 2, BE_INTERRUPT_MODE_MSI = 2,
}; };
#define MAX_ROCE_MSIX_VECTORS 16 #define MAX_MSIX_VECTORS 32
struct be_dev_info { struct be_dev_info {
u8 __iomem *db; u8 __iomem *db;
u64 unmapped_db; u64 unmapped_db;
...@@ -45,7 +45,7 @@ struct be_dev_info { ...@@ -45,7 +45,7 @@ struct be_dev_info {
struct { struct {
int num_vectors; int num_vectors;
int start_vector; int start_vector;
u32 vector_list[MAX_ROCE_MSIX_VECTORS]; u32 vector_list[MAX_MSIX_VECTORS];
} msix; } msix;
}; };
......
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