aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorSathya Perla <sathya.perla@emulex.com>2011-10-23 22:45:01 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-24 18:40:14 -0400
commitf9449ab76805a2f0e739f5e85a6d9e32d089f1b2 (patch)
tree859c82352adf2a5347f03aa46c090aebcc2e738d /drivers/net
parenta54769f51b9495f8313224fea670ab6fe720f4b1 (diff)
be2net: refactor VF setup/teardown code into be_vf_setup/clear()
Currently the code for VF setup/teardown done by a PF (if_create, mac_add_config, link_status_query etc) is scattered; this patch refactors this code into be_vf_setup() and be_vf_clear(). The if_create/if_destroy/mac_addr_query cmds are now called after the MCCQ is created; so these cmds are now modified to use the MCCQ instead of MBOX. Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c66
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c229
3 files changed, 147 insertions, 152 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 6e7b5218c784..e0ff96193c49 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -615,7 +615,7 @@ int be_cmd_eq_create(struct be_adapter *adapter,
615 return status; 615 return status;
616} 616}
617 617
618/* Uses mbox */ 618/* Use MCC */
619int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, 619int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
620 u8 type, bool permanent, u32 if_handle) 620 u8 type, bool permanent, u32 if_handle)
621{ 621{
@@ -623,10 +623,13 @@ int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
623 struct be_cmd_req_mac_query *req; 623 struct be_cmd_req_mac_query *req;
624 int status; 624 int status;
625 625
626 if (mutex_lock_interruptible(&adapter->mbox_lock)) 626 spin_lock_bh(&adapter->mcc_lock);
627 return -1;
628 627
629 wrb = wrb_from_mbox(adapter); 628 wrb = wrb_from_mccq(adapter);
629 if (!wrb) {
630 status = -EBUSY;
631 goto err;
632 }
630 req = embedded_payload(wrb); 633 req = embedded_payload(wrb);
631 634
632 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, 635 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
@@ -643,13 +646,14 @@ int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
643 req->permanent = 0; 646 req->permanent = 0;
644 } 647 }
645 648
646 status = be_mbox_notify_wait(adapter); 649 status = be_mcc_notify_wait(adapter);
647 if (!status) { 650 if (!status) {
648 struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); 651 struct be_cmd_resp_mac_query *resp = embedded_payload(wrb);
649 memcpy(mac_addr, resp->mac.addr, ETH_ALEN); 652 memcpy(mac_addr, resp->mac.addr, ETH_ALEN);
650 } 653 }
651 654
652 mutex_unlock(&adapter->mbox_lock); 655err:
656 spin_unlock_bh(&adapter->mcc_lock);
653 return status; 657 return status;
654} 658}
655 659
@@ -1111,20 +1115,22 @@ err:
1111} 1115}
1112 1116
1113/* Create an rx filtering policy configuration on an i/f 1117/* Create an rx filtering policy configuration on an i/f
1114 * Uses mbox 1118 * Uses MCCQ
1115 */ 1119 */
1116int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, 1120int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
1117 u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id, 1121 u8 *mac, u32 *if_handle, u32 *pmac_id, u32 domain)
1118 u32 domain)
1119{ 1122{
1120 struct be_mcc_wrb *wrb; 1123 struct be_mcc_wrb *wrb;
1121 struct be_cmd_req_if_create *req; 1124 struct be_cmd_req_if_create *req;
1122 int status; 1125 int status;
1123 1126
1124 if (mutex_lock_interruptible(&adapter->mbox_lock)) 1127 spin_lock_bh(&adapter->mcc_lock);
1125 return -1;
1126 1128
1127 wrb = wrb_from_mbox(adapter); 1129 wrb = wrb_from_mccq(adapter);
1130 if (!wrb) {
1131 status = -EBUSY;
1132 goto err;
1133 }
1128 req = embedded_payload(wrb); 1134 req = embedded_payload(wrb);
1129 1135
1130 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, 1136 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
@@ -1136,23 +1142,25 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
1136 req->hdr.domain = domain; 1142 req->hdr.domain = domain;
1137 req->capability_flags = cpu_to_le32(cap_flags); 1143 req->capability_flags = cpu_to_le32(cap_flags);
1138 req->enable_flags = cpu_to_le32(en_flags); 1144 req->enable_flags = cpu_to_le32(en_flags);
1139 req->pmac_invalid = pmac_invalid; 1145 if (mac)
1140 if (!pmac_invalid)
1141 memcpy(req->mac_addr, mac, ETH_ALEN); 1146 memcpy(req->mac_addr, mac, ETH_ALEN);
1147 else
1148 req->pmac_invalid = true;
1142 1149
1143 status = be_mbox_notify_wait(adapter); 1150 status = be_mcc_notify_wait(adapter);
1144 if (!status) { 1151 if (!status) {
1145 struct be_cmd_resp_if_create *resp = embedded_payload(wrb); 1152 struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
1146 *if_handle = le32_to_cpu(resp->interface_id); 1153 *if_handle = le32_to_cpu(resp->interface_id);
1147 if (!pmac_invalid) 1154 if (mac)
1148 *pmac_id = le32_to_cpu(resp->pmac_id); 1155 *pmac_id = le32_to_cpu(resp->pmac_id);
1149 } 1156 }
1150 1157
1151 mutex_unlock(&adapter->mbox_lock); 1158err:
1159 spin_unlock_bh(&adapter->mcc_lock);
1152 return status; 1160 return status;
1153} 1161}
1154 1162
1155/* Uses mbox */ 1163/* Uses MCCQ */
1156int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) 1164int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain)
1157{ 1165{
1158 struct be_mcc_wrb *wrb; 1166 struct be_mcc_wrb *wrb;
@@ -1162,10 +1170,16 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain)
1162 if (adapter->eeh_err) 1170 if (adapter->eeh_err)
1163 return -EIO; 1171 return -EIO;
1164 1172
1165 if (mutex_lock_interruptible(&adapter->mbox_lock)) 1173 if (!interface_id)
1166 return -1; 1174 return 0;
1167 1175
1168 wrb = wrb_from_mbox(adapter); 1176 spin_lock_bh(&adapter->mcc_lock);
1177
1178 wrb = wrb_from_mccq(adapter);
1179 if (!wrb) {
1180 status = -EBUSY;
1181 goto err;
1182 }
1169 req = embedded_payload(wrb); 1183 req = embedded_payload(wrb);
1170 1184
1171 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, 1185 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
@@ -1177,10 +1191,9 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain)
1177 req->hdr.domain = domain; 1191 req->hdr.domain = domain;
1178 req->interface_id = cpu_to_le32(interface_id); 1192 req->interface_id = cpu_to_le32(interface_id);
1179 1193
1180 status = be_mbox_notify_wait(adapter); 1194 status = be_mcc_notify_wait(adapter);
1181 1195err:
1182 mutex_unlock(&adapter->mbox_lock); 1196 spin_unlock_bh(&adapter->mcc_lock);
1183
1184 return status; 1197 return status;
1185} 1198}
1186 1199
@@ -1301,7 +1314,8 @@ int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed,
1301 struct be_cmd_resp_link_status *resp = embedded_payload(wrb); 1314 struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
1302 if (resp->mac_speed != PHY_LINK_SPEED_ZERO) { 1315 if (resp->mac_speed != PHY_LINK_SPEED_ZERO) {
1303 *link_speed = le16_to_cpu(resp->link_speed); 1316 *link_speed = le16_to_cpu(resp->link_speed);
1304 *mac_speed = resp->mac_speed; 1317 if (mac_speed)
1318 *mac_speed = resp->mac_speed;
1305 } 1319 }
1306 } 1320 }
1307 1321
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index abaa90cbfea2..75b75741c80e 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1413,8 +1413,8 @@ extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
1413extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, 1413extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id,
1414 u32 pmac_id, u32 domain); 1414 u32 pmac_id, u32 domain);
1415extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, 1415extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags,
1416 u32 en_flags, u8 *mac, bool pmac_invalid, 1416 u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id,
1417 u32 *if_handle, u32 *pmac_id, u32 domain); 1417 u32 domain);
1418extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle, 1418extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle,
1419 u32 domain); 1419 u32 domain);
1420extern int be_cmd_eq_create(struct be_adapter *adapter, 1420extern int be_cmd_eq_create(struct be_adapter *adapter,
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index d05b6bb5ae81..d32e3787beb4 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2069,7 +2069,7 @@ done:
2069 return; 2069 return;
2070} 2070}
2071 2071
2072static void be_sriov_enable(struct be_adapter *adapter) 2072static int be_sriov_enable(struct be_adapter *adapter)
2073{ 2073{
2074 be_check_sriov_fn_type(adapter); 2074 be_check_sriov_fn_type(adapter);
2075#ifdef CONFIG_PCI_IOV 2075#ifdef CONFIG_PCI_IOV
@@ -2091,8 +2091,17 @@ static void be_sriov_enable(struct be_adapter *adapter)
2091 2091
2092 status = pci_enable_sriov(adapter->pdev, num_vfs); 2092 status = pci_enable_sriov(adapter->pdev, num_vfs);
2093 adapter->sriov_enabled = status ? false : true; 2093 adapter->sriov_enabled = status ? false : true;
2094
2095 if (adapter->sriov_enabled) {
2096 adapter->vf_cfg = kcalloc(num_vfs,
2097 sizeof(struct be_vf_cfg),
2098 GFP_KERNEL);
2099 if (!adapter->vf_cfg)
2100 return -ENOMEM;
2101 }
2094 } 2102 }
2095#endif 2103#endif
2104 return 0;
2096} 2105}
2097 2106
2098static void be_sriov_disable(struct be_adapter *adapter) 2107static void be_sriov_disable(struct be_adapter *adapter)
@@ -2100,6 +2109,7 @@ static void be_sriov_disable(struct be_adapter *adapter)
2100#ifdef CONFIG_PCI_IOV 2109#ifdef CONFIG_PCI_IOV
2101 if (adapter->sriov_enabled) { 2110 if (adapter->sriov_enabled) {
2102 pci_disable_sriov(adapter->pdev); 2111 pci_disable_sriov(adapter->pdev);
2112 kfree(adapter->vf_cfg);
2103 adapter->sriov_enabled = false; 2113 adapter->sriov_enabled = false;
2104 } 2114 }
2105#endif 2115#endif
@@ -2405,7 +2415,7 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable)
2405 */ 2415 */
2406static inline int be_vf_eth_addr_config(struct be_adapter *adapter) 2416static inline int be_vf_eth_addr_config(struct be_adapter *adapter)
2407{ 2417{
2408 u32 vf = 0; 2418 u32 vf;
2409 int status = 0; 2419 int status = 0;
2410 u8 mac[ETH_ALEN]; 2420 u8 mac[ETH_ALEN];
2411 2421
@@ -2427,7 +2437,7 @@ static inline int be_vf_eth_addr_config(struct be_adapter *adapter)
2427 return status; 2437 return status;
2428} 2438}
2429 2439
2430static inline void be_vf_eth_addr_rem(struct be_adapter *adapter) 2440static void be_vf_clear(struct be_adapter *adapter)
2431{ 2441{
2432 u32 vf; 2442 u32 vf;
2433 2443
@@ -2437,29 +2447,25 @@ static inline void be_vf_eth_addr_rem(struct be_adapter *adapter)
2437 adapter->vf_cfg[vf].vf_if_handle, 2447 adapter->vf_cfg[vf].vf_if_handle,
2438 adapter->vf_cfg[vf].vf_pmac_id, vf + 1); 2448 adapter->vf_cfg[vf].vf_pmac_id, vf + 1);
2439 } 2449 }
2450
2451 for (vf = 0; vf < num_vfs; vf++)
2452 if (adapter->vf_cfg[vf].vf_if_handle)
2453 be_cmd_if_destroy(adapter,
2454 adapter->vf_cfg[vf].vf_if_handle, vf + 1);
2440} 2455}
2441 2456
2442static int be_clear(struct be_adapter *adapter) 2457static int be_clear(struct be_adapter *adapter)
2443{ 2458{
2444 int vf;
2445
2446 if (be_physfn(adapter) && adapter->sriov_enabled) 2459 if (be_physfn(adapter) && adapter->sriov_enabled)
2447 be_vf_eth_addr_rem(adapter); 2460 be_vf_clear(adapter);
2461
2462 be_cmd_if_destroy(adapter, adapter->if_handle, 0);
2448 2463
2449 be_mcc_queues_destroy(adapter); 2464 be_mcc_queues_destroy(adapter);
2450 be_rx_queues_destroy(adapter); 2465 be_rx_queues_destroy(adapter);
2451 be_tx_queues_destroy(adapter); 2466 be_tx_queues_destroy(adapter);
2452 adapter->eq_next_idx = 0; 2467 adapter->eq_next_idx = 0;
2453 2468
2454 if (be_physfn(adapter) && adapter->sriov_enabled)
2455 for (vf = 0; vf < num_vfs; vf++)
2456 if (adapter->vf_cfg[vf].vf_if_handle)
2457 be_cmd_if_destroy(adapter,
2458 adapter->vf_cfg[vf].vf_if_handle,
2459 vf + 1);
2460
2461 be_cmd_if_destroy(adapter, adapter->if_handle, 0);
2462
2463 adapter->be3_native = false; 2469 adapter->be3_native = false;
2464 adapter->promiscuous = false; 2470 adapter->promiscuous = false;
2465 2471
@@ -2468,83 +2474,99 @@ static int be_clear(struct be_adapter *adapter)
2468 return 0; 2474 return 0;
2469} 2475}
2470 2476
2477static int be_vf_setup(struct be_adapter *adapter)
2478{
2479 u32 cap_flags, en_flags, vf;
2480 u16 lnk_speed;
2481 int status;
2482
2483 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST;
2484 for (vf = 0; vf < num_vfs; vf++) {
2485 status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL,
2486 &adapter->vf_cfg[vf].vf_if_handle,
2487 NULL, vf+1);
2488 if (status)
2489 goto err;
2490 adapter->vf_cfg[vf].vf_pmac_id = BE_INVALID_PMAC_ID;
2491 }
2492
2493 if (!lancer_chip(adapter)) {
2494 status = be_vf_eth_addr_config(adapter);
2495 if (status)
2496 goto err;
2497 }
2498
2499 for (vf = 0; vf < num_vfs; vf++) {
2500 status = be_cmd_link_status_query(adapter, NULL, &lnk_speed,
2501 vf + 1);
2502 if (status)
2503 goto err;
2504 adapter->vf_cfg[vf].vf_tx_rate = lnk_speed * 10;
2505 }
2506 return 0;
2507err:
2508 return status;
2509}
2510
2471static int be_setup(struct be_adapter *adapter) 2511static int be_setup(struct be_adapter *adapter)
2472{ 2512{
2473 struct net_device *netdev = adapter->netdev; 2513 struct net_device *netdev = adapter->netdev;
2474 u32 cap_flags, en_flags, vf = 0; 2514 u32 cap_flags, en_flags;
2475 u32 tx_fc, rx_fc; 2515 u32 tx_fc, rx_fc;
2476 int status; 2516 int status;
2477 u8 mac[ETH_ALEN]; 2517 u8 mac[ETH_ALEN];
2478 2518
2479 be_cmd_req_native_mode(adapter); 2519 /* Allow all priorities by default. A GRP5 evt may modify this */
2480 2520 adapter->vlan_prio_bmap = 0xff;
2481 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | 2521 adapter->link_speed = -1;
2482 BE_IF_FLAGS_BROADCAST |
2483 BE_IF_FLAGS_MULTICAST;
2484 2522
2485 if (be_physfn(adapter)) { 2523 be_cmd_req_native_mode(adapter);
2486 cap_flags |= BE_IF_FLAGS_MCAST_PROMISCUOUS |
2487 BE_IF_FLAGS_PROMISCUOUS |
2488 BE_IF_FLAGS_PASS_L3L4_ERRORS;
2489 en_flags |= BE_IF_FLAGS_PASS_L3L4_ERRORS;
2490
2491 if (adapter->function_caps & BE_FUNCTION_CAPS_RSS) {
2492 cap_flags |= BE_IF_FLAGS_RSS;
2493 en_flags |= BE_IF_FLAGS_RSS;
2494 }
2495 }
2496 2524
2497 status = be_cmd_if_create(adapter, cap_flags, en_flags, 2525 status = be_tx_queues_create(adapter);
2498 netdev->dev_addr, false/* pmac_invalid */,
2499 &adapter->if_handle, &adapter->pmac_id, 0);
2500 if (status != 0) 2526 if (status != 0)
2501 goto err; 2527 goto err;
2502 2528
2503 if (be_physfn(adapter)) { 2529 status = be_rx_queues_create(adapter);
2504 if (adapter->sriov_enabled) {
2505 while (vf < num_vfs) {
2506 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED |
2507 BE_IF_FLAGS_BROADCAST;
2508 status = be_cmd_if_create(adapter, cap_flags,
2509 en_flags, mac, true,
2510 &adapter->vf_cfg[vf].vf_if_handle,
2511 NULL, vf+1);
2512 if (status) {
2513 dev_err(&adapter->pdev->dev,
2514 "Interface Create failed for VF %d\n",
2515 vf);
2516 goto err;
2517 }
2518 adapter->vf_cfg[vf].vf_pmac_id =
2519 BE_INVALID_PMAC_ID;
2520 vf++;
2521 }
2522 }
2523 } else {
2524 status = be_cmd_mac_addr_query(adapter, mac,
2525 MAC_ADDRESS_TYPE_NETWORK, false, adapter->if_handle);
2526 if (!status) {
2527 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
2528 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
2529 }
2530 }
2531
2532 status = be_tx_queues_create(adapter);
2533 if (status != 0) 2530 if (status != 0)
2534 goto err; 2531 goto err;
2535 2532
2536 status = be_rx_queues_create(adapter); 2533 status = be_mcc_queues_create(adapter);
2537 if (status != 0) 2534 if (status != 0)
2538 goto err; 2535 goto err;
2539 2536
2540 /* Allow all priorities by default. A GRP5 evt may modify this */ 2537 memset(mac, 0, ETH_ALEN);
2541 adapter->vlan_prio_bmap = 0xff; 2538 status = be_cmd_mac_addr_query(adapter, mac, MAC_ADDRESS_TYPE_NETWORK,
2539 true /*permanent */, 0);
2540 if (status)
2541 return status;
2542 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
2543 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
2542 2544
2543 status = be_mcc_queues_create(adapter); 2545 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
2546 BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
2547 cap_flags = en_flags | BE_IF_FLAGS_MCAST_PROMISCUOUS |
2548 BE_IF_FLAGS_PROMISCUOUS;
2549 if (adapter->function_caps & BE_FUNCTION_CAPS_RSS) {
2550 cap_flags |= BE_IF_FLAGS_RSS;
2551 en_flags |= BE_IF_FLAGS_RSS;
2552 }
2553 status = be_cmd_if_create(adapter, cap_flags, en_flags,
2554 netdev->dev_addr, &adapter->if_handle,
2555 &adapter->pmac_id, 0);
2544 if (status != 0) 2556 if (status != 0)
2545 goto err; 2557 goto err;
2546 2558
2547 adapter->link_speed = -1; 2559 /* For BEx, the VF's permanent mac queried from card is incorrect.
2560 * Query the mac configued by the PF using if_handle
2561 */
2562 if (!be_physfn(adapter) && !lancer_chip(adapter)) {
2563 status = be_cmd_mac_addr_query(adapter, mac,
2564 MAC_ADDRESS_TYPE_NETWORK, false, adapter->if_handle);
2565 if (!status) {
2566 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
2567 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
2568 }
2569 }
2548 2570
2549 be_cmd_get_fw_ver(adapter, adapter->fw_ver, NULL); 2571 be_cmd_get_fw_ver(adapter, adapter->fw_ver, NULL);
2550 2572
@@ -2565,8 +2587,14 @@ static int be_setup(struct be_adapter *adapter)
2565 } 2587 }
2566 2588
2567 pcie_set_readrq(adapter->pdev, 4096); 2589 pcie_set_readrq(adapter->pdev, 4096);
2568 return 0;
2569 2590
2591 if (be_physfn(adapter) && adapter->sriov_enabled) {
2592 status = be_vf_setup(adapter);
2593 if (status)
2594 goto err;
2595 }
2596
2597 return 0;
2570err: 2598err:
2571 be_clear(adapter); 2599 be_clear(adapter);
2572 return status; 2600 return status;
@@ -3123,7 +3151,6 @@ static void __devexit be_remove(struct pci_dev *pdev)
3123 3151
3124 be_ctrl_cleanup(adapter); 3152 be_ctrl_cleanup(adapter);
3125 3153
3126 kfree(adapter->vf_cfg);
3127 be_sriov_disable(adapter); 3154 be_sriov_disable(adapter);
3128 3155
3129 be_msix_disable(adapter); 3156 be_msix_disable(adapter);
@@ -3138,30 +3165,12 @@ static void __devexit be_remove(struct pci_dev *pdev)
3138static int be_get_config(struct be_adapter *adapter) 3165static int be_get_config(struct be_adapter *adapter)
3139{ 3166{
3140 int status; 3167 int status;
3141 u8 mac[ETH_ALEN];
3142 3168
3143 status = be_cmd_query_fw_cfg(adapter, &adapter->port_num, 3169 status = be_cmd_query_fw_cfg(adapter, &adapter->port_num,
3144 &adapter->function_mode, &adapter->function_caps); 3170 &adapter->function_mode, &adapter->function_caps);
3145 if (status) 3171 if (status)
3146 return status; 3172 return status;
3147 3173
3148 memset(mac, 0, ETH_ALEN);
3149
3150 /* A default permanent address is given to each VF for Lancer*/
3151 if (be_physfn(adapter) || lancer_chip(adapter)) {
3152 status = be_cmd_mac_addr_query(adapter, mac,
3153 MAC_ADDRESS_TYPE_NETWORK, true /*permanent */, 0);
3154
3155 if (status)
3156 return status;
3157
3158 if (!is_valid_ether_addr(mac))
3159 return -EADDRNOTAVAIL;
3160
3161 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
3162 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
3163 }
3164
3165 if (adapter->function_mode & 0x400) 3174 if (adapter->function_mode & 0x400)
3166 adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/4; 3175 adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/4;
3167 else 3176 else
@@ -3310,18 +3319,13 @@ static int __devinit be_probe(struct pci_dev *pdev,
3310 } 3319 }
3311 } 3320 }
3312 3321
3313 be_sriov_enable(adapter); 3322 status = be_sriov_enable(adapter);
3314 if (adapter->sriov_enabled) { 3323 if (status)
3315 adapter->vf_cfg = kcalloc(num_vfs, 3324 goto free_netdev;
3316 sizeof(struct be_vf_cfg), GFP_KERNEL);
3317
3318 if (!adapter->vf_cfg)
3319 goto free_netdev;
3320 }
3321 3325
3322 status = be_ctrl_init(adapter); 3326 status = be_ctrl_init(adapter);
3323 if (status) 3327 if (status)
3324 goto free_vf_cfg; 3328 goto disable_sriov;
3325 3329
3326 if (lancer_chip(adapter)) { 3330 if (lancer_chip(adapter)) {
3327 status = lancer_test_and_set_rdy_state(adapter); 3331 status = lancer_test_and_set_rdy_state(adapter);
@@ -3375,33 +3379,11 @@ static int __devinit be_probe(struct pci_dev *pdev,
3375 if (status != 0) 3379 if (status != 0)
3376 goto unsetup; 3380 goto unsetup;
3377 3381
3378 if (be_physfn(adapter) && adapter->sriov_enabled) {
3379 u8 mac_speed;
3380 u16 vf, lnk_speed;
3381
3382 if (!lancer_chip(adapter)) {
3383 status = be_vf_eth_addr_config(adapter);
3384 if (status)
3385 goto unreg_netdev;
3386 }
3387
3388 for (vf = 0; vf < num_vfs; vf++) {
3389 status = be_cmd_link_status_query(adapter, &mac_speed,
3390 &lnk_speed, vf + 1);
3391 if (!status)
3392 adapter->vf_cfg[vf].vf_tx_rate = lnk_speed * 10;
3393 else
3394 goto unreg_netdev;
3395 }
3396 }
3397
3398 dev_info(&pdev->dev, "%s port %d\n", nic_name(pdev), adapter->port_num); 3382 dev_info(&pdev->dev, "%s port %d\n", nic_name(pdev), adapter->port_num);
3399 3383
3400 schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); 3384 schedule_delayed_work(&adapter->work, msecs_to_jiffies(100));
3401 return 0; 3385 return 0;
3402 3386
3403unreg_netdev:
3404 unregister_netdev(netdev);
3405unsetup: 3387unsetup:
3406 be_clear(adapter); 3388 be_clear(adapter);
3407msix_disable: 3389msix_disable:
@@ -3410,10 +3392,9 @@ stats_clean:
3410 be_stats_cleanup(adapter); 3392 be_stats_cleanup(adapter);
3411ctrl_clean: 3393ctrl_clean:
3412 be_ctrl_cleanup(adapter); 3394 be_ctrl_cleanup(adapter);
3413free_vf_cfg: 3395disable_sriov:
3414 kfree(adapter->vf_cfg);
3415free_netdev:
3416 be_sriov_disable(adapter); 3396 be_sriov_disable(adapter);
3397free_netdev:
3417 free_netdev(netdev); 3398 free_netdev(netdev);
3418 pci_set_drvdata(pdev, NULL); 3399 pci_set_drvdata(pdev, NULL);
3419rel_reg: 3400rel_reg: