Skip to content

Commit b73d2da

Browse files
committed
Merge branch 'bnx2x-fixes'
Michal Schmidt says: ==================== bnx2x: PTP crash, VF VLAN fixes here are fixes for a crash with PTP, a crash in setting of VF multicast addresses, and non-working VLAN filters configuration from the VF side. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 239870f + e395132 commit b73d2da

File tree

4 files changed

+75
-26
lines changed

4 files changed

+75
-26
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13292,17 +13292,15 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev,
1329213292
dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
1329313293
NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_HIGHDMA;
1329413294

13295-
/* VF with OLD Hypervisor or old PF do not support filtering */
1329613295
if (IS_PF(bp)) {
1329713296
if (chip_is_e1x)
1329813297
bp->accept_any_vlan = true;
1329913298
else
1330013299
dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
13301-
#ifdef CONFIG_BNX2X_SRIOV
13302-
} else if (bp->acquire_resp.pfdev_info.pf_cap & PFVF_CAP_VLAN_FILTER) {
13303-
dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
13304-
#endif
1330513300
}
13301+
/* For VF we'll know whether to enable VLAN filtering after
13302+
* getting a response to CHANNEL_TLV_ACQUIRE from PF.
13303+
*/
1330613304

1330713305
dev->features |= dev->hw_features | NETIF_F_HW_VLAN_CTAG_RX;
1330813306
dev->features |= NETIF_F_HIGHDMA;
@@ -13738,7 +13736,7 @@ static int bnx2x_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
1373813736
if (!netif_running(bp->dev)) {
1373913737
DP(BNX2X_MSG_PTP,
1374013738
"PTP adjfreq called while the interface is down\n");
13741-
return -EFAULT;
13739+
return -ENETDOWN;
1374213740
}
1374313741

