From: Sasha Levin Date: Sun, 26 Sep 2021 22:59:08 +0000 (-0400) Subject: Fixes for 4.14 X-Git-Tag: v5.4.150~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=41424fb92af4fc84e603b35231563e34e9fca148;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/bnxt_en-fix-tx-timeout-when-tx-ring-size-is-set-to-t.patch b/queue-4.14/bnxt_en-fix-tx-timeout-when-tx-ring-size-is-set-to-t.patch new file mode 100644 index 00000000000..f7c005f790f --- /dev/null +++ b/queue-4.14/bnxt_en-fix-tx-timeout-when-tx-ring-size-is-set-to-t.patch @@ -0,0 +1,105 @@ +From beb7348003e4651c04e5a8b8c3e535eba1297025 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Sep 2021 02:51:52 -0400 +Subject: bnxt_en: Fix TX timeout when TX ring size is set to the smallest + +From: Michael Chan + +[ Upstream commit 5bed8b0704c9ecccc8f4a2c377d7c8e21090a82e ] + +The smallest TX ring size we support must fit a TX SKB with MAX_SKB_FRAGS ++ 1. Because the first TX BD for a packet is always a long TX BD, we +need an extra TX BD to fit this packet. Define BNXT_MIN_TX_DESC_CNT with +this value to make this more clear. The current code uses a minimum +that is off by 1. Fix it using this constant. + +The tx_wake_thresh to determine when to wake up the TX queue is half the +ring size but we must have at least BNXT_MIN_TX_DESC_CNT for the next +packet which may have maximum fragments. So the comparison of the +available TX BDs with tx_wake_thresh should be >= instead of > in the +current code. Otherwise, at the smallest ring size, we will never wake +up the TX queue and will cause TX timeout. + +Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") +Reviewed-by: Pavan Chebbi +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++---- + drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 +++++ + drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- + 3 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +index c4b0c35a270c..17592aeb2618 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -278,7 +278,7 @@ static bool bnxt_txr_netif_try_stop_queue(struct bnxt *bp, + * netif_tx_queue_stopped(). + */ + smp_mb(); +- if (bnxt_tx_avail(bp, txr) > bp->tx_wake_thresh) { ++ if (bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh) { + netif_tx_wake_queue(txq); + return false; + } +@@ -609,7 +609,7 @@ static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts) + smp_mb(); + + if (unlikely(netif_tx_queue_stopped(txq)) && +- bnxt_tx_avail(bp, txr) > bp->tx_wake_thresh && ++ bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh && + READ_ONCE(txr->dev_state) != BNXT_DEV_STATE_CLOSING) + netif_tx_wake_queue(txq); + } +@@ -1888,7 +1888,7 @@ static int bnxt_poll_work(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) + if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) { + tx_pkts++; + /* return full budget so NAPI will complete. */ +- if (unlikely(tx_pkts > bp->tx_wake_thresh)) { ++ if (unlikely(tx_pkts >= bp->tx_wake_thresh)) { + rx_pkts = budget; + raw_cons = NEXT_RAW_CMP(raw_cons); + break; +@@ -2662,7 +2662,7 @@ static int bnxt_init_tx_rings(struct bnxt *bp) + u16 i; + + bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2, +- MAX_SKB_FRAGS + 1); ++ BNXT_MIN_TX_DESC_CNT); + + for (i = 0; i < bp->tx_nr_rings; i++) { + struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h +index 5aaf7f5a23dc..ad0a69a81f10 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h +@@ -477,6 +477,11 @@ struct rx_tpa_end_cmp_ext { + #define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1) + #define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1) + ++/* Minimum TX BDs for a TX packet with MAX_SKB_FRAGS + 1. We need one extra ++ * BD because the first TX BD is always a long BD. ++ */ ++#define BNXT_MIN_TX_DESC_CNT (MAX_SKB_FRAGS + 2) ++ + #define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4)) + #define RX_IDX(x) ((x) & (RX_DESC_CNT - 1)) + +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +index e8544e8637db..e3123cb0fb70 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +@@ -348,7 +348,7 @@ static int bnxt_set_ringparam(struct net_device *dev, + + if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) || + (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) || +- (ering->tx_pending <= MAX_SKB_FRAGS)) ++ (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) + return -EINVAL; + + if (netif_running(dev)) +-- +2.33.0 + diff --git a/queue-4.14/net-mlx4_en-don-t-allow-arfs-for-encapsulated-packet.patch b/queue-4.14/net-mlx4_en-don-t-allow-arfs-for-encapsulated-packet.patch new file mode 100644 index 00000000000..b5a4558994c --- /dev/null +++ b/queue-4.14/net-mlx4_en-don-t-allow-arfs-for-encapsulated-packet.patch @@ -0,0 +1,38 @@ +From 43759f3d1554dc173f52219895e6c86e0fb1a8d2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 23 Sep 2021 09:51:45 +0300 +Subject: net/mlx4_en: Don't allow aRFS for encapsulated packets + +From: Aya Levin + +[ Upstream commit fdbccea419dc782079ce5881d2705cc9e3881480 ] + +Driver doesn't support aRFS for encapsulated packets, return early error +in such a case. + +Fixes: 1eb8c695bda9 ("net/mlx4_en: Add accelerated RFS support") +Signed-off-by: Aya Levin +Signed-off-by: Tariq Toukan +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +index f191a0d042b9..879f2beface5 100644 +--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c ++++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +@@ -363,6 +363,9 @@ mlx4_en_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb, + int nhoff = skb_network_offset(skb); + int ret = 0; + ++ if (skb->encapsulation) ++ return -EPROTONOSUPPORT; ++ + if (skb->protocol != htons(ETH_P_IP)) + return -EPROTONOSUPPORT; + +-- +2.33.0 + diff --git a/queue-4.14/net-mlx4_en-resolve-bad-operstate-value.patch b/queue-4.14/net-mlx4_en-resolve-bad-operstate-value.patch new file mode 100644 index 00000000000..14f2189c4c3 --- /dev/null +++ b/queue-4.14/net-mlx4_en-resolve-bad-operstate-value.patch @@ -0,0 +1,127 @@ +From 698b354c5fb8c714cfc1665bf0f43be9a123d992 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 19 Sep 2021 14:55:45 +0300 +Subject: net/mlx4_en: Resolve bad operstate value + +From: Lama Kayal + +[ Upstream commit 72a3c58d18fd780eecd80178bb2132ce741a0a74 ] + +Any link state change that's done prior to net device registration +isn't reflected on the state, thus the operational state is left +obsolete, with 'UNKNOWN' status. + +To resolve the issue, query link state from FW upon open operations +to ensure operational state is updated. + +Fixes: c27a02cd94d6 ("mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC") +Signed-off-by: Lama Kayal +Signed-off-by: Tariq Toukan +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + .../net/ethernet/mellanox/mlx4/en_netdev.c | 47 ++++++++++++------- + drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 - + 2 files changed, 29 insertions(+), 19 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +index b27dbc34df02..f191a0d042b9 100644 +--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c ++++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +@@ -1260,7 +1260,6 @@ static void mlx4_en_do_set_rx_mode(struct work_struct *work) + if (!netif_carrier_ok(dev)) { + if (!mlx4_en_QUERY_PORT(mdev, priv->port)) { + if (priv->port_state.link_state) { +- priv->last_link_state = MLX4_DEV_EVENT_PORT_UP; + netif_carrier_on(dev); + en_dbg(LINK, priv, "Link Up\n"); + } +@@ -1568,26 +1567,36 @@ static void mlx4_en_service_task(struct work_struct *work) + mutex_unlock(&mdev->state_lock); + } + +-static void mlx4_en_linkstate(struct work_struct *work) ++static void mlx4_en_linkstate(struct mlx4_en_priv *priv) ++{ ++ struct mlx4_en_port_state *port_state = &priv->port_state; ++ struct mlx4_en_dev *mdev = priv->mdev; ++ struct net_device *dev = priv->dev; ++ bool up; ++ ++ if (mlx4_en_QUERY_PORT(mdev, priv->port)) ++ port_state->link_state = MLX4_PORT_STATE_DEV_EVENT_PORT_DOWN; ++ ++ up = port_state->link_state == MLX4_PORT_STATE_DEV_EVENT_PORT_UP; ++ if (up == netif_carrier_ok(dev)) ++ netif_carrier_event(dev); ++ if (!up) { ++ en_info(priv, "Link Down\n"); ++ netif_carrier_off(dev); ++ } else { ++ en_info(priv, "Link Up\n"); ++ netif_carrier_on(dev); ++ } ++} ++ ++static void mlx4_en_linkstate_work(struct work_struct *work) + { + struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, + linkstate_task); + struct mlx4_en_dev *mdev = priv->mdev; +- int linkstate = priv->link_state; + + mutex_lock(&mdev->state_lock); +- /* If observable port state changed set carrier state and +- * report to system log */ +- if (priv->last_link_state != linkstate) { +- if (linkstate == MLX4_DEV_EVENT_PORT_DOWN) { +- en_info(priv, "Link Down\n"); +- netif_carrier_off(priv->dev); +- } else { +- en_info(priv, "Link Up\n"); +- netif_carrier_on(priv->dev); +- } +- } +- priv->last_link_state = linkstate; ++ mlx4_en_linkstate(priv); + mutex_unlock(&mdev->state_lock); + } + +@@ -2090,9 +2099,11 @@ static int mlx4_en_open(struct net_device *dev) + mlx4_en_clear_stats(dev); + + err = mlx4_en_start_port(dev); +- if (err) ++ if (err) { + en_err(priv, "Failed starting port:%d\n", priv->port); +- ++ goto out; ++ } ++ mlx4_en_linkstate(priv); + out: + mutex_unlock(&mdev->state_lock); + return err; +@@ -3292,7 +3303,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, + spin_lock_init(&priv->stats_lock); + INIT_WORK(&priv->rx_mode_task, mlx4_en_do_set_rx_mode); + INIT_WORK(&priv->restart_task, mlx4_en_restart); +- INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate); ++ INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate_work); + INIT_DELAYED_WORK(&priv->stats_task, mlx4_en_do_get_stats); + INIT_DELAYED_WORK(&priv->service_task, mlx4_en_service_task); + INIT_WORK(&priv->vxlan_add_task, mlx4_en_add_vxlan_offloads); +diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +index 7078330e25c1..e66efee88c9c 100644 +--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h ++++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +@@ -566,7 +566,6 @@ struct mlx4_en_priv { + + struct mlx4_hwq_resources res; + int link_state; +- int last_link_state; + bool port_up; + int port; + int registered; +-- +2.33.0 + diff --git a/queue-4.14/series b/queue-4.14/series index 835c6edac04..5d22a3a57dc 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -14,3 +14,6 @@ usb-serial-option-add-device-id-for-foxconn-t99w265.patch mcb-fix-error-handling-in-mcb_alloc_bus.patch serial-mvebu-uart-fix-driver-s-tx_empty-callback.patch net-hso-fix-muxed-tty-registration.patch +net-mlx4_en-resolve-bad-operstate-value.patch +bnxt_en-fix-tx-timeout-when-tx-ring-size-is-set-to-t.patch +net-mlx4_en-don-t-allow-arfs-for-encapsulated-packet.patch