Skip to content

Commit edaf382

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix 64-bit division in mlx5 IPSEC offload support, from Ilan Tayari and Arnd Bergmann. 2) Fix race in statistics gathering in bnxt_en driver, from Michael Chan. 3) Can't use a mutex in RCU reader protected section on tap driver, from Cong WANG. 4) Fix mdb leak in bridging code, from Eduardo Valentin. 5) Fix free of wrong pointer variable in nfp driver, from Dan Carpenter. 6) Buffer overflow in brcmfmac driver, from Arend van SPriel. 7) ioremap_nocache() return value needs to be checked in smsc911x driver, from Alexey Khoroshilov. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (34 commits) net: stmmac: revert "support future possible different internal phy mode" sfc: don't read beyond unicast address list datagram: fix kernel-doc comments socket: add documentation for missing elements smsc911x: Add check for ioremap_nocache() return code brcmfmac: fix possible buffer overflow in brcmf_cfg80211_mgmt_tx() net: hns: Bugfix for Tx timeout handling in hns driver net: ipmr: ipmr_get_table() returns NULL nfp: freeing the wrong variable mlxsw: spectrum_switchdev: Check status of memory allocation mlxsw: spectrum_switchdev: Remove unused variable mlxsw: spectrum_router: Fix use-after-free in route replace mlxsw: spectrum_router: Add missing rollback samples/bpf: fix a build issue bridge: mdb: fix leak on complete_info ptr on fail path tap: convert a mutex to a spinlock cxgb4: fix BUG() on interrupt deallocating path of ULD qed: Fix printk option passed when printing ipv6 addresses net: Fix minor code bug in timestamping.txt net: stmmac: Make 'alloc_dma_[rt]x_desc_resources()' look even closer ...
2 parents bd664f6 + d93b07f commit edaf382

File tree

38 files changed

+172
-101
lines changed

38 files changed

+172
-101
lines changed

Documentation/networking/timestamping.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ timeval of SO_TIMESTAMP (ms).
4444
Supports multiple types of timestamp requests. As a result, this
4545
socket option takes a bitmap of flags, not a boolean. In
4646

47-
err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, (void *) val,
48-
sizeof(val));
47+
err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, &val, sizeof(val));
4948

5049
val is an integer with any of the following bits set. Setting other
5150
bit returns EINVAL and does not change the current state.
@@ -249,8 +248,7 @@ setsockopt to receive timestamps:
249248

250249
__u32 val = SOF_TIMESTAMPING_SOFTWARE |
251250
SOF_TIMESTAMPING_OPT_ID /* or any other flag */;
252-
err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, (void *) val,
253-
sizeof(val));
251+
err = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, &val, sizeof(val));
254252

255253

256254
1.4 Bytestream Timestamps

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,13 +3458,18 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)
34583458
req.ver_upd = DRV_VER_UPD;
34593459

34603460
if (BNXT_PF(bp)) {
3461-
DECLARE_BITMAP(vf_req_snif_bmap, 256);
3462-
u32 *data = (u32 *)vf_req_snif_bmap;
3461+
u32 data[8];
34633462
int i;
34643463

3465-
memset(vf_req_snif_bmap, 0, sizeof(vf_req_snif_bmap));
3466-
for (i = 0; i < ARRAY_SIZE(bnxt_vf_req_snif); i++)
3467-
__set_bit(bnxt_vf_req_snif[i], vf_req_snif_bmap);
3464+
memset(data, 0, sizeof(data));
3465+
for (i = 0; i < ARRAY_SIZE(bnxt_vf_req_snif); i++) {
3466+
u16 cmd = bnxt_vf_req_snif[i];
3467+
unsigned int bit, idx;
3468+
3469+
idx = cmd / 32;
3470+
bit = cmd % 32;
3471+
data[idx] |= 1 << bit;
3472+
}
34683473

34693474
for (i = 0; i < 8; i++)
34703475
req.vf_req_fwd[i] = cpu_to_le32(data[i]);
@@ -6279,6 +6284,12 @@ static int bnxt_open(struct net_device *dev)
62796284
return __bnxt_open_nic(bp, true, true);
62806285
}
62816286

