aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPadmanabh Ratnakar <padmanabh.ratnakar@emulex.com>2012-06-07 00:37:08 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-07 16:18:54 -0400
commit1578e7778fa04eb7e32da561effee6cd38139b0f (patch)
tree6d532b6994bf7ba42e371e3c27b44d56fd65842c
parentccf7e72b54253f926a35fdfa0366e0cb9ba72ffd (diff)
be2net: Fix driver load for VFs for Lancer
Permanent MAC is wrongly supplied in create iface command. Call the command with no MAC address and then MAC address should be later queried and applied. Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c21
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h8
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c98
3 files changed, 66 insertions, 61 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 8d06ea381741..f8997521b147 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1132,7 +1132,7 @@ err:
1132 * Uses MCCQ 1132 * Uses MCCQ
1133 */ 1133 */
1134int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, 1134int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
1135 u8 *mac, u32 *if_handle, u32 *pmac_id, u32 domain) 1135 u32 *if_handle, u32 domain)
1136{ 1136{
1137 struct be_mcc_wrb *wrb; 1137 struct be_mcc_wrb *wrb;
1138 struct be_cmd_req_if_create *req; 1138 struct be_cmd_req_if_create *req;
@@ -1152,17 +1152,13 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
1152 req->hdr.domain = domain; 1152 req->hdr.domain = domain;
1153 req->capability_flags = cpu_to_le32(cap_flags); 1153 req->capability_flags = cpu_to_le32(cap_flags);
1154 req->enable_flags = cpu_to_le32(en_flags); 1154 req->enable_flags = cpu_to_le32(en_flags);
1155 if (mac) 1155
1156 memcpy(req->mac_addr, mac, ETH_ALEN); 1156 req->pmac_invalid = true;
1157 else
1158 req->pmac_invalid = true;
1159 1157
1160 status = be_mcc_notify_wait(adapter); 1158 status = be_mcc_notify_wait(adapter);
1161 if (!status) { 1159 if (!status) {
1162 struct be_cmd_resp_if_create *resp = embedded_payload(wrb); 1160 struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
1163 *if_handle = le32_to_cpu(resp->interface_id); 1161 *if_handle = le32_to_cpu(resp->interface_id);
1164 if (mac)
1165 *pmac_id = le32_to_cpu(resp->pmac_id);
1166 } 1162 }
1167 1163
1168err: 1164err:
@@ -2330,8 +2326,8 @@ err:
2330} 2326}
2331 2327
2332/* Uses synchronous MCCQ */ 2328/* Uses synchronous MCCQ */
2333int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 2329int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
2334 bool *pmac_id_active, u32 *pmac_id, u8 *mac) 2330 bool *pmac_id_active, u32 *pmac_id, u8 domain)
2335{ 2331{
2336 struct be_mcc_wrb *wrb; 2332 struct be_mcc_wrb *wrb;
2337 struct be_cmd_req_get_mac_list *req; 2333 struct be_cmd_req_get_mac_list *req;
@@ -2376,8 +2372,9 @@ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
2376 get_mac_list_cmd.va; 2372 get_mac_list_cmd.va;
2377 mac_count = resp->true_mac_count + resp->pseudo_mac_count; 2373 mac_count = resp->true_mac_count + resp->pseudo_mac_count;
2378 /* Mac list returned could contain one or more active mac_ids 2374 /* Mac list returned could contain one or more active mac_ids
2379 * or one or more pseudo permanant mac addresses. If an active 2375 * or one or more true or pseudo permanant mac addresses.
2380 * mac_id is present, return first active mac_id found 2376 * If an active mac_id is present, return first active mac_id
2377 * found.
2381 */ 2378 */
2382 for (i = 0; i < mac_count; i++) { 2379 for (i = 0; i < mac_count; i++) {
2383 struct get_list_macaddr *mac_entry; 2380 struct get_list_macaddr *mac_entry;
@@ -2396,7 +2393,7 @@ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
2396 goto out; 2393 goto out;
2397 } 2394 }
2398 } 2395 }
2399 /* If no active mac_id found, return first pseudo mac addr */ 2396 /* If no active mac_id found, return first mac addr */
2400 *pmac_id_active = false; 2397 *pmac_id_active = false;
2401 memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr, 2398 memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr,
2402 ETH_ALEN); 2399 ETH_ALEN);
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 9625bf420c16..2f6bb06df9c6 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1664,8 +1664,7 @@ extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
1664extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, 1664extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id,
1665 int pmac_id, u32 domain); 1665 int pmac_id, u32 domain);
1666extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, 1666extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags,
1667 u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id, 1667 u32 en_flags, u32 *if_handle, u32 domain);
1668 u32 domain);
1669extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle, 1668extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle,
1670 u32 domain); 1669 u32 domain);
1671extern int be_cmd_eq_create(struct be_adapter *adapter, 1670extern int be_cmd_eq_create(struct be_adapter *adapter,
@@ -1751,8 +1750,9 @@ extern int be_cmd_get_cntl_attributes(struct be_adapter *adapter);
1751extern int be_cmd_req_native_mode(struct be_adapter *adapter); 1750extern int be_cmd_req_native_mode(struct be_adapter *adapter);
1752extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size); 1751extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size);
1753extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf); 1752extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf);
1754extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 1753extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
1755 bool *pmac_id_active, u32 *pmac_id, u8 *mac); 1754 bool *pmac_id_active, u32 *pmac_id,
1755 u8 domain);
1756extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, 1756extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
1757 u8 mac_count, u32 domain); 1757 u8 mac_count, u32 domain);
1758extern int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid, 1758extern int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid,
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index f29827f657eb..896f283967d4 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2601,8 +2601,8 @@ static int be_vf_setup(struct be_adapter *adapter)
2601 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 2601 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
2602 BE_IF_FLAGS_MULTICAST; 2602 BE_IF_FLAGS_MULTICAST;
2603 for_all_vfs(adapter, vf_cfg, vf) { 2603 for_all_vfs(adapter, vf_cfg, vf) {
2604 status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, 2604 status = be_cmd_if_create(adapter, cap_flags, en_flags,
2605 &vf_cfg->if_handle, NULL, vf + 1); 2605 &vf_cfg->if_handle, vf + 1);
2606 if (status) 2606 if (status)
2607 goto err; 2607 goto err;
2608 } 2608 }
@@ -2642,29 +2642,43 @@ static void be_setup_init(struct be_adapter *adapter)
2642 adapter->phy.forced_port_speed = -1; 2642 adapter->phy.forced_port_speed = -1;
2643} 2643}
2644 2644
2645static int be_add_mac_from_list(struct be_adapter *adapter, u8 *mac) 2645static int be_get_mac_addr(struct be_adapter *adapter, u8 *mac, u32 if_handle,
2646 bool *active_mac, u32 *pmac_id)
2646{ 2647{
2647 u32 pmac_id; 2648 int status = 0;
2648 int status;
2649 bool pmac_id_active;
2650 2649
2651 status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id_active, 2650 if (!is_zero_ether_addr(adapter->netdev->perm_addr)) {
2652 &pmac_id, mac); 2651 memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN);
2653 if (status != 0) 2652 if (!lancer_chip(adapter) && !be_physfn(adapter))
2654 goto do_none; 2653 *active_mac = true;
2654 else
2655 *active_mac = false;
2655 2656
2656 if (pmac_id_active) { 2657 return status;
2657 status = be_cmd_mac_addr_query(adapter, mac, 2658 }
2658 MAC_ADDRESS_TYPE_NETWORK,
2659 false, adapter->if_handle, pmac_id);
2660 2659
2661 if (!status) 2660 if (lancer_chip(adapter)) {
2662 adapter->pmac_id[0] = pmac_id; 2661 status = be_cmd_get_mac_from_list(adapter, mac,
2662 active_mac, pmac_id, 0);
2663 if (*active_mac) {
2664 status = be_cmd_mac_addr_query(adapter, mac,
2665 MAC_ADDRESS_TYPE_NETWORK,
2666 false, if_handle,
2667 *pmac_id);
2668 }
2669 } else if (be_physfn(adapter)) {
2670 /* For BE3, for PF get permanent MAC */
2671 status = be_cmd_mac_addr_query(adapter, mac,
2672 MAC_ADDRESS_TYPE_NETWORK, true,
2673 0, 0);
2674 *active_mac = false;
2663 } else { 2675 } else {
2664 status = be_cmd_pmac_add(adapter, mac, 2676 /* For BE3, for VF get soft MAC assigned by PF*/
2665 adapter->if_handle, &adapter->pmac_id[0], 0); 2677 status = be_cmd_mac_addr_query(adapter, mac,
2678 MAC_ADDRESS_TYPE_NETWORK, false,
2679 if_handle, 0);
2680 *active_mac = true;
2666 } 2681 }
2667do_none:
2668 return status; 2682 return status;
2669} 2683}
2670 2684
@@ -2685,12 +2699,12 @@ static int be_get_config(struct be_adapter *adapter)
2685 2699
2686static int be_setup(struct be_adapter *adapter) 2700static int be_setup(struct be_adapter *adapter)
2687{ 2701{
2688 struct net_device *netdev = adapter->netdev;
2689 struct device *dev = &adapter->pdev->dev; 2702 struct device *dev = &adapter->pdev->dev;
2690 u32 cap_flags, en_flags; 2703 u32 cap_flags, en_flags;
2691 u32 tx_fc, rx_fc; 2704 u32 tx_fc, rx_fc;
2692 int status; 2705 int status;
2693 u8 mac[ETH_ALEN]; 2706 u8 mac[ETH_ALEN];
2707 bool active_mac;
2694 2708
2695 be_setup_init(adapter); 2709 be_setup_init(adapter);
2696 2710
@@ -2716,14 +2730,6 @@ static int be_setup(struct be_adapter *adapter)
2716 if (status) 2730 if (status)
2717 goto err; 2731 goto err;
2718 2732
2719 memset(mac, 0, ETH_ALEN);
2720 status = be_cmd_mac_addr_query(adapter, mac, MAC_ADDRESS_TYPE_NETWORK,
2721 true /*permanent */, 0, 0);
2722 if (status)
2723 return status;
2724 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
2725 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
2726
2727 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 2733 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
2728 BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS; 2734 BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
2729 cap_flags = en_flags | BE_IF_FLAGS_MCAST_PROMISCUOUS | 2735 cap_flags = en_flags | BE_IF_FLAGS_MCAST_PROMISCUOUS |
@@ -2733,27 +2739,29 @@ static int be_setup(struct be_adapter *adapter)
2733 cap_flags |= BE_IF_FLAGS_RSS; 2739 cap_flags |= BE_IF_FLAGS_RSS;
2734 en_flags |= BE_IF_FLAGS_RSS; 2740 en_flags |= BE_IF_FLAGS_RSS;
2735 } 2741 }
2742
2736 status = be_cmd_if_create(adapter, cap_flags, en_flags, 2743 status = be_cmd_if_create(adapter, cap_flags, en_flags,
2737 netdev->dev_addr, &adapter->if_handle, 2744 &adapter->if_handle, 0);
2738 &adapter->pmac_id[0], 0);
2739 if (status != 0) 2745 if (status != 0)
2740 goto err; 2746 goto err;
2741 2747
2742 /* The VF's permanent mac queried from card is incorrect. 2748 memset(mac, 0, ETH_ALEN);
2743 * For BEx: Query the mac configued by the PF using if_handle 2749 active_mac = false;
2744 * For Lancer: Get and use mac_list to obtain mac address. 2750 status = be_get_mac_addr(adapter, mac, adapter->if_handle,
2745 */ 2751 &active_mac, &adapter->pmac_id[0]);
2746 if (!be_physfn(adapter)) { 2752 if (status != 0)
2747 if (lancer_chip(adapter)) 2753 goto err;
2748 status = be_add_mac_from_list(adapter, mac); 2754
2749 else 2755 if (!active_mac) {
2750 status = be_cmd_mac_addr_query(adapter, mac, 2756 status = be_cmd_pmac_add(adapter, mac, adapter->if_handle,
2751 MAC_ADDRESS_TYPE_NETWORK, false, 2757 &adapter->pmac_id[0], 0);
2752 adapter->if_handle, 0); 2758 if (status != 0)
2753 if (!status) { 2759 goto err;
2754 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); 2760 }
2755 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); 2761
2756 } 2762 if (is_zero_ether_addr(adapter->netdev->dev_addr)) {
2763 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
2764 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
2757 } 2765 }
2758 2766
2759 status = be_tx_qs_create(adapter); 2767 status = be_tx_qs_create(adapter);