2021-05-26 09:31:27

by Huazhong Tan

[permalink] [raw]
Subject: [RFC net-next 0/4] ethtool: extend coalesce uAPI

In order to support some configuration in coalesce uAPI, this RFC
extends coalesce uAPI and add support for CQE mode.

Below is some test result with HNS3 driver:
1. old ethtool(ioctl) + new kernel:
estuary:/$ ethtool -c eth0
Coalesce parameters for eth0:
Adaptive RX: on TX: on
stats-block-usecs: 0
sample-interval: 0
pkt-rate-low: 0
pkt-rate-high: 0

rx-usecs: 20
rx-frames: 0
rx-usecs-irq: 0
rx-frames-irq: 0

tx-usecs: 20
tx-frames: 0
tx-usecs-irq: 0
tx-frames-irq: 0

rx-usecs-low: 0
rx-frame-low: 0
tx-usecs-low: 0
tx-frame-low: 0

rx-usecs-high: 0
rx-frame-high: 0
tx-usecs-high: 0
tx-frame-high: 0

2. ethtool(netlink with cqe mode) + kernel without cqe mode:
estuary:/$ ethtool -c eth0
Coalesce parameters for eth0:
Adaptive RX: on TX: on
stats-block-usecs: n/a
sample-interval: n/a
pkt-rate-low: n/a
pkt-rate-high: n/a

rx-usecs: 20
rx-frames: 0
rx-usecs-irq: n/a
rx-frames-irq: n/a

tx-usecs: 20
tx-frames: 0
tx-usecs-irq: n/a
tx-frames-irq: n/a

rx-usecs-low: n/a
rx-frame-low: n/a
tx-usecs-low: n/a
tx-frame-low: n/a

rx-usecs-high: 0
rx-frame-high: n/a
tx-usecs-high: 0
tx-frame-high: n/a

CQE mode RX: n/a TX: n/a

3. ethool(netlink with cqe mode) + kernel with cqe mode:
estuary:/$ ethtool -c eth0
Coalesce parameters for eth0:
Adaptive RX: on TX: on
stats-block-usecs: n/a
sample-interval: n/a
pkt-rate-low: n/a
pkt-rate-high: n/a

rx-usecs: 20
rx-frames: 0
rx-usecs-irq: n/a
rx-frames-irq: n/a

tx-usecs: 20
tx-frames: 0
tx-usecs-irq: n/a
tx-frames-irq: n/a

rx-usecs-low: n/a
rx-frame-low: n/a
tx-usecs-low: n/a
tx-frame-low: n/a

rx-usecs-high: 0
rx-frame-high: n/a
tx-usecs-high: 0
tx-frame-high: n/a

CQE mode RX: off TX: off

4. ethool(netlink without cqe mode) + kernel with cqe mode:
estuary:/$ ethtool -c eth0
Coalesce parameters for eth0:
Adaptive RX: on TX: on
stats-block-usecs: n/a
sample-interval: n/a
pkt-rate-low: n/a
pkt-rate-high: n/a

rx-usecs: 20
rx-frames: 0
rx-usecs-irq: n/a
rx-frames-irq: n/a

tx-usecs: 20
tx-frames: 0
tx-usecs-irq: n/a
tx-frames-irq: n/a

rx-usecs-low: n/a
rx-frame-low: n/a
tx-usecs-low: n/a
tx-frame-low: n/a

rx-usecs-high: 0
rx-frame-high: n/a
tx-usecs-high: 0
tx-frame-high: n/a

Huazhong Tan (4):
ethtool: extend coalesce API
ethtool: extend coalesce setting uAPI with CQE mode
net: hns3: add support for EQE/CQE mode configuration
net: hns3: add ethtool support for CQE/EQE mode configuration