6287+
static bool bnxt_drv_busy(struct bnxt *bp)
6288+
{
6289+
return (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state) ||
6290+
test_bit(BNXT_STATE_READ_STATS, &bp->state));
6291+
}
6292+
62826293
int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
62836294
{
62846295
int rc = 0;
@@ -6297,7 +6308,7 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
62976308

62986309
clear_bit(BNXT_STATE_OPEN, &bp->state);
62996310
smp_mb__after_atomic();
6300-
while (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state))
6311+
while (bnxt_drv_busy(bp))
63016312
msleep(20);
63026313

63036314
/* Flush rings and and disable interrupts */
@@ -6358,8 +6369,15 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
63586369
u32 i;
63596370
struct bnxt *bp = netdev_priv(dev);
63606371

6361-
if (!bp->bnapi)
6372+
set_bit(BNXT_STATE_READ_STATS, &bp->state);
6373+
/* Make sure bnxt_close_nic() sees that we are reading stats before
6374+
* we check the BNXT_STATE_OPEN flag.
6375+
*/
6376+
smp_mb__after_atomic();
6377+
if (!test_bit(BNXT_STATE_OPEN, &bp->state)) {
6378+
clear_bit(BNXT_STATE_READ_STATS, &bp->state);
63626379
return;
6380+
}
63636381

63646382
/* TODO check if we need to synchronize with bnxt_close path */
63656383
for (i = 0; i < bp->cp_nr_rings; i++) {
@@ -6406,6 +6424,7 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
64066424
stats->tx_fifo_errors = le64_to_cpu(tx->tx_fifo_underruns);
64076425
stats->tx_errors = le64_to_cpu(tx->tx_err);
64086426
}
6427+
clear_bit(BNXT_STATE_READ_STATS, &bp->state);
64096428
}
64106429

64116430
static bool bnxt_mc_list_updated(struct bnxt *bp, u32 *rx_mask)
@@ -6904,16 +6923,13 @@ static void bnxt_sp_task(struct work_struct *work)
69046923
}
69056924

