Skip to content

Commit deec4f7

Browse files
author
Paolo Abeni
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== For ice: Michal corrects call to alloc_etherdev_mqs() to provide maximum number of queues supported rather than currently allocated number of queues. Petr Oros fixes issues related to some ethtool operations in switchdev mode. For iavf: Kohei Enju corrects number of reported queues for ethtool statistics to absolute max as using current number could race and cause out-of-bounds issues. For idpf: Josh NULLs cdev_info pointer after freeing to prevent possible subsequent improper access. He also defers setting of refillqs value until after allocation to prevent possible NULL pointer dereference. * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: idpf: only assign num refillqs if allocation was successful idpf: clear stale cdev_info ptr iavf: fix out-of-bounds writes in iavf_get_ethtool_stats() ice: use ice_update_eth_stats() for representor stats ice: fix inverted ready check for VF representors ice: set max queues in alloc_etherdev_mqs() ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 72d96e4 + b5e5797 commit deec4f7

9 files changed

Lines changed: 60 additions & 46 deletions

File tree

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,13 @@ static int iavf_get_sset_count(struct net_device *netdev, int sset)
313313
{
314314
/* Report the maximum number queues, even if not every queue is
315315
* currently configured. Since allocation of queues is in pairs,
316-
* use netdev->real_num_tx_queues * 2. The real_num_tx_queues is set
317-
* at device creation and never changes.
316+
* use netdev->num_tx_queues * 2. The num_tx_queues is set at
317+
* device creation and never changes.
318318
*/
319319

320320
if (sset == ETH_SS_STATS)
321321
return IAVF_STATS_LEN +
322-
(IAVF_QUEUE_STATS_LEN * 2 *
323-
netdev->real_num_tx_queues);
322+
(IAVF_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues);
324323
else
325324
return -EINVAL;
326325
}
@@ -345,19 +344,19 @@ static void iavf_get_ethtool_stats(struct net_device *netdev,
345344
iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats);
346345

347346
rcu_read_lock();
348-
/* As num_active_queues describe both tx and rx queues, we can use
349-
* it to iterate over rings' stats.
347+
/* Use num_tx_queues to report stats for the maximum number of queues.
348+
* Queues beyond num_active_queues will report zero.
350349
*/
351-
for (i = 0; i < adapter->num_active_queues; i++) {
352-
struct iavf_ring *ring;
350+
for (i = 0; i < netdev->num_tx_queues; i++) {
351+
struct iavf_ring *tx_ring = NULL, *rx_ring = NULL;
353352

354-
/* Tx rings stats */
355-
ring = &adapter->tx_rings[i];
356-
iavf_add_queue_stats(&data, ring);
353+
if (i < adapter->num_active_queues) {
354+
tx_ring = &adapter->tx_rings[i];
355+
rx_ring = &adapter->rx_rings[i];
356+
}
357357

358-
/* Rx rings stats */
359-
ring = &adapter->rx_rings[i];
360-
iavf_add_queue_stats(&data, ring);
358+
iavf_add_queue_stats(&data, tx_ring);
359+
iavf_add_queue_stats(&data, rx_ring);
361360
}
362361
rcu_read_unlock();
363362
}
@@ -376,9 +375,9 @@ static void iavf_get_stat_strings(struct net_device *netdev, u8 *data)
376375
iavf_add_stat_strings(&data, iavf_gstrings_stats);
377376

378377
/* Queues are always allocated in pairs, so we just use
379-
* real_num_tx_queues for both Tx and Rx queues.
378+
* num_tx_queues for both Tx and Rx queues.
380379
*/
381-
for (i = 0; i < netdev->real_num_tx_queues; i++) {
380+
for (i = 0; i < netdev->num_tx_queues; i++) {
382381
iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
383382
"tx", i);
384383
iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,28 @@ static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid)
839839
WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
840840
}
841841

842+
/**
843+
* ice_get_max_txq - return the maximum number of Tx queues for in a PF
844+
* @pf: PF structure
845+
*
846+
* Return: maximum number of Tx queues
847+
*/
848+
static inline int ice_get_max_txq(struct ice_pf *pf)
849+
{
850+
return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_txq);
851+
}
852+
853+
/**
854+
* ice_get_max_rxq - return the maximum number of Rx queues for in a PF
855+
* @pf: PF structure
856+
*
857+
* Return: maximum number of Rx queues
858+
*/
859+
static inline int ice_get_max_rxq(struct ice_pf *pf)
860+
{
861+
return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_rxq);
862+
}
863+
842864
/**
843865
* ice_get_main_vsi - Get the PF VSI
844866
* @pf: PF instance

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,17 @@ __ice_get_ethtool_stats(struct net_device *netdev,
19301930
int i = 0;
19311931
char *p;
19321932

1933+
if (ice_is_port_repr_netdev(netdev)) {
1934+
ice_update_eth_stats(vsi);
1935+
1936+
for (j = 0; j < ICE_VSI_STATS_LEN; j++) {
1937+
p = (char *)vsi + ice_gstrings_vsi_stats[j].stat_offset;
1938+
data[i++] = (ice_gstrings_vsi_stats[j].sizeof_stat ==
1939+
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1940+
}
1941+
return;
1942+
}
1943+
19331944
ice_update_pf_stats(pf);
19341945
ice_update_vsi_stats(vsi);
19351946

@@ -1939,9 +1950,6 @@ __ice_get_ethtool_stats(struct net_device *netdev,
19391950
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
19401951
}
19411952

1942-
if (ice_is_port_repr_netdev(netdev))
1943-
return;
1944-
19451953
/* populate per queue stats */
19461954
rcu_read_lock();
19471955