1374413742
if (ppb < 0) {
@@ -13797,6 +13795,12 @@ static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
1379713795
{
1379813796
struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
1379913797

13798+
if (!netif_running(bp->dev)) {
13799+
DP(BNX2X_MSG_PTP,
13800+
"PTP adjtime called while the interface is down\n");
13801+
return -ENETDOWN;
13802+
}
13803+
1380013804
DP(BNX2X_MSG_PTP, "PTP adjtime called, delta = %llx\n", delta);
1380113805

1380213806
timecounter_adjtime(&bp->timecounter, delta);
@@ -13809,6 +13813,12 @@ static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
1380913813
struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
1381013814
u64 ns;
1381113815

13816+
if (!netif_running(bp->dev)) {
13817+
DP(BNX2X_MSG_PTP,
13818+
"PTP gettime called while the interface is down\n");
13819+
return -ENETDOWN;
13820+
}
13821+
1381213822
ns = timecounter_read(&bp->timecounter);
1381313823

1381413824
DP(BNX2X_MSG_PTP, "PTP gettime called, ns = %llu\n", ns);
@@ -13824,6 +13834,12 @@ static int bnx2x_ptp_settime(struct ptp_clock_info *ptp,
1382413834
struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
1382513835
u64 ns;
1382613836

13837+
if (!netif_running(bp->dev)) {
13838+
DP(BNX2X_MSG_PTP,
13839+
"PTP settime called while the interface is down\n");
13840+
return -ENETDOWN;
13841+
}
13842+
1382713843
ns = timespec64_to_ns(ts);
1382813844

1382913845
DP(BNX2X_MSG_PTP, "PTP settime called, ns = %llu\n", ns);
@@ -13991,6 +14007,14 @@ static int bnx2x_init_one(struct pci_dev *pdev,
1399114007
rc = bnx2x_vfpf_acquire(bp, tx_count, rx_count);
1399214008
if (rc)
1399314009
goto init_one_freemem;
14010+
14011+
#ifdef CONFIG_BNX2X_SRIOV
14012+
/* VF with OLD Hypervisor or old PF do not support filtering */
14013+
if (bp->acquire_resp.pfdev_info.pf_cap & PFVF_CAP_VLAN_FILTER) {
14014+
dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
14015+
dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
14016+
}
14017+
#endif
1399414018
}
1399514019

1399614020
/* Enable SRIOV if capability found in configuration space */

drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@ static int bnx2x_vf_mac_vlan_config(struct bnx2x *bp,
434434

435435
/* Add/Remove the filter */
436436
rc = bnx2x_config_vlan_mac(bp, &ramrod);
437-
if (rc && rc != -EEXIST) {
437+
if (rc == -EEXIST)
438+
return 0;
439+
if (rc) {
438440
BNX2X_ERR("Failed to %s %s\n",
439441
filter->add ? "add" : "delete",
440442
(filter->type == BNX2X_VF_FILTER_VLAN_MAC) ?
@@ -444,6 +446,8 @@ static int bnx2x_vf_mac_vlan_config(struct bnx2x *bp,
444446
return rc;
445447
}
446448

449+
filter->applied = true;
450+
447451
return 0;
448452
}
449453

@@ -469,8 +473,10 @@ int bnx2x_vf_mac_vlan_config_list(struct bnx2x *bp, struct bnx2x_virtf *vf,
469473
/* Rollback if needed */
470474
if (i != filters->count) {
471475
BNX2X_ERR("Managed only %d/%d filters - rolling back\n",
472-
i, filters->count + 1);
476+
i, filters->count);
473477
while (--i >= 0) {
478+
if (!filters->filters[i].applied)
479+
continue;
474480
filters->filters[i].add = !filters->filters[i].add;
475481
bnx2x_vf_mac_vlan_config(bp, vf, qid,
476482
&filters->filters[i],
@@ -1899,7 +1905,8 @@ void bnx2x_iov_adjust_stats_req(struct bnx2x *bp)
18991905
continue;
19001906
}
19011907

1902-
DP(BNX2X_MSG_IOV, "add addresses for vf %d\n", vf->abs_vfid);
1908+
DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS),
1909+
"add addresses for vf %d\n", vf->abs_vfid);
19031910
for_each_vfq(vf, j) {
19041911
struct bnx2x_vf_queue *rxq = vfq_get(vf, j);
19051912

@@ -1920,11 +1927,12 @@ void bnx2x_iov_adjust_stats_req(struct bnx2x *bp)
19201927
cpu_to_le32(U64_HI(q_stats_addr));
19211928
cur_query_entry->address.lo =
19221929
cpu_to_le32(U64_LO(q_stats_addr));
1923-
DP(BNX2X_MSG_IOV,
1924-
"added address %x %x for vf %d queue %d client %d\n",
1925-
cur_query_entry->address.hi,
1926-
cur_query_entry->address.lo, cur_query_entry->funcID,
1927-
j, cur_query_entry->index);
1930+
DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS),
1931+
"added address %x %x for vf %d queue %d client %d\n",
1932+
cur_query_entry->address.hi,
1933+
cur_query_entry->address.lo,
1934+
cur_query_entry->funcID,
1935+
j, cur_query_entry->index);
19281936
cur_query_entry++;
19291937
cur_data_offset += sizeof(struct per_queue_stats);
19301938
stats_count++;

drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct bnx2x_vf_mac_vlan_filter {
114114
(BNX2X_VF_FILTER_MAC | BNX2X_VF_FILTER_VLAN) /*shortcut*/
115115

116116
bool add;
117+
bool applied;
117118
u8 *mac;
118119
u16 vid;
119120
};

drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
868868
struct bnx2x *bp = netdev_priv(dev);
869869
struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
870870
struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
871-
int rc, i = 0;
871+
int rc = 0, i = 0;
872872
struct netdev_hw_addr *ha;
873873

874874
if (bp->state != BNX2X_STATE_OPEN) {
@@ -883,23 +883,22 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
883883
/* Get Rx mode requested */
884884
DP(NETIF_MSG_IFUP, "dev->flags = %x\n", dev->flags);
885885

886+
/* We support PFVF_MAX_MULTICAST_PER_VF mcast addresses tops */
887+
if (netdev_mc_count(dev) > PFVF_MAX_MULTICAST_PER_VF) {
888+
DP(NETIF_MSG_IFUP,
889+
"VF supports not more than %d multicast MAC addresses\n",
890+
PFVF_MAX_MULTICAST_PER_VF);
891+
rc = -EINVAL;
892+
goto out;
893+
}
894+
886895
netdev_for_each_mc_addr(ha, dev) {
887896
DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
888897
bnx2x_mc_addr(ha));
889898
memcpy(req->multicast[i], bnx2x_mc_addr(ha), ETH_ALEN);
890899
i++;
891900
}
892901

893-
/* We support four PFVF_MAX_MULTICAST_PER_VF mcast
894-
* addresses tops
895-
*/
896-
if (i >= PFVF_MAX_MULTICAST_PER_VF) {
897-
DP(NETIF_MSG_IFUP,
898-
"VF supports not more than %d multicast MAC addresses\n",
899-
PFVF_MAX_MULTICAST_PER_VF);
900-
return -EINVAL;
901-
}
902-
903902
req->n_multicast = i;
904903
req->flags |= VFPF_SET_Q_FILTERS_MULTICAST_CHANGED;
905904
req->vf_qid = 0;
@@ -924,7 +923,7 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)
924923
out:
925924
bnx2x_vfpf_finalize(bp, &req->first_tlv);
926925

927-
return 0;
926+
return rc;
928927
}
929928

930929
/* request pf to add a vlan for the vf */
@@ -1778,6 +1777,23 @@ static int bnx2x_vf_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
17781777
goto op_err;
17791778
}
17801779

1780+
/* build vlan list */
1781+
fl = NULL;
1782+
1783+
rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl,
1784+
VFPF_VLAN_FILTER);
1785+
if (rc)
1786+
goto op_err;
1787+
1788+
if (fl) {
1789+
/* set vlan list */
1790+
rc = bnx2x_vf_mac_vlan_config_list(bp, vf, fl,
1791+
msg->vf_qid,
1792+
false);
1793+
if (rc)
1794+
goto op_err;
1795+
}
1796+
17811797
}
17821798

17831799
if (msg->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED) {

0 commit comments

Comments
 (0)