69066925
/* Under rtnl_lock */
6907-
int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, int tcs, int tx_xdp)
6926+
int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
6927+
int tx_xdp)
69086928
{
69096929
int max_rx, max_tx, tx_sets = 1;
69106930
int tx_rings_needed;
6911-
bool sh = true;
69126931
int rc;
69136932

6914-
if (!(bp->flags & BNXT_FLAG_SHARED_RINGS))
6915-
sh = false;
6916-
69176933
if (tcs)
69186934
tx_sets = tcs;
69196935

@@ -7121,7 +7137,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
71217137
sh = true;
71227138

71237139
rc = bnxt_reserve_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings,
7124-
tc, bp->tx_nr_rings_xdp);
7140+
sh, tc, bp->tx_nr_rings_xdp);
71257141
if (rc)
71267142
return rc;
71277143

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,7 @@ struct bnxt {
11171117
unsigned long state;
11181118
#define BNXT_STATE_OPEN 0
11191119
#define BNXT_STATE_IN_SP_TASK 1
1120+
#define BNXT_STATE_READ_STATS 2
11201121

11211122
struct bnxt_irq *irq_tbl;
11221123
int total_irqs;
@@ -1300,7 +1301,8 @@ int bnxt_open_nic(struct bnxt *, bool, bool);
13001301
int bnxt_half_open_nic(struct bnxt *bp);
13011302
void bnxt_half_close_nic(struct bnxt *bp);
13021303
int bnxt_close_nic(struct bnxt *, bool, bool);
1303-
int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, int tcs, int tx_xdp);
1304+
int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
1305+
int tx_xdp);
13041306
int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
13051307
int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
13061308
void bnxt_restore_pf_fw_resources(struct bnxt *bp);

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ static int bnxt_set_channels(struct net_device *dev,
432432
}
433433
tx_xdp = req_rx_rings;
434434
}
435-
rc = bnxt_reserve_rings(bp, req_tx_rings, req_rx_rings, tcs, tx_xdp);
435+
rc = bnxt_reserve_rings(bp, req_tx_rings, req_rx_rings, sh, tcs,
436+
tx_xdp);
436437
if (rc) {
437438
netdev_warn(dev, "Unable to allocate the requested rings\n");
438439
return rc;

drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
170170
if (!tc)
171171
tc = 1;
172172
rc = bnxt_reserve_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings,
173-
tc, tx_xdp);
173+
true, tc, tx_xdp);
174174
if (rc) {
175175
netdev_warn(dev, "Unable to reserve enough TX rings to support XDP.\n");
176176
return rc;

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,12 +2083,12 @@ static void detach_ulds(struct adapter *adap)
20832083

20842084
mutex_lock(&uld_mutex);
20852085
list_del(&adap->list_node);
2086+
20862087
for (i = 0; i < CXGB4_ULD_MAX; i++)
2087-
if (adap->uld && adap->uld[i].handle) {
2088+
if (adap->uld && adap->uld[i].handle)
20882089
adap->uld[i].state_change(adap->uld[i].handle,
20892090
CXGB4_STATE_DETACH);
2090-
adap->uld[i].handle = NULL;
2091-
}
2091+
20922092
if (netevent_registered && list_empty(&adapter_list)) {
20932093
unregister_netevent_notifier(&cxgb4_netevent_nb);
20942094
netevent_registered = false;
@@ -5303,8 +5303,10 @@ static void remove_one(struct pci_dev *pdev)
53035303
*/
53045304
destroy_workqueue(adapter->workq);
53055305

5306-
if (is_uld(adapter))
5306+
if (is_uld(adapter)) {
53075307
detach_ulds(adapter);
5308+
t4_uld_clean_up(adapter);
5309+
}
53085310

53095311
disable_interrupts(adapter);
53105312

@@ -5385,7 +5387,11 @@ static void shutdown_one(struct pci_dev *pdev)
53855387
if (adapter->port[i]->reg_state == NETREG_REGISTERED)
53865388
cxgb_close(adapter->port[i]);
53875389

5388-
t4_uld_clean_up(adapter);
5390+
if (is_uld(adapter)) {
5391+
detach_ulds(adapter);
5392+
t4_uld_clean_up(adapter);
5393+
}
5394+
53895395
disable_interrupts(adapter);
53905396
disable_msi(adapter);
53915397

drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -589,22 +589,37 @@ void t4_uld_mem_free(struct adapter *adap)
589589
kfree(adap->uld);
590590
}
591591

592+
/* This function should be called with uld_mutex taken. */
593+
static void cxgb4_shutdown_uld_adapter(struct adapter *adap, enum cxgb4_uld type)
594+
{
595+
if (adap->uld[type].handle) {
596+
adap->uld[type].handle = NULL;
597+
adap->uld[type].add = NULL;
598+
release_sge_txq_uld(adap, type);
599+
600+
if (adap->flags & FULL_INIT_DONE)
601+
quiesce_rx_uld(adap, type);
602+
603+
if (adap->flags & USING_MSIX)
604+
free_msix_queue_irqs_uld(adap, type);
605+
606+
free_sge_queues_uld(adap, type);
607+
free_queues_uld(adap, type);
608+
}
609+
}
610+
592611
void t4_uld_clean_up(struct adapter *adap)
593612
{
594613
unsigned int i;
595614

596-
if (!adap->uld)
597-
return;
615+
mutex_lock(&uld_mutex);
598616
for (i = 0; i < CXGB4_ULD_MAX; i++) {
599617
if (!adap->uld[i].handle)
600618
continue;
601-
if (adap->flags & FULL_INIT_DONE)
602-
quiesce_rx_uld(adap, i);
603-
if (adap->flags & USING_MSIX)
604-
free_msix_queue_irqs_uld(adap, i);
605-
free_sge_queues_uld(adap, i);
606-
free_queues_uld(adap, i);
619+
620+
cxgb4_shutdown_uld_adapter(adap, i);
607621
}
622+
mutex_unlock(&uld_mutex);
608623
}
609624

610625
static void uld_init(struct adapter *adap, struct cxgb4_lld_info *lld)
@@ -783,15 +798,8 @@ int cxgb4_unregister_uld(enum cxgb4_uld type)
783798
continue;
784799
if (type == CXGB4_ULD_ISCSIT && is_t4(adap->params.chip))
785800
continue;
786-
adap->uld[type].handle = NULL;
787-
adap->uld[type].add = NULL;
788-
release_sge_txq_uld(adap, type);
789-
if (adap->flags & FULL_INIT_DONE)
790-
quiesce_rx_uld(adap, type);
791-
if (adap->flags & USING_MSIX)
792-
free_msix_queue_irqs_uld(adap, type);
793-
free_sge_queues_uld(adap, type);
794-
free_queues_uld(adap, type);
801+
802+
cxgb4_shutdown_uld_adapter(adap, type);
795803
}
796804
mutex_unlock(&uld_mutex);
797805