Documentation/networking/ethtool-netlink.rst | 4 +
drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 24 +++--
drivers/net/ethernet/amazon/ena/ena_ethtool.c | 22 ++--
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 24 +++--
.../net/ethernet/aquantia/atlantic/aq_ethtool.c | 40 +++----
drivers/net/ethernet/broadcom/bcmsysport.c | 40 +++----
drivers/net/ethernet/broadcom/bnx2.c | 50 +++++----
.../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 18 ++--
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 52 ++++-----
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 36 ++++---
drivers/net/ethernet/broadcom/tg3.c | 54 +++++-----
drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 38 ++++---
drivers/net/ethernet/cavium/liquidio/lio_ethtool.c | 66 ++++++------
.../net/ethernet/cavium/thunder/nicvf_ethtool.c | 6 +-
drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 22 ++--
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 16 ++-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 29 ++---
.../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 16 +--
drivers/net/ethernet/cisco/enic/enic_ethtool.c | 32 +++---
drivers/net/ethernet/cortina/gemini.c | 22 ++--
drivers/net/ethernet/emulex/benet/be_ethtool.c | 36 ++++---
drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 16 +--
.../net/ethernet/freescale/enetc/enetc_ethtool.c | 28 ++---
drivers/net/ethernet/freescale/fec_main.c | 48 +++++----
drivers/net/ethernet/freescale/gianfar_ethtool.c | 44 ++++----
drivers/net/ethernet/hisilicon/hip04_eth.c | 24 +++--
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 48 +++++----
drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 +
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 49 ++++++++-
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 11 ++
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 58 ++++++----
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 +
.../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 1 +
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c | 13 ++-
drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 28 ++---
drivers/net/ethernet/intel/e1000e/ethtool.c | 28 ++---
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 28 ++---
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 14 ++-
drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 14 ++-
drivers/net/ethernet/intel/ice/ice_ethtool.c | 18 ++--
drivers/net/ethernet/intel/igb/igb_ethtool.c | 48 +++++----
drivers/net/ethernet/intel/igbvf/ethtool.c | 26 +++--
drivers/net/ethernet/intel/igc/igc_ethtool.c | 48 +++++----
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 34 +++---
drivers/net/ethernet/intel/ixgbevf/ethtool.c | 34 +++---
drivers/net/ethernet/jme.c | 40 +++----
drivers/net/ethernet/marvell/mv643xx_eth.c | 20 ++--
drivers/net/ethernet/marvell/mvneta.c | 20 ++--
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 24 +++--
.../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 63 ++++++-----
drivers/net/ethernet/marvell/skge.c | 36 ++++---
drivers/net/ethernet/marvell/sky2.c | 63 ++++++-----
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 74 +++++++------
.../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 12 ++-
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 12 ++-
.../ethernet/mellanox/mlx5/core/ipoib/ethtool.c | 12 ++-
drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 16 +--
.../net/ethernet/netronome/nfp/nfp_net_ethtool.c | 36 ++++---
drivers/net/ethernet/ni/nixge.c | 20 ++--
.../net/ethernet/pensando/ionic/ionic_ethtool.c | 42 ++++----
.../ethernet/qlogic/netxen/netxen_nic_ethtool.c | 36 ++++---
drivers/net/ethernet/qlogic/qede/qede.h | 3 +-
drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 24 +++--
.../net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 26 +++--
drivers/net/ethernet/realtek/r8169_main.c | 35 +++---
drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c | 14 ++-
drivers/net/ethernet/sfc/ethtool.c | 36 ++++---
drivers/net/ethernet/sfc/falcon/ethtool.c | 36 ++++---
drivers/net/ethernet/socionext/netsec.c | 49 +++++----
.../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++-
drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c | 20 ++--
drivers/net/ethernet/tehuti/tehuti.c | 28 ++---
drivers/net/ethernet/ti/cpsw.c | 6 +-
drivers/net/ethernet/ti/cpsw_ethtool.c | 12 ++-
drivers/net/ethernet/ti/cpsw_new.c | 6 +-
drivers/net/ethernet/ti/cpsw_priv.h | 6 +-
drivers/net/ethernet/ti/davinci_emac.c | 20 ++--
drivers/net/ethernet/via/via-velocity.c | 32 +++---
drivers/net/ethernet/xilinx/ll_temac_main.c | 32 +++---
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 20 ++--
drivers/net/netdevsim/ethtool.c | 12 ++-
drivers/net/tun.c | 14 ++-
drivers/net/usb/r8152.c | 16 +--
drivers/net/virtio_net.c | 18 ++--
drivers/net/vmxnet3/vmxnet3_ethtool.c | 68 ++++++------
drivers/net/wireless/ath/wil6210/ethtool.c | 25 +++--
drivers/staging/qlge/qlge_ethtool.c | 10 +-
include/linux/ethtool.h | 21 +++-
include/uapi/linux/ethtool_netlink.h | 2 +
net/ethtool/coalesce.c | 117 ++++++++++++---------
net/ethtool/ioctl.c | 69 ++++++------
net/ethtool/netlink.h | 2 +-
92 files changed, 1540 insertions(+), 1088 deletions(-)

