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

be2net: init (vf)_if_handle/vf_pmac_id to handle failure scenarios

Initialize if_handle, vf_if_handle and vf_pmac_id with "-1" so that in
failure cases when be_clear() is called, we can skip over
if_destroy/pmac_del cmds if they have not been created.
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d826eb14
...@@ -289,14 +289,12 @@ struct be_drv_stats { ...@@ -289,14 +289,12 @@ struct be_drv_stats {
struct be_vf_cfg { struct be_vf_cfg {
unsigned char vf_mac_addr[ETH_ALEN]; unsigned char vf_mac_addr[ETH_ALEN];
u32 vf_if_handle; int vf_if_handle;
u32 vf_pmac_id; int vf_pmac_id;
u16 vf_vlan_tag; u16 vf_vlan_tag;
u32 vf_tx_rate; u32 vf_tx_rate;
}; };
#define BE_INVALID_PMAC_ID 0xffffffff
struct be_adapter { struct be_adapter {
struct pci_dev *pdev; struct pci_dev *pdev;
struct net_device *netdev; struct net_device *netdev;
...@@ -347,7 +345,7 @@ struct be_adapter { ...@@ -347,7 +345,7 @@ struct be_adapter {
/* Ethtool knobs and info */ /* Ethtool knobs and info */
char fw_ver[FW_VER_LEN]; char fw_ver[FW_VER_LEN];
u32 if_handle; /* Used to configure filtering */ int if_handle; /* Used to configure filtering */
u32 pmac_id; /* MAC addr handle used by BE card */ u32 pmac_id; /* MAC addr handle used by BE card */
u32 beacon_state; /* for set_phys_id */ u32 beacon_state; /* for set_phys_id */
......
...@@ -695,12 +695,15 @@ int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, ...@@ -695,12 +695,15 @@ int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
} }
/* Uses synchronous MCCQ */ /* Uses synchronous MCCQ */
int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id, u32 dom) int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id, u32 dom)
{ {
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_pmac_del *req; struct be_cmd_req_pmac_del *req;
int status; int status;
if (pmac_id == -1)
return 0;
spin_lock_bh(&adapter->mcc_lock); spin_lock_bh(&adapter->mcc_lock);
wrb = wrb_from_mccq(adapter); wrb = wrb_from_mccq(adapter);
...@@ -1136,7 +1139,7 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, ...@@ -1136,7 +1139,7 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
} }
/* Uses MCCQ */ /* Uses MCCQ */
int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) int be_cmd_if_destroy(struct be_adapter *adapter, int interface_id, u32 domain)
{ {
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_if_destroy *req; struct be_cmd_req_if_destroy *req;
...@@ -1145,7 +1148,7 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) ...@@ -1145,7 +1148,7 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain)
if (adapter->eeh_err) if (adapter->eeh_err)
return -EIO; return -EIO;
if (!interface_id) if (interface_id == -1)
return 0; return 0;
spin_lock_bh(&adapter->mcc_lock); spin_lock_bh(&adapter->mcc_lock);
......
...@@ -1417,11 +1417,11 @@ extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, ...@@ -1417,11 +1417,11 @@ extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
u32 if_id, u32 *pmac_id, u32 domain); u32 if_id, u32 *pmac_id, u32 domain);
extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id,
u32 pmac_id, u32 domain); int pmac_id, u32 domain);
extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags,
u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id, u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id,
u32 domain); u32 domain);
extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle, extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle,
u32 domain); u32 domain);
extern int be_cmd_eq_create(struct be_adapter *adapter, extern int be_cmd_eq_create(struct be_adapter *adapter,
struct be_queue_info *eq, int eq_delay); struct be_queue_info *eq, int eq_delay);
......
...@@ -848,15 +848,11 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) ...@@ -848,15 +848,11 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) if (!is_valid_ether_addr(mac) || (vf >= num_vfs))
return -EINVAL; return -EINVAL;
if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) status = be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle,
status = be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
adapter->vf_cfg[vf].vf_if_handle,
adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
status = be_cmd_pmac_add(adapter, mac, status = be_cmd_pmac_add(adapter, mac, adapter->vf_cfg[vf].vf_if_handle,
adapter->vf_cfg[vf].vf_if_handle,
&adapter->vf_cfg[vf].vf_pmac_id, vf + 1); &adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
if (status) if (status)
dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n",
mac, vf); mac, vf);
...@@ -2488,17 +2484,13 @@ static void be_vf_clear(struct be_adapter *adapter) ...@@ -2488,17 +2484,13 @@ static void be_vf_clear(struct be_adapter *adapter)
{ {
u32 vf; u32 vf;
for (vf = 0; vf < num_vfs; vf++) { for (vf = 0; vf < num_vfs; vf++)
if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle,
be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
adapter->vf_cfg[vf].vf_if_handle,
adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
}
for (vf = 0; vf < num_vfs; vf++) for (vf = 0; vf < num_vfs; vf++)
if (adapter->vf_cfg[vf].vf_if_handle) be_cmd_if_destroy(adapter, adapter->vf_cfg[vf].vf_if_handle,
be_cmd_if_destroy(adapter, vf + 1);
adapter->vf_cfg[vf].vf_if_handle, vf + 1);
} }
static int be_clear(struct be_adapter *adapter) static int be_clear(struct be_adapter *adapter)
...@@ -2511,22 +2503,30 @@ static int be_clear(struct be_adapter *adapter) ...@@ -2511,22 +2503,30 @@ static int be_clear(struct be_adapter *adapter)
be_mcc_queues_destroy(adapter); be_mcc_queues_destroy(adapter);
be_rx_queues_destroy(adapter); be_rx_queues_destroy(adapter);
be_tx_queues_destroy(adapter); be_tx_queues_destroy(adapter);
adapter->eq_next_idx = 0;
adapter->be3_native = false;
adapter->promiscuous = false;
/* tell fw we're done with firing cmds */ /* tell fw we're done with firing cmds */
be_cmd_fw_clean(adapter); be_cmd_fw_clean(adapter);
return 0; return 0;
} }
static void be_vf_setup_init(struct be_adapter *adapter)
{
int vf;
for (vf = 0; vf < num_vfs; vf++) {
adapter->vf_cfg[vf].vf_if_handle = -1;
adapter->vf_cfg[vf].vf_pmac_id = -1;
}
}
static int be_vf_setup(struct be_adapter *adapter) static int be_vf_setup(struct be_adapter *adapter)
{ {
u32 cap_flags, en_flags, vf; u32 cap_flags, en_flags, vf;
u16 lnk_speed; u16 lnk_speed;
int status; int status;
be_vf_setup_init(adapter);
cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST; cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST;
for (vf = 0; vf < num_vfs; vf++) { for (vf = 0; vf < num_vfs; vf++) {
status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL,
...@@ -2534,7 +2534,6 @@ static int be_vf_setup(struct be_adapter *adapter) ...@@ -2534,7 +2534,6 @@ static int be_vf_setup(struct be_adapter *adapter)
NULL, vf+1); NULL, vf+1);
if (status) if (status)
goto err; goto err;
adapter->vf_cfg[vf].vf_pmac_id = BE_INVALID_PMAC_ID;
} }
if (!lancer_chip(adapter)) { if (!lancer_chip(adapter)) {
...@@ -2555,6 +2554,16 @@ static int be_vf_setup(struct be_adapter *adapter) ...@@ -2555,6 +2554,16 @@ static int be_vf_setup(struct be_adapter *adapter)
return status; return status;
} }
static void be_setup_init(struct be_adapter *adapter)
{
adapter->vlan_prio_bmap = 0xff;
adapter->link_speed = -1;
adapter->if_handle = -1;
adapter->be3_native = false;
adapter->promiscuous = false;
adapter->eq_next_idx = 0;
}
static int be_setup(struct be_adapter *adapter) static int be_setup(struct be_adapter *adapter)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
...@@ -2563,9 +2572,7 @@ static int be_setup(struct be_adapter *adapter) ...@@ -2563,9 +2572,7 @@ static int be_setup(struct be_adapter *adapter)
int status; int status;
u8 mac[ETH_ALEN]; u8 mac[ETH_ALEN];
/* Allow all priorities by default. A GRP5 evt may modify this */ be_setup_init(adapter);
adapter->vlan_prio_bmap = 0xff;
adapter->link_speed = -1;
be_cmd_req_native_mode(adapter); be_cmd_req_native_mode(adapter);
......
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