drivers/net/ethernet/cisco/enic/vnic_dev.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
402402
fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index);
403403
if (fetch_index == 0xFFFFFFFF) { /* check for hardware gone */
404404
vdev_err(vdev, "Fatal error in devcmd2 init - hardware surprise removal\n");
405-
406-
return -ENODEV;
405+
err = -ENODEV;
406+
goto err_free_wq;
407407
}
408408

409409
enic_wq_init_start(&vdev->devcmd2->wq, 0, fetch_index, fetch_index, 0,
@@ -414,7 +414,7 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
414414
err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring,
415415
DEVCMD2_RING_SIZE, DEVCMD2_DESC_SIZE);
416416
if (err)
417-
goto err_free_wq;
417+
goto err_disable_wq;
418418

419419
vdev->devcmd2->result = vdev->devcmd2->results_ring.descs;
420420
vdev->devcmd2->cmd_ring = vdev->devcmd2->wq.ring.descs;
@@ -433,8 +433,9 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
433433

434434
err_free_desc_ring:
435435
vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring);
436-
err_free_wq:
436+
err_disable_wq:
437437
vnic_wq_disable(&vdev->devcmd2->wq);
438+
err_free_wq:
438439
vnic_wq_free(&vdev->devcmd2->wq);
439440
err_free_devcmd2:
440441
kfree(vdev->devcmd2);

drivers/net/ethernet/hisilicon/hns/hns_enet.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,13 +1378,20 @@ void hns_nic_net_reset(struct net_device *ndev)
13781378
void hns_nic_net_reinit(struct net_device *netdev)
13791379
{
13801380
struct hns_nic_priv *priv = netdev_priv(netdev);
1381+
enum hnae_port_type type = priv->ae_handle->port_type;
13811382

13821383
netif_trans_update(priv->netdev);
13831384
while (test_and_set_bit(NIC_STATE_REINITING, &priv->state))
13841385
usleep_range(1000, 2000);
13851386

13861387
hns_nic_net_down(netdev);
1387-
hns_nic_net_reset(netdev);
1388+
1389+
/* Only do hns_nic_net_reset in debug mode
1390+
* because of hardware limitation.
1391+
*/
1392+
if (type == HNAE_PORT_DEBUG)
1393+
hns_nic_net_reset(netdev);
1394+
13881395
(void)hns_nic_net_up(netdev);
13891396
clear_bit(NIC_STATE_REINITING, &priv->state);
13901397
}
@@ -1997,13 +2004,8 @@ static void hns_nic_reset_subtask(struct hns_nic_priv *priv)
19972004
rtnl_lock();
19982005
/* put off any impending NetWatchDogTimeout */
19992006
netif_trans_update(priv->netdev);
2007+
hns_nic_net_reinit(priv->netdev);
20002008