--
2.7.4


2021-05-26 09:32:04

by Huazhong Tan

[permalink] [raw]
Subject: [RFC net-next 4/4] net: hns3: add ethtool support for CQE/EQE mode configuration

Add support in ethtool for switching EQE/CQE mode.

Signed-off-by: Huazhong Tan <[email protected]>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 +++---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 +++
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 16 +++++++++++++++-
include/linux/ethtool.h | 2 ++
4 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 3399f26..2096f22 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -4553,9 +4553,9 @@ static void hns3_set_cq_period_mode(struct hns3_nic_priv *priv,
}
}

-static void hns3_cq_period_mode_init(struct hns3_nic_priv *priv,
- enum dim_cq_period_mode tx_mode,
- enum dim_cq_period_mode rx_mode)
+void hns3_cq_period_mode_init(struct hns3_nic_priv *priv,
+ enum dim_cq_period_mode tx_mode,
+ enum dim_cq_period_mode rx_mode)
{
hns3_set_cq_period_mode(priv, tx_mode, true);
hns3_set_cq_period_mode(priv, rx_mode, false);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index 8445596..b031fd0 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -666,4 +666,7 @@ void hns3_dbg_register_debugfs(const char *debugfs_dir_name);
void hns3_dbg_unregister_debugfs(void);
void hns3_shinfo_pack(struct skb_shared_info *shinfo, __u32 *size);
u16 hns3_get_max_available_channels(struct hnae3_handle *h);
+void hns3_cq_period_mode_init(struct hns3_nic_priv *priv,
+ enum dim_cq_period_mode tx_mode,
+ enum dim_cq_period_mode rx_mode);
#endif
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 0042be0..b1fcd3e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1159,6 +1159,11 @@ static int hns3_get_coalesce(struct net_device *netdev,
coal_base->tx_max_coalesced_frames = tx_coal->int_ql;
coal_base->rx_max_coalesced_frames = rx_coal->int_ql;

+ cmd->use_cqe_mode_tx = (priv->tx_cqe_mode ==
+ DIM_CQ_PERIOD_MODE_START_FROM_CQE);
+ cmd->use_cqe_mode_rx = (priv->rx_cqe_mode ==
+ DIM_CQ_PERIOD_MODE_START_FROM_CQE);
+
return 0;
}

@@ -1328,6 +1333,8 @@ static int hns3_set_coalesce(struct net_device *netdev,
struct hns3_enet_coalesce *tx_coal = &priv->tx_coal;
struct hns3_enet_coalesce *rx_coal = &priv->rx_coal;
u16 queue_num = h->kinfo.num_tqps;
+ enum dim_cq_period_mode tx_mode;
+ enum dim_cq_period_mode rx_mode;
int ret;
int i;

@@ -1353,6 +1360,12 @@ static int hns3_set_coalesce(struct net_device *netdev,
for (i = 0; i < queue_num; i++)
hns3_set_coalesce_per_queue(netdev, coal_base, i);

+ tx_mode = cmd->use_cqe_mode_tx ? DIM_CQ_PERIOD_MODE_START_FROM_CQE :
+ DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+ rx_mode = cmd->use_cqe_mode_rx ? DIM_CQ_PERIOD_MODE_START_FROM_CQE :
+ DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+ hns3_cq_period_mode_init(priv, tx_mode, rx_mode);
+
return 0;
}

@@ -1604,7 +1617,8 @@ static int hns3_set_priv_flags(struct net_device *netdev, u32 pflags)
ETHTOOL_COALESCE_USE_ADAPTIVE | \
ETHTOOL_COALESCE_RX_USECS_HIGH | \
ETHTOOL_COALESCE_TX_USECS_HIGH | \
- ETHTOOL_COALESCE_MAX_FRAMES)
+ ETHTOOL_COALESCE_MAX_FRAMES | \
+ ETHTOOL_COALESCE_USE_CQE)

static const struct ethtool_ops hns3vf_ethtool_ops = {
.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 9d0a386..4867008 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -250,6 +250,8 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \
ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \
ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL)
+#define ETHTOOL_COALESCE_USE_CQE \
+ (ETHTOOL_COALESCE_USE_CQE_RX | ETHTOOL_COALESCE_USE_CQE_TX)

#define ETHTOOL_STAT_NOT_SET (~0ULL)

--
2.7.4