@@ -3773,24 +3781,6 @@ ice_get_ts_info(struct net_device *dev, struct kernel_ethtool_ts_info *info)
37733781
return 0;
37743782
}
37753783

3776-
/**
3777-
* ice_get_max_txq - return the maximum number of Tx queues for in a PF
3778-
* @pf: PF structure
3779-
*/
3780-
static int ice_get_max_txq(struct ice_pf *pf)
3781-
{
3782-
return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_txq);
3783-
}
3784-
3785-
/**
3786-
* ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3787-
* @pf: PF structure
3788-
*/
3789-
static int ice_get_max_rxq(struct ice_pf *pf)
3790-
{
3791-
return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_rxq);
3792-
}
3793-
37943784
/**
37953785
* ice_get_combined_cnt - return the current number of combined channels
37963786
* @vsi: PF VSI pointer

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4699,8 +4699,8 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)
46994699
struct net_device *netdev;
47004700
u8 mac_addr[ETH_ALEN];
47014701

4702-
netdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq,
4703-
vsi->alloc_rxq);
4702+
netdev = alloc_etherdev_mqs(sizeof(*np), ice_get_max_txq(vsi->back),
4703+
ice_get_max_rxq(vsi->back));
47044704
if (!netdev)
47054705
return -ENOMEM;
47064706

drivers/net/ethernet/intel/ice/ice_repr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright (C) 2019-2021, Intel Corporation. */
33

44
#include "ice.h"
5+
#include "ice_lib.h"
56
#include "ice_eswitch.h"
67
#include "devlink/devlink.h"
78
#include "devlink/port.h"
@@ -67,7 +68,7 @@ ice_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
6768
return;
6869
vsi = repr->src_vsi;
6970

70-
ice_update_vsi_stats(vsi);
71+
ice_update_eth_stats(vsi);
7172
eth_stats = &vsi->eth_stats;
7273

7374
stats->tx_packets = eth_stats->tx_unicast + eth_stats->tx_broadcast +
@@ -315,7 +316,7 @@ ice_repr_reg_netdev(struct net_device *netdev, const struct net_device_ops *ops)
315316

316317
static int ice_repr_ready_vf(struct ice_repr *repr)
317318
{
318-
return !ice_check_vf_ready_for_cfg(repr->vf);
319+
return ice_check_vf_ready_for_cfg(repr->vf);
319320
}
320321

321322
static int ice_repr_ready_sf(struct ice_repr *repr)

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ bool idpf_vport_set_hsplit(const struct idpf_vport *vport, u8 val);
10661066
int idpf_idc_init(struct idpf_adapter *adapter);
10671067
int idpf_idc_init_aux_core_dev(struct idpf_adapter *adapter,
10681068
enum iidc_function_type ftype);
1069-
void idpf_idc_deinit_core_aux_device(struct iidc_rdma_core_dev_info *cdev_info);
1069+
void idpf_idc_deinit_core_aux_device(struct idpf_adapter *adapter);
10701070
void idpf_idc_deinit_vport_aux_device(struct iidc_rdma_vport_dev_info *vdev_info);
10711071
void idpf_idc_issue_reset_event(struct iidc_rdma_core_dev_info *cdev_info);
10721072
void idpf_idc_vdev_mtu_event(struct iidc_rdma_vport_dev_info *vdev_info,

drivers/net/ethernet/intel/idpf/idpf_idc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,11 @@ int idpf_idc_init_aux_core_dev(struct idpf_adapter *adapter,
470470

471471
/**
472472
* idpf_idc_deinit_core_aux_device - de-initialize Auxiliary Device(s)
473-
* @cdev_info: IDC core device info pointer
473+
* @adapter: driver private data structure
474474
*/
475-
void idpf_idc_deinit_core_aux_device(struct iidc_rdma_core_dev_info *cdev_info)
475+
void idpf_idc_deinit_core_aux_device(struct idpf_adapter *adapter)
476476
{
477+
struct iidc_rdma_core_dev_info *cdev_info = adapter->cdev_info;
477478
struct iidc_rdma_priv_dev_info *privd;
478479

479480
if (!cdev_info)
@@ -485,6 +486,7 @@ void idpf_idc_deinit_core_aux_device(struct iidc_rdma_core_dev_info *cdev_info)
485486
kfree(privd->mapped_mem_regions);
486487
kfree(privd);
487488
kfree(cdev_info);
489+
adapter->cdev_info = NULL;
488490
}
489491

490492
/**

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,13 +1860,13 @@ static int idpf_rxq_group_alloc(struct idpf_vport *vport,
18601860
idpf_queue_assign(HSPLIT_EN, q, hs);
18611861
idpf_queue_assign(RSC_EN, q, rsc);
18621862

1863-
bufq_set->num_refillqs = num_rxq;
18641863
bufq_set->refillqs = kcalloc(num_rxq, swq_size,
18651864
GFP_KERNEL);
18661865
if (!bufq_set->refillqs) {
18671866
err = -ENOMEM;
18681867
goto err_alloc;
18691868
}
1869+
bufq_set->num_refillqs = num_rxq;
18701870
for (unsigned int k = 0; k < bufq_set->num_refillqs; k++) {
18711871
struct idpf_sw_queue *refillq =
18721872
&bufq_set->refillqs[k];

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3668,7 +3668,7 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter)
36683668

36693669
idpf_ptp_release(adapter);
36703670
idpf_deinit_task(adapter);
3671-
idpf_idc_deinit_core_aux_device(adapter->cdev_info);
3671+
idpf_idc_deinit_core_aux_device(adapter);
36723672
idpf_rel_rx_pt_lkup(adapter);
36733673
idpf_intr_rel(adapter);
36743674

0 commit comments

Comments
 (0)