net: ethernet: ti: am65-cpsw: add sw tx/rx irq coalescing based on hrtimers
Subsystems (2)
PATCH 1/1 net: ethernet: ti: am65-cpsw: add sw tx/rx irq coalescing based on hrtimers
From: Grygorii Strashko <[email protected]>
Add SW IRQ coalescing based on hrtimers for TX and RX data path which can be enabled by ethtool commands:
- RX coalescing
ethtool -C eth1 rx-usecs 50
- TX coalescing can be enabled per TX queue
- by default enables coalesing for TX0
ethtool -C eth1 tx-usecs 50
- configure TX0
ethtool -Q eth0 queue_mask 1 --coalesce tx-usecs 100
- configure TX1
ethtool -Q eth0 queue_mask 2 --coalesce tx-usecs 100
- configure TX0 and TX1
ethtool -Q eth0 queue_mask 3 --coalesce tx-usecs 100 --coalesce tx-usecs 100
show configuration for TX0 and TX1:
ethtool -Q eth0 queue_mask 3 --show-coalesce
Comparing to gro_flush_timeout and napi_defer_hard_irqs, this patch allows to enable IRQ coalesing for RX path separately.
--- drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 79 +++++++++++++++++++++ drivers/net/ethernet/ti/am65-cpsw-nuss.c | 59 ++++++++++++--- drivers/net/ethernet/ti/am65-cpsw-nuss.h | 4 ++ 3 files changed, 134 insertions(+), 8 deletions(-)
Patch depends on series [1]
[1] am65-cpsw: mqprio and Frame Pre-emption support
https://lore.kernel.org/all/[email protected]/
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +79 -0
@@ -862,6 +862,80 @@ static void am65_cpsw_get_mm_stats(struct net_device *ndev, s->MACMergeHoldCount =readl (base +AM65_CPSW_STATN_IET_TX_HOLD ); } +static int am65_cpsw_get_coalesce (struct net_device *ndev,struct ethtool_coalesce *coal, +struct kernel_ethtool_coalesce *kernel_coal, +struct netlink_ext_ack *extack) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); +struct am65_cpsw_tx_chn *tx_chn; + + tx_chn = &common->tx_chns[0 ]; + + coal->rx_coalesce_usecs = common->rx_pace_timeout /1000 ; + coal->tx_coalesce_usecs = tx_chn->tx_pace_timeout /1000 ; + +return 0 ; +} + +static int am65_cpsw_get_per_queue_coalesce (struct net_device *ndev,u32 queue, +struct ethtool_coalesce *coal) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); +struct am65_cpsw_tx_chn *tx_chn; + +if (queue >=AM65_CPSW_MAX_TX_QUEUES ) +return -EINVAL ; + + tx_chn = &common->tx_chns[queue]; + + coal->tx_coalesce_usecs = tx_chn->tx_pace_timeout /1000 ; + +return 0 ; +} + +static int am65_cpsw_set_coalesce (struct net_device *ndev,struct ethtool_coalesce *coal, +struct kernel_ethtool_coalesce *kernel_coal, +struct netlink_ext_ack *extack) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); +struct am65_cpsw_tx_chn *tx_chn; + + tx_chn = &common->tx_chns[0 ]; + +if (coal->rx_coalesce_usecs && coal->rx_coalesce_usecs <20 ) +return -EINVAL ; + +if (coal->tx_coalesce_usecs && coal->tx_coalesce_usecs <20 ) +return -EINVAL ; + + common->rx_pace_timeout = coal->rx_coalesce_usecs *1000 ; + tx_chn->tx_pace_timeout = coal->tx_coalesce_usecs *1000 ; + +return 0 ; +} + +static int am65_cpsw_set_per_queue_coalesce (struct net_device *ndev,u32 queue, +struct ethtool_coalesce *coal) +{ +struct am65_cpsw_common *common =am65_ndev_to_common (ndev); +struct am65_cpsw_tx_chn *tx_chn; + +if (queue >=AM65_CPSW_MAX_TX_QUEUES ) +return -EINVAL ; + + tx_chn = &common->tx_chns[queue]; + +if (coal->tx_coalesce_usecs && coal->tx_coalesce_usecs <20 ) { +dev_info (common->dev,"defaulting to min value of 20us for tx-usecs for tx-%u\n" , + queue); + coal->tx_coalesce_usecs =20 ; + } + + tx_chn->tx_pace_timeout = coal->tx_coalesce_usecs *1000 ; + +return 0 ; +} +const struct ethtool_ops am65_cpsw_ethtool_ops_slave = { .begin = am65_cpsw_ethtool_op_begin, .complete = am65_cpsw_ethtool_op_complete,
@@ -879,6 +953,11 @@ const struct ethtool_ops am65_cpsw_ethtool_ops_slave = { .get_ts_info = am65_cpsw_get_ethtool_ts_info, .get_priv_flags = am65_cpsw_get_ethtool_priv_flags, .set_priv_flags = am65_cpsw_set_ethtool_priv_flags, + .supported_coalesce_params = ETHTOOL_COALESCE_USECS, + .get_coalesce = am65_cpsw_get_coalesce, + .set_coalesce = am65_cpsw_set_coalesce, + .get_per_queue_coalesce = am65_cpsw_get_per_queue_coalesce, + .set_per_queue_coalesce = am65_cpsw_set_per_queue_coalesce, .get_link = ethtool_op_get_link, .get_link_ksettings = am65_cpsw_get_link_ksettings,
drivers/net/ethernet/ti/am65-cpsw-nuss.c +51 -8
137 lines not on this page · raw message
drivers/net/ethernet/ti/am65-cpsw-nuss.h +4 -0
@@ -75,6 +75,8 @@ struct am65_cpsw_tx_chn {struct k3_cppi_desc_pool *desc_pool;struct k3_udma_glue_tx_channel *tx_chn;spinlock_t lock;/* protect TX rings in multi-port mode */ +struct hrtimer tx_hrtimer; +unsigned long tx_pace_timeout;int irq;u32 id;u32 descs_num;
@@ -138,6 +140,8 @@ struct am65_cpsw_common {struct napi_struct napi_rx;bool rx_irq_disabled; +struct hrtimer rx_hrtimer; +unsigned long rx_pace_timeout;u32 nuss_ver;u32 cpsw_ver;
base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
prerequisite-patch-id: 281ee877d949be7a0c0d4460281c7c6a356cffdf
prerequisite-patch-id: 2633189c7e9e0d30c8d5b8edc2468b2475e42816
prerequisite-patch-id: 656c6308f2b6782a43371ef66a9f1bfa8177b1cf
Signature · 1 line
2.34.1
Quoted 19 lines · Roger Quadros
From: Grygorii Strashko <[email protected]>
Add SW IRQ coalescing based on hrtimers for TX and RX data path which can be enabled by ethtool commands:
- RX coalescing
ethtool -C eth1 rx-usecs 50- TX coalescing can be enabled per TX queue
- by default enables coalesing for TX0
ethtool -C eth1 tx-usecs 50
- configure TX0
ethtool -Q eth0queue_mask1 --coalesce tx-usecs 100
- configure TX1
ethtool -Q eth0queue_mask2 --coalesce tx-usecs 100
- configure TX0 and TX1
ethtool -Q eth0queue_mask3 --coalesce tx-usecs 100 --coalesce tx-usecs 100
Quoted 8 lines
show configuration for TX0 and TX1:
ethtool -Q eth0queue_mask3 --show-coalesceComparing to
gro_flush_timeoutandnapi_defer_hard_irqs, this patch allows to enable IRQ coalesing for RX path separately.Signed-off-by Grygorii Strashko <[email protected]>Signed-off-by Roger Quadros <[email protected]>