@@ -2601,8 +2601,8 @@ static int be_vf_setup(struct be_adapter *adapter)
26012601 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
26022602 BE_IF_FLAGS_MULTICAST ;
26032603 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 );
26062606 if (status )
26072607 goto err ;
26082608 }
@@ -2642,29 +2642,43 @@ static void be_setup_init(struct be_adapter *adapter)
26422642 adapter -> phy .forced_port_speed = -1 ;
26432643}
26442644
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 )
26462647{
2647- u32 pmac_id ;
2648- int status ;
2649- bool pmac_id_active ;
2648+ int status = 0 ;
26502649
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;
26552656
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 );
2657+ return status ;
2658+ }
26602659
2661- if (!status )
2662- adapter -> pmac_id [0 ] = pmac_id ;
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;
26632675 } else {
2664- status = be_cmd_pmac_add (adapter , mac ,
2665- adapter -> if_handle , & adapter -> pmac_id [0 ], 0 );
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;
26662681 }
2667- do_none :
26682682 return status ;
26692683}
26702684
@@ -2685,12 +2699,12 @@ static int be_get_config(struct be_adapter *adapter)
26852699
26862700static int be_setup (struct be_adapter * adapter )
26872701{
2688- struct net_device * netdev = adapter -> netdev ;
26892702 struct device * dev = & adapter -> pdev -> dev ;
26902703 u32 cap_flags , en_flags ;
26912704 u32 tx_fc , rx_fc ;
26922705 int status ;
26932706 u8 mac [ETH_ALEN ];
2707+ bool active_mac ;
26942708
26952709 be_setup_init (adapter );
26962710
@@ -2716,14 +2730,6 @@ static int be_setup(struct be_adapter *adapter)
27162730 if (status )
27172731 goto err ;
27182732
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-
27272733 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
27282734 BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS ;
27292735 cap_flags = en_flags | BE_IF_FLAGS_MCAST_PROMISCUOUS |
@@ -2733,27 +2739,29 @@ static int be_setup(struct be_adapter *adapter)
27332739 cap_flags |= BE_IF_FLAGS_RSS ;
27342740 en_flags |= BE_IF_FLAGS_RSS ;
27352741 }
2742+
27362743 status = be_cmd_if_create (adapter , cap_flags , en_flags ,
2737- netdev -> dev_addr , & adapter -> if_handle ,
2738- & adapter -> pmac_id [0 ], 0 );
2744+ & adapter -> if_handle , 0 );
27392745 if (status != 0 )
27402746 goto err ;
27412747
2742- /* The VF's permanent mac queried from card is incorrect.
2743- * For BEx: Query the mac configued by the PF using if_handle
2744- * For Lancer: Get and use mac_list to obtain mac address.
2745- */
2746- if (!be_physfn (adapter )) {
2747- if (lancer_chip (adapter ))
2748- status = be_add_mac_from_list (adapter , mac );
2749- else
2750- status = be_cmd_mac_addr_query (adapter , mac ,
2751- MAC_ADDRESS_TYPE_NETWORK , false,
2752- adapter -> if_handle , 0 );
2753- if (!status ) {
2754- memcpy (adapter -> netdev -> dev_addr , mac , ETH_ALEN );
2755- memcpy (adapter -> netdev -> perm_addr , mac , ETH_ALEN );
2756- }
2748+ memset (mac , 0 , ETH_ALEN );
2749+ active_mac = false;
2750+ status = be_get_mac_addr (adapter , mac , adapter -> if_handle ,
2751+ & active_mac , & adapter -> pmac_id [0 ]);
2752+ if (status != 0 )
2753+ goto err ;
2754+
2755+ if (!active_mac ) {
2756+ status = be_cmd_pmac_add (adapter , mac , adapter -> if_handle ,
2757+ & adapter -> pmac_id [0 ], 0 );
2758+ if (status != 0 )
2759+ goto err ;
2760+ }
2761+
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 );
27572765 }
27582766
27592767 status = be_tx_qs_create (adapter );
0 commit comments