2001-
if (type == HNAE_PORT_DEBUG) {
2002-
hns_nic_net_reinit(priv->netdev);
2003-
} else {
2004-
netif_carrier_off(priv->netdev);
2005-
netif_tx_disable(priv->netdev);
2006-
}
20072009
rtnl_unlock();
20082010
}
20092011

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ subdir-ccflags-y += -I$(src)
44
mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
55
health.o mcg.o cq.o srq.o alloc.o qp.o port.o mr.o pd.o \
66
mad.o transobj.o vport.o sriov.o fs_cmd.o fs_core.o \
7-
fs_counters.o rl.o lag.o dev.o lib/gid.o
7+
fs_counters.o rl.o lag.o dev.o wq.o lib/gid.o
88

99
mlx5_core-$(CONFIG_MLX5_ACCEL) += accel/ipsec.o
1010

1111
mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
1212
fpga/ipsec.o
1313

14-
mlx5_core-$(CONFIG_MLX5_CORE_EN) += wq.o eswitch.o eswitch_offloads.o \
14+
mlx5_core-$(CONFIG_MLX5_CORE_EN) += eswitch.o eswitch_offloads.o \
1515
en_main.o en_common.o en_fs.o en_ethtool.o en_tx.o \
1616
en_rx.o en_rx_am.o en_txrx.o en_clock.o vxlan.o \
1717
en_tc.o en_arfs.o en_rep.o en_fs_ethtool.o en_selftest.o
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subdir-ccflags-y += -I$(src)/..
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subdir-ccflags-y += -I$(src)/..

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void mlx5e_ipsec_build_inverse_table(void)
372372
*/
373373
mlx5e_ipsec_inverse_table[1] = htons(0xFFFF);
374374
for (mss = 2; mss < MAX_LSO_MSS; mss++) {
375-
mss_inv = ((1ULL << 32) / mss) >> 16;
375+
mss_inv = div_u64(1ULL << 32, mss) >> 16;
376376
mlx5e_ipsec_inverse_table[mss] = htons(mss_inv);
377377
}
378378
}

drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ static void mlx5e_dcbnl_getpermhwaddr(struct net_device *netdev,
464464
if (!perm_addr)
465465
return;
466466

467+
memset(perm_addr, 0xff, MAX_ADDR_LEN);
468+
467469
mlx5_query_nic_vport_mac_address(priv->mdev, 0, perm_addr);
468470
}
469471

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subdir-ccflags-y += -I$(src)/..

drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int mlx5_fpga_device_load_check(struct mlx5_fpga_device *fdev)
102102
return 0;
103103
}
104104

105-
int mlx5_fpga_device_brb(struct mlx5_fpga_device *fdev)
105+
static int mlx5_fpga_device_brb(struct mlx5_fpga_device *fdev)
106106
{
107107
int err;
108108
struct mlx5_core_dev *mdev = fdev->mdev;

drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ int mlx5_fpga_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters,
275275
{
276276
struct mlx5_fpga_device *fdev = mdev->fpga;
277277
unsigned int i;
278-
u32 *data;
278+
__be32 *data;
279279
u32 count;
280280
u64 addr;
281281
int ret;
@@ -290,7 +290,7 @@ int mlx5_fpga_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters,
290290

291291
count = mlx5_fpga_ipsec_counters_count(mdev);
292292

293-
data = kzalloc(sizeof(u32) * count * 2, GFP_KERNEL);
293+
data = kzalloc(sizeof(*data) * count * 2, GFP_KERNEL);
294294
if (!data) {
295295
ret = -ENOMEM;
296296
goto out;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subdir-ccflags-y += -I$(src)/..

0 commit comments

Comments
 (0)