mlx5 updates 2023-02-15
Subsystems (6)
PATCH 1/9 net/mlx5e: Switch to using napi_build_skb()
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Use napi_build_skb() which uses NAPI percpu caches to obtain skbuff_head instead of inplace allocation.
napi_build_skb() calls napi_skb_cache_get(), which returns a cached skb, or allocates a bulk of NAPI_SKB_CACHE_BULK (16) if cache is empty.
Performance test:
TCP single stream, single ring, single core, default MTU (1500B).
Before: 26.5 Gbits/sec After: 30.1 Gbits/sec (+13.6%)
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -1
@@ -1556,7 +1556,7 @@ struct sk_buff *mlx5e_build_linear_skb(struct mlx5e_rq *rq, void *va, u32 frag_size, u16 headroom, u32 cqe_bcnt, u32 metasize) { - struct sk_buff *skb = build_skb(va, frag_size); + struct sk_buff *skb = napi_build_skb(va, frag_size);if (unlikely (!skb)) { rq->stats->buff_alloc_err++;
Signature · 1 line
2.39.1
From: Saeed Mahameed <[email protected]>
This series adds misc updates to mlx5 driver.
For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
The following changes since commit 894341ad3ad7dfbced8556efe92a9ebfd5924bd6:
net: phylink: support validated pause and autoneg in fixed-link (2023-02-15 10:35:27 +0000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2023-02-15
for you to fetch changes up to b38e55f4eb69d826b3bc862eacb82246125a5c0b:
net/mlx5e: RX, Remove doubtful unlikely call (2023-02-15 16:07:35 -0800)
----------------------------------------------------------------
mlx5-updates-2023-02-15
1) From Gal Tariq and Parav, Few cleanups for mlx5 driver.
2) From Vlad: Allow offloading of ct 'new' match based on [1]
[1] https://lore.kernel.org/netdev/[email protected]/
----------------------------------------------------------------
Gal Pressman (1):
net/mlx5e: RX, Remove doubtful unlikely call
Parav Pandit (1):
net/mlx5: Simplify eq list traversal
Tariq Toukan (5):
net/mlx5e: Switch to using napi_build_skb()
net/mlx5e: Remove redundant page argument in mlx5e_xmit_xdp_buff() net/mlx5e: Remove redundant page argument in mlx5e_xdp_handle() net/mlx5e: Remove unused function mlx5e_sq_xmit_simple net/mlx5e: Fix outdated TLS comment
Vlad Buslov (2):
net/mlx5e: Implement CT entry update net/mlx5e: Allow offloading of ct 'new' match
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 139 +++++++++++++++++++-- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 1 - drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 9 +- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h | 2 +- .../net/ethernet/mellanox/mlx5/core/en/xsk/rx.c | 4 +- .../mellanox/mlx5/core/en_accel/en_accel.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 14 +-- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 15 --- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 8 +- 9 files changed, 145 insertions(+), 49 deletions(-)
PATCH 3/9 net/mlx5e: Remove redundant page argument in mlx5e_xdp_handle()
From: Tariq Toukan <[email protected]>
Remove the page parameter, it can be derived from the xdp_buff member of mlx5e_xdp_buff.
--- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 10 ++++------ 4 files changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +2 -2
@@ -186,7 +186,7 @@ const struct xdp_metadata_ops mlx5e_xdp_metadata_ops = { };/* returns true if packet was consumed by xdp */ -bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct page *page, +bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct bpf_prog *prog,struct mlx5e_xdp_buff *mxbuf) {struct xdp_buff *xdp = &mxbuf->xdp;
@@ -210,7 +210,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct page *page,__set_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags);__set_bit (MLX5E_RQ_FLAG_XDP_REDIRECT , rq->flags);if (xdp->rxq->mem.type !=MEM_TYPE_XSK_BUFF_POOL ) -mlx5e_page_dma_unmap (rq, page); +mlx5e_page_dma_unmap (rq,virt_to_page (xdp->data)); rq->stats->xdp_redirect++;return true;default :
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h +1 -1
@@ -52,7 +52,7 @@ struct mlx5e_xdp_buff {struct mlx5e_xsk_param ;int mlx5e_xdp_max_mtu (struct mlx5e_params *params,struct mlx5e_xsk_param *xsk); -bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct page *page, +bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct bpf_prog *prog,struct mlx5e_xdp_buff *mlctx);void mlx5e_xdp_mpwqe_complete (struct mlx5e_xdpsq *sq);bool mlx5e_poll_xdpsq_cq (struct mlx5e_cq *cq);
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +2 -2
@@ -289,7 +289,7 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq,*/ prog =rcu_dereference (rq->xdp_prog); -if (likely (prog &&mlx5e_xdp_handle (rq,NULL , prog, mxbuf))) { +if (likely (prog &&mlx5e_xdp_handle (rq, prog, mxbuf))) {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 */
@@ -323,7 +323,7 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_linear(struct mlx5e_rq *rq,net_prefetch (mxbuf->xdp.data); prog =rcu_dereference (rq->xdp_prog); -if (likely (prog &&mlx5e_xdp_handle (rq,NULL , prog, mxbuf))) +if (likely (prog &&mlx5e_xdp_handle (rq, prog, mxbuf)))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_rx.c +4 -6
@@ -1610,7 +1610,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi,net_prefetchw (va);/* xdp_frame data area */ mlx5e_fill_mxbuf (rq, cqe, va, rx_headroom, cqe_bcnt, &mxbuf); -if (mlx5e_xdp_handle (rq, au->page, prog, &mxbuf)) +if (mlx5e_xdp_handle (rq, prog, &mxbuf))return NULL ;/* page/packet was consumed by XDP */ rx_headroom = mxbuf.xdp.data - mxbuf.xdp.data_hard_start;
@@ -1698,10 +1698,8 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi wi++; } - au = head_wi->au; - prog =rcu_dereference (rq->xdp_prog); -if (prog &&mlx5e_xdp_handle (rq, au->page, prog, &mxbuf)) { +if (prog &&mlx5e_xdp_handle (rq, prog, &mxbuf)) {if (test_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags)) {int i;
@@ -1718,7 +1716,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wiif (unlikely (!skb))return NULL ; -page_ref_inc (au->page); +page_ref_inc (head_wi->au->page);if (unlikely (xdp_buff_has_frags (&mxbuf.xdp))) {int i;
@@ -2013,7 +2011,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,net_prefetchw (va);/* xdp_frame data area */ mlx5e_fill_mxbuf (rq, cqe, va, rx_headroom, cqe_bcnt, &mxbuf); -if (mlx5e_xdp_handle (rq, au->page, prog, &mxbuf)) { +if (mlx5e_xdp_handle (rq, prog, &mxbuf)) {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 */
Signature · 1 line
2.39.1
PATCH 4/9 net/mlx5: Simplify eq list traversal
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
EQ list is read only while finding the matching EQ. Hence, avoid *_safe() version.
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +4 -4
@@ -960,11 +960,11 @@ static int vector2eqnirqn(struct mlx5_core_dev *dev, int vector, int *eqn, unsigned int *irqn) {struct mlx5_eq_table *table = dev->priv.eq_table; -struct mlx5_eq_comp *eq, *n; +struct mlx5_eq_comp *eq;int err = -ENOENT ;int i =0 ; -list_for_each_entry_safe (eq, n, &table->comp_eqs_list, list) { +list_for_each_entry (eq, &table->comp_eqs_list, list) {if (i++ == vector) {if (irqn) *irqn = eq->core.irqn;
@@ -999,10 +999,10 @@ struct cpumask * mlx5_comp_irq_get_affinity_mask(struct mlx5_core_dev *dev, int vector) {struct mlx5_eq_table *table = dev->priv.eq_table; -struct mlx5_eq_comp *eq, *n; +struct mlx5_eq_comp *eq;int i =0 ; -list_for_each_entry_safe (eq, n, &table->comp_eqs_list, list) { +list_for_each_entry (eq, &table->comp_eqs_list, list) {if (i++ == vector)break ; }
Signature · 1 line
2.39.1
PATCH 2/9 net/mlx5e: Remove redundant page argument in mlx5e_xmit_xdp_buff()
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Remove the page parameter, it can be derived from the xdp_buff.
--- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +3 -2
@@ -57,8 +57,9 @@ int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk)static inline bool mlx5e_xmit_xdp_buff (struct mlx5e_xdpsq *sq,struct mlx5e_rq *rq, -struct page *page,struct xdp_buff *xdp) +struct xdp_buff *xdp) { +struct page *page =virt_to_page (xdp->data);struct skb_shared_info *sinfo =NULL ;struct mlx5e_xmit_data xdptxd;struct mlx5e_xdp_info xdpi;
@@ -197,7 +198,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct page *page,case XDP_PASS :return false;case XDP_TX : -if (unlikely (!mlx5e_xmit_xdp_buff (rq->xdpsq, rq, page, xdp))) +if (unlikely (!mlx5e_xmit_xdp_buff (rq->xdpsq, rq, xdp))) goto xdp_abort;__set_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags);/* non-atomic */ return true;
Signature · 1 line
2.39.1
PATCH 6/9 net/mlx5e: Allow offloading of ct 'new' match
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
Allow offloading filters that match on conntrack 'new' state in order to enable UDP NEW offload in the following patch.
Unhardcode ct 'established' from ct modify header infrastructure code and determine correct ct state bit according to the metadata action 'cookie' field.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +9 -12
@@ -35,6 +35,7 @@#define MLX5_CT_STATE_REPLY_BIT BIT(4)#define MLX5_CT_STATE_RELATED_BIT BIT(5)#define MLX5_CT_STATE_INVALID_BIT BIT(6) +#define MLX5_CT_STATE_NEW_BIT BIT(7)#define MLX5_CT_LABELS_BITS MLX5_REG_MAPPING_MBITS(LABELS_TO_REG)#define MLX5_CT_LABELS_MASK MLX5_REG_MAPPING_MASK(LABELS_TO_REG)
@@ -721,12 +722,14 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,DECLARE_MOD_HDR_ACTS_ACTIONS (actions_arr,MLX5_CT_MIN_MOD_ACTS );DECLARE_MOD_HDR_ACTS (mod_acts, actions_arr);struct flow_action_entry *meta; +enum ip_conntrack_info ctinfo;u16 ct_state =0 ;int err; meta =mlx5_tc_ct_get_ct_metadata_action (flow_rule);if (!meta)return -EOPNOTSUPP ; + ctinfo = meta->ct_metadata.cookie &NFCT_INFOMASK ; err =mlx5_get_label_mapping (ct_priv, meta->ct_metadata.labels, &attr->ct_attr.ct_labels_id);
@@ -742,7 +745,8 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv, ct_state |=MLX5_CT_STATE_NAT_BIT ; } - ct_state |=MLX5_CT_STATE_ESTABLISHED_BIT |MLX5_CT_STATE_TRK_BIT ; + ct_state |=MLX5_CT_STATE_TRK_BIT ; + ct_state |= ctinfo ==IP_CT_NEW ?MLX5_CT_STATE_NEW_BIT :MLX5_CT_STATE_ESTABLISHED_BIT ; ct_state |= meta->ct_metadata.orig_dir ?0 :MLX5_CT_STATE_REPLY_BIT ; err = mlx5_tc_ct_entry_set_registers(ct_priv, &mod_acts, ct_state,
@@ -1181,16 +1185,12 @@ mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft,struct mlx5_tc_ct_priv *ct_priv = ft->ct_priv;struct flow_action_entry *meta_action;unsigned long cookie = flow->cookie; -enum ip_conntrack_info ctinfo;struct mlx5_ct_entry *entry;int err; meta_action =mlx5_tc_ct_get_ct_metadata_action (flow_rule);if (!meta_action)return -EOPNOTSUPP ; - ctinfo = meta_action->ct_metadata.cookie &NFCT_INFOMASK ; -if (ctinfo ==IP_CT_NEW ) -return -EOPNOTSUPP ;spin_lock_bh (&ct_priv->ht_lock); entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params);
@@ -1443,7 +1443,7 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,struct mlx5_ct_attr *ct_attr, struct netlink_ext_ack *extack) { - bool trk, est, untrk, unest, new, rpl, unrpl, rel, unrel, inv, uninv; + bool trk, est, untrk, unnew, unest, new, rpl, unrpl, rel, unrel, inv, uninv;struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_dissector_key_ct *mask, *key;u32 ctstate =0 , ctstate_mask =0 ;
@@ -1489,15 +1489,18 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv, rel = ct_state_on &TCA_FLOWER_KEY_CT_FLAGS_RELATED ; inv = ct_state_on &TCA_FLOWER_KEY_CT_FLAGS_INVALID ; untrk = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_TRACKED ; + unnew = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_NEW ; unest = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED ; unrpl = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_REPLY ; unrel = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_RELATED ; uninv = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_INVALID ; ctstate |= trk ?MLX5_CT_STATE_TRK_BIT :0 ; + ctstate |= new ?MLX5_CT_STATE_NEW_BIT :0 ; ctstate |= est ?MLX5_CT_STATE_ESTABLISHED_BIT :0 ; ctstate |= rpl ?MLX5_CT_STATE_REPLY_BIT :0 ; ctstate_mask |= (untrk || trk) ?MLX5_CT_STATE_TRK_BIT :0 ; + ctstate_mask |= (unnew || new) ?MLX5_CT_STATE_NEW_BIT :0 ; ctstate_mask |= (unest || est) ?MLX5_CT_STATE_ESTABLISHED_BIT :0 ; ctstate_mask |= (unrpl || rpl) ?MLX5_CT_STATE_REPLY_BIT :0 ; ctstate_mask |= unrel ?MLX5_CT_STATE_RELATED_BIT :0 ;
@@ -1515,12 +1518,6 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,return -EOPNOTSUPP ; } -if (new) { -NL_SET_ERR_MSG_MOD (extack, -"matching on ct_state +new isn't supported" ); -return -EOPNOTSUPP ; - } -if (mask->ct_zone)mlx5e_tc_match_to_reg_match (spec,ZONE_TO_REG , key->ct_zone,MLX5_CT_ZONE_MASK );
Signature · 1 line
2.39.1
PATCH 7/9 net/mlx5e: Remove unused function mlx5e_sq_xmit_simple
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
The last usage was removed as part of
commit 40379a0084c2 ("net/mlx5_fpga: Drop INNOVA TLS support").
--- drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 15 --------------- 2 files changed, 16 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h +0 -1
@@ -320,7 +320,6 @@ mlx5e_tx_dma_unmap(struct device *pdev, struct mlx5e_sq_dma *dma) } } -void mlx5e_sq_xmit_simple (struct mlx5e_txqsq *sq,struct sk_buff *skb,bool xmit_more);void mlx5e_tx_mpwqe_ensure_complete (struct mlx5e_txqsq *sq);static inline bool mlx5e_tx_mpwqe_is_full (struct mlx5e_tx_mpwqe *session,u8 max_sq_mpw_wqebbs)
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +0 -15
@@ -720,21 +720,6 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)return NETDEV_TX_OK ; } -void mlx5e_sq_xmit_simple (struct mlx5e_txqsq *sq,struct sk_buff *skb,bool xmit_more) -{ -struct mlx5e_tx_wqe_attr wqe_attr; -struct mlx5e_tx_attr attr; -struct mlx5e_tx_wqe *wqe; -u16 pi; - -mlx5e_sq_xmit_prepare (sq, skb,NULL , &attr); -mlx5e_sq_calc_wqe_attr (skb, &attr, &wqe_attr); - pi =mlx5e_txqsq_get_next_pi (sq, wqe_attr.num_wqebbs); - wqe =MLX5E_TX_FETCH_WQE (sq, pi); -mlx5e_txwqe_build_eseg_csum (sq, skb,NULL , &wqe->eth); -mlx5e_sq_xmit_wqe (sq, skb, &attr, &wqe_attr, wqe, pi, xmit_more); -} -static void mlx5e_tx_wi_dma_unmap (struct mlx5e_txqsq *sq,struct mlx5e_tx_wqe_info *wi,u32 *dma_fifo_cc) {
Signature · 1 line
2.39.1
PATCH 5/9 net/mlx5e: Implement CT entry update
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
With support for UDP NEW offload the flow_table may now send updates for existing flows. Support properly replacing existing entries by updating flow restore_cookie and replacing the rule with new one with the same match but new mod_hdr action that sets updated ctinfo.
--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 118 +++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +117 -1
@@ -871,6 +871,68 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,return err; } +static int +mlx5_tc_ct_entry_replace_rule (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +bool nat,u8 zone_restore_id) +{ +struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat]; +struct mlx5_flow_attr *attr = zone_rule->attr, *old_attr; +struct mlx5e_mod_hdr_handle *mh; +struct mlx5_ct_fs_rule *rule; +struct mlx5_flow_spec *spec; +int err; + + spec =kvzalloc (sizeof (*spec),GFP_KERNEL ); +if (!spec) +return -ENOMEM ; + + old_attr =mlx5_alloc_flow_attr (ct_priv->ns_type); +if (!attr) { + err = -ENOMEM ; + goto err_attr; + } + *old_attr = *attr; + + err =mlx5_tc_ct_entry_create_mod_hdr (ct_priv, attr, flow_rule, &mh, zone_restore_id, + nat,mlx5_tc_ct_entry_has_nat (entry)); +if (err) { +ct_dbg ("Failed to create ct entry mod hdr" ); + goto err_mod_hdr; + } + +mlx5_tc_ct_set_tuple_match (ct_priv, spec, flow_rule); +mlx5e_tc_match_to_reg_match (spec,ZONE_TO_REG , entry->tuple.zone,MLX5_CT_ZONE_MASK ); + + rule = ct_priv->fs_ops->ct_rule_add (ct_priv->fs, spec, attr, flow_rule); +if (IS_ERR (rule)) { + err =PTR_ERR (rule); +ct_dbg ("Failed to add replacement ct entry rule, nat: %d" , nat); + goto err_rule; + } + + ct_priv->fs_ops->ct_rule_del (ct_priv->fs, zone_rule->rule); + zone_rule->rule = rule; +mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, old_attr, zone_rule->mh); + zone_rule->mh = mh; + +kfree (old_attr); +kvfree (spec); +ct_dbg ("Replaced ct entry rule in zone %d" , entry->tuple.zone); + +return 0 ; + +err_rule: +mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, zone_rule->attr, mh); +mlx5_put_label_mapping (ct_priv, attr->ct_attr.ct_labels_id); +err_mod_hdr: +kfree (old_attr); +err_attr: +kvfree (spec); +return err; +} +static bool mlx5_tc_ct_entry_valid (struct mlx5_ct_entry *entry) {
@@ -1065,6 +1127,52 @@ mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv,return err; } +static int +mlx5_tc_ct_entry_replace_rules (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +u8 zone_restore_id) +{ +int err; + + err =mlx5_tc_ct_entry_replace_rule (ct_priv, flow_rule, entry, false, + zone_restore_id); +if (err) +return err; + + err =mlx5_tc_ct_entry_replace_rule (ct_priv, flow_rule, entry, true, + zone_restore_id); +if (err) +mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); +return err; +} + +static int +mlx5_tc_ct_block_flow_offload_replace (struct mlx5_ct_ft *ft,struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry,unsigned long cookie) +{ +struct mlx5_tc_ct_priv *ct_priv = ft->ct_priv; +int err; + + err =mlx5_tc_ct_entry_replace_rules (ct_priv, flow_rule, entry, ft->zone_restore_id); +if (!err) +return 0 ; + +/* If failed to update the entry, then look it up again under ht_lock +* protection and properly delete it. +*/ +spin_lock_bh (&ct_priv->ht_lock); + entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params); +if (entry) { +rhashtable_remove_fast (&ft->ct_entries_ht, &entry->node, cts_ht_params); +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); + }else { +spin_unlock_bh (&ct_priv->ht_lock); + } +return err; +} +static int mlx5_tc_ct_block_flow_offload_add (struct mlx5_ct_ft *ft,struct flow_cls_offload *flow)
@@ -1087,9 +1195,17 @@ mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft,spin_lock_bh (&ct_priv->ht_lock); entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params);if (entry &&refcount_inc_not_zero (&entry->refcnt)) { +if (entry->restore_cookie == meta_action->ct_metadata.cookie) { +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); +return -EEXIST ; + } + entry->restore_cookie = meta_action->ct_metadata.cookie;spin_unlock_bh (&ct_priv->ht_lock); + + err =mlx5_tc_ct_block_flow_offload_replace (ft, flow_rule, entry, cookie);mlx5_tc_ct_entry_put (entry); -return -EEXIST ; +return err; }spin_unlock_bh (&ct_priv->ht_lock);
Signature · 1 line
2.39.1
PATCH 8/9 net/mlx5e: Fix outdated TLS comment
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Comment is outdated since
commit 40379a0084c2 ("net/mlx5_fpga: Drop INNOVA TLS support").
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +1 -1
@@ -124,7 +124,7 @@ static inline bool mlx5e_accel_tx_begin(struct net_device *dev,mlx5e_udp_gso_handle_tx_skb (skb);#ifdef CONFIG_MLX5_EN_TLS -/* May send SKBs and WQEs. */ +/* May send WQEs. */ if (mlx5e_ktls_skb_offloaded (skb))if (unlikely (!mlx5e_ktls_handle_tx_skb (dev, sq, skb, &state->tls)))
Signature · 1 line
2.39.1
PATCH 9/9 net/mlx5e: RX, Remove doubtful unlikely call
In reply to Saeed MahameedFrom: Gal Pressman <[email protected]>
When building an skb in non-linear mode, it is not likely nor unlikely that the xdp buff has fragments, it depends on the size of the packet received.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -1
@@ -1718,7 +1718,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wipage_ref_inc (head_wi->au->page); -if (unlikely (xdp_buff_has_frags (&mxbuf.xdp))) { +if (xdp_buff_has_frags (&mxbuf.xdp)) {int i;/* sinfo->nr_frags is reset by build_skb, calculate again. */
Signature · 1 line
2.39.1
Re: [net-next 1/9] net/mlx5e: Switch to using napi_build_skb()
In reply to Saeed MahameedQuoted 5 lines · Saeed Mahameed
From: Tariq Toukan <[email protected]>
Use
napi_build_skb()which uses NAPI percpu caches to obtainskbuff_headinstead of inplace allocation.
Quoted 8 lines
napi_build_skb()callsnapi_skb_cache_get(), which returns a cached skb, or allocates a bulk ofNAPI_SKB_CACHE_BULK(16) if cache is empty.Performance test:
TCP single stream, single ring, single core, default MTU (1500B).Before: 26.5 Gbits/sec After: 30.1 Gbits/sec (+13.6%)
Quoted 24 lines
Signed-off-by Tariq Toukan <[email protected]>Reviewed-by Gal Pressman <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1
-1@@ -1556,7 +1556,7 @@ struct sk_buff *mlx5e_build_linear_skb(struct mlx5e_rq *rq, void *va, u32 frag_size, u16 headroom, u32 cqe_bcnt, u32 metasize) { - struct sk_buff *skb = build_skb(va, frag_size); + struct sk_buff *skb = napi_build_skb(va, frag_size);if (unlikely (!skb)) { rq->stats->buff_alloc_err++;Signature · 1 line
2.39.1
Re: [net-next 2/9] net/mlx5e: Remove redundant page argument in mlx5e_xmit_xdp_buff()
In reply to Saeed MahameedQuoted 27 lines · Saeed Mahameed
From: Tariq Toukan <[email protected]>
Remove the page parameter, it can be derived from the
xdp_buff.Signed-off-by Tariq Toukan <[email protected]>Reviewed-by Dragos Tatulea <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +2
-1@@ -57,8 +57,9 @@ int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk)static inline bool mlx5e_xmit_xdp_buff (struct mlx5e_xdpsq *sq,struct mlx5e_rq *rq, -struct page *page,struct xdp_buff *xdp) +struct xdp_buff *xdp) { +struct page *page =virt_to_page (xdp->data);struct skb_shared_info *sinfo =NULL ;struct mlx5e_xmit_data xdptxd;struct mlx5e_xdp_info xdpi;
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct page *page, · line 201
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +1
-1@@ -197,7 +198,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct page *page,case XDP_PASS :return false;case XDP_TX : -if (unlikely (!mlx5e_xmit_xdp_buff (rq->xdpsq, rq, page, xdp))) +if (unlikely (!mlx5e_xmit_xdp_buff (rq->xdpsq, rq, xdp)))
is there any value behind this patch? you're not super excessive in terms of count of args that mlx5e_xmit_xdp_buff() takes.
Maybe don't initialize this right on the start but rather just before getting dma_addr? This way XSK XDP_TX won't be doing this.
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +0
-0goto xdp_abort;__set_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags);/* non-atomic */ return true;Signature · 1 line
2.39.1
Re: [net-next 3/9] net/mlx5e: Remove redundant page argument in mlx5e_xdp_handle()
In reply to Saeed MahameedQuoted 4 lines · Saeed Mahameed
From: Tariq Toukan <[email protected]>
Remove the page parameter, it can be derived from the
xdp_buffmember ofmlx5e_xdp_buff.
Okay that's nice cleanup. How about squashing this with the previous patch that does the same thing for xmit xdp_buff routine?
Quoted 114 lines
Signed-off-by Tariq Toukan <[email protected]>Reviewed-by Dragos Tatulea <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 10 ++++------ 4 files changed, 9 insertions(+), 11 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +2
-2@@ -186,7 +186,7 @@ const struct xdp_metadata_ops mlx5e_xdp_metadata_ops = { };/* returns true if packet was consumed by xdp */ -bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct page *page, +bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct bpf_prog *prog,struct mlx5e_xdp_buff *mxbuf) {struct xdp_buff *xdp = &mxbuf->xdp;@@ -210,7 +210,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct page *page,__set_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags);__set_bit (MLX5E_RQ_FLAG_XDP_REDIRECT , rq->flags);if (xdp->rxq->mem.type !=MEM_TYPE_XSK_BUFF_POOL ) -mlx5e_page_dma_unmap (rq, page); +mlx5e_page_dma_unmap (rq,virt_to_page (xdp->data)); rq->stats->xdp_redirect++;return true;default :drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h +1
-1@@ -52,7 +52,7 @@ struct mlx5e_xdp_buff {struct mlx5e_xsk_param ;int mlx5e_xdp_max_mtu (struct mlx5e_params *params,struct mlx5e_xsk_param *xsk); -bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct page *page, +bool mlx5e_xdp_handle (struct mlx5e_rq *rq,struct bpf_prog *prog,struct mlx5e_xdp_buff *mlctx);void mlx5e_xdp_mpwqe_complete (struct mlx5e_xdpsq *sq);bool mlx5e_poll_xdpsq_cq (struct mlx5e_cq *cq);drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +2
-2@@ -289,7 +289,7 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq,*/ prog =rcu_dereference (rq->xdp_prog); -if (likely (prog &&mlx5e_xdp_handle (rq,NULL , prog, mxbuf))) { +if (likely (prog &&mlx5e_xdp_handle (rq, prog, mxbuf))) {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 */ @@ -323,7 +323,7 @@ struct sk_buff *mlx5e_xsk_skb_from_cqe_linear(struct mlx5e_rq *rq,net_prefetch (mxbuf->xdp.data); prog =rcu_dereference (rq->xdp_prog); -if (likely (prog &&mlx5e_xdp_handle (rq,NULL , prog, mxbuf))) +if (likely (prog &&mlx5e_xdp_handle (rq, prog, mxbuf)))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_rx.c +4
-6@@ -1610,7 +1610,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi,net_prefetchw (va);/* xdp_frame data area */ mlx5e_fill_mxbuf (rq, cqe, va, rx_headroom, cqe_bcnt, &mxbuf); -if (mlx5e_xdp_handle (rq, au->page, prog, &mxbuf)) +if (mlx5e_xdp_handle (rq, prog, &mxbuf))return NULL ;/* page/packet was consumed by XDP */ rx_headroom = mxbuf.xdp.data - mxbuf.xdp.data_hard_start;@@ -1698,10 +1698,8 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi wi++; } - au = head_wi->au; - prog =rcu_dereference (rq->xdp_prog); -if (prog &&mlx5e_xdp_handle (rq, au->page, prog, &mxbuf)) { +if (prog &&mlx5e_xdp_handle (rq, prog, &mxbuf)) {if (test_bit (MLX5E_RQ_FLAG_XDP_XMIT , rq->flags)) {int i;@@ -1718,7 +1716,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wiif (unlikely (!skb))return NULL ; -page_ref_inc (au->page); +page_ref_inc (head_wi->au->page);if (unlikely (xdp_buff_has_frags (&mxbuf.xdp))) {int i;@@ -2013,7 +2011,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,net_prefetchw (va);/* xdp_frame data area */ mlx5e_fill_mxbuf (rq, cqe, va, rx_headroom, cqe_bcnt, &mxbuf); -if (mlx5e_xdp_handle (rq, au->page, prog, &mxbuf)) { +if (mlx5e_xdp_handle (rq, prog, &mxbuf)) {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 */ Signature · 1 line
2.39.1
Re: [net-next 4/9] net/mlx5: Simplify eq list traversal
In reply to Saeed MahameedQuoted 8 lines · Saeed Mahameed
From: Parav Pandit <[email protected]>
EQ list is read only while finding the matching EQ. Hence, avoid
*_safe()version.Signed-off-by Parav Pandit <[email protected]>Reviewed-by Shay Drory <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
Quoted 38 lines
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/eq.c +4
-4@@ -960,11 +960,11 @@ static int vector2eqnirqn(struct mlx5_core_dev *dev, int vector, int *eqn, unsigned int *irqn) {struct mlx5_eq_table *table = dev->priv.eq_table; -struct mlx5_eq_comp *eq, *n; +struct mlx5_eq_comp *eq;int err = -ENOENT ;int i =0 ; -list_for_each_entry_safe (eq, n, &table->comp_eqs_list, list) { +list_for_each_entry (eq, &table->comp_eqs_list, list) {if (i++ == vector) {if (irqn) *irqn = eq->core.irqn;@@ -999,10 +999,10 @@ struct cpumask * mlx5_comp_irq_get_affinity_mask(struct mlx5_core_dev *dev, int vector) {struct mlx5_eq_table *table = dev->priv.eq_table; -struct mlx5_eq_comp *eq, *n; +struct mlx5_eq_comp *eq;int i =0 ; -list_for_each_entry_safe (eq, n, &table->comp_eqs_list, list) { +list_for_each_entry (eq, &table->comp_eqs_list, list) {if (i++ == vector)break ; }Signature · 1 line
2.39.1
Re: [net-next 5/9] net/mlx5e: Implement CT entry update
In reply to Saeed MahameedQuoted 32 lines · Saeed Mahameed
From: Vlad Buslov <[email protected]>
With support for UDP NEW offload the
flow_tablemay now send updates for existing flows. Support properly replacing existing entries by updating flowrestore_cookieand replacing the rule with new one with the same match but newmod_hdraction that sets updated ctinfo.Signed-off-by Vlad Buslov <[email protected]>Reviewed-by Oz Shlomo <[email protected]>Reviewed-by Paul Blakey <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 118 +++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +9
-0@@ -871,6 +871,68 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,return err; } +static int +mlx5_tc_ct_entry_replace_rule (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +bool nat,u8 zone_restore_id) +{ +struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat]; +struct mlx5_flow_attr *attr = zone_rule->attr, *old_attr; +struct mlx5e_mod_hdr_handle *mh;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 892
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +10
-0+struct mlx5_ct_fs_rule *rule; +struct mlx5_flow_spec *spec; +int err; + + spec =kvzalloc (sizeof (*spec),GFP_KERNEL ); +if (!spec) +return -ENOMEM ; + + old_attr =mlx5_alloc_flow_attr (ct_priv->ns_type); +if (!attr) {
when can attr == NULL? maybe check it in the first place before allocing spec above?
Quoted 19 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +19
-0+ err = -ENOMEM ; + goto err_attr; + } + *old_attr = *attr; + + err =mlx5_tc_ct_entry_create_mod_hdr (ct_priv, attr, flow_rule, &mh, zone_restore_id, + nat,mlx5_tc_ct_entry_has_nat (entry)); +if (err) { +ct_dbg ("Failed to create ct entry mod hdr" ); + goto err_mod_hdr; + } + +mlx5_tc_ct_set_tuple_match (ct_priv, spec, flow_rule); +mlx5e_tc_match_to_reg_match (spec,ZONE_TO_REG , entry->tuple.zone,MLX5_CT_ZONE_MASK ); + + rule = ct_priv->fs_ops->ct_rule_add (ct_priv->fs, spec, attr, flow_rule); +if (IS_ERR (rule)) { + err =PTR_ERR (rule); +ct_dbg ("Failed to add replacement ct entry rule, nat: %d" , nat);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 921
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +10
-0+ goto err_rule; + } + + ct_priv->fs_ops->ct_rule_del (ct_priv->fs, zone_rule->rule); + zone_rule->rule = rule; +mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, old_attr, zone_rule->mh); + zone_rule->mh = mh; + +kfree (old_attr); +kvfree (spec);
not a big deal but you could make a common goto below with a different name
Quoted 20 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +14
-0+ct_dbg ("Replaced ct entry rule in zone %d" , entry->tuple.zone); + +return 0 ; + +err_rule: +mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, zone_rule->attr, mh); +mlx5_put_label_mapping (ct_priv, attr->ct_attr.ct_labels_id); +err_mod_hdr: +kfree (old_attr); +err_attr: +kvfree (spec); +return err; +} +static bool mlx5_tc_ct_entry_valid (struct mlx5_ct_entry *entry) {@@ -1065,6 +1127,52 @@ mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv,return err; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv, · line 1138
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +9
-0+static int +mlx5_tc_ct_entry_replace_rules (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +u8 zone_restore_id) +{ +int err; + + err = mlx5_tc_ct_entry_replace_rule(ct_priv, flow_rule, entry, false,
would it make sense to replace the bool nat in here with some kind of enum?
Quoted 44 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +37
-0+ zone_restore_id); +if (err) +return err; + + err =mlx5_tc_ct_entry_replace_rule (ct_priv, flow_rule, entry, true, + zone_restore_id); +if (err) +mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); +return err; +} + +static int +mlx5_tc_ct_block_flow_offload_replace (struct mlx5_ct_ft *ft,struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry,unsigned long cookie) +{ +struct mlx5_tc_ct_priv *ct_priv = ft->ct_priv; +int err; + + err =mlx5_tc_ct_entry_replace_rules (ct_priv, flow_rule, entry, ft->zone_restore_id); +if (!err) +return 0 ; + +/* If failed to update the entry, then look it up again under ht_lock +* protection and properly delete it. +*/ +spin_lock_bh (&ct_priv->ht_lock); + entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params); +if (entry) { +rhashtable_remove_fast (&ft->ct_entries_ht, &entry->node, cts_ht_params); +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); + }else { +spin_unlock_bh (&ct_priv->ht_lock); + } +return err; +} +static int mlx5_tc_ct_block_flow_offload_add (struct mlx5_ct_ft *ft,struct flow_cls_offload *flow)@@ -1087,9 +1195,17 @@ mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft,spin_lock_bh (&ct_priv->ht_lock); entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params);if (entry &&refcount_inc_not_zero (&entry->refcnt)) {
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft, · line 1207
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +8
-0+if (entry->restore_cookie == meta_action->ct_metadata.cookie) { +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); +return -EEXIST ; + } + entry->restore_cookie = meta_action->ct_metadata.cookie;spin_unlock_bh (&ct_priv->ht_lock); + + err =mlx5_tc_ct_block_flow_offload_replace (ft, flow_rule, entry, cookie);mlx5_tc_ct_entry_put (entry);
in case of err != 0, haven't you already put the entry inside mlx5_tc_ct_block_flow_offload_replace() ?
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1
-1-return -EEXIST ; +return err; }spin_unlock_bh (&ct_priv->ht_lock);Signature · 1 line
2.39.1
Re: [net-next 9/9] net/mlx5e: RX, Remove doubtful unlikely call
In reply to Saeed MahameedQuoted 5 lines · Saeed Mahameed
From: Gal Pressman <[email protected]>
When building an skb in non-linear mode, it is not likely nor unlikely that the xdp buff has fragments, it depends on the size of the packet received.
Quoted 23 lines
Signed-off-by Gal Pressman <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1
-1@@ -1718,7 +1718,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wipage_ref_inc (head_wi->au->page); -if (unlikely (xdp_buff_has_frags (&mxbuf.xdp))) { +if (xdp_buff_has_frags (&mxbuf.xdp)) {int i;/* sinfo->nr_frags is reset by build_skb, calculate again. */ Signature · 1 line
2.39.1
Re: [net-next 5/9] net/mlx5e: Implement CT entry update
In reply to Maciej FijalkowskiQuoted 38 lines · Maciej Fijalkowski
Quoted 37 lines · Saeed Mahameed
From: Vlad Buslov <[email protected]>
With support for UDP NEW offload the
flow_tablemay now send updates for existing flows. Support properly replacing existing entries by updating flowrestore_cookieand replacing the rule with new one with the same match but newmod_hdraction that sets updated ctinfo.Signed-off-by Vlad Buslov <[email protected]>Reviewed-by Oz Shlomo <[email protected]>Reviewed-by Paul Blakey <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 118 +++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +14
-0@@ -871,6 +871,68 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,return err; } +static int +mlx5_tc_ct_entry_replace_rule (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +bool nat,u8 zone_restore_id) +{ +struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat]; +struct mlx5_flow_attr *attr = zone_rule->attr, *old_attr; +struct mlx5e_mod_hdr_handle *mh; +struct mlx5_ct_fs_rule *rule; +struct mlx5_flow_spec *spec; +int err; + + spec =kvzalloc (sizeof (*spec),GFP_KERNEL );
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 892
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +5
-0+if (!spec) +return -ENOMEM ; + + old_attr =mlx5_alloc_flow_attr (ct_priv->ns_type); +if (!attr) {when can attr == NULL? maybe check it in the first place before allocing spec above?
Should verify 'old_attr', not 'attr'. Thanks for catching this!
Quoted 25 lines
Quoted 25 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +24
-0+ err = -ENOMEM ; + goto err_attr; + } + *old_attr = *attr; + + err =mlx5_tc_ct_entry_create_mod_hdr (ct_priv, attr, flow_rule, &mh, zone_restore_id, + nat,mlx5_tc_ct_entry_has_nat (entry)); +if (err) { +ct_dbg ("Failed to create ct entry mod hdr" ); + goto err_mod_hdr; + } + +mlx5_tc_ct_set_tuple_match (ct_priv, spec, flow_rule); +mlx5e_tc_match_to_reg_match (spec,ZONE_TO_REG , entry->tuple.zone,MLX5_CT_ZONE_MASK ); + + rule = ct_priv->fs_ops->ct_rule_add (ct_priv->fs, spec, attr, flow_rule); +if (IS_ERR (rule)) { + err =PTR_ERR (rule); +ct_dbg ("Failed to add replacement ct entry rule, nat: %d" , nat); + goto err_rule; + } + + ct_priv->fs_ops->ct_rule_del (ct_priv->fs, zone_rule->rule); + zone_rule->rule = rule;
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 921
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +5
-0+mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, old_attr, zone_rule->mh); + zone_rule->mh = mh; + +kfree (old_attr); +kvfree (spec);not a big deal but you could make a common goto below with a different name
You mean jump from here to the middle of the error handling code below in order not to duplicate these two calls to *free()? Honestly, I would much rather prefer _not_ to do that since goto is necessary evil for error handling in C but I don't believe we should handle any common non-error code paths with it and it is not typically done in mlx5.
Quoted 22 lines
Quoted 22 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +14
-0+ct_dbg ("Replaced ct entry rule in zone %d" , entry->tuple.zone); + +return 0 ; + +err_rule: +mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, zone_rule->attr, mh); +mlx5_put_label_mapping (ct_priv, attr->ct_attr.ct_labels_id); +err_mod_hdr: +kfree (old_attr); +err_attr: +kvfree (spec); +return err; +} +static bool mlx5_tc_ct_entry_valid (struct mlx5_ct_entry *entry) {@@ -1065,6 +1127,52 @@ mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv,return err; }
Quoted 12 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv, · line 1138
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +9
-0+static int +mlx5_tc_ct_entry_replace_rules (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +u8 zone_restore_id) +{ +int err; + + err = mlx5_tc_ct_entry_replace_rule(ct_priv, flow_rule, entry, false,would it make sense to replace the bool nat in here with some kind of enum?
It is either nat rule or non-nat rule. Why would we invent an enum here? Moreover, boolean 'nat' is already used in multiple places in this file, so this patch just re-uses existing convention.
Quoted 50 lines
Quoted 50 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +42
-0+ zone_restore_id); +if (err) +return err; + + err =mlx5_tc_ct_entry_replace_rule (ct_priv, flow_rule, entry, true, + zone_restore_id); +if (err) +mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); +return err; +} + +static int +mlx5_tc_ct_block_flow_offload_replace (struct mlx5_ct_ft *ft,struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry,unsigned long cookie) +{ +struct mlx5_tc_ct_priv *ct_priv = ft->ct_priv; +int err; + + err =mlx5_tc_ct_entry_replace_rules (ct_priv, flow_rule, entry, ft->zone_restore_id); +if (!err) +return 0 ; + +/* If failed to update the entry, then look it up again under ht_lock +* protection and properly delete it. +*/ +spin_lock_bh (&ct_priv->ht_lock); + entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params); +if (entry) { +rhashtable_remove_fast (&ft->ct_entries_ht, &entry->node, cts_ht_params); +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); + }else { +spin_unlock_bh (&ct_priv->ht_lock); + } +return err; +} +static int mlx5_tc_ct_block_flow_offload_add (struct mlx5_ct_ft *ft,struct flow_cls_offload *flow)@@ -1087,9 +1195,17 @@ mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft,spin_lock_bh (&ct_priv->ht_lock); entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params);if (entry &&refcount_inc_not_zero (&entry->refcnt)) { +if (entry->restore_cookie == meta_action->ct_metadata.cookie) { +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); +return -EEXIST ; + }
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft, · line 1207
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +3
-0+ entry->restore_cookie = meta_action->ct_metadata.cookie;spin_unlock_bh (&ct_priv->ht_lock); + + err =mlx5_tc_ct_block_flow_offload_replace (ft, flow_rule, entry, cookie);mlx5_tc_ct_entry_put (entry);in case of err != 0, haven't you already put the entry inside
mlx5_tc_ct_block_flow_offload_replace()?
No. Here we release the reference that was obtained 10 lines up and mlx5_tc_ct_block_flow_offload_replace() releases the reference held by ct_entries_ht table.
Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1
-1-return -EEXIST ; +return err; }spin_unlock_bh (&ct_priv->ht_lock);Signature · 1 line
2.39.1
Re: [net-next 1/9] net/mlx5e: Switch to using napi_build_skb()
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Date: Wed, 15 Feb 2023 16:09:10 -0800
Quoted 5 lines
From: Tariq Toukan <[email protected]>
Use
napi_build_skb()which uses NAPI percpu caches to obtainskbuff_headinstead of inplace allocation.
Quoted 8 lines
napi_build_skb()callsnapi_skb_cache_get(), which returns a cached skb, or allocates a bulk ofNAPI_SKB_CACHE_BULK(16) if cache is empty.Performance test:
TCP single stream, single ring, single core, default MTU (1500B).Before: 26.5 Gbits/sec After: 30.1 Gbits/sec (+13.6%)
+14%, gosh! Happy to see more and more vendors switching to it, someone told me back then we have so fast RAM nowadays that it won't make any sense to directly recycle kmem-cached objects. Maybe it's fast, but seems like not *so* fast :D
Quoted 13 lines
Signed-off-by Tariq Toukan <[email protected]>Reviewed-by Gal Pressman <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c struct sk_buff *mlx5e_build_linear_skb(struct mlx5e_rq *rq, void *va, · line 1562
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1
-1@@ -1556,7 +1556,7 @@ struct sk_buff *mlx5e_build_linear_skb(struct mlx5e_rq *rq, void *va, u32 frag_size, u16 headroom, u32 cqe_bcnt, u32 metasize) { - struct sk_buff *skb = build_skb(va, frag_size); + struct sk_buff *skb = napi_build_skb(va, frag_size);if (unlikely (!skb)) { rq->stats->buff_alloc_err++;
Thanks,
Olek
Jakub Kicinski
maintainerRe: [net-next 1/9] net/mlx5e: Switch to using napi_build_skb()
Quoted 7 lines · On Thu, 16 Feb 2023 18:26:19 +0100 Alexander Lobakin wrote:
Quoted 2 lines
Before: 26.5 Gbits/sec After: 30.1 Gbits/sec (+13.6%)+14%, gosh! Happy to see more and more vendors switching to it, someone told me back then we have so fast RAM nowadays that it won't make any sense to directly recycle kmem-cached objects. Maybe it's fast, but seems like not *so* fast :D
Interestingly I had a similar patch in my tree when testing the skb_ext cache and enabling slow_gro kills this gain.
IOW without adding an skb_ext using napi_build_skb() gives me ~12% boost. If I start adding skb_ext (with the cache and perfect reuse) I'm back to the baseline (26.5Gbps in this case).
But without using napi_build_skb() adding skb_ext (with the cache) doesn't change anything, skb_ext or not, I'll get 26.5Gbps.
Very finicky. Not sure why this happens. Perhaps napi_build_skb() let's us fit under some CPU resource constraint and additional functionality knocks us back over the line?
Re: [net-next 1/9] net/mlx5e: Switch to using napi_build_skb()
From: Jakub Kicinski <[email protected]>
Date: Thu, 16 Feb 2023 09:53:24 -0800
Quoted 16 lines · On Thu, 16 Feb 2023 18:26:19 +0100 Alexander Lobakin wrote:
Quoted 7 lines
Quoted 2 lines
Before: 26.5 Gbits/sec After: 30.1 Gbits/sec (+13.6%)+14%, gosh! Happy to see more and more vendors switching to it, someone told me back then we have so fast RAM nowadays that it won't make any sense to directly recycle kmem-cached objects. Maybe it's fast, but seems like not *so* fast :D
Interestingly I had a similar patch in my tree when testing the
skb_extcache and enablingslow_grokills this gain.IOW without adding an
skb_extusingnapi_build_skb()gives me ~12% boost. If I start addingskb_ext(with the cache and perfect reuse) I'm back to the baseline (26.5Gbps in this case).
Quoted 6 lines
But without using
napi_build_skb()addingskb_ext(with the cache) doesn't change anything,skb_extor not, I'll get 26.5Gbps.Very finicky. Not sure why this happens. Perhaps
napi_build_skb()let's us fit under some CPU resource constraint and additional functionality knocks us back over the line?
Both skb and skb ext use kmem cache, maybe calling kmem cache related functions like alloc/free touches some global objects (or even locks) we'd like to avoid accessing on hotpath? I'm not deep into the kmem cache, so might be saying something perfectly stupid here :D
Nevertheless, it's always fun to see how performance does some weird and counter-intuitive moves sometimes (not speaking of why CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B exists).
Thanks,
Olek
Re: [net-next 5/9] net/mlx5e: Implement CT entry update
In reply to Vlad BuslovQuoted 84 lines · Vlad Buslov
Quoted 38 lines · Maciej Fijalkowski
Quoted 37 lines · Saeed Mahameed
From: Vlad Buslov <[email protected]>
With support for UDP NEW offload the
flow_tablemay now send updates for existing flows. Support properly replacing existing entries by updating flowrestore_cookieand replacing the rule with new one with the same match but newmod_hdraction that sets updated ctinfo.Signed-off-by Vlad Buslov <[email protected]>Reviewed-by Oz Shlomo <[email protected]>Reviewed-by Paul Blakey <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 118 +++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +14
-0@@ -871,6 +871,68 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,return err; } +static int +mlx5_tc_ct_entry_replace_rule (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +bool nat,u8 zone_restore_id) +{ +struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat]; +struct mlx5_flow_attr *attr = zone_rule->attr, *old_attr; +struct mlx5e_mod_hdr_handle *mh; +struct mlx5_ct_fs_rule *rule; +struct mlx5_flow_spec *spec; +int err; + + spec =kvzalloc (sizeof (*spec),GFP_KERNEL );Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 892
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +5
-0+if (!spec) +return -ENOMEM ; + + old_attr =mlx5_alloc_flow_attr (ct_priv->ns_type); +if (!attr) {when can attr == NULL? maybe check it in the first place before allocing spec above?
Should verify '
old_attr', not 'attr'. Thanks for catching this!Quoted 25 lines
Quoted 25 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +24
-0+ err = -ENOMEM ; + goto err_attr; + } + *old_attr = *attr; + + err =mlx5_tc_ct_entry_create_mod_hdr (ct_priv, attr, flow_rule, &mh, zone_restore_id, + nat,mlx5_tc_ct_entry_has_nat (entry)); +if (err) { +ct_dbg ("Failed to create ct entry mod hdr" ); + goto err_mod_hdr; + } + +mlx5_tc_ct_set_tuple_match (ct_priv, spec, flow_rule); +mlx5e_tc_match_to_reg_match (spec,ZONE_TO_REG , entry->tuple.zone,MLX5_CT_ZONE_MASK ); + + rule = ct_priv->fs_ops->ct_rule_add (ct_priv->fs, spec, attr, flow_rule); +if (IS_ERR (rule)) { + err =PTR_ERR (rule); +ct_dbg ("Failed to add replacement ct entry rule, nat: %d" , nat); + goto err_rule; + } + + ct_priv->fs_ops->ct_rule_del (ct_priv->fs, zone_rule->rule); + zone_rule->rule = rule;Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, · line 921
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +5
-0+mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, old_attr, zone_rule->mh); + zone_rule->mh = mh; + +kfree (old_attr); +kvfree (spec);not a big deal but you could make a common goto below with a different name
Quoted 5 lines
You mean jump from here to the middle of the error handling code below in order not to duplicate these two calls to
*free()? Honestly, I would much rather prefer _not_ to do that since goto is necessary evil for error handling in C but I don't believe we should handle any common non-error code paths with it and it is not typically done in mlx5.
ok it's fine as-is
Quoted 36 lines
Quoted 23 lines
Quoted 23 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +14
-0+ct_dbg ("Replaced ct entry rule in zone %d" , entry->tuple.zone); + +return 0 ; + +err_rule: +mlx5_tc_ct_entry_destroy_mod_hdr (ct_priv, zone_rule->attr, mh); +mlx5_put_label_mapping (ct_priv, attr->ct_attr.ct_labels_id); +err_mod_hdr: +kfree (old_attr); +err_attr: +kvfree (spec); +return err; +} +static bool mlx5_tc_ct_entry_valid (struct mlx5_ct_entry *entry) {@@ -1065,6 +1127,52 @@ mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv,return err; }Quoted 12 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_entry_add_rules(struct mlx5_tc_ct_priv *ct_priv, · line 1138
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +9
-0+static int +mlx5_tc_ct_entry_replace_rules (struct mlx5_tc_ct_priv *ct_priv, +struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry, +u8 zone_restore_id) +{ +int err; + + err = mlx5_tc_ct_entry_replace_rule(ct_priv, flow_rule, entry, false,would it make sense to replace the bool nat in here with some kind of enum?
Quoted 3 lines
It is either nat rule or non-nat rule. Why would we invent an enum here? Moreover, boolean 'nat' is already used in multiple places in this file, so this patch just re-uses existing convention.
This was just a suggestion to improve readability on callsites and using bool as an array index was a bit odd for me, but that's related to personal taste probably.
err = mlx5_tc_ct_entry_replace_rule(ct_priv, flow_rule, entry, NAT_RULE, zone_restore_id); if (err) return err; err = mlx5_tc_ct_entry_replace_rule(ct_priv, flow_rule, entry, NON_NAT_RULE, zone_restore_id); if (err) return err;
above sheds more light on what is going on instead of opaque true/false.
I didn't realize it's the pattern you're using throughout whole file, so this change would be weird per-se, maybe consider such refactoring when you would have some free cycles... or just ignore it:)
Quoted 57 lines
Quoted 48 lines
Quoted 48 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +41
-0+if (err) +return err; + + err =mlx5_tc_ct_entry_replace_rule (ct_priv, flow_rule, entry, true, + zone_restore_id); +if (err) +mlx5_tc_ct_entry_del_rule (ct_priv, entry, false); +return err; +} + +static int +mlx5_tc_ct_block_flow_offload_replace (struct mlx5_ct_ft *ft,struct flow_rule *flow_rule, +struct mlx5_ct_entry *entry,unsigned long cookie) +{ +struct mlx5_tc_ct_priv *ct_priv = ft->ct_priv; +int err; + + err =mlx5_tc_ct_entry_replace_rules (ct_priv, flow_rule, entry, ft->zone_restore_id); +if (!err) +return 0 ; + +/* If failed to update the entry, then look it up again under ht_lock +* protection and properly delete it. +*/ +spin_lock_bh (&ct_priv->ht_lock); + entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params); +if (entry) { +rhashtable_remove_fast (&ft->ct_entries_ht, &entry->node, cts_ht_params); +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); + }else { +spin_unlock_bh (&ct_priv->ht_lock); + } +return err; +} +static int mlx5_tc_ct_block_flow_offload_add (struct mlx5_ct_ft *ft,struct flow_cls_offload *flow)@@ -1087,9 +1195,17 @@ mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft,spin_lock_bh (&ct_priv->ht_lock); entry =rhashtable_lookup_fast (&ft->ct_entries_ht, &cookie, cts_ht_params);if (entry &&refcount_inc_not_zero (&entry->refcnt)) { +if (entry->restore_cookie == meta_action->ct_metadata.cookie) { +spin_unlock_bh (&ct_priv->ht_lock); +mlx5_tc_ct_entry_put (entry); +return -EEXIST ; + }Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft, · line 1207
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +3
-0+ entry->restore_cookie = meta_action->ct_metadata.cookie;spin_unlock_bh (&ct_priv->ht_lock); + + err =mlx5_tc_ct_block_flow_offload_replace (ft, flow_rule, entry, cookie);mlx5_tc_ct_entry_put (entry);in case of err != 0, haven't you already put the entry inside
mlx5_tc_ct_block_flow_offload_replace()?
Quoted 3 lines
No. Here we release the reference that was obtained 10 lines up and
mlx5_tc_ct_block_flow_offload_replace()releases the reference held byct_entries_httable.
thanks for explanation
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1
-1-return -EEXIST ; +return err; }spin_unlock_bh (&ct_priv->ht_lock);Signature · 1 line
2.39.1