mlx5 fixes-2020-09-18
Subsystems (6)
PATCH v2 1/15 net/mlx5: Fix FTE cleanup
In reply to [email protected]From: Maor Gottlieb <[email protected]>
Currently, when an FTE is allocated, its refcount is decreased to 0 with the purpose it will not be a stand alone steering object and every rule (destination) of the FTE would increase the refcount. When mlx5_cleanup_fs is called while not all rules were deleted by the steering users, it hit refcount underflow on the FTE once clean_tree calls to tree_remove_node after the deleted rules already decreased the refcount to 0.
FTE is no longer destroyed implicitly when the last rule (destination) is deleted. mlx5_del_flow_rules avoids it by increasing the refcount on the FTE and destroy it explicitly after all rules were deleted. So we can avoid the refcount underflow by making FTE as stand alone object. In addition need to set del_hw_func to FTE so the HW object will be destroyed when the FTE is deleted from the cleanup_tree flow.
refcount_t: underflow; use-after-free.
WARNING: CPU: 2 PID: 15715 at lib/refcount.c:28 refcount_warn_saturate+0xd9/0xe0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Call Trace: tree_put_node+0xf2/0x140 [mlx5_core] clean_tree+0x4e/0xf0 [mlx5_core] clean_tree+0x4e/0xf0 [mlx5_core] clean_tree+0x4e/0xf0 [mlx5_core] clean_tree+0x5f/0xf0 [mlx5_core] clean_tree+0x4e/0xf0 [mlx5_core] clean_tree+0x5f/0xf0 [mlx5_core] mlx5_cleanup_fs+0x26/0x270 [mlx5_core] mlx5_unload+0x2e/0xa0 [mlx5_core] mlx5_unload_one+0x51/0x120 [mlx5_core] mlx5_devlink_reload_down+0x51/0x90 [mlx5_core] devlink_reload+0x39/0x120 ? devlink_nl_cmd_reload+0x43/0x220 genl_rcv_msg+0x1e4/0x420 ? genl_family_rcv_msg_attrs_parse+0x100/0x100 netlink_rcv_skb+0x47/0x110 genl_rcv+0x24/0x40 netlink_unicast+0x217/0x2f0 netlink_sendmsg+0x30f/0x430 sock_sendmsg+0x30/0x40 __sys_sendto+0x10e/0x140 ? handle_mm_fault+0xc4/0x1f0 ? do_page_fault+0x33f/0x630 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x48/0x130 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +4 -4
@@ -654,7 +654,7 @@ static struct fs_fte *alloc_fte(struct mlx5_flow_table *ft, fte->action = *flow_act; fte->flow_context = spec->flow_context; -tree_init_node (&fte->node,NULL , del_sw_fte); +tree_init_node (&fte->node, del_hw_fte, del_sw_fte);return fte; }
@@ -1792,7 +1792,6 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,up_write_ref_node (&g->node, false); rule =add_rule_fg (g, spec, flow_act, dest, dest_num, fte);up_write_ref_node (&fte->node, false); -tree_put_node (&fte->node, false);return rule; } rule =ERR_PTR (-ENOENT );
@@ -1891,7 +1890,6 @@ _mlx5_add_flow_rules(struct mlx5_flow_table *ft,up_write_ref_node (&g->node, false); rule =add_rule_fg (g, spec, flow_act, dest, dest_num, fte);up_write_ref_node (&fte->node, false); -tree_put_node (&fte->node, false);tree_put_node (&g->node, false);return rule;
@@ -2001,7 +1999,9 @@ void mlx5_del_flow_rules(struct mlx5_flow_handle *handle)up_write_ref_node (&fte->node, false); }else {del_hw_fte (&fte->node); -up_write (&fte->node.lock); +/* Avoid double call to del_hw_fte */ + fte->node.del_hw_func =NULL ; +up_write_ref_node (&fte->node, false);tree_put_node (&fte->node, false); }kfree (handle);
Signature · 1 line
2.26.2
PATCH v2 2/15 net/mlx5e: Use RCU to protect rq->xdp_prog
In reply to [email protected]From: Maxim Mikityanskiy <[email protected]>
Currently, the RQs are temporarily deactivated while hot-replacing the XDP program, and napi_synchronize is used to make sure rq->xdp_prog is not in use. However, napi_synchronize is not ideal: instead of waiting till the end of a NAPI cycle, it polls and waits until NAPI is not running, sleeping for 1ms between the periodic checks. Under heavy workloads, this loop will never end, which may even lead to a kernel panic if the kernel detects the hangup. Such workloads include XSK TX and possibly also heavy RX (XSK or normal).
The fix is inspired by commit 326fe02d1ed6 ("net/mlx4_en: protect ring->xdp_prog with rcu_read_lock"). As mlx5e_xdp_handle is already protected by rcu_read_lock, and bpf_prog_put uses call_rcu to free the program, there is no need for additional synchronization if proper RCU functions are used to access the pointer. This patch converts all accesses to rq->xdp_prog to use RCU functions.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- .../net/ethernet/mellanox/mlx5/core/en/xdp.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 53 +++++++++---------- 3 files changed, 27 insertions(+), 30 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
@@ -600,7 +600,7 @@ struct mlx5e_rq {struct dim dim;/* Dynamic Interrupt Moderation */ /* XDP */ -struct bpf_prog *xdp_prog; +struct bpf_prog __rcu *xdp_prog;struct mlx5e_xdpsq *xdpsq;DECLARE_BITMAP (flags,8 );struct page_pool *page_pool;
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +1 -1
@@ -122,7 +122,7 @@ mlx5e_xmit_xdp_buff(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq,bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct mlx5e_dma_info *di,u32 *len,struct xdp_buff *xdp) { -struct bpf_prog *prog =READ_ONCE (rq->xdp_prog); +struct bpf_prog *prog =rcu_dereference (rq->xdp_prog);u32 act;int err;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +25 -28
92 lines not on this page · raw message
Signature · 1 line
2.26.2
From: Saeed Mahameed <[email protected]>
Hi Dave,
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
v1->v2:
Remove missing patch from -stable list.
For -stable v5.1
('net/mlx5: Fix FTE cleanup')
For -stable v5.3
('net/mlx5e: TLS, Do not expose FPGA TLS counter if not supported') ('net/mlx5e: Enable adding peer miss rules only if merged eswitch is supported')
For -stable v5.7
('net/mlx5e: Fix memory leak of tunnel info when rule under multipath not ready')
For -stable v5.8
('net/mlx5e: Use RCU to protect rq->xdp_prog') ('net/mlx5e: Fix endianness when calculating pedit mask first bit') ('net/mlx5e: Use synchronize_rcu to sync with NAPI')
Thanks,
Saeed.
---
The following changes since commit 5f6857e808a8bd078296575b417c4b9d160b9779:
nfp: use correct define to return NONE fec (2020-09-17 17:59:12 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2020-09-18
for you to fetch changes up to cb39ccc5cbe1011d8d21886b75e2468070ac672c:
net/mlx5e: mlx5e_fec_in_caps() returns a boolean (2020-09-21 17:22:25 -0700)
----------------------------------------------------------------
mlx5-fixes-2020-09-18
----------------------------------------------------------------
Alaa Hleihel (1):
net/mlx5e: Fix using wrong stats_grps in mlx5e_update_ndo_stats()
Jianbo Liu (1):
net/mlx5e: Fix memory leak of tunnel info when rule under multipath not ready
Maor Dickman (2):
net/mlx5e: Enable adding peer miss rules only if merged eswitch is supported net/mlx5e: Fix endianness when calculating pedit mask first bit
Maor Gottlieb (1):
net/mlx5: Fix FTE cleanup
Maxim Mikityanskiy (2):
net/mlx5e: Use RCU to protect rq->xdp_prog net/mlx5e: Use synchronize_rcu to sync with NAPI
Roi Dayan (1):
net/mlx5e: CT: Fix freeing ct_label mapping
Ron Diskin (1):
net/mlx5e: Fix multicast counter not up-to-date in "ip -s"
Saeed Mahameed (4):
net/mlx5e: kTLS, Add missing dma_unmap in RX resync net/mlx5e: kTLS, Fix leak on resync error flow net/mlx5e: kTLS, Avoid kzalloc(GFP_KERNEL) under spinlock net/mlx5e: mlx5e_fec_in_caps() returns a boolean
Tariq Toukan (2):
net/mlx5e: TLS, Do not expose FPGA TLS counter if not supported net/mlx5e: kTLS, Fix napi sync and possible use-after-free
drivers/net/ethernet/mellanox/mlx5/core/en.h | 3 +- .../ethernet/mellanox/mlx5/core/en/monitor_stats.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/port.c | 7 +- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 21 ++++-- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h | 26 ++++--- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 5 ++ drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en/xsk/rx.c | 14 +--- .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 3 +- .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 43 +++++------ .../mellanox/mlx5/core/en_accel/tls_stats.c | 12 ++- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 85 ++++++++-------------- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 16 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 12 +++ drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 3 + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 45 +++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 17 ++++- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 52 +++++++------ drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 8 +- 20 files changed, 200 insertions(+), 180 deletions(-)
PATCH v2 8/15 net/mlx5e: Fix multicast counter not up-to-date in "ip -s"
From: Ron Diskin <[email protected]>
Currently the FW does not generate events for counters other than error counters. Unlike ".get_ethtool_stats", ".ndo_get_stats64" (which ip -s uses) might run in atomic context, while the FW interface is non atomic. Thus, 'ip' is not allowed to issue FW commands, so it will only display cached counters in the driver.
Add a SW counter (mcast_packets) in the driver to count rx multicast packets. The counter also counts broadcast packets, as we consider it a special case of multicast.
Use the counter value when calling "ip -s"/"ifconfig".
--- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 5 +++++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 +------- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++++ drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 2 ++ 4 files changed, 12 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +5 -0
@@ -20,6 +20,11 @@ enum mlx5e_icosq_wqe_type { };/* General */ +static inline bool mlx5e_skb_is_multicast (struct sk_buff *skb) +{ +return skb->pkt_type ==PACKET_MULTICAST || skb->pkt_type ==PACKET_BROADCAST ; +} +void mlx5e_trigger_irq (struct mlx5e_icosq *sq);void mlx5e_completion_event (struct mlx5_core_cq *mcq,struct mlx5_eqe *eqe);void mlx5e_cq_error_event (struct mlx5_core_cq *mcq,enum mlx5_event event);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -7
@@ -3569,6 +3569,7 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s) s->rx_packets += rq_stats->packets + xskrq_stats->packets; s->rx_bytes += rq_stats->bytes + xskrq_stats->bytes; + s->multicast += rq_stats->mcast_packets + xskrq_stats->mcast_packets;for (j =0 ; j < priv->max_opened_tc; j++) {struct mlx5e_sq_stats *sq_stats = &channel_stats->sq[j];
@@ -3584,7 +3585,6 @@ void mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) { struct mlx5e_priv *priv = netdev_priv(dev); -struct mlx5e_vport_stats *vstats = &priv->stats.vport;struct mlx5e_pport_stats *pstats = &priv->stats.pport;/* In switchdev mode, monitor counters doesn't monitor
@@ -3619,12 +3619,6 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) stats->rx_errors = stats->rx_length_errors + stats->rx_crc_errors + stats->rx_frame_errors; stats->tx_errors = stats->tx_aborted_errors + stats->tx_carrier_errors; - -/* vport multicast also counts packets that are dropped due to steering -* or rx out of buffer -*/ - stats->multicast = -VPORT_COUNTER_GET (vstats, received_eth_multicast.packets); }static void mlx5e_set_rx_mode (struct net_device *dev)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +4 -0
@@ -53,6 +53,7 @@#include "en/xsk/rx.h" #include "en/health.h" #include "en/params.h" +#include "en/txrx.h" static struct sk_buff * mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
@@ -1080,6 +1081,9 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,mlx5e_enable_ecn (rq, skb); skb->protocol =eth_type_trans (skb, netdev); + +if (unlikely (mlx5e_skb_is_multicast (skb))) + stats->mcast_packets++; } static inline void mlx5e_complete_rx_cqe(struct mlx5e_rq *rq,
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +2 -0
@@ -119,6 +119,7 @@ struct mlx5e_sw_stats {u64 tx_nop;u64 rx_lro_packets;u64 rx_lro_bytes; +u64 rx_mcast_packets;u64 rx_ecn_mark;u64 rx_removed_vlan_packets;u64 rx_csum_unnecessary;
@@ -298,6 +299,7 @@ struct mlx5e_rq_stats {u64 csum_none;u64 lro_packets;u64 lro_bytes; +u64 mcast_packets;u64 ecn_mark;u64 removed_vlan_packets;u64 xdp_drop;
Signature · 1 line
2.26.2
PATCH v2 5/15 net/mlx5e: CT: Fix freeing ct_label mapping
In reply to [email protected]From: Roi Dayan <[email protected]>
Add missing mapping remove call when removing ct rule, as the mapping was allocated when ct rule was adding with ct_label. Also there is a missing mapping remove call in error flow.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 21 +++++++++++---- .../ethernet/mellanox/mlx5/core/en/tc_ct.h | 26 ++++++++++++------- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 6 +++-- 3 files changed, 36 insertions(+), 17 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +16 -5
@@ -699,6 +699,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, err_rule:mlx5e_mod_hdr_detach (ct_priv->esw->dev, &esw->offloads.mod_hdr, zone_rule->mh); +mapping_remove (ct_priv->labels_mapping, attr->ct_attr.ct_labels_id); err_mod_hdr:kfree (spec);return err;
@@ -958,12 +959,22 @@ mlx5_tc_ct_add_no_trk_match(struct mlx5e_priv *priv,return 0 ; } +void mlx5_tc_ct_match_del (struct mlx5e_priv *priv,struct mlx5_ct_attr *ct_attr) +{ +struct mlx5_tc_ct_priv *ct_priv =mlx5_tc_ct_get_ct_priv (priv); + +if (!ct_priv || !ct_attr->ct_labels_id) +return ; + +mapping_remove (ct_priv->labels_mapping, ct_attr->ct_labels_id); +} +int -mlx5_tc_ct_parse_match (struct mlx5e_priv *priv, -struct mlx5_flow_spec *spec, -struct flow_cls_offload *f, -struct mlx5_ct_attr *ct_attr, -struct netlink_ext_ack *extack) +mlx5_tc_ct_match_add (struct mlx5e_priv *priv, +struct mlx5_flow_spec *spec, +struct flow_cls_offload *f, +struct mlx5_ct_attr *ct_attr, +struct netlink_ext_ack *extack) {struct mlx5_tc_ct_priv *ct_priv =mlx5_tc_ct_get_ct_priv (priv);struct flow_rule *rule =flow_cls_offload_flow_rule (f);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +16 -10
@@ -87,12 +87,15 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv);void mlx5_tc_ct_clean (struct mlx5_rep_uplink_priv *uplink_priv); +void +mlx5_tc_ct_match_del (struct mlx5e_priv *priv,struct mlx5_ct_attr *ct_attr); +int -mlx5_tc_ct_parse_match (struct mlx5e_priv *priv, -struct mlx5_flow_spec *spec, -struct flow_cls_offload *f, -struct mlx5_ct_attr *ct_attr, -struct netlink_ext_ack *extack); +mlx5_tc_ct_match_add (struct mlx5e_priv *priv, +struct mlx5_flow_spec *spec, +struct flow_cls_offload *f, +struct mlx5_ct_attr *ct_attr, +struct netlink_ext_ack *extack);int mlx5_tc_ct_add_no_trk_match (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec);
@@ -130,12 +133,15 @@ mlx5_tc_ct_clean(struct mlx5_rep_uplink_priv *uplink_priv) { } +static inline void +mlx5_tc_ct_match_del (struct mlx5e_priv *priv,struct mlx5_ct_attr *ct_attr) {} +static inline int -mlx5_tc_ct_parse_match (struct mlx5e_priv *priv, -struct mlx5_flow_spec *spec, -struct flow_cls_offload *f, -struct mlx5_ct_attr *ct_attr, -struct netlink_ext_ack *extack) +mlx5_tc_ct_match_add (struct mlx5e_priv *priv, +struct mlx5_flow_spec *spec, +struct flow_cls_offload *f, +struct mlx5_ct_attr *ct_attr, +struct netlink_ext_ack *extack) {struct flow_rule *rule =flow_cls_offload_flow_rule (f);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -2
@@ -1312,6 +1312,8 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, }kvfree (attr->parse_attr); +mlx5_tc_ct_match_del (priv, &flow->esw_attr->ct_attr); +if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR )mlx5e_detach_mod_hdr (priv, flow);
@@ -4399,8 +4401,8 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv, goto err_free;/* actions validation depends on parsing the ct matches first */ - err =mlx5_tc_ct_parse_match (priv, &parse_attr->spec, f, - &flow->esw_attr->ct_attr, extack); + err =mlx5_tc_ct_match_add (priv, &parse_attr->spec, f, + &flow->esw_attr->ct_attr, extack);if (err) goto err_free;
Signature · 1 line
2.26.2
PATCH v2 3/15 net/mlx5e: Use synchronize_rcu to sync with NAPI
In reply to [email protected]From: Maxim Mikityanskiy <[email protected]>
As described in the previous commit, napi_synchronize doesn't quite fit the purpose when we just need to wait until the currently running NAPI quits. Its implementation waits until NAPI is not running by polling and waiting for 1ms in between. In cases where we need to deactivate one queue (e.g., recovery flows) or where we deactivate them one-by-one (deactivate channel flow), we may get stuck in napi_synchronize forever if other queues keep NAPI active, causing a soft lockup. Depending on kernel configuration (CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC), it may result in a kernel panic.
To fix the issue, use synchronize_rcu to wait for NAPI to quit, and wrap the whole NAPI in rcu_read_lock.
--- .../net/ethernet/mellanox/mlx5/core/en/xsk/rx.c | 14 ++------------ .../ethernet/mellanox/mlx5/core/en/xsk/setup.c | 3 +-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 12 ++++-------- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 12 ++---------- .../net/ethernet/mellanox/mlx5/core/en_txrx.c | 17 +++++++++++++---- 5 files changed, 22 insertions(+), 36 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +2 -12
@@ -31,7 +31,6 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, {struct xdp_buff *xdp = wi->umr.dma_info[page_idx].xsk;u32 cqe_bcnt32 = cqe_bcnt; -bool consumed;/* Check packet size. Note LRO doesn't use linear SKB */ if (unlikely (cqe_bcnt > rq->hw_mtu)) {
@@ -51,10 +50,6 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq,xsk_buff_dma_sync_for_cpu (xdp);prefetch (xdp->data); -rcu_read_lock (); - consumed =mlx5e_xdp_handle (rq,NULL , &cqe_bcnt32, xdp); -rcu_read_unlock (); -/* Possible flows: * - XDP_REDIRECT to XSKMAP: * The page is owned by the userspace from now.
@@ -70,7 +65,7 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq,* allocated first from the Reuse Ring, so it has enough space. */ -if (likely (consumed)) { +if (likely (mlx5e_xdp_handle (rq,NULL , &cqe_bcnt32, xdp))) {if (likely (__test_and_clear_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags)))__set_bit (page_idx, wi->xdp_xmit_bitmap);/* non-atomic */ return NULL ;/* page/packet was consumed by XDP */
@@ -88,7 +83,6 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_linear(struct mlx5e_rq *rq, u32 cqe_bcnt) {struct xdp_buff *xdp = wi->di->xsk; -bool consumed;/* wi->offset is not used in this function, because xdp->data and the * DMA address point directly to the necessary place. Furthermore, the
@@ -107,11 +101,7 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_linear(struct mlx5e_rq *rq,return NULL ; } -rcu_read_lock (); - consumed =mlx5e_xdp_handle (rq,NULL , &cqe_bcnt, xdp); -rcu_read_unlock (); - -if (likely (consumed)) +if (likely (mlx5e_xdp_handle (rq,NULL , &cqe_bcnt, xdp)))return NULL ;/* page/packet was consumed by XDP */ /* XDP_PASS: copy the data from the UMEM to a new SKB. The frame reuse
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +1 -2
@@ -106,8 +106,7 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,void mlx5e_close_xsk (struct mlx5e_channel *c) {clear_bit (MLX5E_CHANNEL_STATE_XSK , c->state); -napi_synchronize (&c->napi); -synchronize_rcu ();/* Sync with the XSK wakeup. */ +synchronize_rcu ();/* Sync with the XSK wakeup and with NAPI. */ mlx5e_close_rq (&c->xskrq);mlx5e_close_cq (&c->xskrq.cq);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -8
@@ -873,7 +873,7 @@ void mlx5e_activate_rq(struct mlx5e_rq *rq)void mlx5e_deactivate_rq (struct mlx5e_rq *rq) {clear_bit (MLX5E_RQ_STATE_ENABLED , &rq->state); -napi_synchronize (&rq->channel->napi);/* prevent mlx5e_post_rx_wqes */ +synchronize_rcu ();/* Sync with NAPI to prevent mlx5e_post_rx_wqes. */ }void mlx5e_close_rq (struct mlx5e_rq *rq)
@@ -1318,12 +1318,10 @@ void mlx5e_tx_disable_queue(struct netdev_queue *txq)static void mlx5e_deactivate_txqsq (struct mlx5e_txqsq *sq) { -struct mlx5e_channel *c = sq->channel;struct mlx5_wq_cyc *wq = &sq->wq;clear_bit (MLX5E_SQ_STATE_ENABLED , &sq->state); -/* prevent netif_tx_wake_queue */ -napi_synchronize (&c->napi); +synchronize_rcu ();/* Sync with NAPI to prevent netif_tx_wake_queue. */ mlx5e_tx_disable_queue (sq->txq);
@@ -1398,10 +1396,8 @@ void mlx5e_activate_icosq(struct mlx5e_icosq *icosq)void mlx5e_deactivate_icosq (struct mlx5e_icosq *icosq) { -struct mlx5e_channel *c = icosq->channel; -clear_bit (MLX5E_SQ_STATE_ENABLED , &icosq->state); -napi_synchronize (&c->napi); +synchronize_rcu ();/* Sync with NAPI. */ }void mlx5e_close_icosq (struct mlx5e_icosq *sq)
@@ -1480,7 +1476,7 @@ void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)struct mlx5e_channel *c = sq->channel;clear_bit (MLX5E_SQ_STATE_ENABLED , &sq->state); -napi_synchronize (&c->napi); +synchronize_rcu ();/* Sync with NAPI. */ mlx5e_destroy_sq (c->mdev, sq->sqn);mlx5e_free_xdpsq_descs (sq);
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +2 -10
@@ -1132,7 +1132,6 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,struct xdp_buff xdp;struct sk_buff *skb;void *va, *data; -bool consumed;u32 frag_size; va =page_address (di->page) + wi->offset;
@@ -1144,11 +1143,8 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,prefetchw (va);/* xdp_frame data area */ prefetch (data); -rcu_read_lock ();mlx5e_fill_xdp_buff (rq, va, rx_headroom, cqe_bcnt, &xdp); - consumed =mlx5e_xdp_handle (rq, di, &cqe_bcnt, &xdp); -rcu_read_unlock (); -if (consumed) +if (mlx5e_xdp_handle (rq, di, &cqe_bcnt, &xdp))return NULL ;/* page/packet was consumed by XDP */ rx_headroom = xdp.data - xdp.data_hard_start;
@@ -1438,7 +1434,6 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,struct sk_buff *skb;void *va, *data;u32 frag_size; -bool consumed;/* Check packet size. Note LRO doesn't use linear SKB */ if (unlikely (cqe_bcnt > rq->hw_mtu)) {
@@ -1455,11 +1450,8 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,prefetchw (va);/* xdp_frame data area */ prefetch (data); -rcu_read_lock ();mlx5e_fill_xdp_buff (rq, va, rx_headroom, cqe_bcnt32, &xdp); - consumed =mlx5e_xdp_handle (rq, di, &cqe_bcnt32, &xdp); -rcu_read_unlock (); -if (consumed) { +if (mlx5e_xdp_handle (rq, di, &cqe_bcnt32, &xdp)) {if (__test_and_clear_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags))__set_bit (page_idx, wi->xdp_xmit_bitmap);/* non-atomic */ return NULL ;/* page/packet was consumed by XDP */
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +13 -4
@@ -121,13 +121,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)struct mlx5e_xdpsq *xsksq = &c->xsksq;struct mlx5e_rq *xskrq = &c->xskrq;struct mlx5e_rq *rq = &c->rq; -bool xsk_open =test_bit (MLX5E_CHANNEL_STATE_XSK , c->state);bool aff_change = false;bool busy_xsk = false;bool busy = false;int work_done =0 ; +bool xsk_open;int i; +rcu_read_lock (); + + xsk_open =test_bit (MLX5E_CHANNEL_STATE_XSK , c->state); + ch_stats->poll++;for (i =0 ; i < c->num_tc; i++)
@@ -167,8 +171,10 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) busy |= busy_xsk;if (busy) { -if (likely (mlx5e_channel_no_affinity_change (c))) -return budget; +if (likely (mlx5e_channel_no_affinity_change (c))) { + work_done = budget; + goto out; + } ch_stats->aff_change++; aff_change = true;if (budget && work_done == budget)
@@ -176,7 +182,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) }if (unlikely (!napi_complete_done (napi, work_done))) -return work_done; + goto out; ch_stats->arm++;
@@ -203,6 +209,9 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) ch_stats->force_irq++; } +out: +rcu_read_unlock (); +return work_done; }
Signature · 1 line
2.26.2
PATCH v2 10/15 net/mlx5e: TLS, Do not expose FPGA TLS counter if not supported
In reply to [email protected]From: Tariq Toukan <[email protected]>
The set of TLS TX global SW counters in mlx5e_tls_sw_stats_desc is updated from all rings by using atomic ops.
This set of stats is used only in the FPGA TLS use case, not in the Connect-X TLS one, where regular per-ring counters are used.
Do not expose them in the Connect-X use case, as this would cause counter duplication. For example, tx_tls_drop_no_sync_data would appear twice in the ethtool stats.
--- .../ethernet/mellanox/mlx5/core/en_accel/tls_stats.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_stats.c +8 -4
@@ -35,7 +35,6 @@#include <net/sock.h> #include "en.h" -#include "accel/tls.h" #include "fpga/sdk.h" #include "en_accel/tls.h"
@@ -51,9 +50,14 @@ static const struct counter_desc mlx5e_tls_sw_stats_desc[] = {#define NUM_TLS_SW_COUNTERS ARRAY_SIZE(mlx5e_tls_sw_stats_desc) +static bool is_tls_atomic_stats (struct mlx5e_priv *priv) +{ +return priv->tls && !mlx5_accel_is_ktls_device (priv->mdev); +} +int mlx5e_tls_get_count (struct mlx5e_priv *priv) { -if (!priv->tls) +if (!is_tls_atomic_stats (priv))return 0 ;return NUM_TLS_SW_COUNTERS ;
@@ -63,7 +67,7 @@ int mlx5e_tls_get_strings(struct mlx5e_priv *priv, uint8_t *data) {unsigned int i, idx =0 ; -if (!priv->tls) +if (!is_tls_atomic_stats (priv))return 0 ;for (i =0 ; i <NUM_TLS_SW_COUNTERS ; i++)
@@ -77,7 +81,7 @@ int mlx5e_tls_get_stats(struct mlx5e_priv *priv, u64 *data) {int i, idx =0 ; -if (!priv->tls) +if (!is_tls_atomic_stats (priv))return 0 ;for (i =0 ; i <NUM_TLS_SW_COUNTERS ; i++)
Signature · 1 line
2.26.2
PATCH v2 15/15 net/mlx5e: mlx5e_fec_in_caps() returns a boolean
In reply to [email protected]From: Saeed Mahameed <[email protected]>
Returning errno is a bug, fix that.
Also fixes smatch warnings:drivers/net/ethernet/mellanox/mlx5/core/en/port.c:453 mlx5e_fec_in_caps() warn: signedness bug returning '(-95)'
--- drivers/net/ethernet/mellanox/mlx5/core/en/port.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/port.c +2 -5
@@ -490,11 +490,8 @@ bool mlx5e_fec_in_caps(struct mlx5_core_dev *dev, int fec_policy)int err;int i; -if (!MLX5_CAP_GEN (dev, pcam_reg)) -return -EOPNOTSUPP ; - -if (!MLX5_CAP_PCAM_REG (dev, pplm)) -return -EOPNOTSUPP ; +if (!MLX5_CAP_GEN (dev, pcam_reg) || !MLX5_CAP_PCAM_REG (dev, pplm)) +return false;MLX5_SET (pplm_reg, in, local_port,1 ); err =mlx5_core_access_reg (dev, in, sz, out, sz,MLX5_REG_PPLM ,0 ,0 );
Signature · 1 line
2.26.2
PATCH v2 6/15 net/mlx5e: Enable adding peer miss rules only if merged eswitch is supported
In reply to [email protected]From: Maor Dickman <[email protected]>
The cited commit creates peer miss group during switchdev mode initialization in order to handle miss packets correctly while in VF LAG mode. This is done regardless of FW support of such groups which could cause rules setups failure later on.
Fix by adding FW capability check before creating peer groups/rule.
--- .../mellanox/mlx5/core/eswitch_offloads.c | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +28 -24
@@ -1219,35 +1219,37 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw) } esw->fdb_table.offloads.send_to_vport_grp = g; -/* create peer esw miss group */ -memset (flow_group_in,0 , inlen); +if (MLX5_CAP_ESW (esw->dev, merged_eswitch)) { +/* create peer esw miss group */ +memset (flow_group_in,0 , inlen); -esw_set_flow_group_source_port (esw, flow_group_in); +esw_set_flow_group_source_port (esw, flow_group_in); -if (!mlx5_eswitch_vport_match_metadata_enabled (esw)) { - match_criteria =MLX5_ADDR_OF (create_flow_group_in, - flow_group_in, - match_criteria); +if (!mlx5_eswitch_vport_match_metadata_enabled (esw)) { + match_criteria =MLX5_ADDR_OF (create_flow_group_in, + flow_group_in, + match_criteria); -MLX5_SET_TO_ONES (fte_match_param, match_criteria, - misc_parameters.source_eswitch_owner_vhca_id); +MLX5_SET_TO_ONES (fte_match_param, match_criteria, + misc_parameters.source_eswitch_owner_vhca_id); -MLX5_SET (create_flow_group_in, flow_group_in, - source_eswitch_owner_vhca_id_valid,1 ); - } +MLX5_SET (create_flow_group_in, flow_group_in, + source_eswitch_owner_vhca_id_valid,1 ); + } -MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, ix); -MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, - ix + esw->total_vports -1 ); - ix += esw->total_vports; +MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, ix); +MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, + ix + esw->total_vports -1 ); + ix += esw->total_vports; - g =mlx5_create_flow_group (fdb, flow_group_in); -if (IS_ERR (g)) { - err =PTR_ERR (g); -esw_warn (dev,"Failed to create peer miss flow group err(%d)\n" , err); - goto peer_miss_err; + g =mlx5_create_flow_group (fdb, flow_group_in); +if (IS_ERR (g)) { + err =PTR_ERR (g); +esw_warn (dev,"Failed to create peer miss flow group err(%d)\n" , err); + goto peer_miss_err; + } + esw->fdb_table.offloads.peer_miss_grp = g; } - esw->fdb_table.offloads.peer_miss_grp = g;/* create miss group */ memset (flow_group_in,0 , inlen);
@@ -1281,7 +1283,8 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw) miss_rule_err:mlx5_destroy_flow_group (esw->fdb_table.offloads.miss_grp); miss_err: -mlx5_destroy_flow_group (esw->fdb_table.offloads.peer_miss_grp); +if (MLX5_CAP_ESW (esw->dev, merged_eswitch)) +mlx5_destroy_flow_group (esw->fdb_table.offloads.peer_miss_grp); peer_miss_err:mlx5_destroy_flow_group (esw->fdb_table.offloads.send_to_vport_grp); send_vport_err:
@@ -1305,7 +1308,8 @@ static void esw_destroy_offloads_fdb_tables(struct mlx5_eswitch *esw)mlx5_del_flow_rules (esw->fdb_table.offloads.miss_rule_multi);mlx5_del_flow_rules (esw->fdb_table.offloads.miss_rule_uni);mlx5_destroy_flow_group (esw->fdb_table.offloads.send_to_vport_grp); -mlx5_destroy_flow_group (esw->fdb_table.offloads.peer_miss_grp); +if (MLX5_CAP_ESW (esw->dev, merged_eswitch)) +mlx5_destroy_flow_group (esw->fdb_table.offloads.peer_miss_grp);mlx5_destroy_flow_group (esw->fdb_table.offloads.miss_grp);mlx5_esw_chains_destroy (esw);
Signature · 1 line
2.26.2
PATCH v2 14/15 net/mlx5e: kTLS, Avoid kzalloc(GFP_KERNEL) under spinlock
In reply to [email protected]From: Saeed Mahameed <[email protected]>
The spinlock only needed when accessing the channel's icosq, grab the lock after the buf allocation in resync_post_get_progress_params() to avoid kzalloc(GFP_KERNEL) in atomic context.
--- .../mellanox/mlx5/core/en_accel/ktls_rx.c | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +10 -15
@@ -234,7 +234,7 @@ mlx5e_get_ktls_rx_priv_ctx(struct tls_context *tls_ctx)/* Re-sync */ /* Runs in work context */ -static struct mlx5_wqe_ctrl_seg * +static int resync_post_get_progress_params (struct mlx5e_icosq *sq,struct mlx5e_ktls_offload_context_rx *priv_rx) {
@@ -264,7 +264,11 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq, buf->priv_rx = priv_rx;BUILD_BUG_ON (MLX5E_KTLS_GET_PROGRESS_WQEBBS !=1 ); + +spin_lock (&sq->channel->async_icosq_lock); +if (unlikely (!mlx5e_wqc_has_room_for (&sq->wq, sq->cc, sq->pc,1 ))) { +spin_unlock (&sq->channel->async_icosq_lock); err = -ENOSPC ; goto err_dma_unmap; }
@@ -294,8 +298,10 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq, };icosq_fill_wi (sq, pi, &wi); sq->pc++; +mlx5e_notify_hw (&sq->wq, sq->pc, sq->uar_map, cseg); +spin_unlock (&sq->channel->async_icosq_lock); -return cseg; +return 0 ; err_dma_unmap:dma_unmap_single (pdev, buf->dma_addr,PROGRESS_PARAMS_PADDED_SIZE ,DMA_FROM_DEVICE );
@@ -303,7 +309,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,kfree (buf); err_out: priv_rx->stats->tls_resync_req_skip++; -return ERR_PTR (err); +return err; }/* Function is called with elevated refcount.
@@ -313,10 +319,8 @@ static void resync_handle_work(struct work_struct *work) {struct mlx5e_ktls_offload_context_rx *priv_rx;struct mlx5e_ktls_rx_resync_ctx *resync; -struct mlx5_wqe_ctrl_seg *cseg;struct mlx5e_channel *c;struct mlx5e_icosq *sq; -struct mlx5_wq_cyc *wq; resync = container_of(work, struct mlx5e_ktls_rx_resync_ctx, work); priv_rx = container_of(resync, struct mlx5e_ktls_offload_context_rx, resync);
@@ -328,18 +332,9 @@ static void resync_handle_work(struct work_struct *work) c = resync->priv->channels.c[priv_rx->rxq]; sq = &c->async_icosq; - wq = &sq->wq; -spin_lock (&c->async_icosq_lock); - - cseg =resync_post_get_progress_params (sq, priv_rx); -if (IS_ERR (cseg)) { +if (resync_post_get_progress_params (sq, priv_rx))refcount_dec (&resync->refcnt); - goto unlock; - } -mlx5e_notify_hw (wq, sq->pc, sq->uar_map, cseg); -unlock: -spin_unlock (&c->async_icosq_lock); } static void resync_init(struct mlx5e_ktls_rx_resync_ctx *resync,
Signature · 1 line
2.26.2
PATCH v2 4/15 net/mlx5e: Fix memory leak of tunnel info when rule under multipath not ready
In reply to [email protected]From: Jianbo Liu <[email protected]>
When deleting vxlan flow rule under multipath, tun_info in parse_attr is not freed when the rule is not ready.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -4
@@ -1290,11 +1290,8 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,mlx5e_put_flow_tunnel_id (flow); -if (flow_flag_test (flow,NOT_READY )) { +if (flow_flag_test (flow,NOT_READY ))remove_unready_flow (flow); -kvfree (attr->parse_attr); -return ; - }if (mlx5e_is_offloaded_flow (flow)) {if (flow_flag_test (flow,SLOW ))
Signature · 1 line
2.26.2
PATCH v2 7/15 net/mlx5e: Fix endianness when calculating pedit mask first bit
In reply to [email protected]From: Maor Dickman <[email protected]>
The field mask value is provided in network byte order and has to be converted to host byte order before calculating pedit mask first bit.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +21 -13
@@ -2624,6 +2624,22 @@ static struct mlx5_fields fields[] = { OFFLOAD(UDP_DPORT, 16, U16_MAX, udp.dest, 0, udp_dport), }; +static unsigned long mask_to_le (unsigned long mask,int size) +{ +__be32 mask_be32; +__be16 mask_be16; + +if (size ==32 ) { + mask_be32 = (__force __be32)(mask); + mask = (__force unsigned long )cpu_to_le32 (be32_to_cpu (mask_be32)); + }else if (size ==16 ) { + mask_be32 = (__force __be32)(mask); + mask_be16 = *(__be16 *)&mask_be32; + mask = (__force unsigned long )cpu_to_le16 (be16_to_cpu (mask_be16)); + } + +return mask; +} static int offload_pedit_fields(struct mlx5e_priv *priv, int namespace, struct pedit_headers_action *hdrs,
@@ -2637,9 +2653,7 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,u32 *s_masks_p, *a_masks_p, s_mask, a_mask;struct mlx5e_tc_mod_hdr_acts *mod_acts;struct mlx5_fields *f; -unsigned long mask; -__be32 mask_be32; -__be16 mask_be16; +unsigned long mask, field_mask;int err;u8 cmd;
@@ -2705,14 +2719,7 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,if (skip)continue ; -if (f->field_bsize ==32 ) { - mask_be32 = (__force __be32)(mask); - mask = (__force unsigned long )cpu_to_le32 (be32_to_cpu (mask_be32)); - }else if (f->field_bsize ==16 ) { - mask_be32 = (__force __be32)(mask); - mask_be16 = *(__be16 *)&mask_be32; - mask = (__force unsigned long )cpu_to_le16 (be16_to_cpu (mask_be16)); - } + mask =mask_to_le (mask, f->field_bsize); first =find_first_bit (&mask, f->field_bsize); next_z =find_next_zero_bit (&mask, f->field_bsize, first);
@@ -2743,9 +2750,10 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,if (cmd ==MLX5_ACTION_TYPE_SET ) {int start; + field_mask =mask_to_le (f->field_mask, f->field_bsize); +/* if field is bit sized it can start not from first bit */ - start =find_first_bit ((unsigned long *)&f->field_mask, - f->field_bsize); + start =find_first_bit (&field_mask, f->field_bsize);MLX5_SET (set_action_in, action, offset, first - start);/* length is num of bits to be written, zero means length of 32 */
Signature · 1 line
2.26.2
PATCH v2 13/15 net/mlx5e: kTLS, Fix leak on resync error flow
In reply to [email protected]From: Saeed Mahameed <[email protected]>
Resync progress params buffer and dma weren't released on error, Add missing error unwinding for resync_post_get_progress_params().
--- .../net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +6 -2
@@ -258,7 +258,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq, PROGRESS_PARAMS_PADDED_SIZE, DMA_FROM_DEVICE);if (unlikely (dma_mapping_error (pdev, buf->dma_addr))) { err = -ENOMEM ; - goto err_out; + goto err_free; } buf->priv_rx = priv_rx;
@@ -266,7 +266,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,BUILD_BUG_ON (MLX5E_KTLS_GET_PROGRESS_WQEBBS !=1 );if (unlikely (!mlx5e_wqc_has_room_for (&sq->wq, sq->cc, sq->pc,1 ))) { err = -ENOSPC ; - goto err_out; + goto err_dma_unmap; } pi =mlx5e_icosq_get_next_pi (sq,1 );
@@ -297,6 +297,10 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,return cseg; +err_dma_unmap: +dma_unmap_single (pdev, buf->dma_addr,PROGRESS_PARAMS_PADDED_SIZE ,DMA_FROM_DEVICE ); +err_free: +kfree (buf); err_out: priv_rx->stats->tls_resync_req_skip++;return ERR_PTR (err);
Signature · 1 line
2.26.2
PATCH v2 12/15 net/mlx5e: kTLS, Add missing dma_unmap in RX resync
In reply to [email protected]From: Saeed Mahameed <[email protected]>
Progress params dma address is never unmapped, unmap it when completion handling is over.
--- .../net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +5 -3
@@ -386,16 +386,17 @@ void mlx5e_ktls_handle_get_psv_completion(struct mlx5e_icosq_wqe_info *wi,struct mlx5e_ktls_offload_context_rx *priv_rx;struct mlx5e_ktls_rx_resync_ctx *resync;u8 tracker_state, auth_state, *ctx; +struct device *dev;u32 hw_seq; priv_rx = buf->priv_rx; resync = &priv_rx->resync; - + dev = resync->priv->mdev->device;if (unlikely (test_bit (MLX5E_PRIV_RX_FLAG_DELETING , priv_rx->flags))) goto out; -dma_sync_single_for_cpu (resync->priv->mdev->device, buf->dma_addr, -PROGRESS_PARAMS_PADDED_SIZE ,DMA_FROM_DEVICE ); +dma_sync_single_for_cpu (dev, buf->dma_addr,PROGRESS_PARAMS_PADDED_SIZE , +DMA_FROM_DEVICE ); ctx = buf->progress.ctx; tracker_state =MLX5_GET (tls_progress_params, ctx, record_tracker_state);
@@ -411,6 +412,7 @@ void mlx5e_ktls_handle_get_psv_completion(struct mlx5e_icosq_wqe_info *wi, priv_rx->stats->tls_resync_req_end++; out:refcount_dec (&resync->refcnt); +dma_unmap_single (dev, buf->dma_addr,PROGRESS_PARAMS_PADDED_SIZE ,DMA_FROM_DEVICE );kfree (buf); }
Signature · 1 line
2.26.2
PATCH v2 9/15 net/mlx5e: Fix using wrong stats_grps in mlx5e_update_ndo_stats()
In reply to [email protected]From: Alaa Hleihel <[email protected]>
The cited commit started to reuse function mlx5e_update_ndo_stats() for the representors as well.
However, the function is hard-coded to work on mlx5e_nic_stats_grps only. Due to this issue, the representors statistics were not updated in the output of "ip -s".
Fix it to work with the correct group by extracting it from the caller's profile.
Also, while at it and since this function became generic, move it to en_stats.c and rename it accordingly.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 - .../ethernet/mellanox/mlx5/core/en/monitor_stats.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 12 +----------- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 12 ++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 1 + 6 files changed, 17 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +0 -1
@@ -1005,7 +1005,6 @@ int mlx5e_update_nic_rx(struct mlx5e_priv *priv);void mlx5e_update_carrier (struct mlx5e_priv *priv);int mlx5e_close (struct net_device *netdev);int mlx5e_open (struct net_device *netdev); -void mlx5e_update_ndo_stats (struct mlx5e_priv *priv);void mlx5e_queue_update_stats (struct mlx5e_priv *priv);int mlx5e_bits_invert (unsigned long a,int size);
drivers/net/ethernet/mellanox/mlx5/core/en/monitor_stats.c +1 -1
@@ -51,7 +51,7 @@ static void mlx5e_monitor_counters_work(struct work_struct *work) monitor_counters_work);mutex_lock (&priv->state_lock); -mlx5e_update_ndo_stats (priv); +mlx5e_stats_update_ndo_stats (priv);mutex_unlock (&priv->state_lock);mlx5e_monitor_counter_arm (priv); }
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -11
@@ -158,16 +158,6 @@ static void mlx5e_update_carrier_work(struct work_struct *work)mutex_unlock (&priv->state_lock); } -void mlx5e_update_ndo_stats (struct mlx5e_priv *priv) -{ -int i; - -for (i =mlx5e_nic_stats_grps_num (priv) -1 ; i >=0 ; i--) -if (mlx5e_nic_stats_grps[i]->update_stats_mask & -MLX5E_NDO_UPDATE_STATS ) - mlx5e_nic_stats_grps[i]->update_stats (priv); -} -static void mlx5e_update_stats_work (struct work_struct *work) { struct mlx5e_priv *priv = container_of(work, struct mlx5e_priv,
@@ -5187,7 +5177,7 @@ static const struct mlx5e_profile mlx5e_nic_profile = { .enable = mlx5e_nic_enable, .disable = mlx5e_nic_disable, .update_rx = mlx5e_update_nic_rx, - .update_stats = mlx5e_update_ndo_stats, + .update_stats = mlx5e_stats_update_ndo_stats, .update_carrier = mlx5e_update_carrier, .rx_handlers = &mlx5e_rx_handlers_nic, .max_tc = MLX5E_MAX_NUM_TC,
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -2
@@ -1171,7 +1171,7 @@ static const struct mlx5e_profile mlx5e_rep_profile = { .cleanup_tx = mlx5e_cleanup_rep_tx, .enable = mlx5e_rep_enable, .update_rx = mlx5e_update_rep_rx, - .update_stats = mlx5e_update_ndo_stats, + .update_stats = mlx5e_stats_update_ndo_stats, .rx_handlers = &mlx5e_rx_handlers_rep, .max_tc = 1, .rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR),
@@ -1189,7 +1189,7 @@ static const struct mlx5e_profile mlx5e_uplink_rep_profile = { .enable = mlx5e_uplink_rep_enable, .disable = mlx5e_uplink_rep_disable, .update_rx = mlx5e_update_rep_rx, - .update_stats = mlx5e_update_ndo_stats, + .update_stats = mlx5e_stats_update_ndo_stats, .update_carrier = mlx5e_update_carrier, .rx_handlers = &mlx5e_rx_handlers_rep, .max_tc = MLX5E_MAX_NUM_TC,
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +12 -0
@@ -54,6 +54,18 @@ unsigned int mlx5e_stats_total_num(struct mlx5e_priv *priv)return total; } +void mlx5e_stats_update_ndo_stats (struct mlx5e_priv *priv) +{ +mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps; +const unsigned int num_stats_grps =stats_grps_num (priv); +int i; + +for (i = num_stats_grps -1 ; i >=0 ; i--) +if (stats_grps[i]->update_stats && + stats_grps[i]->update_stats_mask &MLX5E_NDO_UPDATE_STATS ) + stats_grps[i]->update_stats (priv); +} +void mlx5e_stats_update (struct mlx5e_priv *priv) {mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps;
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +1 -0
@@ -103,6 +103,7 @@ unsigned int mlx5e_stats_total_num(struct mlx5e_priv *priv);void mlx5e_stats_update (struct mlx5e_priv *priv);void mlx5e_stats_fill (struct mlx5e_priv *priv,u64 *data,int idx);void mlx5e_stats_fill_strings (struct mlx5e_priv *priv,u8 *data); +void mlx5e_stats_update_ndo_stats (struct mlx5e_priv *priv);/* Concrete NIC Stats */
Signature · 1 line
2.26.2
PATCH v2 11/15 net/mlx5e: kTLS, Fix napi sync and possible use-after-free
In reply to [email protected]From: Tariq Toukan <[email protected]>
Using synchronize_rcu() is sufficient to wait until running NAPI quits.
See similar upstream fix with detailed explanation:
("net/mlx5e: Use synchronize_rcu to sync with NAPI")
This change also fixes a possible use-after-free as the NAPI might be already released at this stage.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +1 -1
@@ -659,7 +659,7 @@ void mlx5e_ktls_del_rx(struct net_device *netdev, struct tls_context *tls_ctx) priv_rx =mlx5e_get_ktls_rx_priv_ctx (tls_ctx);set_bit (MLX5E_PRIV_RX_FLAG_DELETING , priv_rx->flags);mlx5e_set_ktls_rx_priv_ctx (tls_ctx,NULL ); -napi_synchronize (&priv->channels.c[priv_rx->rxq]->napi); +synchronize_rcu ();/* Sync with NAPI */ if (!cancel_work_sync (&priv_rx->rule.work))/* completion is needed, as the priv_rx in the add flow * is maintained on the wqe info (wi), not on the socket.
Signature · 1 line
2.26.2
From: [email protected]
Date: Mon, 21 Sep 2020 17:30:46 -0700
Quoted 3 lines
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
Pulled.
Quoted 7 lines
For -stable v5.1
('net/mlx5: Fix FTE cleanup')For -stable v5.3
('net/mlx5e: TLS, Do not expose FPGA TLS counter if not supported') ('net/mlx5e: Enable adding peer miss rules only if merged eswitch is supported')
Quoted 7 lines
For -stable v5.7
('net/mlx5e: Fix memory leak of tunnel info when rule under multipath not ready')For -stable v5.8
('net/mlx5e: Use RCU to protectrq->xdp_prog') ('net/mlx5e: Fix endianness when calculating pedit mask first bit') ('net/mlx5e: Usesynchronize_rcuto sync with NAPI')
Queued up, thanks.