Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Padmanabh Ratnakar and committed by
David S. Miller
1578e777 ccf7e72b

+68 -63
+9 -12
drivers/net/ethernet/emulex/benet/be_cmds.c
··· 1132 1132 * Uses MCCQ 1133 1133 */ 1134 1134 int 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 1137 struct be_mcc_wrb *wrb; 1138 1138 struct be_cmd_req_if_create *req; ··· 1152 1152 req->hdr.domain = domain; 1153 1153 req->capability_flags = cpu_to_le32(cap_flags); 1154 1154 req->enable_flags = cpu_to_le32(en_flags); 1155 - if (mac) 1156 - memcpy(req->mac_addr, mac, ETH_ALEN); 1157 - else 1158 - req->pmac_invalid = true; 1155 + 1156 + req->pmac_invalid = true; 1159 1157 1160 1158 status = be_mcc_notify_wait(adapter); 1161 1159 if (!status) { 1162 1160 struct be_cmd_resp_if_create *resp = embedded_payload(wrb); 1163 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 1168 1164 err: ··· 2326 2330 } 2327 2331 2328 2332 /* Uses synchronous MCCQ */ 2329 - int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 2330 - bool *pmac_id_active, u32 *pmac_id, u8 *mac) 2333 + int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac, 2334 + bool *pmac_id_active, u32 *pmac_id, u8 domain) 2331 2335 { 2332 2336 struct be_mcc_wrb *wrb; 2333 2337 struct be_cmd_req_get_mac_list *req; ··· 2372 2376 get_mac_list_cmd.va; 2373 2377 mac_count = resp->true_mac_count + resp->pseudo_mac_count; 2374 2378 /* Mac list returned could contain one or more active mac_ids 2375 - * or one or more pseudo permanant mac addresses. If an active 2376 - * mac_id is present, return first active mac_id found 2379 + * or one or more true or pseudo permanant mac addresses. 2380 + * If an active mac_id is present, return first active mac_id 2381 + * found. 2377 2382 */ 2378 2383 for (i = 0; i < mac_count; i++) { 2379 2384 struct get_list_macaddr *mac_entry; ··· 2393 2396 goto out; 2394 2397 } 2395 2398 } 2396 - /* If no active mac_id found, return first pseudo mac addr */ 2399 + /* If no active mac_id found, return first mac addr */ 2397 2400 *pmac_id_active = false; 2398 2401 memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr, 2399 2402 ETH_ALEN);
+4 -4
drivers/net/ethernet/emulex/benet/be_cmds.h
··· 1664 1664 extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, 1665 1665 int pmac_id, u32 domain); 1666 1666 extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, 1667 - u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id, 1668 - u32 domain); 1667 + u32 en_flags, u32 *if_handle, u32 domain); 1669 1668 extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle, 1670 1669 u32 domain); 1671 1670 extern int be_cmd_eq_create(struct be_adapter *adapter, ··· 1750 1751 extern int be_cmd_req_native_mode(struct be_adapter *adapter); 1751 1752 extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size); 1752 1753 extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf); 1753 - extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 1754 - bool *pmac_id_active, u32 *pmac_id, u8 *mac); 1754 + extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac, 1755 + bool *pmac_id_active, u32 *pmac_id, 1756 + u8 domain); 1755 1757 extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, 1756 1758 u8 mac_count, u32 domain); 1757 1759 extern int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid,
+55 -47
drivers/net/ethernet/emulex/benet/be_main.c
··· 2601 2601 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 2602 2602 BE_IF_FLAGS_MULTICAST; 2603 2603 for_all_vfs(adapter, vf_cfg, vf) { 2604 - status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, 2605 - &vf_cfg->if_handle, NULL, vf + 1); 2604 + status = be_cmd_if_create(adapter, cap_flags, en_flags, 2605 + &vf_cfg->if_handle, vf + 1); 2606 2606 if (status) 2607 2607 goto err; 2608 2608 } ··· 2642 2642 adapter->phy.forced_port_speed = -1; 2643 2643 } 2644 2644 2645 - static int be_add_mac_from_list(struct be_adapter *adapter, u8 *mac) 2645 + static 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; 2649 - bool pmac_id_active; 2648 + int status = 0; 2650 2649 2651 - status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id_active, 2652 - &pmac_id, mac); 2653 - if (status != 0) 2654 - goto do_none; 2650 + if (!is_zero_ether_addr(adapter->netdev->perm_addr)) { 2651 + memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN); 2652 + if (!lancer_chip(adapter) && !be_physfn(adapter)) 2653 + *active_mac = true; 2654 + else 2655 + *active_mac = false; 2655 2656 2656 - if (pmac_id_active) { 2657 - status = be_cmd_mac_addr_query(adapter, mac, 2658 - MAC_ADDRESS_TYPE_NETWORK, 2659 - false, adapter->if_handle, pmac_id); 2660 - 2661 - if (!status) 2662 - adapter->pmac_id[0] = pmac_id; 2663 - } else { 2664 - status = be_cmd_pmac_add(adapter, mac, 2665 - adapter->if_handle, &adapter->pmac_id[0], 0); 2657 + return status; 2666 2658 } 2667 - do_none: 2659 + 2660 + if (lancer_chip(adapter)) { 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; 2675 + } else { 2676 + /* For BE3, for VF get soft MAC assigned by PF*/ 2677 + status = be_cmd_mac_addr_query(adapter, mac, 2678 + MAC_ADDRESS_TYPE_NETWORK, false, 2679 + if_handle, 0); 2680 + *active_mac = true; 2681 + } 2668 2682 return status; 2669 2683 } 2670 2684 ··· 2699 2685 2700 2686 static int be_setup(struct be_adapter *adapter) 2701 2687 { 2702 - struct net_device *netdev = adapter->netdev; 2703 2688 struct device *dev = &adapter->pdev->dev; 2704 2689 u32 cap_flags, en_flags; 2705 2690 u32 tx_fc, rx_fc; 2706 2691 int status; 2707 2692 u8 mac[ETH_ALEN]; 2693 + bool active_mac; 2708 2694 2709 2695 be_setup_init(adapter); 2710 2696 ··· 2730 2716 if (status) 2731 2717 goto err; 2732 2718 2733 - memset(mac, 0, ETH_ALEN); 2734 - status = be_cmd_mac_addr_query(adapter, mac, MAC_ADDRESS_TYPE_NETWORK, 2735 - true /*permanent */, 0, 0); 2736 - if (status) 2737 - return status; 2738 - memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); 2739 - memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); 2740 - 2741 2719 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 2742 2720 BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS; 2743 2721 cap_flags = en_flags | BE_IF_FLAGS_MCAST_PROMISCUOUS | ··· 2739 2733 cap_flags |= BE_IF_FLAGS_RSS; 2740 2734 en_flags |= BE_IF_FLAGS_RSS; 2741 2735 } 2736 + 2742 2737 status = be_cmd_if_create(adapter, cap_flags, en_flags, 2743 - netdev->dev_addr, &adapter->if_handle, 2744 - &adapter->pmac_id[0], 0); 2738 + &adapter->if_handle, 0); 2745 2739 if (status != 0) 2746 2740 goto err; 2747 2741 2748 - /* The VF's permanent mac queried from card is incorrect. 2749 - * For BEx: Query the mac configued by the PF using if_handle 2750 - * For Lancer: Get and use mac_list to obtain mac address. 2751 - */ 2752 - if (!be_physfn(adapter)) { 2753 - if (lancer_chip(adapter)) 2754 - status = be_add_mac_from_list(adapter, mac); 2755 - else 2756 - status = be_cmd_mac_addr_query(adapter, mac, 2757 - MAC_ADDRESS_TYPE_NETWORK, false, 2758 - adapter->if_handle, 0); 2759 - if (!status) { 2760 - memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); 2761 - memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); 2762 - } 2742 + memset(mac, 0, ETH_ALEN); 2743 + active_mac = false; 2744 + status = be_get_mac_addr(adapter, mac, adapter->if_handle, 2745 + &active_mac, &adapter->pmac_id[0]); 2746 + if (status != 0) 2747 + goto err; 2748 + 2749 + if (!active_mac) { 2750 + status = be_cmd_pmac_add(adapter, mac, adapter->if_handle, 2751 + &adapter->pmac_id[0], 0); 2752 + if (status != 0) 2753 + goto err; 2754 + } 2755 + 2756 + if (is_zero_ether_addr(adapter->netdev->dev_addr)) { 2757 + memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); 2758 + memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); 2763 2759 } 2764 2760 2765 2761 status = be_tx_qs_create(adapter);