aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex
diff options
context:
space:
mode:
authorSathya Perla <sathya.perla@emulex.com>2011-11-10 14:17:57 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-12 17:59:35 -0500
commit30128031d71741ef7d0e32c345e3bf02aa8a0704 (patch)
tree1ca0ba5c5c34c252c8bcfc8d53c82b19fa2e7d4c /drivers/net/ethernet/emulex
parentd826eb14ecef3574b6b3be55e5f4329f4a76fbf3 (diff)
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: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/emulex')
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h8
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c9
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c55
4 files changed, 42 insertions, 34 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 644e8fed8364..4163980d6bcd 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -289,14 +289,12 @@ struct be_drv_stats {
289 289
290struct be_vf_cfg { 290struct be_vf_cfg {
291 unsigned char vf_mac_addr[ETH_ALEN]; 291 unsigned char vf_mac_addr[ETH_ALEN];
292 u32 vf_if_handle; 292 int vf_if_handle;
293 u32 vf_pmac_id; 293 int vf_pmac_id;
294 u16 vf_vlan_tag; 294 u16 vf_vlan_tag;
295 u32 vf_tx_rate; 295 u32 vf_tx_rate;
296}; 296};
297 297
298#define BE_INVALID_PMAC_ID 0xffffffff
299
300struct be_adapter { 298struct be_adapter {
301 struct pci_dev *pdev; 299 struct pci_dev *pdev;
302 struct net_device *netdev; 300 struct net_device *netdev;
@@ -347,7 +345,7 @@ struct be_adapter {
347 345
348 /* Ethtool knobs and info */ 346 /* Ethtool knobs and info */
349 char fw_ver[FW_VER_LEN]; 347 char fw_ver[FW_VER_LEN];
350 u32 if_handle; /* Used to configure filtering */ 348 int if_handle; /* Used to configure filtering */
351 u32 pmac_id; /* MAC addr handle used by BE card */ 349 u32 pmac_id; /* MAC addr handle used by BE card */
352 u32 beacon_state; /* for set_phys_id */ 350 u32 beacon_state; /* for set_phys_id */
353 351
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 2c7b36673dfc..c5912c4ed24f 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -695,12 +695,15 @@ err:
695} 695}
696 696
697/* Uses synchronous MCCQ */ 697/* Uses synchronous MCCQ */
698int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id, u32 dom) 698int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id, u32 dom)
699{ 699{
700 struct be_mcc_wrb *wrb; 700 struct be_mcc_wrb *wrb;
701 struct be_cmd_req_pmac_del *req; 701 struct be_cmd_req_pmac_del *req;
702 int status; 702 int status;
703 703
704 if (pmac_id == -1)
705 return 0;
706
704 spin_lock_bh(&adapter->mcc_lock); 707 spin_lock_bh(&adapter->mcc_lock);
705 708
706 wrb = wrb_from_mccq(adapter); 709 wrb = wrb_from_mccq(adapter);
@@ -1136,7 +1139,7 @@ err:
1136} 1139}
1137 1140
1138/* Uses MCCQ */ 1141/* Uses MCCQ */
1139int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) 1142int be_cmd_if_destroy(struct be_adapter *adapter, int interface_id, u32 domain)
1140{ 1143{
1141 struct be_mcc_wrb *wrb; 1144 struct be_mcc_wrb *wrb;
1142 struct be_cmd_req_if_destroy *req; 1145 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 if (adapter->eeh_err) 1148 if (adapter->eeh_err)
1146 return -EIO; 1149 return -EIO;
1147 1150
1148 if (!interface_id) 1151 if (interface_id == -1)
1149 return 0; 1152 return 0;
1150 1153
1151 spin_lock_bh(&adapter->mcc_lock); 1154 spin_lock_bh(&adapter->mcc_lock);
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index a35cd03fac4e..08180396891c 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1417,11 +1417,11 @@ extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
1417extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, 1417extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
1418 u32 if_id, u32 *pmac_id, u32 domain); 1418 u32 if_id, u32 *pmac_id, u32 domain);
1419extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, 1419extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id,
1420 u32 pmac_id, u32 domain); 1420 int pmac_id, u32 domain);
1421extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, 1421extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags,
1422 u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id, 1422 u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id,
1423 u32 domain); 1423 u32 domain);
1424extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle, 1424extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle,
1425 u32 domain); 1425 u32 domain);
1426extern int be_cmd_eq_create(struct be_adapter *adapter, 1426extern int be_cmd_eq_create(struct be_adapter *adapter,
1427 struct be_queue_info *eq, int eq_delay); 1427 struct be_queue_info *eq, int eq_delay);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index bf266a00c774..83d971d8a5a3 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -848,15 +848,11 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
848 if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) 848 if (!is_valid_ether_addr(mac) || (vf >= num_vfs))
849 return -EINVAL; 849 return -EINVAL;
850 850
851 if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) 851 status = be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle,
852 status = be_cmd_pmac_del(adapter, 852 adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
853 adapter->vf_cfg[vf].vf_if_handle,
854 adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
855 853
856 status = be_cmd_pmac_add(adapter, mac, 854 status = be_cmd_pmac_add(adapter, mac, adapter->vf_cfg[vf].vf_if_handle,
857 adapter->vf_cfg[vf].vf_if_handle,
858 &adapter->vf_cfg[vf].vf_pmac_id, vf + 1); 855 &adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
859
860 if (status) 856 if (status)
861 dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", 857 dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n",
862 mac, vf); 858 mac, vf);
@@ -2488,17 +2484,13 @@ static void be_vf_clear(struct be_adapter *adapter)
2488{ 2484{
2489 u32 vf; 2485 u32 vf;
2490 2486
2491 for (vf = 0; vf < num_vfs; vf++) { 2487 for (vf = 0; vf < num_vfs; vf++)
2492 if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) 2488 be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle,
2493 be_cmd_pmac_del(adapter, 2489 adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
2494 adapter->vf_cfg[vf].vf_if_handle,
2495 adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
2496 }
2497 2490
2498 for (vf = 0; vf < num_vfs; vf++) 2491 for (vf = 0; vf < num_vfs; vf++)
2499 if (adapter->vf_cfg[vf].vf_if_handle) 2492 be_cmd_if_destroy(adapter, adapter->vf_cfg[vf].vf_if_handle,
2500 be_cmd_if_destroy(adapter, 2493 vf + 1);
2501 adapter->vf_cfg[vf].vf_if_handle, vf + 1);
2502} 2494}
2503 2495
2504static int be_clear(struct be_adapter *adapter) 2496static int be_clear(struct be_adapter *adapter)
@@ -2511,22 +2503,30 @@ static int be_clear(struct be_adapter *adapter)
2511 be_mcc_queues_destroy(adapter); 2503 be_mcc_queues_destroy(adapter);
2512 be_rx_queues_destroy(adapter); 2504 be_rx_queues_destroy(adapter);
2513 be_tx_queues_destroy(adapter); 2505 be_tx_queues_destroy(adapter);
2514 adapter->eq_next_idx = 0;
2515
2516 adapter->be3_native = false;
2517 adapter->promiscuous = false;
2518 2506
2519 /* tell fw we're done with firing cmds */ 2507 /* tell fw we're done with firing cmds */
2520 be_cmd_fw_clean(adapter); 2508 be_cmd_fw_clean(adapter);
2521 return 0; 2509 return 0;
2522} 2510}
2523 2511
2512static void be_vf_setup_init(struct be_adapter *adapter)
2513{
2514 int vf;
2515
2516 for (vf = 0; vf < num_vfs; vf++) {
2517 adapter->vf_cfg[vf].vf_if_handle = -1;
2518 adapter->vf_cfg[vf].vf_pmac_id = -1;
2519 }
2520}
2521
2524static int be_vf_setup(struct be_adapter *adapter) 2522static int be_vf_setup(struct be_adapter *adapter)
2525{ 2523{
2526 u32 cap_flags, en_flags, vf; 2524 u32 cap_flags, en_flags, vf;
2527 u16 lnk_speed; 2525 u16 lnk_speed;
2528 int status; 2526 int status;
2529 2527
2528 be_vf_setup_init(adapter);
2529
2530 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST; 2530 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST;
2531 for (vf = 0; vf < num_vfs; vf++) { 2531 for (vf = 0; vf < num_vfs; vf++) {
2532 status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, 2532 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 NULL, vf+1); 2534 NULL, vf+1);
2535 if (status) 2535 if (status)
2536 goto err; 2536 goto err;
2537 adapter->vf_cfg[vf].vf_pmac_id = BE_INVALID_PMAC_ID;
2538 } 2537 }
2539 2538
2540 if (!lancer_chip(adapter)) { 2539 if (!lancer_chip(adapter)) {
@@ -2555,6 +2554,16 @@ err:
2555 return status; 2554 return status;
2556} 2555}
2557 2556
2557static void be_setup_init(struct be_adapter *adapter)
2558{
2559 adapter->vlan_prio_bmap = 0xff;
2560 adapter->link_speed = -1;
2561 adapter->if_handle = -1;
2562 adapter->be3_native = false;
2563 adapter->promiscuous = false;
2564 adapter->eq_next_idx = 0;
2565}
2566
2558static int be_setup(struct be_adapter *adapter) 2567static int be_setup(struct be_adapter *adapter)
2559{ 2568{
2560 struct net_device *netdev = adapter->netdev; 2569 struct net_device *netdev = adapter->netdev;
@@ -2563,9 +2572,7 @@ static int be_setup(struct be_adapter *adapter)
2563 int status; 2572 int status;
2564 u8 mac[ETH_ALEN]; 2573 u8 mac[ETH_ALEN];
2565 2574
2566 /* Allow all priorities by default. A GRP5 evt may modify this */ 2575 be_setup_init(adapter);
2567 adapter->vlan_prio_bmap = 0xff;
2568 adapter->link_speed = -1;
2569 2576
2570 be_cmd_req_native_mode(adapter); 2577 be_cmd_req_native_mode(adapter);
2571 2578