]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bnxt_en: add support for tcp-data-split ethtool command
authorTaehee Yoo <ap420073@gmail.com>
Tue, 14 Jan 2025 14:28:49 +0000 (14:28 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 15 Jan 2025 22:42:12 +0000 (14:42 -0800)
NICs that uses bnxt_en driver supports tcp-data-split feature by the
name of HDS(header-data-split).
But there is no implementation for the HDS to enable by ethtool.
Only getting the current HDS status is implemented and The HDS is just
automatically enabled only when either LRO, HW-GRO, or JUMBO is enabled.
The hds_threshold follows rx-copybreak value. and it was unchangeable.

This implements `ethtool -G <interface name> tcp-data-split <value>`
command option.
The value can be <on> and <auto>.
The value is <auto> and one of LRO/GRO/JUMBO is enabled, HDS is
automatically enabled and all LRO/GRO/JUMBO are disabled, HDS is
automatically disabled.

HDS feature relies on the aggregation ring.
So, if HDS is enabled, the bnxt_en driver initializes the aggregation ring.
This is the reason why BNXT_FLAG_AGG_RINGS contains HDS condition.

Acked-by: Jakub Kicinski <kuba@kernel.org>
Tested-by: Stanislav Fomichev <sdf@fomichev.me>
Tested-by: Andy Gospodarek <gospo@broadcom.com>
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250114142852.3364986-8-ap420073@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c

index d19c4fb588e592dbfbb1f5d161c67448cff3f876..f029559a581e515034d462e4766b4b67e621fd35 100644 (file)
@@ -4630,7 +4630,7 @@ void bnxt_set_ring_params(struct bnxt *bp)
        bp->rx_agg_ring_size = 0;
        bp->rx_agg_nr_pages = 0;
 
-       if (bp->flags & BNXT_FLAG_TPA)
+       if (bp->flags & BNXT_FLAG_TPA || bp->flags & BNXT_FLAG_HDS)
                agg_factor = min_t(u32, 4, 65536 / BNXT_RX_PAGE_SIZE);
 
        bp->flags &= ~BNXT_FLAG_JUMBO;
index 7edb92ce59762bb700ae4cbee587ba1cc0201272..7dc06e07bae2aadd350c946b6152b1a3fd0c5d3d 100644 (file)
@@ -2244,8 +2244,6 @@ struct bnxt {
        #define BNXT_FLAG_TPA           (BNXT_FLAG_LRO | BNXT_FLAG_GRO)
        #define BNXT_FLAG_JUMBO         0x10
        #define BNXT_FLAG_STRIP_VLAN    0x20
-       #define BNXT_FLAG_AGG_RINGS     (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \
-                                        BNXT_FLAG_LRO)
        #define BNXT_FLAG_RFS           0x100
        #define BNXT_FLAG_SHARED_RINGS  0x200
        #define BNXT_FLAG_PORT_STATS    0x400
@@ -2266,6 +2264,9 @@ struct bnxt {
        #define BNXT_FLAG_ROCE_MIRROR_CAP       0x4000000
        #define BNXT_FLAG_TX_COAL_CMPL  0x8000000
        #define BNXT_FLAG_PORT_STATS_EXT        0x10000000
+       #define BNXT_FLAG_HDS           0x20000000
+       #define BNXT_FLAG_AGG_RINGS     (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \
+                                        BNXT_FLAG_LRO | BNXT_FLAG_HDS)
 
        #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA |             \
                                            BNXT_FLAG_RFS |             \
index e9e63d95df1773a2681f96c5aa7cbe27118ee4f8..413007190f509c0884f04a79c8528709b4562f00 100644 (file)
@@ -840,16 +840,35 @@ static int bnxt_set_ringparam(struct net_device *dev,
                              struct kernel_ethtool_ringparam *kernel_ering,
                              struct netlink_ext_ack *extack)
 {
+       u8 tcp_data_split = kernel_ering->tcp_data_split;
        struct bnxt *bp = netdev_priv(dev);
+       u8 hds_config_mod;
 
        if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) ||
            (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) ||
            (ering->tx_pending < BNXT_MIN_TX_DESC_CNT))
                return -EINVAL;
 
+       hds_config_mod = tcp_data_split != dev->ethtool->hds_config;
+       if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED && hds_config_mod)
+               return -EINVAL;
+
+       if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
+           hds_config_mod && BNXT_RX_PAGE_MODE(bp)) {
+               NL_SET_ERR_MSG_MOD(extack, "tcp-data-split is disallowed when XDP is attached");
+               return -EINVAL;
+       }
+
        if (netif_running(dev))
                bnxt_close_nic(bp, false, false);
 
+       if (hds_config_mod) {
+               if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED)
+                       bp->flags |= BNXT_FLAG_HDS;
+               else if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN)
+                       bp->flags &= ~BNXT_FLAG_HDS;
+       }
+
        bp->rx_ring_size = ering->rx_pending;
        bp->tx_ring_size = ering->tx_pending;
        bnxt_set_ring_params(bp);
@@ -5371,6 +5390,7 @@ const struct ethtool_ops bnxt_ethtool_ops = {
                                     ETHTOOL_COALESCE_STATS_BLOCK_USECS |
                                     ETHTOOL_COALESCE_USE_ADAPTIVE_RX |
                                     ETHTOOL_COALESCE_USE_CQE,
+       .supported_ring_params  = ETHTOOL_RING_USE_TCP_DATA_SPLIT,
        .get_link_ksettings     = bnxt_get_link_ksettings,
        .set_link_ksettings     = bnxt_set_link_ksettings,
        .get_fec_stats          = bnxt_get_fec_stats,
index f88b641533fcc55d3ec11e497bb3a7a0d39c0575..1bfff7f29310ec2d39a37fa9a835f0f49c438d29 100644 (file)
@@ -395,6 +395,10 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
                            bp->dev->mtu, BNXT_MAX_PAGE_MODE_MTU);
                return -EOPNOTSUPP;
        }
+       if (prog && bp->flags & BNXT_FLAG_HDS) {
+               netdev_warn(dev, "XDP is disallowed when HDS is enabled.\n");
+               return -EOPNOTSUPP;
+       }
        if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) {
                netdev_warn(dev, "ethtool rx/tx channels must be combined to support XDP.\n");
                return -EOPNOTSUPP;