Skip to content

Commit 1578e77

Browse files
Padmanabh Ratnakardavem330
authored andcommitted
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>
1 parent ccf7e72 commit 1578e77

3 files changed

Lines changed: 66 additions & 61 deletions

File tree

‎drivers/net/ethernet/emulex/benet/be_cmds.c‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ int be_cmd_rxq_destroy(struct be_adapter *adapter, struct be_queue_info *q)
11321132
* Uses MCCQ
11331133
*/
11341134
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)
11361136
{
11371137
struct be_mcc_wrb *wrb;
11381138
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,
11521152
req->hdr.domain = domain;
11531153
req->capability_flags = cpu_to_le32(cap_flags);
11541154
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;
11591157

11601158
status = be_mcc_notify_wait(adapter);
11611159
if (!status) {
11621160
struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
11631161
*if_handle = le32_to_cpu(resp->interface_id);
1164-
if (mac)
1165-
*pmac_id = le32_to_cpu(resp->pmac_id);
11661162
}
11671163

11681164
err:
@@ -2330,8 +2326,8 @@ int be_cmd_req_native_mode(struct be_adapter *adapter)
23302326
}
23312327

23322328
/* Uses synchronous MCCQ */
2333-
int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
2334-
bool *pmac_id_active, u32 *pmac_id, u8 *mac)
2329+
int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
2330+
bool *pmac_id_active, u32 *pmac_id, u8 domain)
23352331
{
23362332
struct be_mcc_wrb *wrb;
23372333
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,
23762372
get_mac_list_cmd.va;
23772373
mac_count = resp->true_mac_count + resp->pseudo_mac_count;
23782374
/* Mac list returned could contain one or more active mac_ids
2379-
* or one or more pseudo permanant mac addresses. If an active
2380-
* mac_id is present, return first active mac_id found
2375+
* or one or more true or pseudo permanant mac addresses.
2376+
* If an active mac_id is present, return first active mac_id
2377+
* found.
23812378
*/
23822379
for (i = 0; i < mac_count; i++) {
23832380
struct get_list_macaddr *mac_entry;
@@ -2396,7 +2393,7 @@ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
23962393
goto out;
23972394
}
23982395
}
2399-
/* If no active mac_id found, return first pseudo mac addr */
2396+
/* If no active mac_id found, return first mac addr */
24002397
*pmac_id_active = false;
24012398
memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr,
24022399
ETH_ALEN);

‎drivers/net/ethernet/emulex/benet/be_cmds.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,8 +1664,7 @@ extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
16641664
extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id,
16651665
int pmac_id, u32 domain);
16661666
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);
16691668
extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle,
16701669
u32 domain);
16711670
extern int be_cmd_eq_create(struct be_adapter *adapter,
@@ -1751,8 +1750,9 @@ extern int be_cmd_get_cntl_attributes(struct be_adapter *adapter);
17511750
extern int be_cmd_req_native_mode(struct be_adapter *adapter);
17521751
extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size);
17531752
extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf);
1754-
extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
1755-
bool *pmac_id_active, u32 *pmac_id, u8 *mac);
1753+
extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
1754+
bool *pmac_id_active, u32 *pmac_id,
1755+
u8 domain);
17561756
extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
17571757
u8 mac_count, u32 domain);
17581758
extern int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid,

‎drivers/net/ethernet/emulex/benet/be_main.c‎

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -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

26862700
static 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

Comments
 (0)